|
@@ -0,0 +1,271 @@
|
|
|
+package com.huyi.task.taskMan.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.huyi.task.base.entity.*;
|
|
|
+import com.huyi.task.base.service.*;
|
|
|
+import com.huyi.task.taskMan.service.FinanceTimedTaskService;
|
|
|
+import com.keao.tianhu.core.util.AmtUtil;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.utils.IdUtils;
|
|
|
+import com.tianhu.common.redis.common.RedisUtils;
|
|
|
+import com.tianhu.system.api.RemoteConfigService;
|
|
|
+import com.tianhu.system.api.RemoteSystemService;
|
|
|
+import com.tianhu.system.api.domain.DictData;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
|
|
+@EnableScheduling // 2.开启定时任务
|
|
|
+public class FinanceTimedTaskController {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(FinanceTimedTaskController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceInfService iZcFinanceInfService;
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceProductService iZcFinanceProductService;
|
|
|
+ @Autowired
|
|
|
+ private FinanceTimedTaskService financeTimedTaskService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+ @Autowired
|
|
|
+ private ISysNoticeService iSysNoticeService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteConfigService configService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 融信消息提醒定时跑批
|
|
|
+ */
|
|
|
+ //每十分钟
|
|
|
+// @Scheduled(cron = "0 */10 * * * ?")
|
|
|
+ //每一分钟(测试用)
|
|
|
+// @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ private void financeInformation() throws Exception{
|
|
|
+ LambdaQueryWrapper<ZcFinanceProduct> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ZcFinanceProduct::getZfpStatus,"01");
|
|
|
+ List<ZcFinanceProduct> productList = iZcFinanceProductService.findZcFinanceProducts(queryWrapper);
|
|
|
+ //融信融信到期前30天提醒
|
|
|
+ for (int i = 0; i < productList.size(); i++) {
|
|
|
+ //最短账期
|
|
|
+ String shortestPeriod= productList.get(i).getZfpShortestPeriod();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //据当前时间还有30天的日期
|
|
|
+ String day = DateUtils.getFetureDate(30+Integer.parseInt(shortestPeriod));
|
|
|
+ map.put("day",day);
|
|
|
+ //融信信息
|
|
|
+ List<Map> list = financeTimedTaskService.selectFinanceInfList(map);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(Map res :list){
|
|
|
+ //主键
|
|
|
+ String zfiId = CommonUtil.objToString(res.get("zfiId"));
|
|
|
+ //经办人Id
|
|
|
+ String user = CommonUtil.objToString(res.get("sucrUserId"));
|
|
|
+ //企业
|
|
|
+ String companyId = CommonUtil.objToString(res.get("sucrCompanyId"));
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = CommonUtil.objToString(res.get("zfiNumber"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(res.get("zfiEffectiveDate"));
|
|
|
+ //申请金额
|
|
|
+ String zfiAmount = CommonUtil.objToString(res.get("zfiAmount"));
|
|
|
+ //金额大写
|
|
|
+ String zfiAmountBig = AmtUtil.convert(AmtUtil.moneyFormat(zfiAmount));
|
|
|
+
|
|
|
+// List userList = new ArrayList();
|
|
|
+// userList.add(user);
|
|
|
+ //到期前30天发送消息
|
|
|
+ //标题
|
|
|
+ String title = "【融信到期】您持有的一笔融信【"+zfiAmount+"】(大写:"+zfiAmountBig+")的融信【"+zfiNumber+"】将于【"+zfiEffectiveDate+"】失效,请尽快去融资";
|
|
|
+ remoteSystemService.sendNotice(companyId, zfiId,title,"01","05","","0",user,"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //融信融信到期前7天提醒
|
|
|
+ for (int i = 0; i < productList.size(); i++) {
|
|
|
+ //最短账期
|
|
|
+ String shortestPeriod= productList.get(i).getZfpShortestPeriod();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //据当前时间还有30天的日期
|
|
|
+ String day = DateUtils.getFetureDate(7+Integer.parseInt(shortestPeriod));
|
|
|
+ map.put("day",day);
|
|
|
+ //融信信息
|
|
|
+ List<Map> list = financeTimedTaskService.selectFinanceInfList(map);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(Map res :list){
|
|
|
+ //主键
|
|
|
+ String zfiId = CommonUtil.objToString(res.get("zfiId"));
|
|
|
+ //经办人Id
|
|
|
+ String user = CommonUtil.objToString(res.get("sucrUserId"));
|
|
|
+ //企业
|
|
|
+ String companyId = CommonUtil.objToString(res.get("sucrCompanyId"));
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = CommonUtil.objToString(res.get("zfiNumber"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(res.get("zfiEffectiveDate"));
|
|
|
+ //申请金额
|
|
|
+ String zfiAmount = CommonUtil.objToString(res.get("zfiAmount"));
|
|
|
+ //金额大写
|
|
|
+ String zfiAmountBig = AmtUtil.convert(AmtUtil.moneyFormat(zfiAmount));
|
|
|
+ //核心企业名称
|
|
|
+ String scyName = CommonUtil.objToString(res.get("scyName"));
|
|
|
+// List userList = new ArrayList();
|
|
|
+// userList.add(user);
|
|
|
+ //到期前7天生成待办
|
|
|
+ //标题
|
|
|
+ String title = "【融资待办】【"+scyName+"】签发的融信【"+zfiNumber+"】将于【"+zfiEffectiveDate+"】失效," +
|
|
|
+ "融信金额【"+zfiAmount+"】(大写:"+zfiAmountBig+"),请尽快融资";
|
|
|
+ remoteSystemService.sendNotice(companyId, zfiId,title,"00","","05","0",user,"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //融信融信到期前5天提醒
|
|
|
+ for (int i = 0; i < productList.size(); i++) {
|
|
|
+ //最短账期
|
|
|
+ String shortestPeriod= productList.get(i).getZfpShortestPeriod();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //据当前时间还有30天的日期
|
|
|
+ String day = DateUtils.getFetureDate(5+Integer.parseInt(shortestPeriod));
|
|
|
+ map.put("day",day);
|
|
|
+ //融信信息
|
|
|
+ List<Map> list = financeTimedTaskService.selectFinanceInfList(map);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(Map res :list){
|
|
|
+ //主键
|
|
|
+ String zfiId = CommonUtil.objToString(res.get("zfiId"));
|
|
|
+ //经办人Id
|
|
|
+ String user = CommonUtil.objToString(res.get("sucrUserId"));
|
|
|
+ //手机号
|
|
|
+ String phone = CommonUtil.objToString(res.get("phone"));
|
|
|
+ //企业
|
|
|
+ String companyId = CommonUtil.objToString(res.get("sucrCompanyId"));
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = CommonUtil.objToString(res.get("zfiNumber"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(res.get("zfiEffectiveDate"));
|
|
|
+ //申请金额
|
|
|
+ String zfiAmount = CommonUtil.objToString(res.get("zfiAmount"));
|
|
|
+ //金额大写
|
|
|
+ String zfiAmountBig = AmtUtil.convert(AmtUtil.moneyFormat(zfiAmount));
|
|
|
+// List userList = new ArrayList();
|
|
|
+// userList.add(user);
|
|
|
+ //到期前5天发送短信
|
|
|
+ //标题
|
|
|
+ String title = "【招采云链】您持有的一笔【"+zfiAmount+"】(大写:"+zfiAmountBig+")"
|
|
|
+ + "的融信【"+zfiNumber+"】将于【"+zfiEffectiveDate+"】失效,请尽快处理;";
|
|
|
+// remoteSystemService.sendNotice(companyId, zfiId,title,"","","","1",user,"");
|
|
|
+ //手机模板
|
|
|
+ String mould = RedisUtils.getDictValue("aliyun_message_code","zhuce");
|
|
|
+ //参数
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("融信编号",zfiNumber);
|
|
|
+ map1.put("融信金额",zfiAmount);
|
|
|
+ map1.put("大写",zfiAmountBig);
|
|
|
+ map1.put("失效期",zfiEffectiveDate);
|
|
|
+// JSONObject jsonObject = new JSONObject(map1);
|
|
|
+ String json = JSONObject.toJSONString(map1);
|
|
|
+ remoteSystemService.sendAliMessage(phone,mould,json,"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //融信融信到期前3天提醒
|
|
|
+ for (int i = 0; i < productList.size(); i++) {
|
|
|
+ //最短账期
|
|
|
+ String shortestPeriod= productList.get(i).getZfpShortestPeriod();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //据当前时间还有30天的日期
|
|
|
+ String day = DateUtils.getFetureDate(3+Integer.parseInt(shortestPeriod));
|
|
|
+ map.put("day",day);
|
|
|
+ //融信信息
|
|
|
+ List<Map> list = financeTimedTaskService.selectFinanceInfList(map);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(Map res :list){
|
|
|
+ //主键
|
|
|
+ String zfiId = CommonUtil.objToString(res.get("zfiId"));
|
|
|
+ //经办人Id
|
|
|
+ String user = CommonUtil.objToString(res.get("sucrUserId"));
|
|
|
+ //企业
|
|
|
+ String companyId = CommonUtil.objToString(res.get("sucrCompanyId"));
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = CommonUtil.objToString(res.get("zfiNumber"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(res.get("zfiEffectiveDate"));
|
|
|
+ //申请金额
|
|
|
+ String zfiAmount = CommonUtil.objToString(res.get("zfiAmount"));
|
|
|
+ //金额大写
|
|
|
+ String zfiAmountBig = AmtUtil.convert(AmtUtil.moneyFormat(zfiAmount));
|
|
|
+ //供应商
|
|
|
+ String supplierName = CommonUtil.objToString(res.get("supplierName"));
|
|
|
+// List userList = new ArrayList();
|
|
|
+// userList.add(user);
|
|
|
+ //到期前3天生成平台内部待办
|
|
|
+ //标题
|
|
|
+ String title = "【融资待办】【"+supplierName+"】融信【"+zfiNumber+"】融信金额【"+zfiAmount+"】(大写:"+zfiAmountBig+")" +
|
|
|
+ "将于【"+zfiEffectiveDate+"】失效,请相关人员跟进!";
|
|
|
+ remoteSystemService.sendNotice(companyId, zfiId,title,"00","","07","0",user,"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 融信失效定时跑批
|
|
|
+ */
|
|
|
+ //每十分钟
|
|
|
+// @Scheduled(cron = "0 */10 * * * ?")
|
|
|
+ //每一分钟(测试用)
|
|
|
+// @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ private void financeStatus() throws Exception{
|
|
|
+ //融信到期 => 融信失效,待办删除
|
|
|
+ Map map = new HashMap();
|
|
|
+ List<Map> list = financeTimedTaskService.selectFinanceInfDetail(map);
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ //融信id
|
|
|
+ String zfiId = CommonUtil.objToString(list.get(i).get("zfiId"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(list.get(i).get("zfiEffectiveDate"));
|
|
|
+ //最短账期
|
|
|
+ int zfpShortestPeriod = Integer.parseInt(list.get(i).get("zfpShortestPeriod")+"");
|
|
|
+ //String 转 Date
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
|
|
|
+ Date date = simpleDateFormat.parse(zfiEffectiveDate);
|
|
|
+ //签发有效期 - 最短账期(天数) = 失效日期
|
|
|
+ GregorianCalendar cal = new GregorianCalendar();
|
|
|
+ cal.setTime(date);
|
|
|
+ cal.add(Calendar.DATE, -zfpShortestPeriod);
|
|
|
+ //失效日期
|
|
|
+ String expirationDate=DateUtils.parseDateToStr("yyyy-MM-dd",cal.getTime());
|
|
|
+ //获取当前时间
|
|
|
+ String currentDate = DateUtils.getDate();
|
|
|
+ //失效日期 = 获取当前时间 修改融信状态,删除待办
|
|
|
+ if (expirationDate.equals(currentDate)){
|
|
|
+ //修改融信表
|
|
|
+ ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
+ //主键
|
|
|
+ zcFinanceInf.setZfiId(zfiId);
|
|
|
+ //状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回 07:已失效(到期失效) 99:删除)
|
|
|
+ zcFinanceInf.setZfiStatus("07");
|
|
|
+ //修改待办表
|
|
|
+ LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysNotice::getTableId,zfiId);
|
|
|
+ SysNotice sysNotice = new SysNotice();
|
|
|
+ sysNotice.setStatus("2");
|
|
|
+ iSysNoticeService.update(sysNotice,queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|