Sfoglia il codice sorgente

更新告警状态

suntianwu 2 anni fa
parent
commit
70e8c62b81

+ 4 - 4
purchase-admin/src/main/java/com/ozs/web/controller/tool/PmTaskServer.java

@@ -40,7 +40,7 @@ public class PmTaskServer {
         if(ObjectUtils.isEmpty(list)){
             return;
         }
-        Date now = new Date();
+        Date now = DateUtils.parseDate(DateUtils.getDate());
         List<PmDemand> updateList = new ArrayList<>();
         List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
         int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
@@ -52,7 +52,7 @@ public class PmTaskServer {
         list.forEach(item-> {
             //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
             int diff1 = DateUtils.differentDaysByMillisecond(item.getPlanDemandSubTime(), now);
-            if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff1 > setting1) {
+            if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff1 >= setting1) {
                 log.info("******** 需求提报预警: " + item.getProjectName());
                 PmDemand pmDemand = new PmDemand();
                 pmDemand.setDemandId(item.getDemandId());
@@ -61,7 +61,7 @@ public class PmTaskServer {
             } else {
                 //采购完成时间:根据数据阈值中设置的采购完成时间进行判断,进行预警
                 int diff2 = DateUtils.differentDaysByMillisecond(item.getPlanPurchaseFinishTime(), now);
-                if ( ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff2 > setting2) {
+                if ( ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff2 >= setting2) {
                     log.info("******** 采购完成预警: " + item.getProjectName());
                     PmDemand pmDemand = new PmDemand();
                     pmDemand.setDemandId(item.getDemandId());
@@ -70,7 +70,7 @@ public class PmTaskServer {
                 } else {
                     //计划交付时间:根据数据阈值中设置的交付时间进行判断,进行预警
                     int diff3 = DateUtils.differentDaysByMillisecond(item.getPlanDeliverTime(), now);
-                    if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff3 > setting3) {
+                    if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff3 >= setting3) {
                         log.info("******** 计划交付预警: " + item.getProjectName());
                         PmDemand pmDemand = new PmDemand();
                         pmDemand.setDemandId(item.getDemandId());

+ 8 - 0
purchase-system/src/main/java/com/ozs/pm/service/IPmDemandService.java

@@ -116,6 +116,14 @@ public interface IPmDemandService extends IService<PmDemand> {
 
     boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception;
 
+    /**
+     * 更新需求预警状态
+     *
+     * @param demnadId
+     * @return
+     */
+    void updateDemandWarnStatus(Long demnadId);
+
     /**
      * 通过需求ID列表 查询采购执行列表 sunhh
      *

+ 25 - 2
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -17,6 +17,7 @@ import com.ozs.base.domain.vo.BaseExpertVo;
 import com.ozs.base.service.*;
 import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.common.core.domain.entity.SysDept;
+import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.common.core.domain.entity.SysRole;
 import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.common.enums.*;
@@ -85,8 +86,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Autowired
     private PmBidWinningService pmBidWinningService;
-
-
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
     @Autowired
     private PmBidFailureService pmBidFailureService;
     @Autowired
@@ -1449,6 +1450,28 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         }
     }
 
+    /**
+     * 更新需求预警状态
+     *
+     * @param demnadId
+     * @return
+     */
+    @Override
+    public void updateDemandWarnStatus(Long demnadId) {
+        PmDemand pmDemand = this.getById(demnadId);
+        List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
+        int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
+        //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
+        int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
+        if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 >= setting1) {
+            PmDemand pmDemandUpdate = new PmDemand();
+            pmDemandUpdate.setDemandId(demnadId);
+            pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
+            this.updateById(pmDemand);
+        }
+    }
+
+
     /**
      * 通过需求ID列表 查询采购执行列表 sunhh
      *