|
@@ -9,6 +9,7 @@ import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.cache.ConfigCache;
|
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.model.OauthUser;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
@@ -81,6 +82,8 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
private SbInfoService sbInfoService;
|
|
|
private SysConfigService sysConfigService;
|
|
|
private final SysFileMapper sysFileMapper;
|
|
|
+ private CheckStandardMapper checkStandardMapper;
|
|
|
+ private CheckJobMapper checkJobMapper;
|
|
|
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
@@ -430,6 +433,13 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
generateJobBySbId(currentDate);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void genTaskById(String id) {
|
|
|
+ LocalDateTime currentDate = LocalDateTime.now();
|
|
|
+ generateJobById(id,currentDate);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。
|
|
|
*
|
|
@@ -503,6 +513,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
if(standard.getLastDate() == null){
|
|
|
standard.setLastDate(currentDate.toLocalDate());
|
|
|
}
|
|
|
+ standard.setIsGet(new BigDecimal(1));
|
|
|
updateStandardList.add(standard);
|
|
|
jobList.add(checkJob);
|
|
|
}
|
|
@@ -517,6 +528,87 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void generateJobById(String id,LocalDateTime currentDate) {
|
|
|
+ List<CheckStandard> updateStandardList=new ArrayList<>();
|
|
|
+ List<CheckJob> jobList = new ArrayList<>();
|
|
|
+ CheckStandard query=new CheckStandard();
|
|
|
+ query.setId(id);
|
|
|
+ CheckStandard standard = checkStandardMapper.selectByPrimaryKey(query);
|
|
|
+ // 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。初次执行的时候,没有未执行的任务
|
|
|
+// Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
+// weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue());
|
|
|
+// List<CheckJob> checkJobs = mapper.selectByExample(weekend);
|
|
|
+
|
|
|
+
|
|
|
+ if(!CheckPlanPeriodTypeEnum.MILES.getValue().equals(standard.getPeriodType()) && !CheckPlanPeriodTypeEnum.TAISHI.getValue().equals(standard.getPeriodType()) ){
|
|
|
+ boolean find = false;
|
|
|
+// for(CheckJob unDoJob :checkJobs){
|
|
|
+// if(standard.getId().equals(unDoJob.getStandardId()) && standard.getSbId().equals(unDoJob.getSbId())){
|
|
|
+// find = true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ CheckJob checkJob = new CheckJob();
|
|
|
+ checkJob.setSbId(standard.getSbId());
|
|
|
+
|
|
|
+ // 有可能设备已经删除了,继续执行其他的
|
|
|
+ if(StringUtils.isBlank(standard.getSbId())){
|
|
|
+ throw new DeniedException("设备已经被删除了,无法生成保养任务!");
|
|
|
+ }
|
|
|
+ SbInfo sbInfo = sbInfoService.getModelById(standard.getSbId());
|
|
|
+ if(sbInfo == null){
|
|
|
+ throw new DeniedException("没有找到该设备,无法生成保养任务!");
|
|
|
+ }
|
|
|
+ if(!sbInfo.getStatus().equals(SbInfoStatusEnum.IN_USE.getValue())){
|
|
|
+ throw new DeniedException("设备不在使用中,无法生成保养任务!");
|
|
|
+ }
|
|
|
+ if(standard.getCheckUserType() == null){
|
|
|
+ if(standard.getPeriodType()< CheckPlanPeriodTypeEnum.WEEK.getValue()){
|
|
|
+ checkJob.setCheckUserId(sbInfo.getSaveUser());
|
|
|
+ standard.setCheckUserType(CheckUserTypeEnum.USE_USER.getValue());
|
|
|
+ }else{
|
|
|
+ checkJob.setCheckUserId(sbInfo.getRepairUser());
|
|
|
+ standard.setCheckUserType(CheckUserTypeEnum.REPAIR_USER.getValue());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(standard.getCheckUserType().equals(CheckUserTypeEnum.USE_USER.getValue())){
|
|
|
+ checkJob.setCheckUserId(sbInfo.getSaveUser());
|
|
|
+ }else if(standard.getCheckUserType().equals(CheckUserTypeEnum.REPAIR_USER.getValue())){
|
|
|
+ checkJob.setCheckUserId(sbInfo.getRepairUser());
|
|
|
+ }else if(standard.getCheckUserType().equals(CheckUserTypeEnum.ZHIDING.getValue())){
|
|
|
+ checkJob.setCheckUserId(sbInfo.getRepairUser());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkJob.setStandardHours(standard.getStandardHours());
|
|
|
+ checkJob.setStatus(CheckJobStatusEnum.NOT_EXECUTE.getValue());
|
|
|
+ // 计算计划开始时间和结束时间
|
|
|
+ calcTime(checkJob, currentDate, standard);
|
|
|
+ checkJob.setCreatedTime(LocalDateTime.now());
|
|
|
+ checkJob.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ checkJob.setPartId(standard.getPart());
|
|
|
+ checkJob.setStandardId(standard.getId());
|
|
|
+ checkJob.setType(standard.getType());
|
|
|
+ checkJob.setReceiveOvertime(false);
|
|
|
+ checkJob.setRequirement(standard.getRequirement());
|
|
|
+ checkJob.setRemark(standard.getRemark());
|
|
|
+ checkJob.setName(standard.getName());
|
|
|
+ if(standard.getLastDate() == null){
|
|
|
+ standard.setLastDate(currentDate.toLocalDate());
|
|
|
+ }
|
|
|
+ standard.setIsGet(new BigDecimal(1));
|
|
|
+ updateStandardList.add(standard);
|
|
|
+ jobList.add(checkJob);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(jobList)) {
|
|
|
+ mapper.insertListforComplex(jobList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(updateStandardList)) {
|
|
|
+ standardMapper.updateBatch(updateStandardList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断某个计划,某个设备,某个标准,是否要生成任务
|
|
|
*
|