|
@@ -1,5 +1,6 @@
|
|
|
package com.platform.service.check.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
@@ -13,8 +14,10 @@ import com.platform.dao.dto.check.CheckPlanDTO;
|
|
|
import com.platform.dao.dto.check.CheckProjectPlanRelationDTO;
|
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
import com.platform.dao.entity.check.*;
|
|
|
+import com.platform.dao.entity.upms.SysFile;
|
|
|
import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.mapper.check.*;
|
|
|
+import com.platform.dao.mapper.upms.SysFileMapper;
|
|
|
import com.platform.dao.vo.SysUserVO;
|
|
|
import com.platform.dao.vo.query.check.CheckJobVO;
|
|
|
import com.platform.dao.vo.query.check.CheckPlanVO;
|
|
@@ -58,6 +61,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
private SysUserDeptService sysUserDeptService;
|
|
|
private SbInfoService sbInfoService;
|
|
|
|
|
|
+ private final SysFileMapper sysFileMapper;
|
|
|
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
@@ -520,12 +524,26 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
|
|
|
@Override
|
|
|
public CheckJobVO getDetail(Object id) {
|
|
|
- return mapper.selectDetail(id);
|
|
|
+ CheckJobVO vo = mapper.selectDetail(id);
|
|
|
+ Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getTargetId, vo.getId());
|
|
|
+ List<SysFile> sysFiles = sysFileMapper.selectByExample(weekend);
|
|
|
+ List<SysFile> sbFileList = ListUtils.newArrayList();
|
|
|
+ sysFiles.forEach(item -> {
|
|
|
+ if (item.getType().equals( SysFileTypeEnum.CHECK_JOB_FILES.getValue())) {
|
|
|
+ sbFileList.add(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ vo.setImgList(sbFileList);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void executeJob(Object id) {
|
|
|
CheckJob checkJob = mapper.selectByPrimaryKey(id);
|
|
|
+ if(!CheckJobStatusEnum.NOT_EXECUTE.getValue().equals(checkJob.getStatus()) && !CheckJobStatusEnum.OUT_OF_DATE.getValue().equals(checkJob.getStatus())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
checkJob.setStatus(CheckJobStatusEnum.EXECUTING.getValue());
|
|
|
checkJob.setActualStartTime(LocalDateTime.now());
|
|
|
UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
|
|
@@ -547,6 +565,9 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
public void finishJob(CheckJobDTO dto) {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
CheckJob checkJob = mapper.selectByPrimaryKey(dto.getId());
|
|
|
+ if(!CheckJobStatusEnum.EXECUTING.getValue().equals(checkJob.getStatus()) && !CheckJobStatusEnum.OUT_OF_DATE.getValue().equals(checkJob.getStatus())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
checkJob.setStatus(CheckJobStatusEnum.FINISHED.getValue());
|
|
|
checkJob.setActualEndTime(now);
|
|
|
checkJob.setRealHours(DateUtils.getDurationMinutes(checkJob.getActualStartTime(), checkJob.getActualEndTime()) + "");
|
|
@@ -558,8 +579,11 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
checkJob.setFeedback(dto.getFeedback());
|
|
|
mapper.updateByPrimaryKeySelective(checkJob);
|
|
|
|
|
|
+ // 提交完成图片信息
|
|
|
+ this.saveFile(dto);
|
|
|
+
|
|
|
// 非台时和公里,则需要生成下一次的任务
|
|
|
- CheckStandard checkStandard = standardMapper.selectByPrimaryKey(dto.getStandardId());
|
|
|
+ CheckStandard checkStandard = standardMapper.selectByPrimaryKey(checkJob.getStandardId());
|
|
|
if(!CheckPlanPeriodTypeEnum.MILES.getValue().equals(checkStandard.getPeriodType()) && !CheckPlanPeriodTypeEnum.TAISHI.getValue().equals(checkStandard.getPeriodType()) ){
|
|
|
CheckJob nextCheckJob = BeanConverterUtil.copyObjectProperties(checkJob,CheckJob.class);
|
|
|
nextCheckJob.setId(IdGeneratorUtils.getObjectId());
|
|
@@ -568,6 +592,20 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void executeJobBatch(List<String> ids) {
|
|
|
+ ids.forEach(id->this.executeJob(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void finishJobBatch(List<String> ids) {
|
|
|
+ ids.forEach(id->{
|
|
|
+ CheckJobDTO dto = new CheckJobDTO();
|
|
|
+ dto.setId(id);
|
|
|
+ this.finishJob(dto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int countUserTask(String userId, Integer type) {
|
|
|
Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
@@ -579,4 +617,24 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
weekendCriteria.andIn(CheckJob::getStatus, statusList);
|
|
|
return mapper.selectCountByExample(weekend);
|
|
|
}
|
|
|
+
|
|
|
+ private void saveFile(CheckJobDTO model) {
|
|
|
+
|
|
|
+ List<SysFile> repairFileList = model.getImgList();
|
|
|
+ List<SysFile> list = ListUtils.newArrayList();
|
|
|
+ if (CollectionUtil.isNotEmpty(repairFileList)) {
|
|
|
+ Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ sysFileMapper.deleteByExample(weekend);
|
|
|
+ repairFileList.forEach(item -> {
|
|
|
+ item.setType(SysFileTypeEnum.CHECK_JOB_FILES.getValue());
|
|
|
+ item.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ item.setTargetId(model.getId());
|
|
|
+ list.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ sysFileMapper.insertListforComplex(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|