|
@@ -1,10 +1,13 @@
|
|
|
package com.ozs.web.controller.tool;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.ozs.common.core.domain.entity.SysDictData;
|
|
|
import com.ozs.common.enums.PmProjectStatus;
|
|
|
+import com.ozs.common.enums.WarnStatus;
|
|
|
import com.ozs.common.utils.DateUtils;
|
|
|
import com.ozs.pm.doman.PmDemand;
|
|
|
import com.ozs.pm.service.IPmDemandService;
|
|
|
+import com.ozs.system.service.ISysDictTypeService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -13,6 +16,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 项目管理任务调度
|
|
@@ -22,64 +26,65 @@ import java.util.List;
|
|
|
public class PmTaskServer {
|
|
|
@Autowired
|
|
|
private IPmDemandService pmDemandService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDictTypeService iSysDictTypeService;
|
|
|
|
|
|
/**
|
|
|
* 更新预警状态
|
|
|
*/
|
|
|
public void updateDemandWarnStatus(){
|
|
|
- log.info("******** 项目管理任务 开始");
|
|
|
+ log.info("******** 项目更新预警状态任务 开始");
|
|
|
LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
|
|
|
- lw.in(PmDemand::getProjectStatus,
|
|
|
- PmProjectStatus.DEMAND_WAIT_FILL.getCode(),
|
|
|
- PmProjectStatus.DEMAND_WAIT_COMMIT.getCode(),
|
|
|
- PmProjectStatus.DEMAND_AUDIT_RETURN.getCode(),
|
|
|
-
|
|
|
- PmProjectStatus.DEMAND_WAIT_AUDIT.getCode(),
|
|
|
- PmProjectStatus.TASK_WAIT_RELEASE.getCode(),
|
|
|
- PmProjectStatus.CONTRACT_WAIT_FILL.getCode(),
|
|
|
- PmProjectStatus.UNDER_CONSTRUCTION.getCode()
|
|
|
- );
|
|
|
-
|
|
|
+ lw.ne(PmDemand::getProjectStatus, PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
|
|
|
List<PmDemand> list = this.pmDemandService.list(lw);
|
|
|
if(ObjectUtils.isEmpty(list)){
|
|
|
return;
|
|
|
}
|
|
|
+ Date now = new Date();
|
|
|
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());
|
|
|
+ log.info("******** setting1 == " + setting1);
|
|
|
+ int setting2 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划完成时间")).collect(Collectors.toList()).get(0).getDictValue());
|
|
|
+ log.info("******** setting2 == " + setting2);
|
|
|
+ int setting3 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划交付(实施)时间")).collect(Collectors.toList()).get(0).getDictValue());
|
|
|
+ log.info("******** setting3 == " + setting3);
|
|
|
list.forEach(item-> {
|
|
|
- if(PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(item.getProjectStatus())
|
|
|
- || PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(item.getProjectStatus())
|
|
|
- || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(item.getProjectStatus())){
|
|
|
- //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
|
|
|
- int diff = DateUtils.differentDaysByMillisecond(item.getPlanDemandSubTime(), new Date());
|
|
|
- if (diff > 30 && ObjectUtils.isEmpty(item.getRealDemandCommitTime())) {
|
|
|
- updateList.add(item);
|
|
|
- }
|
|
|
- } else if(PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(item.getProjectStatus())){
|
|
|
+ //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
|
|
|
+ int diff1 = DateUtils.differentDaysByMillisecond(item.getPlanDemandSubTime(), now);
|
|
|
+ if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff1 > setting1) {
|
|
|
+ log.info("******** 需求提报预警: " + item.getProjectName());
|
|
|
+ PmDemand pmDemand = new PmDemand();
|
|
|
+ pmDemand.setDemandId(item.getDemandId());
|
|
|
+ pmDemand.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
|
|
|
+ updateList.add(pmDemand);
|
|
|
+ } else {
|
|
|
//采购完成时间:根据数据阈值中设置的采购完成时间进行判断,进行预警
|
|
|
- int diff = DateUtils.differentDaysByMillisecond(item.getPlanDemandSubTime(), new Date());
|
|
|
- if (diff > 30 && ObjectUtils.isEmpty(item.getRealDemandCommitTime())) {
|
|
|
- updateList.add(item);
|
|
|
- }
|
|
|
-
|
|
|
- } else if(PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(item.getProjectStatus())){
|
|
|
- //计划交付时间:根据数据阈值中设置的交付时间进行判断,进行预警和发函催告
|
|
|
- int diff = DateUtils.differentDaysByMillisecond(item.getPlanDemandSubTime(), new Date());
|
|
|
- if (diff > 30 && ObjectUtils.isEmpty(item.getRealDemandCommitTime())) {
|
|
|
- updateList.add(item);
|
|
|
+ int diff2 = DateUtils.differentDaysByMillisecond(item.getPlanPurchaseFinishTime(), now);
|
|
|
+ if ( ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff2 > setting2) {
|
|
|
+ log.info("******** 采购完成预警: " + item.getProjectName());
|
|
|
+ PmDemand pmDemand = new PmDemand();
|
|
|
+ pmDemand.setDemandId(item.getDemandId());
|
|
|
+ pmDemand.setWarnStatus(WarnStatus.PURCHASE_FINISH_WARNING.getCode());
|
|
|
+ updateList.add(pmDemand);
|
|
|
+ } else {
|
|
|
+ //计划交付时间:根据数据阈值中设置的交付时间进行判断,进行预警
|
|
|
+ int diff3 = DateUtils.differentDaysByMillisecond(item.getPlanDeliverTime(), now);
|
|
|
+ if (ObjectUtils.isEmpty(item.getRealDemandCommitTime()) && diff3 > setting3) {
|
|
|
+ log.info("******** 计划交付预警: " + item.getProjectName());
|
|
|
+ PmDemand pmDemand = new PmDemand();
|
|
|
+ pmDemand.setDemandId(item.getDemandId());
|
|
|
+ pmDemand.setWarnStatus(WarnStatus.PLAN_DELIVER_WARNING.getCode());
|
|
|
+ updateList.add(pmDemand);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- log.info("******** 项目管理任务 结束");
|
|
|
+ if(!ObjectUtils.isEmpty(updateList)){
|
|
|
+ this.pmDemandService.updateBatchById(updateList);
|
|
|
+ }
|
|
|
+ log.info("******** 项目更新预警状态任务 结束");
|
|
|
}
|
|
|
|
|
|
}
|