|
@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.util.*;
|
|
import com.platform.common.util.*;
|
|
import com.platform.dao.bean.MyPage;
|
|
import com.platform.dao.bean.MyPage;
|
|
|
|
+import com.platform.dao.bean.MyVOPage;
|
|
import com.platform.dao.dto.check.CheckJobDTO;
|
|
import com.platform.dao.dto.check.CheckJobDTO;
|
|
import com.platform.dao.dto.check.CheckStandardDTO;
|
|
import com.platform.dao.dto.check.CheckStandardDTO;
|
|
import com.platform.dao.dto.check.CheckStandardParamDTO;
|
|
import com.platform.dao.dto.check.CheckStandardParamDTO;
|
|
@@ -462,19 +463,20 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询备件预警
|
|
* 查询备件预警
|
|
- *
|
|
|
|
- * @param type
|
|
|
|
|
|
+ * @param month 距离当前时间的几个月
|
|
|
|
+ * @param type 类型:1点检,2保养
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public void genSpareWarnTask(int type) {
|
|
|
|
|
|
+ public void genSpareWarnTask(int month, int type) {
|
|
CheckStandardDTO checkStandardDTO = new CheckStandardDTO();
|
|
CheckStandardDTO checkStandardDTO = new CheckStandardDTO();
|
|
|
|
+ checkStandardDTO.setType(type);
|
|
checkStandardDTO.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
|
|
checkStandardDTO.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
|
|
List<CheckStandard> checkStandardList = super.getModelListByDTO(checkStandardDTO);
|
|
List<CheckStandard> checkStandardList = super.getModelListByDTO(checkStandardDTO);
|
|
|
|
|
|
// 查询近六个月待执行的任务列表。
|
|
// 查询近六个月待执行的任务列表。
|
|
LocalDate now = LocalDate.now();
|
|
LocalDate now = LocalDate.now();
|
|
- LocalDate afterSixMonth = DateUtils.plus(now, 6, ChronoUnit.MONTHS);
|
|
|
|
|
|
+ LocalDate afterSixMonth = DateUtils.plus(now, month, ChronoUnit.MONTHS);
|
|
Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue())
|
|
weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue())
|
|
.andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
.andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
@@ -497,13 +499,43 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
}
|
|
}
|
|
if(CollectionUtil.isNotEmpty(warnList)){
|
|
if(CollectionUtil.isNotEmpty(warnList)){
|
|
List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXZG.getValue()}));
|
|
List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXZG.getValue()}));
|
|
- sendOverTimeNotice(users, warnList);
|
|
|
|
|
|
+ sendOverTimeNotice(month, users, warnList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public AbstractPageResultBean<CheckStandardSpareVO> selectSpareWarnVOPage(int month, int type, int pageNum, int pageSize) {
|
|
|
|
+ CheckStandardDTO checkStandardDTO = new CheckStandardDTO();
|
|
|
|
+ checkStandardDTO.setType(type);
|
|
|
|
+ checkStandardDTO.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
|
|
|
|
+ List<CheckStandard> checkStandardList = super.getModelListByDTO(checkStandardDTO);
|
|
|
|
+
|
|
|
|
+ // 查询近六个月待执行的任务列表。
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+ LocalDate afterSixMonth = DateUtils.plus(now, month, ChronoUnit.MONTHS);
|
|
|
|
+ Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
|
+ weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue())
|
|
|
|
+ .andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
|
|
+ List<CheckJob> checkJobs = checkJobMapper.selectByExample(weekend);
|
|
|
|
+
|
|
|
|
+ // 获取未执行的标准id,不能用stream获取id列表,会覆盖重复的标准id(不会重复,因为一个标准对应一个任务。)
|
|
|
|
+ List<CheckStandardSpareVO> voList = new ArrayList<CheckStandardSpareVO>();
|
|
|
|
+ if(CollectionUtil.isNotEmpty(checkJobs)){
|
|
|
|
+ List<String> ids = checkJobs.stream().map(CheckJob::getStandardId).collect(Collectors.toList());
|
|
|
|
+ ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
|
+ if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
|
+ CheckStandardSpareDTO dto = new CheckStandardSpareDTO();
|
|
|
|
+ dto.setCheckIds(ids);
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ voList = spareMapper.selectSpareWarn(dto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return new MyVOPage<>(voList);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据身份获取用户
|
|
* 根据身份获取用户
|
|
*
|
|
*
|
|
@@ -522,14 +554,14 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
* @param users
|
|
* @param users
|
|
* @param tasks
|
|
* @param tasks
|
|
*/
|
|
*/
|
|
- private void sendOverTimeNotice(List<SysUser> users, List<CheckStandardSpareVO> tasks) {
|
|
|
|
|
|
+ private void sendOverTimeNotice(int month, List<SysUser> users, List<CheckStandardSpareVO> tasks) {
|
|
if (CollectionUtil.isNotEmpty(users) && CollectionUtil.isNotEmpty(tasks)) {
|
|
if (CollectionUtil.isNotEmpty(users) && CollectionUtil.isNotEmpty(tasks)) {
|
|
List<String> userIds = users.stream().map(item -> item.getUserId()).collect(Collectors.toList());
|
|
List<String> userIds = users.stream().map(item -> item.getUserId()).collect(Collectors.toList());
|
|
List<String> mails = users.stream().map(item -> item.getEmail()).collect(Collectors.toList());
|
|
List<String> mails = users.stream().map(item -> item.getEmail()).collect(Collectors.toList());
|
|
StringBuffer context = new StringBuffer();
|
|
StringBuffer context = new StringBuffer();
|
|
tasks.forEach(item -> context.append(item.toString()));
|
|
tasks.forEach(item -> context.append(item.toString()));
|
|
SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
|
|
SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
|
|
- null, MessageTemplateUtil.getSpareWarnNotic(context.toString(), tasks.size()),
|
|
|
|
|
|
+ null, MessageTemplateUtil.getSpareWarnNotic(month, context.toString(), tasks.size()),
|
|
null, userIds, mails));
|
|
null, userIds, mails));
|
|
}
|
|
}
|
|
}
|
|
}
|