Procházet zdrojové kódy

定时任务处理

wks před 1 rokem
rodič
revize
8ef2d6814e

+ 93 - 90
src/main/java/com/ydtech/modules/order/service/impl/InsOrderPayDateRecordServiceImpl.java

@@ -37,8 +37,8 @@ import java.util.stream.Collectors;
 public class InsOrderPayDateRecordServiceImpl extends ServiceImpl<InsOrderPayDateRecordMapper, InsOrderPayDateRecord>
         implements InsOrderPayDateRecordService {
 
-     @Autowired
-     private InsOrderPdfUrlService  insOrderPdfUrlService;
+    @Autowired
+    private InsOrderPdfUrlService insOrderPdfUrlService;
 
     @Autowired
     private InsAreaCompanyService insAreaCompanyService;
@@ -53,7 +53,7 @@ public class InsOrderPayDateRecordServiceImpl extends ServiceImpl<InsOrderPayDat
     private String apiUrl;
 
     @Autowired
-    private InsOrderReadPdfService  insOrderReadPdfService;
+    private InsOrderReadPdfService insOrderReadPdfService;
 
     @Autowired
     private InsOrdersTrackService insOrdersTrackService;
@@ -61,114 +61,116 @@ public class InsOrderPayDateRecordServiceImpl extends ServiceImpl<InsOrderPayDat
 
     @Autowired
     private InsPlyIncomeService insPlyIncomeService;
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/10/21 15:00
-     *  @Description: 更新签单日期和缴费时间
+     * @version
+     * @author: hxl
+     * @Date: 2024/10/21 15:00
+     * @Description: 更新签单日期和缴费时间
      */
     @Override
     public void updateOrderDate(String subOrderId) {
-        ReadPdfUrlListDto readPdfUrlListDto =null;
-        try{
-             readPdfUrlListDto = insOrderPdfUrlService.readPdfUrlList(subOrderId, false);
-        }catch(Exception e) {
-             throw new SystemException(e.getMessage());
+        ReadPdfUrlListDto readPdfUrlListDto = null;
+        try {
+            readPdfUrlListDto = insOrderPdfUrlService.readPdfUrlList(subOrderId, false);
+        } catch (Exception e) {
+            throw new SystemException(e.getMessage());
         }
         //判断外部订单
         InsAreaCompany subOrder = insAreaCompanyService.getById(subOrderId);
-        if(readPdfUrlListDto!=null){
-            String code ="";
-            String jqFileurl ="";
-            String sqFileurl ="";
+        if (readPdfUrlListDto != null) {
+            String code = "";
+            String jqFileurl = "";
+            String sqFileurl = "";
             //判断订单交强路径是否为空
-            if(readPdfUrlListDto.getOldfileList()!=null && !readPdfUrlListDto.getOldfileList().isEmpty()){
-                code="1";
+            if (readPdfUrlListDto.getOldfileList() != null && !readPdfUrlListDto.getOldfileList().isEmpty()) {
+                code = "1";
                 //交强
-                ReadPdfUrlDto jq= readPdfUrlListDto.getOldfileList().stream().filter(s->s.getFileTitle().equals("交强电子保单")).collect(Collectors.toList()).get(0);
-                if(jq!=null){
+                ReadPdfUrlDto jq = readPdfUrlListDto.getOldfileList().stream().filter(s -> s.getFileTitle().equals("交强电子保单")).collect(Collectors.toList()).get(0);
+                if (jq != null) {
                     jqFileurl = jq.getFileurl();
                 }
             }
-            if(readPdfUrlListDto.getBusinessList()!=null && !readPdfUrlListDto.getBusinessList().isEmpty()){
+            if (readPdfUrlListDto.getBusinessList() != null && !readPdfUrlListDto.getBusinessList().isEmpty()) {
                 //商业
-                ReadPdfUrlDto sy= readPdfUrlListDto.getBusinessList().stream().filter(s->s.getFileTitle().equals("商业电子保单")).collect(Collectors.toList()).get(0);
-                if(sy!=null){
+                ReadPdfUrlDto sy = readPdfUrlListDto.getBusinessList().stream().filter(s -> s.getFileTitle().equals("商业电子保单")).collect(Collectors.toList()).get(0);
+                if (sy != null) {
                     sqFileurl = sy.getFileurl();
                 }
             }
-            if(StringUtils.isBlank(jqFileurl)){
-                jqFileurl=sqFileurl;
-                code="2";
+            if (StringUtils.isBlank(jqFileurl)) {
+                jqFileurl = sqFileurl;
+                code = "2";
             }
-            String localUrl ="";
-            if(StringUtils.isNotBlank(jqFileurl)){
+            String localUrl = "";
+            if (StringUtils.isNotBlank(jqFileurl)) {
                 localUrl = PDFUtil.trafferHttpToLocalPath(jqFileurl);
-            }else{
+            } else {
                 throw new SystemException("保单为空不能更新!!");
             }
             //通过保险公司配置读取截取的前缀和后缀
             LambdaQueryWrapper<InsOrderReadPdf> qws = new LambdaQueryWrapper<>();
-            qws.eq(InsOrderReadPdf::getCompanyId,subOrder.getCompanyId());
-            qws.eq(InsOrderReadPdf::getType,code);
+            qws.eq(InsOrderReadPdf::getCompanyId, subOrder.getCompanyId());
+            qws.eq(InsOrderReadPdf::getType, code);
             List<InsOrderReadPdf> list = insOrderReadPdfService.list(qws);
-            HashMap<String,LocalDateTime> map=new HashMap<>();
-            HashMap<String,LocalDateTime> oldMap=new HashMap<>();
-            oldMap.put("payDate",subOrder.getPayDate());
-            oldMap.put("signingTime",subOrder.getPayDate());
+            HashMap<String, LocalDateTime> map = new HashMap<>();
+            HashMap<String, LocalDateTime> oldMap = new HashMap<>();
+            oldMap.put("payDate", subOrder.getPayDate());
+            oldMap.put("signingTime", subOrder.getPayDate());
             String pdfText = PDFUtil.getPdfText(localUrl);
-            if(StringUtils.isNotBlank(pdfText)){
-                if(list!=null  && list.size()>0){
-                    for(InsOrderReadPdf insOrderReadPdf:list){
-                       LocalDateTime pdfContentDate = PDFUtil.getPdfContentDate(pdfText, insOrderReadPdf.getReadBegin(), insOrderReadPdf.getReadEnd(), insOrderReadPdf.getReadType());
-                       map.put(insOrderReadPdf.getOrderMsg(),pdfContentDate);
+            if (StringUtils.isNotBlank(pdfText)) {
+                if (list != null && list.size() > 0) {
+                    for (InsOrderReadPdf insOrderReadPdf : list) {
+                        LocalDateTime pdfContentDate = PDFUtil.getPdfContentDate(pdfText, insOrderReadPdf.getReadBegin(), insOrderReadPdf.getReadEnd(), insOrderReadPdf.getReadType());
+                        map.put(insOrderReadPdf.getOrderMsg(), pdfContentDate);
                     }
                 }
             }
             //刪除临时文件
             if (jqFileurl.contains("http") || jqFileurl.contains("https")) {
-                File file =new File(localUrl);
+                File file = new File(localUrl);
                 file.delete();
             }
             //插入數據
-            InsOrderPayDateRecord  dto=new InsOrderPayDateRecord(null, subOrderId, new Date(), "admin", subOrder.getPayDate(), subOrder.getSigningTime(), map.get("payDate"), map.get("signingTime"), oldMap.toString(), map.toString());
+            InsOrderPayDateRecord dto = new InsOrderPayDateRecord(null, subOrderId, new Date(), "admin", subOrder.getPayDate(), subOrder.getSigningTime(), map.get("payDate"), map.get("signingTime"), oldMap.toString(), map.toString());
             this.save(dto);
-            if(map.get("payDate")!=null){
+            if (map.get("payDate") != null) {
                 subOrder.setPayDate(map.get("payDate"));
                 //插入轨迹表
-               // InsOrdersTrack insOrdersTrack = new InsOrdersTrack(subOrder.getId(), subOrder.getCompanyId(), subOrder.getInscompany(), subOrder.getOrderno(), "缴费时间", new BaseController().getUser().getId(), new BaseController().getUser().getName(),"缴费时间",map.get("payDate"));
-               // insOrdersTrackService.save(insOrdersTrack);
+                // InsOrdersTrack insOrdersTrack = new InsOrdersTrack(subOrder.getId(), subOrder.getCompanyId(), subOrder.getInscompany(), subOrder.getOrderno(), "缴费时间", new BaseController().getUser().getId(), new BaseController().getUser().getName(),"缴费时间",map.get("payDate"));
+                // insOrdersTrackService.save(insOrdersTrack);
             }
-            if(map.get("signingTime")!=null){
+            if (map.get("signingTime") != null) {
                 subOrder.setSigningTime(map.get("signingTime"));
             }
             //更新时间表
-             insAreaCompanyService.updateById(subOrder);
-             log.info("更新的订单表为"+subOrder.toString()+new Date().toString());
+            insAreaCompanyService.updateById(subOrder);
+            log.info("更新的订单表为" + subOrder.toString() + new Date().toString());
             //判斷又沒有結算表如果有更新  add  by hxl  2024-12-30
-            if(subOrder.getSigningTime()!=null){
+            if (subOrder.getSigningTime() != null) {
                 LambdaQueryWrapper<InsPlyIncome> lqw = new LambdaQueryWrapper<>();
                 lqw.eq(InsPlyIncome::getOrderno, subOrder.getId());
                 List<InsPlyIncome> insPlyIncome = insPlyIncomeService.list(lqw);
 
-                if(insPlyIncome!=null && insPlyIncome.size()>0){
+                if (insPlyIncome != null && insPlyIncome.size() > 0) {
                     for (InsPlyIncome plyIncome : insPlyIncome) {
                         plyIncome.setSignDate(subOrder.getSigningTime());
                         insPlyIncomeService.updateById(plyIncome);
-                        log.info("更新的结算表为"+plyIncome.toString()+new Date().toString());
+                        log.info("更新的结算表为" + plyIncome.toString() + new Date().toString());
                     }
                 }
             }
 
-        }else{
-           throw   new SystemException("生成保单失败");
+        } else {
+            throw new SystemException("生成保单失败");
         }
     }
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/10/21 17:01
-     *  @Description:  查看保单修改记录
+     * @version
+     * @author: hxl
+     * @Date: 2024/10/21 17:01
+     * @Description: 查看保单修改记录
      */
     @Override
     public List<InsOrderPayDateRecord> updateOrderDateRecord(String subOrderId) {
@@ -178,58 +180,59 @@ public class InsOrderPayDateRecordServiceImpl extends ServiceImpl<InsOrderPayDat
     }
 
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/10/22 10:51
-     *  @Description: 定时更新订单的缴费时间和签单日期
+     * @version
+     * @author: hxl
+     * @Date: 2024/10/22 10:51
+     * @Description: 定时更新订单的缴费时间和签单日期
      */
-    public void batchOrderDate(String beginDate,String endDate) {
-       //查询当前时间0点 到当前时间范围内的已承保的订单  并更新时间 HH:mm:ss
-       List<InsAreaCompany> list = insAreaCompanyService.findListByDate(beginDate,endDate);
-       if(list!=null && list.size()>0){
-           for(InsAreaCompany  insAreaCompany : list){
-               try{
-                   //更新時間
-                   updateOrderDate(insAreaCompany.getId());
-               }catch(Exception e){
-
-               }
-           }
-       }
+    public void batchOrderDate(String beginDate, String endDate) {
+        //查询当前时间0点 到当前时间范围内的已承保的订单  并更新时间 HH:mm:ss
+        List<InsAreaCompany> list = insAreaCompanyService.findListByDate(beginDate, endDate);
+        if (list != null && list.size() > 0) {
+            for (InsAreaCompany insAreaCompany : list) {
+                try {
+                    //更新時間
+                    updateOrderDate(insAreaCompany.getId());
+                } catch (Exception e) {
+
+                }
+            }
+        }
     }
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/12/30 10:03
-     *  @Description: 自动更新签单表的日期
+     * @version
+     * @author: hxl
+     * @Date: 2024/12/30 10:03
+     * @Description: 自动更新签单表的日期
      */
     @Override
     public void batchOrderPlyOrderDate(String benginDate, String endDate) {
         //查询签单日期为空的数据
-        List<InsPlyIncome> list = insPlyIncomeService.findListByDate(benginDate,endDate);
-        List<InsPlyIncome>  newList =new ArrayList<>();
-        if(list!=null && list.size()>0){
-            for(InsPlyIncome  insPlyIncome : list){
+        List<InsPlyIncome> list = insPlyIncomeService.findListByDate(benginDate, endDate);
+        List<InsPlyIncome> newList = new ArrayList<>();
+        if (list != null && list.size() > 0) {
+            for (InsPlyIncome insPlyIncome : list) {
                 //更新子订单的签单时间
-                if(insPlyIncome.getSignDate()==null){
-                    try{
-                       updateOrderDate(insPlyIncome.getOrderno());
-                    }catch(Exception e){
+                if (insPlyIncome.getSignDate() == null) {
+                    try {
+                        updateOrderDate(insPlyIncome.getOrderno());
+                    } catch (Exception e) {
 
                     }
                 }
                 //更新時間
-                InsPlyIncome  ply = insPlyIncomeService.getById(insPlyIncome.getId());
-                if(ply!=null){
+                InsPlyIncome ply = insPlyIncomeService.getById(insPlyIncome.getId());
+                if (ply != null) {
                     InsAreaCompany iac = insAreaCompanyService.getById(insPlyIncome.getOrderno());
-                    if(iac.getSigningTime()!=null){
+                    if (iac.getSigningTime() != null) {
                         ply.setSignDate(iac.getSigningTime());
                         newList.add(ply);
                     }
                 }
             }
             insPlyIncomeService.saveOrUpdateBatch(newList);
-            log.info("更新的结算表为"+newList.toString()+new Date().toString());
+            log.info("更新的结算表为" + newList.toString() + new Date().toString());
         }
     }
 }

+ 7 - 4
src/main/java/com/ydtech/modules/order/timer/UpdateOrderTimer.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.order.timer;
 
+import com.xxl.job.core.handler.annotation.XxlJob;
 import com.ydtech.modules.admin.utils.SliceUpDateUtil;
 import com.ydtech.modules.order.service.InsOrderPayDateRecordService;
 import com.ydtech.utils.DateUtil;
@@ -35,8 +36,9 @@ public class UpdateOrderTimer {
      *  @Date: 2024/12/27 17:26
      *  @Description:  每10分钟执行下更新订单时间
      */
-    @Async
-    @Scheduled(cron = "0 0/30 * * * ?")
+//    @Async
+//    @Scheduled(cron = "0 0/30 * * * ?")
+    @XxlJob("updateOrderDateMinite")
     public void updateOrderDateMinite() {
         String benginDate = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd")+" 00:00:00";
         String endDate = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd")+" 23:59:59";
@@ -88,8 +90,9 @@ public class UpdateOrderTimer {
       *  @Date: 2024/12/30 9:59
       *  @Description:  自动更新结算表中签单日期为空的数据
       */
-    @Async
-    @Scheduled(cron = "0 0/30 * * * ?")
+//    @Async
+//    @Scheduled(cron = "0 0/30 * * * ?")
+    @XxlJob("updateOrderPlyDateMinite")
     public void updateOrderPlyDateMinite() {
         String benginDate = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd")+" 00:00:00";
         String endDate = DateUtil.getDateFormat(new Date(), "yyyy-MM-dd")+" 23:59:59";

+ 1 - 1
src/main/resources/application-pre.yml

@@ -433,7 +433,7 @@ xxl:
       # 执行器注册 [选填]:优先使用该配置作为注册地址
       address: ""
       # 执行器IP [选填]:默认为空表示自动获取IP
-      ip: "172.24.144.220"
+      ip: ""
       # 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999
       port: 0
       # 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;

+ 1 - 1
src/main/resources/application-prod.yml

@@ -439,7 +439,7 @@ xxl:
       # 执行器注册 [选填]:优先使用该配置作为注册地址
       address: ""
       # 执行器IP [选填]:默认为空表示自动获取IP
-      ip: "172.24.144.220"
+      ip: ""
       # 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999
       port: 0
       # 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;