|  | @@ -7,10 +7,14 @@ import cn.hutool.core.util.ObjectUtil;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 | 
	
		
			
				|  |  | +import com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.constant.SecurityConstants;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.exception.ServiceException;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.utils.DateHelper;
 | 
	
		
			
				|  |  |  import com.xunmei.common.security.utils.SecurityUtils;
 | 
	
		
			
				|  |  | +import com.xunmei.core.question.QuestionConfirmEnum;
 | 
	
		
			
				|  |  | +import com.xunmei.core.question.QuestionReformEnum;
 | 
	
		
			
				|  |  |  import com.xunmei.core.question.QuestionSrcType;
 | 
	
		
			
				|  |  |  import com.xunmei.core.question.domain.Question;
 | 
	
		
			
				|  |  |  import com.xunmei.core.question.service.IQuestionService;
 | 
	
	
		
			
				|  | @@ -26,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.TransactionManager;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.support.TransactionSynchronization;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.support.TransactionSynchronizationAdapter;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.support.TransactionSynchronizationManager;
 | 
	
		
			
				|  |  |  import sun.nio.ch.ThreadPool;
 | 
	
	
		
			
				|  | @@ -61,6 +66,9 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private AppPlanService appPlanService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ResumptionDelServiceImpl resumptionDelService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public ResumptionTaskDetailVo getTask(ResumptionTaskDetailVo taskDetailVo) throws Exception {
 | 
	
	
		
			
				|  | @@ -85,10 +93,10 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |          //履职状态:1 待履职,2 进行中,3 已完成,4 已过期
 | 
	
		
			
				|  |  |          Resumption resumption = resumptionMapper.findOneByTaskIdAndDate(taskDetailVo.getTaskId(), year, quarter);
 | 
	
		
			
				|  |  |          Integer status = resumption.getStatus();
 | 
	
		
			
				|  |  | -        if(status == 1){
 | 
	
		
			
				|  |  | +        if (status == 1) {
 | 
	
		
			
				|  |  |              //增加待履职不能在未开始时打开逻辑
 | 
	
		
			
				|  |  |              Date start = resumption.getPlanStartTime();
 | 
	
		
			
				|  |  | -            if(start.after(new Date())){
 | 
	
		
			
				|  |  | +            if (start.after(new Date())) {
 | 
	
		
			
				|  |  |                  throw new RuntimeException("任务未到开始时间!");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -126,6 +134,9 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |          int quarter = dateTime.getQuarter();
 | 
	
		
			
				|  |  |          //获取履职任务
 | 
	
		
			
				|  |  |          Resumption sysResumption = resumptionMapper.findOneByTaskIdAndDate(taskId, year, quarter);
 | 
	
		
			
				|  |  | +        if (sysResumption == null) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException("任务数据不存在!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          AppPlan appPlan = appPlanMapper.selectById(sysResumption.getPlanId());
 | 
	
		
			
				|  |  |          sysResumption.setUpdateBy(SecurityUtils.getUsername());
 | 
	
		
			
				|  |  |          sysResumption.setSubmitorId(SecurityUtils.getUserId());
 | 
	
	
		
			
				|  | @@ -141,19 +152,23 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |              sysResumption.setStatus(3);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //删除之前的数据
 | 
	
		
			
				|  |  | -        appResumptionDataMapper.deleteByResumptionId(taskId);
 | 
	
		
			
				|  |  | -        appResumptionDataNfcMapper.deleteByResumptionId(taskId);
 | 
	
		
			
				|  |  | -        appResumptionDataRemarkimgMapper.deleteByResumptionId(taskId);
 | 
	
		
			
				|  |  | +        resumptionDelService.delResumptionData(taskId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //保存新的数据
 | 
	
		
			
				|  |  |          AppResumptionData data = null;
 | 
	
		
			
				|  |  |          List<ResumptionItemVo> checks = taskDetailVo.getChecks();
 | 
	
		
			
				|  |  |          Integer exceptionCount = 0;
 | 
	
		
			
				|  |  | +        List<AppResumptionData> ards = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<Question> questions = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<AppResumptionDataRemarkimg> adImgs = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<AppResumptionDataNfc> dataNfcs = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (ResumptionItemVo check : checks) {
 | 
	
		
			
				|  |  |              List<ResumptionPointVo> points = check.getPoints();
 | 
	
		
			
				|  |  |              for (ResumptionPointVo point : points) {
 | 
	
		
			
				|  |  |                  data = new AppResumptionData();
 | 
	
		
			
				|  |  | +                Long pointId = IdWorker.getId(data);
 | 
	
		
			
				|  |  |                  data.setDataStatus(point.getDataStatus());
 | 
	
		
			
				|  |  |                  data.setResumptionId(taskId);
 | 
	
		
			
				|  |  |                  data.setAreaId(check.getAreaId());
 | 
	
	
		
			
				|  | @@ -174,10 +189,11 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |                          data.setDataStatus(2);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                appResumptionDataMapper.insert(data);
 | 
	
		
			
				|  |  | +                //appResumptionDataMapper.insert(data);
 | 
	
		
			
				|  |  | +                ards.add(data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (taskDetailVo.getSubType() == 2 && ObjectUtil.equal(point.getResValue(), 1)) {
 | 
	
		
			
				|  |  | -                    if(ObjectUtil.isNull(point.getRectificationDeadline()) || !NumberUtil.isNumber(point.getRectificationDeadline())){
 | 
	
		
			
				|  |  | +                    if (ObjectUtil.isNull(point.getRectificationDeadline()) || !NumberUtil.isNumber(point.getRectificationDeadline())) {
 | 
	
		
			
				|  |  |                          throw new ServiceException("整改期限为空或不是有效的数值");
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      SysOrg org = remoteOrgService.selectSysOrgById(sysResumption.getOrgId(), SecurityConstants.INNER);
 | 
	
	
		
			
				|  | @@ -187,7 +203,7 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |                              .orgName(org.getShortName())
 | 
	
		
			
				|  |  |                              .orgPath(org.getPath())
 | 
	
		
			
				|  |  |                              .SrcPointId(point.getPointId())
 | 
	
		
			
				|  |  | -                            .srcDataPointId(data.getId())
 | 
	
		
			
				|  |  | +                            .srcDataPointId(pointId)
 | 
	
		
			
				|  |  |                              .srcType(QuestionSrcType.Resumption.getValue())
 | 
	
		
			
				|  |  |                              .srcTaskType(appPlan.getPlanType())
 | 
	
		
			
				|  |  |                              .srcTaskName(sysResumption.getName())
 | 
	
	
		
			
				|  | @@ -199,7 +215,15 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |                              .submitTime(ObjectUtil.isNull(data.getSubmitTime()) ? new Date() : data.getSubmitTime())
 | 
	
		
			
				|  |  |                              .reformDeadline(DateUtil.endOfDay(DateUtil.offsetDay(new Date(), Integer.parseInt(point.getRectificationDeadline()))))
 | 
	
		
			
				|  |  |                              .build();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +                    IdWorker.getId(question);
 | 
	
		
			
				|  |  | +                    if (ObjectUtil.equal(question.getOrgId(),SecurityUtils.getLoginUser().getOrgId())) {
 | 
	
		
			
				|  |  | +                        question.setConfirmStatus(QuestionConfirmEnum.Confirmed.getValue());
 | 
	
		
			
				|  |  | +                        question.setReformStatus(QuestionReformEnum.Unreform.getValue());
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        question.setConfirmStatus(QuestionConfirmEnum.Unconfirm.getValue());
 | 
	
		
			
				|  |  | +                        question.setReformStatus(null);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    questions.add(question);
 | 
	
		
			
				|  |  |                      questionService.insertQuestion(question);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -208,10 +232,12 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  List<AppResumptionDataRemarkimg> imgs = point.getImgs();
 | 
	
		
			
				|  |  |                  for (AppResumptionDataRemarkimg img : imgs) {
 | 
	
		
			
				|  |  | -                    img.setResumptionDataId(data.getId());
 | 
	
		
			
				|  |  | +                    img.setResumptionDataId(pointId);
 | 
	
		
			
				|  |  |                      img.setResumptionId(taskId);
 | 
	
		
			
				|  |  | -                    appResumptionDataRemarkimgMapper.insert(img);
 | 
	
		
			
				|  |  | +                    IdWorker.getId(img);
 | 
	
		
			
				|  |  | +                    //appResumptionDataRemarkimgMapper.insert(img);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                adImgs.addAll(imgs);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          sysResumption.setExceptionCount(exceptionCount);
 | 
	
	
		
			
				|  | @@ -231,19 +257,43 @@ public class ResumptionServiceImpl implements ResumptionService {
 | 
	
		
			
				|  |  |              dataNfc.setStatus(nfc.getStatus());
 | 
	
		
			
				|  |  |              dataNfc.setSubmitTime(ObjectUtil.isNull(nfc.getSubmitTime()) ? new Date() : nfc.getSubmitTime());
 | 
	
		
			
				|  |  |              dataNfc.setSubmitBy(nfc.getSubmitBy());
 | 
	
		
			
				|  |  | -            appResumptionDataNfcMapper.insert(dataNfc);
 | 
	
		
			
				|  |  | +            IdWorker.getId(dataNfc);
 | 
	
		
			
				|  |  | +            dataNfcs.add(dataNfc);
 | 
	
		
			
				|  |  | +            //appResumptionDataNfcMapper.insert(dataNfc);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        /**
 | 
	
		
			
				|  |  | +         * 批量修改数据
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //1.批量插入 履职数据。
 | 
	
		
			
				|  |  | +        if(ards.size() > 0){
 | 
	
		
			
				|  |  | +            resumptionMapper.batchInsertResumptionData(ards);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //2.批量插入 问题数据。
 | 
	
		
			
				|  |  | +        if(questions.size() > 0){
 | 
	
		
			
				|  |  | +            resumptionMapper.batchInsertResumptionQuestion(questions);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //3.批量插入 图片数据。
 | 
	
		
			
				|  |  | +        if(adImgs.size() > 0){
 | 
	
		
			
				|  |  | +            resumptionMapper.batchInsertResumptionImg(adImgs);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //3.批量插入 扫描数据。
 | 
	
		
			
				|  |  | +        if(dataNfcs.size() > 0){
 | 
	
		
			
				|  |  | +            resumptionMapper.batchInsertResumptionNfc(dataNfcs);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          resumptionMapper.updateById(sysResumption);
 | 
	
		
			
				|  |  |          if (ObjectUtil.equal(taskDetailVo.getSubType(), 2)) {
 | 
	
		
			
				|  |  | -//            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
 | 
	
		
			
				|  |  | -//                @Override
 | 
	
		
			
				|  |  | -//                public void afterCommit() {
 | 
	
		
			
				|  |  | -            appPlanService.updatePlanCompletedState(sysResumption.getPlanId(), 1);
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//            });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
 | 
	
		
			
				|  |  | +                @Override
 | 
	
		
			
				|  |  | +                public void afterCommit() {
 | 
	
		
			
				|  |  | +                    appPlanService.updatePlanCompletedState(sysResumption.getPlanId(), 1);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 |