Commit 7eaabac8 authored by 刘林's avatar 刘林

fix(jg):超设计使用年限作废功能开发

parent 3bdbe47b
...@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgOverDesignServiceLife; import com.yeejoin.amos.boot.module.jg.api.entity.JgOverDesignServiceLife;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
...@@ -152,4 +151,17 @@ public class JgOverDesignServiceLifeController extends BaseController { ...@@ -152,4 +151,17 @@ public class JgOverDesignServiceLifeController extends BaseController {
String.valueOf(map.get("equDefineCode"))); String.valueOf(map.get("equDefineCode")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
/**
* 超设计使用年限作废
* @param dto
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "超设计使用年限作废", notes = "超设计使用年限作废")
@PutMapping(value = "/invalid")
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<JgOverDesignServiceLife> invalid(@RequestBody JgOverDesignServiceLifeDto dto) {
return ResponseHelper.buildResponse(jgOverDesignServiceLifeServiceImpl.invalid(dto.getSequenceNbr(), dto.getCancelReason()));
}
} }
...@@ -26,6 +26,8 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgOverDesignServiceLifeServi ...@@ -26,6 +26,8 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgOverDesignServiceLifeServi
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICompensateFlowDataOfRedis; import com.yeejoin.amos.boot.module.jg.biz.service.ICompensateFlowDataOfRedis;
...@@ -48,6 +50,8 @@ import org.springframework.beans.BeanUtils; ...@@ -48,6 +50,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -115,6 +119,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -115,6 +119,8 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private InspectionDetectionInfoMapper inspectionDetectionInfoMapper; private InspectionDetectionInfoMapper inspectionDetectionInfoMapper;
@Autowired @Autowired
private SnowflakeIdUtil sequence; private SnowflakeIdUtil sequence;
@Autowired
private EventPublisher eventPublisher;
/** /**
* 分页查询 * 分页查询
...@@ -855,4 +861,106 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign ...@@ -855,4 +861,106 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
.eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr)); .eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr));
return Boolean.TRUE; return Boolean.TRUE;
} }
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgOverDesignServiceLife invalid(Long sequenceNbr, String cancelReason) {
JgOverDesignServiceLife overDesignServiceLife = this.getById(sequenceNbr);
String oldStatus = overDesignServiceLife.getStatus();
overDesignServiceLife.setStatus(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
overDesignServiceLife.setCancelReason(cancelReason);
overDesignServiceLife.setCancelDate(new Date());
overDesignServiceLife.setCancelUserId(RequestContext.getExeUserId());
overDesignServiceLife.setNextExecuteUserIds(null);
overDesignServiceLife.setPromoter(null);
this.updateById(overDesignServiceLife);
// 2.更新关联的业务
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldStatus))), overDesignServiceLife);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(overDesignServiceLife)));
}
});
return overDesignServiceLife;
}
private List<String> getEquList(JgOverDesignServiceLife overDesignServiceLife) {
return jgOverDesignServiceLifeEqMapper.selectList(new LambdaQueryWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLife.getSequenceNbr()))
.stream()
.map(JgOverDesignServiceLifeEq::getEquId)
.collect(toList());
}
private void processElseDataByStatus(FlowStatusEnum oldStatus, JgOverDesignServiceLife overDesignServiceLife) {
switch (oldStatus) {
case TO_BE_SUBMITTED:
commonService.deleteTasksByRelationId(overDesignServiceLife.getSequenceNbr() + "");
break;
case TO_BE_FINISHED:
this.delRepeatUseEquipData(overDesignServiceLife);
this.recoverDesignInfoOfEquip(overDesignServiceLife);
this.recoverUseRegistrationManage(overDesignServiceLife);
break;
default:
this.finishedTask(overDesignServiceLife);
cmWorkflowService.stopProcess(overDesignServiceLife.getInstanceId(), overDesignServiceLife.getCancelReason());
this.delRepeatUseEquipData(overDesignServiceLife);
}
}
private void recoverUseRegistrationManage(JgOverDesignServiceLife overDesignServiceLife) {
List<String> useOrgCodes = jgOverDesignServiceLifeEqMapper.selectList(
new LambdaQueryWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLife.getSequenceNbr()))
.stream()
.map(JgOverDesignServiceLifeEq::getUseRegistrationCode)
.collect(Collectors.toList());
if (!useOrgCodes.isEmpty()) {
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes)
.list();
if (!registrationList.isEmpty()) {
useRegistrationManageService.updateBatchById(
registrationList.stream().peek(v -> {
v.setIsOverDesign("0");
v.setVersion(v.getVersion() - 1);
}).collect(Collectors.toList())
);
}
}
}
private void recoverDesignInfoOfEquip(JgOverDesignServiceLife overDesignServiceLife) {
List<String> records = jgOverDesignServiceLifeEqMapper.selectList(
new LambdaQueryWrapper<JgOverDesignServiceLifeEq>()
.eq(JgOverDesignServiceLifeEq::getOverDesignId, overDesignServiceLife.getSequenceNbr()))
.stream()
.map(JgOverDesignServiceLifeEq::getEquId)
.collect(Collectors.toList());
List<IdxBizJgDesignInfo> designInfoList = idxBizJgDesignInfoServiceImpl.checkOverDesignRegNum(records);
designInfoList.forEach(designInfo -> {
designInfo.setOverDesignRegNum(Math.max(designInfo.getOverDesignRegNum() -1,0));
designInfo.setDelayServiceLifeDate("");
jgResumeInfoService.deleteByBusinessId(String.valueOf(overDesignServiceLife.getSequenceNbr()));
});
}
private void finishedTask(JgOverDesignServiceLife overDesignServiceLife) {
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("relationId", overDesignServiceLife.getInstanceId());
TaskMessageDto taskMessageDto = new TaskMessageDto();
overDesignServiceLife.setOtherAccessories(null);
BeanUtils.copyProperties(overDesignServiceLife, taskMessageDto);
this.setEquListForWorkSpace(overDesignServiceLife, taskMessageDto);
taskMap.put("model", taskMessageDto);
commonServiceImpl.updateTaskModel(taskMap);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment