Commit f184f1c5 authored by 刘林's avatar 刘林

fix(jg):单位办理-历史设备登记添加routePath

parent 3ee6943d
......@@ -42,6 +42,7 @@ import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
......@@ -58,6 +59,8 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -66,8 +69,8 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -133,6 +136,8 @@ public class DataDockServiceImpl {
List<String> useOrgCodeList = new ArrayList<>();// 使用登记证集合
Map<String, List<String>> projectContraptionMap = new HashMap<>();// 工程装置名称集合
private static final String DEFINITION_KEY = "useRegistration";
@Value("classpath:/json/urlInfo.json")
private Resource urlInfo;
private final JgVehicleInformationMapper jgVehicleInformationMapper;
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private final ExcelImportErrorLogDao excelImportErrorLogDao;
......@@ -2006,8 +2011,8 @@ public class DataDockServiceImpl {
.setUseRegistrationCode(paramsDto.getUseOrgCode())
.setReceiveOrgCode(paramsDto.getReceiveOrgCode())
.setReceiveCompanyCode(paramsDto.getReceiveOrgCode())
// .setReceiveCompanyOrgCode()
.setReceiveOrgName(paramsDto.getReceiveOrgName())
//.setReceiveCompanyOrgCode()
//.setReceiveOrgName(paramsDto.getReceiveOrgName())
.setUseAddress("")
.setManageType("unit")
.setCreateDate(new Date())
......@@ -2029,9 +2034,7 @@ public class DataDockServiceImpl {
useRegEq.setRecUserName(paramsDto.getExecUserName());
jgUseRegistrationEqServiceImpl.save(useRegEq);
});
JSONObject changeData = getJgUseRegistrationChangeData(paramsDto, records, applyNo);
JgRegistrationHistory registrationHistory = JgRegistrationHistory.builder()
.registrationClass("使用登记")
.changeData(JSON.toJSONString(changeData))
......@@ -2044,9 +2047,68 @@ public class DataDockServiceImpl {
registrationHistory.setCreateUserId(paramsDto.getExecUserId());
registrationHistory.setRecUserName(paramsDto.getExecUserName());
jgRegistrationHistoryService.save(registrationHistory);
String routePath = this.buildTaskModel(useReg, paramsDto);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(useReg.getApplyNo())
.businessType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName())
.businessId(useReg.getSequenceNbr() + "")
.equId(useReg.getProjectContraptionId())
.approvalUnit(useReg.getReceiveOrgName())
.approvalUnitCode(useReg.getReceiveOrgCode())
.status("正常")
.routePath(routePath)
.changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理")
.build());
return useReg;
}
public String buildTaskModel(JgUseRegistration jgUseRegistration, EquipRequestParamsDto paramsDto) {
TaskModelDto modelDto = new TaskModelDto();
modelDto.setNextExecuteUser(jgUseRegistration.getNextExecuteUserIds());
modelDto.setPageType("look");
modelDto.setStartUserId(RequestContext.getExeUserId());
modelDto.setStartDate(new Date());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtil.copyProperties(jgUseRegistration, taskMessageDto);
taskMessageDto.setRegType("历史登记");
taskMessageDto.setEQU_LIST_CODE(paramsDto.getEquCategoryCode());
taskMessageDto.setAuditStatus(null);
taskMessageDto.setEquipId((jgUseRegistration.getProjectContraptionId()));
modelDto.setModel(taskMessageDto);
// 获取URL配置并匹配对应业务类型和pageType
List<Map> urlList = JsonUtils.getResourceList(urlInfo);
if (CollectionUtils.isEmpty(urlList)) {
throw new IllegalStateException("URL配置未初始化");
}
final String targetType = BusinessTypeEnum.JG_USAGE_REGISTRATION.getCode();
final String targetPageType = modelDto.getPageType();
for (Map urlMap : urlList) {
Object type = urlMap.get("type");
Object pageType = urlMap.get("pageType");
if (Objects.equals(type, targetType) && Objects.equals(pageType, targetPageType)) {
String baseUrl = String.valueOf(urlMap.get("url"));
try {
String queryParams = commonService.toQueryParams(modelDto.getModel());
String roleIds = Optional.ofNullable(modelDto.getNextExecuteUser()).orElse("");
return baseUrl.replace("{roleIds}", roleIds)
.replace("{userId}", taskMessageDto.getCreateUserId())
+ "&" + queryParams
+ "&nextExecuteUserIds=" + Optional.ofNullable(modelDto.getExecuteUserIds()).orElse("");
} catch (UnsupportedEncodingException e) {
// 建议记录日志,便于排查问题
log.error("URL参数编码失败", e);
throw new IllegalStateException("构建任务模型URL失败", e);
}
}
}
throw new IllegalStateException("未找到匹配的URL配置项,type=" + targetType + ", pageType=" + targetPageType);
}
private JSONObject getJgUseRegistrationChangeData(EquipRequestParamsDto paramsDto, List<String> records, String spplyNo) {
String record = Optional.ofNullable(records.get(0)).orElse("");
JSONObject jsonObject = new JSONObject();
......
......@@ -27,9 +27,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.CodeGenerateDto;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipInfoCylinderExcelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipmentInfoDto;
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.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
......@@ -38,6 +36,7 @@ import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgRegisterInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
......@@ -67,6 +66,7 @@ import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpStatus;
......@@ -84,6 +84,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -286,6 +287,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
private JgUseRegistrationEqMapper jgRelationEquipMapper;
@Autowired
private JgResumeInfoServiceImpl jgResumeInfoService;
@Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
private SafetyProblemTracingMapper safetyProblemTracingMapper;
......@@ -301,6 +304,10 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private ShCarServiceImpl shCarService;
@Autowired
private IIdxBizJgProjectContraptionService idxBizJgProjectContraptionService;
@Value("classpath:/json/urlInfo.json")
private Resource urlInfo;
@Autowired
private CommonServiceImpl commonServiceImpl;
/**
* 将对象的属性由驼峰转为纯大写下划线格式
......@@ -4110,6 +4117,23 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
objectHashMap.put("EQU_CATEGORY_CODE", equipInfoDto.getEquCategoryCode());
objectHashMap.put("orgBranchCode", equipInfoDto.getOrgBranchCode());
updateHistory(objectHashMap, String.valueOf(jgUseRegistration.getSequenceNbr()));
String routePath = this.buildTaskModel(jgUseRegistration, equipInfoDto.getEquListCode());
jgResumeInfoService.saveBatchResume(
equipmentLists.stream()
.map(equipId -> JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName())
.businessId(String.valueOf(jgUseRegistration.getSequenceNbr()))
.equId(String.valueOf(equipId))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.status("正常")
.changeContent(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName() + "业务办理")
.routePath(routePath)
.build())
.collect(Collectors.toList())
);
}
Optional.of(supervisionInfoList).filter(list -> !list.isEmpty()).ifPresent(iIdxBizJgSupervisionInfoService::saveBatch);
......@@ -4124,6 +4148,53 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
}
public String buildTaskModel(JgUseRegistration jgUseRegistration, String equListCode) {
TaskModelDto modelDto = new TaskModelDto();
modelDto.setNextExecuteUser(jgUseRegistration.getNextExecuteUserIds());
modelDto.setPageType("look");
modelDto.setStartUserId(RequestContext.getExeUserId());
modelDto.setStartDate(new Date());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtil.copyProperties(jgUseRegistration, taskMessageDto);
taskMessageDto.setRegType("历史登记");
taskMessageDto.setEQU_LIST_CODE(equListCode);
taskMessageDto.setAuditStatus(null);
taskMessageDto.setEquipId((jgUseRegistration.getProjectContraptionId()));
modelDto.setModel(taskMessageDto);
// 获取URL配置并匹配对应业务类型和pageType
List<Map> urlList = JsonUtils.getResourceList(urlInfo);
if (CollectionUtils.isEmpty(urlList)) {
throw new IllegalStateException("URL配置未初始化");
}
final String targetType = BusinessTypeEnum.JG_USAGE_REGISTRATION.getCode();
final String targetPageType = modelDto.getPageType();
for (Map urlMap : urlList) {
Object type = urlMap.get("type");
Object pageType = urlMap.get("pageType");
if (Objects.equals(type, targetType) && Objects.equals(pageType, targetPageType)) {
String baseUrl = String.valueOf(urlMap.get("url"));
try {
String queryParams = commonServiceImpl.toQueryParams(modelDto.getModel());
String roleIds = Optional.ofNullable(modelDto.getNextExecuteUser()).orElse("");
return baseUrl.replace("{roleIds}", roleIds)
.replace("{userId}", taskMessageDto.getCreateUserId())
+ "&" + queryParams
+ "&nextExecuteUserIds=" + Optional.ofNullable(modelDto.getExecuteUserIds()).orElse("");
} catch (UnsupportedEncodingException e) {
// 建议记录日志,便于排查问题
log.error("URL参数编码失败", e);
throw new IllegalStateException("构建任务模型URL失败", e);
}
}
}
throw new IllegalStateException("未找到匹配的URL配置项,type=" + targetType + ", pageType=" + targetPageType);
}
private static void setSupervisionInfo(String orgBranchCode, String orgBranchName, String record, List<IdxBizJgSupervisionInfo> supervisionInfoList) {
IdxBizJgSupervisionInfo supervisionInfo = new IdxBizJgSupervisionInfo();
supervisionInfo.setOrgBranchCode(orgBranchCode);
......
......@@ -4027,11 +4027,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
modelDto.setStartUser(reginParams.getUserModel().getRealName());
modelDto.setStartUserCompanyName(reginParams.getCompany().getCompanyName());
modelDto.setStartDate(new Date());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtil.copyProperties(jgUseRegistration, taskMessageDto);
taskMessageDto.setRegType("历史登记");
taskMessageDto.setEQU_LIST_CODE("3000");
taskMessageDto.setEQU_LIST_CODE(String.valueOf(map.get("equListCode")));
taskMessageDto.setAuditStatus(null);
taskMessageDto.setEquipId((String.valueOf(map.get("equipId"))));
modelDto.setModel(taskMessageDto);
......
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