|
@@ -850,84 +850,86 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
* @param currentDate
|
|
|
*/
|
|
|
private void generateJobBySbId(LocalDateTime currentDate) {
|
|
|
- List<CheckJob> jobList = new ArrayList<CheckJob>();
|
|
|
- List<CheckStandard> standardList = standardMapper.selectAll();
|
|
|
+ List<CheckJob> jobList = new ArrayList<CheckJob>();
|
|
|
|
|
|
- // 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。初次执行的时候,没有未执行的任务
|
|
|
- Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
- weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue());
|
|
|
- List<CheckJob> checkJobs = mapper.selectByExample(weekend);
|
|
|
+ List<CheckStandard> standardList = standardMapper.selectAll();
|
|
|
|
|
|
- // 针对没有设置指定人方式的,要更新
|
|
|
- List<CheckStandard> updateStandardList = new ArrayList<CheckStandard>();
|
|
|
- for(CheckStandard standard: standardList){
|
|
|
- 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;
|
|
|
+ // 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。初次执行的时候,没有未执行的任务
|
|
|
+ Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
+ weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue());
|
|
|
+ List<CheckJob> checkJobs = mapper.selectByExample(weekend);
|
|
|
+
|
|
|
+ // 针对没有设置指定人方式的,要更新
|
|
|
+ List<CheckStandard> updateStandardList = new ArrayList<CheckStandard>();
|
|
|
+ for (CheckStandard standard : standardList) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if(!find){
|
|
|
- CheckJob checkJob = new CheckJob();
|
|
|
- checkJob.setSbId(standard.getSbId());
|
|
|
+ if (!find) {
|
|
|
+ CheckJob checkJob = new CheckJob();
|
|
|
+ checkJob.setSbId(standard.getSbId());
|
|
|
|
|
|
- // 有可能设备已经删除了,继续执行其他的
|
|
|
- if(StringUtils.isBlank(standard.getSbId())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- SbInfo sbInfo = sbInfoService.getModelById(standard.getSbId());
|
|
|
- if(sbInfo == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(!sbInfo.getStatus().equals(SbInfoStatusEnum.IN_USE.getValue())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- 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());
|
|
|
+ // 有可能设备已经删除了,继续执行其他的
|
|
|
+ if (StringUtils.isBlank(standard.getSbId())) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }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());
|
|
|
+ SbInfo sbInfo = sbInfoService.getModelById(standard.getSbId());
|
|
|
+ if (sbInfo == null) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ if (!sbInfo.getStatus().equals(SbInfoStatusEnum.IN_USE.getValue())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ updateStandardList.add(standard);
|
|
|
+ jobList.add(checkJob);
|
|
|
}
|
|
|
- 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());
|
|
|
- }
|
|
|
- updateStandardList.add(standard);
|
|
|
- jobList.add(checkJob);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(jobList)) {
|
|
|
- mapper.insertListforComplex(jobList);
|
|
|
- }
|
|
|
+ if (!CollectionUtils.isEmpty(jobList)) {
|
|
|
+ mapper.insertListforComplex(jobList);
|
|
|
+ }
|
|
|
|
|
|
- if (!CollectionUtils.isEmpty(updateStandardList)) {
|
|
|
- standardMapper.updateBatch(updateStandardList);
|
|
|
- }
|
|
|
+ if (!CollectionUtils.isEmpty(updateStandardList)) {
|
|
|
+ standardMapper.updateBatch(updateStandardList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|