Commit 2147749d authored by 刘林's avatar 刘林

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

parent 894b5621
......@@ -171,4 +171,10 @@ public class JgOverDesignServiceLife extends BaseEntity {
*/
@TableField("use_registration_code")
private String useRegistrationCode;
@TableField(exist = false)
private String equList;
@TableField(exist = false)
private String equCategory;
}
......@@ -2282,8 +2282,8 @@ public class CommonServiceImpl implements ICommonService {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Pattern timePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}");
//如果是历史无证的修改类型为SP_TT并且枚举没有在登记类型中
if(Objects.isNull(RegistrationTypeEnum.getNameByType(formData.getString("type"))) && "jg_his_black".equals(formData.getString("dataSource"))){
formData.put("type","SP_TT");
if (Objects.isNull(RegistrationTypeEnum.getNameByType(formData.getString("type"))) && "jg_his_black".equals(formData.getString("dataSource"))) {
formData.put("type", "SP_TT");
}
//如果是历史无证的修改类型为SP_TT并且枚举没有在登记类型中
......@@ -2588,31 +2588,46 @@ public class CommonServiceImpl implements ICommonService {
File mergedPdfFile = null;
try {
List<File> pdfFiles = new ArrayList<>();
for (JSONObject formData : formDataList) {
File pdfFile = wordToPdf(fileName, wordPath, formData);
pdfFiles.add(pdfFile);
generatedFiles.add(pdfFile);
List<File> pdfFiles = formDataList.stream()
.map(formData -> {
File pdfFile = null;
try {
pdfFile = wordToPdf(fileName, wordPath, formData);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (pdfFile != null && pdfFile.exists()) {
generatedFiles.add(pdfFile);
}
return pdfFile;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!pdfFiles.isEmpty()) {
mergedPdfFile = mergePdfFiles(pdfFiles, fileName + "合并.pdf");
if (mergedPdfFile.exists()) {
generatedFiles.add(mergedPdfFile);
}
}
mergedPdfFile = mergePdfFiles(pdfFiles, fileName + "合并.pdf");
String uploadedUrl = uploadFile(mergedPdfFile, "useRegistrationFormFiles");
return MapBuilder.<String, Object>create().put("useRegistrationFormUrl", uploadedUrl).build();
return Collections.singletonMap("useRegistrationFormUrl", uploadedUrl);
} catch (Exception e) {
throw new RuntimeException(e);
log.error("生成或上传文件失败", e);
throw new RuntimeException("文件处理失败", e);
} finally {
for (File file : generatedFiles) {
try {
Files.deleteIfExists(file.toPath());
} catch (Exception e) {
log.error("文件找不到,删除失败:{}", e);
}
}
if (mergedPdfFile != null) {
try {
Files.deleteIfExists(mergedPdfFile.toPath());
} catch (Exception e) {
log.error("合并 PDF 文件删除失败:{}", e);
}
generatedFiles.forEach(this::deleteFileSafely);
}
}
/**
* 安全删除文件方法
*/
private void deleteFileSafely(File file) {
if (file != null && file.exists()) {
try {
Files.deleteIfExists(file.toPath());
} catch (IOException e) {
log.error("删除文件失败: {}", file.getAbsolutePath(), e);
}
}
}
......
......@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
......@@ -33,9 +34,10 @@ import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionI
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.InspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgDesignInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.InspectionDetectionInfoMapper;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
......@@ -64,6 +66,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
......@@ -79,7 +82,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
private static final String DEFINITION_KEY = "overDesignServiceLife";
public static final String SUBMIT_TYPE_FLOW = "1";
public static final String SUBMIT_DATA = "0";
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废");
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废", "已完成");
@Autowired
private CommonServiceImpl commonService;
@Autowired
......@@ -107,15 +110,15 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
@Autowired
private IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoServiceImpl;
@Autowired
private JgRegistrationHistoryMapper jgRegistrationHistoryMapper;
@Autowired
private JgUseRegistrationManageServiceImpl useRegistrationManageService;
@Autowired
IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
private IIdxBizJgInspectionDetectionInfoService iIdxBizJgInspectionDetectionInfoService;
@Autowired
private JgResumeInfoServiceImpl jgResumeInfoService;
@Autowired
IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
private InspectionDetectionInfoMapper inspectionDetectionInfoMapper;
@Autowired
IIdxBizJgInspectionDetectionInfoService iIdxBizJgInspectionDetectionInfoService;
private SnowflakeIdUtil sequence;
/**
* 分页查询
......@@ -210,6 +213,12 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
overDesignServiceLife.setCreateUserId(reginParams.getUserModel().getUserId());
overDesignServiceLife.setCreateUserName(reginParams.getUserModel().getRealName());
overDesignServiceLife.setUseRegistrationCode(String.join(",", registrationNoList));
Function<String, String> getFirstValue = key -> equipmentLists.stream()
.findFirst()
.map(e -> Objects.toString(e.get(key), ""))
.orElse("");
overDesignServiceLife.setEquList(getFirstValue.apply("EQU_LIST"));
overDesignServiceLife.setEquCategory(getFirstValue.apply("EQU_CATEGORY"));
boolean hasId = StringUtils.isEmpty(overDesignDto.getSequenceNbr());
//新增
if (hasId) {
......@@ -353,10 +362,6 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
return Boolean.TRUE;
}
public JgOverDesignServiceLife detail(Long sequenceNbr) {
return null;
}
/**
* 撤回
*
......@@ -407,7 +412,7 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(data));
jsonObject.put("nextTaskId", data.getNextTaskId());
jsonObject.put("nextExecuteUser", data.getNextExecuteIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_USAGE_REGISTRATION.getCode());
jsonObject.put("taskType", BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.getCode());
jsonObject.put("flowStatus", commonServiceImpl.getDictionaryCodeByName(overDesign.getStatus()));
jsonObject.put("flowStatusLabel", overDesign.getStatus());
jsonObject.remove("otherAccessories");
......@@ -582,8 +587,6 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambdaSelect);
String jsonData = jgRegistrationHistory.getChangeData();
JSONObject jsonObject = JSONObject.parseObject(jsonData);
this.updateEquipMessage(jsonObject);
// 更新代办状态
HashMap<String, Object> params = new HashMap<>();
params.put("relationId", jgOverDesignServiceLife.getInstanceId());
params.put("flowStatus", commonService.getDictionaryCodeByName(jgOverDesignServiceLife.getStatus()));
......@@ -594,12 +597,13 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
BeanUtil.copyProperties(jgOverDesignServiceLife, taskMessageDto);
params.put("model", taskMessageDto);
TaskV2Model taskV2Model = commonService.updateTaskModel(params);
this.updateEquipMessage(jsonObject, taskV2Model, jgOverDesignServiceLife);
}
this.getBaseMapper().updateById(jgOverDesignServiceLife);
commonService.saveExecuteFlowData2Redis(jgOverDesignServiceLife.getInstanceId(), this.buildInstanceRuntimeData(jgOverDesignServiceLife));
}
private void updateEquipMessage(JSONObject jsonObject) {
private void updateEquipMessage(JSONObject jsonObject, TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife) {
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> useOrgCodes = equipmentLists.stream()
.map(obj -> Objects.toString(obj.get("USE_ORG_CODE"), ""))
......@@ -611,6 +615,40 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
if (CollectionUtils.isEmpty(designInfoList)) {
throw new BadRequest("未查询到设备设计信息!");
}
// 更新检验检测信息
this.updateOrCreateInspectionDetection(equipmentLists);
this.updateDesignInfo(taskV2Model, jgOverDesignServiceLife, equipmentLists, designInfoList);
this.updateRegistrationManage(useOrgCodes);
}
private void updateOrCreateInspectionDetection(List<Map<String, Object>> equipmentLists) {
for (Map<String, Object> equipment : equipmentLists) {
InspectionDetectionInfo inspectionDetectionInfo = new InspectionDetectionInfo();
BeanUtil.copyProperties(equipment, inspectionDetectionInfo);
// 处理jySeq更新逻辑
String jySeq = Objects.toString(equipment.get("jySeq"), "");
if (!jySeq.isEmpty()) {
InspectionDetectionInfo inspectionDetectionInfoDb = inspectionDetectionInfoMapper.selectById(jySeq);
if (inspectionDetectionInfoDb != null) {
Bean.copyExistPropertis(inspectionDetectionInfo, inspectionDetectionInfoDb);
inspectionDetectionInfoDb.setRecDate(new Date());
inspectionDetectionInfoMapper.updateById(inspectionDetectionInfoDb);
}
continue;
}
// 处理新增逻辑
String record = Objects.toString(equipment.get("record"), "");
if (inspectionDetectionInfo.getInspectType() != null && inspectionDetectionInfo.getInspectConclusion() != null) {
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setSequenceNbr(String.valueOf(sequence.nextId()));
inspectionDetectionInfoMapper.insert(inspectionDetectionInfo);
}
}
}
private void updateDesignInfo(TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife, List<Map<String, Object>> equipmentLists, List<IdxBizJgDesignInfo> designInfoList) {
String equListCode = Objects.toString(equipmentLists.get(0).get("EQU_LIST_CODE"), "");
ZoneId zoneId = ZoneId.systemDefault();
designInfoList.forEach(designInfo -> {
......@@ -627,7 +665,11 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
})
.orElse(null)
);
this.saveResumeInfo(taskV2Model, jgOverDesignServiceLife, designInfo);
});
}
private void updateRegistrationManage(List<String> useOrgCodes) {
List<JgUseRegistrationManage> registrationList = useRegistrationManageService.lambdaQuery()
.in(JgUseRegistrationManage::getUseRegistrationCode, useOrgCodes).list();
if (!CollectionUtils.isEmpty(registrationList)) {
......@@ -640,6 +682,19 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
}
}
private void saveResumeInfo(TaskV2Model taskV2Model, JgOverDesignServiceLife jgOverDesignServiceLife, IdxBizJgDesignInfo designInfo) {
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgOverDesignServiceLife.getApplyNo())
.businessType(BusinessTypeEnum.JG_OVER_DESIGN_SERVICE_LIFE.getName())
.businessId(jgOverDesignServiceLife.getSequenceNbr() + "")
.equId(designInfo.getRecord())
.approvalUnit(jgOverDesignServiceLife.getReceiveOrgName())
.approvalUnitCode(jgOverDesignServiceLife.getReceiveCompanyCode())
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
}
private void buildTask(JgOverDesignServiceLife jgOverDesignServiceLife, WorkflowResultDto workflowResultDto) {
// 代办消息
ArrayList<TaskModelDto> list = new ArrayList<>();
......@@ -696,7 +751,6 @@ public class JgOverDesignServiceLifeServiceImpl extends BaseService<JgOverDesign
return null;
}
public InstanceRuntimeData buildInstanceRuntimeData(JgOverDesignServiceLife overDesign) {
return InstanceRuntimeData.builder()
.nextExecuteUserIds(overDesign.getNextExecuteUserIds())
......
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