Commit ae58d916 authored by tianbo's avatar tianbo Committed by suhuiguang

1.设备代码生成逻辑修改:在安装告知时,新增设备时如选择无设备代码,则在安装告知审批完成后生成设备代码。后续的使用登记不在自动生成

parent aca756f7
......@@ -358,7 +358,7 @@
ri."EQU_CODE_TYPE" equCodeType,
ri."WHETHER_VEHICLE_CYLINDER" whetherVehicleCylinder,
pp."DEVICE_NAME" deviceName,
pp."DEVICE_LEVEL" deviceLevel,
(select name from cb_data_dictionary where code = pp."DEVICE_LEVEL" and type = 'GBI') deviceLevel,
pp."PIPE_NAME" pipeName,
pp."PIPELINE_NUMBER" pipelineNumber,
pp."NOMINAL_DIAMETER" nominalDiameter,
......@@ -368,7 +368,7 @@
pp."TEMPERATURE" temperature,
pp."MEDIUM" medium,
(select INSPECT_ORG_NAME from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY INSPECT_DATE limit 1) inspectOrgName,
(select INSPECT_CONCLUSION from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY INSPECT_DATE limit 1) inspectConclusion,
(select name from cb_data_dictionary where type = 'JYJL' and code = (select INSPECT_CONCLUSION from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY INSPECT_DATE limit 1)) inspectConclusion,
to_char((select NEXT_INSPECT_DATE from idx_biz_jg_inspection_detection_info where "RECORD" = ui."RECORD" ORDER BY INSPECT_DATE limit 1), 'YYYY-MM-DD') nextInspectDate
FROM
idx_biz_jg_use_info ui
......@@ -377,7 +377,7 @@
</sql>
<select id="queryForUnitPipelineEquipmentPage" resultType="com.alibaba.fastjson.JSONObject">
<include refid="page-list-pipeline"/>
WHERE ri."EQU_CATEGORY" = '8300'
WHERE ri."EQU_CATEGORY" = '8300' ui."DATA_SOURCE" = 'jg'
<if test="jsonObject.useUnitCreditCode != null and jsonObject.useUnitCreditCode != ''" >
and ui."USE_UNIT_CREDIT_CODE" = #{jsonObject.useUnitCreditCode}
</if>
......@@ -386,7 +386,7 @@
<select id="queryForUnitPipelineEquipment" resultType="java.util.Map">
<include refid="page-list-pipeline"/>
WHERE ri."EQU_CATEGORY" = '8300'
WHERE ri."EQU_CATEGORY" = '8300' ui."DATA_SOURCE" = 'jg'
and ui.record in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
......@@ -426,7 +426,7 @@
</sql>
<select id="queryForUnitVesselEquipmentPage" resultType="com.alibaba.fastjson.JSONObject">
<include refid="page-list-vessel"/>
WHERE ri."EQU_CATEGORY" = '2300' and (ri.whether_vehicle_cylinder is null or ri.whether_vehicle_cylinder != 1)
WHERE ri."EQU_CATEGORY" = '2300' ui."DATA_SOURCE" = 'jg' and (ri.whether_vehicle_cylinder is null or ri.whether_vehicle_cylinder != 1)
<if test="jsonObject.useUnitCreditCode != null and jsonObject.useUnitCreditCode != ''" >
and ui."USE_UNIT_CREDIT_CODE" = #{jsonObject.useUnitCreditCode}
</if>
......@@ -435,7 +435,7 @@
<select id="queryForUnitVesselEquipment" resultType="java.util.Map">
<include refid="page-list-vessel"/>
WHERE ri."EQU_CATEGORY" = '2300' and (ri.whether_vehicle_cylinder is null or ri.whether_vehicle_cylinder != 1)
WHERE ri."EQU_CATEGORY" = '2300' ui."DATA_SOURCE" = 'jg' and (ri.whether_vehicle_cylinder is null or ri.whether_vehicle_cylinder != 1)
and ui.record in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
......
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
......@@ -29,10 +30,12 @@ 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.IIdxBizJgConstructionInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils;
import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
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.EquCodeTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
......@@ -111,12 +114,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private CommonMapper commonMapper;
private ProduceInfoMapper produceInfoMapper;
// @Autowired
// private EquipmentCategoryServiceImpl equipmentCategoryService;
@Autowired
RegistrationInfoMapper tzsJgRegistrationInfoMapper;
IdxBizJgRegisterInfoMapper tzsJgRegistrationInfoMapper;
@Autowired
OtherInfoMapper tzsJgOtherInfoMapper;
@Autowired
......@@ -164,6 +165,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
private RedissonClient redissonClient;
@Autowired
CodeUtil codeUtil;
/**
* 根据sequenceNbr查询
*
......@@ -891,9 +895,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
LambdaQueryWrapper<IdxBizJgRegisterInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(IdxBizJgRegisterInfo::getRecord,jgRelationEquip.getEquId());
IdxBizJgRegisterInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getReceiveOrgCreditCode()).append(ym);
String equCode = stringBuffer.toString();
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(equCode);
......@@ -918,28 +922,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
map1.put("CODE96333",tzsJgOtherInfo.getCode96333() );
}
tzsJgOtherInfo.setSupervisoryCode(mapCode.get("superviseCode").toString());
//tzsJgRegistrationInfo.setEquCode(deviceRegistrationCode);
//jgInstallationNotice.setEquRegisterCode(deviceRegistrationCode);
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
jgInstallationNotice.setInformNumber(deviceRegistrationCode);
jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString());
Map<String,Map<String,Object>> objMap = new HashMap<>();
map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() );
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
map1.put("USE_UNIT_CREDIT_CODE",jgInstallationNotice.getUseUnitCreditCode());
map1.put("USE_UNIT_NAME",jgInstallationNotice.getUseUnitName());
map1.put("USC_UNIT_CREDIT_CODE",jgInstallationNotice.getInstallUnitCreditCode());
map1.put("USC_UNIT_NAME",jgInstallationNotice.getInstallUnitName());
// 安装告知去除该字段,使用登记时添加
// map1.put("ORG_BRANCH_CODE",jgInstallationNotice.getOrgBranchCode());
// map1.put("ORG_BRANCH_NAME",jgInstallationNotice.getOrgBranchCode());
map1.put("USE_PLACE",String.format("%s/%s/%s", jgInstallationNotice.getProvinceName(), jgInstallationNotice.getCityName(), jgInstallationNotice.getCounty()));
map1.put("ADDRESS",String.format("%s/%s", jgInstallationNotice.getStreetName(), jgInstallationNotice.getAddress()));
objMap.put(tzsJgOtherInfo.getRecord(), map1);
jgInstallationNotice.setPromoter("");
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
// 生成设备代码及更新历史表的的设备代码字段
this.justGenerateEquCode(tzsJgRegistrationInfo,jgInstallationNotice.getReceiveOrgCreditCode(), jgInstallationNotice);
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo);
// 更新es
updateEquipEs(jgInstallationNotice, tzsJgOtherInfo, tzsJgRegistrationInfo, map1);
// 更新施工信息表
IdxBizJgConstructionInfo idxBizJgConstructionInfo = constructionInfoService.queryNewestDetailByRecord(jgRelationEquip.getEquId());
if (!ObjectUtils.isEmpty(idxBizJgConstructionInfo)) {
......@@ -1042,6 +1033,53 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
}
private void updateEquipEs(JgInstallationNotice jgInstallationNotice, OtherInfo tzsJgOtherInfo, IdxBizJgRegisterInfo tzsJgRegistrationInfo, Map<String, Object> map1) {
Map<String,Map<String,Object>> objMap = new HashMap<>();
map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() );
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
map1.put("USE_UNIT_CREDIT_CODE",jgInstallationNotice.getUseUnitCreditCode());
map1.put("USE_UNIT_NAME",jgInstallationNotice.getUseUnitName());
map1.put("USC_UNIT_CREDIT_CODE",jgInstallationNotice.getInstallUnitCreditCode());
map1.put("USC_UNIT_NAME",jgInstallationNotice.getInstallUnitName());
map1.put("USE_PLACE",String.format("%s/%s/%s", jgInstallationNotice.getProvinceName(), jgInstallationNotice.getCityName(), jgInstallationNotice.getCounty()));
map1.put("ADDRESS",String.format("%s/%s", jgInstallationNotice.getStreetName(), jgInstallationNotice.getAddress()));
objMap.put(tzsJgOtherInfo.getRecord(), map1);
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
}
/**
* 系统类型的code 自动生成设备代码
*
* @param registerInfo 注册信息
* @param receiveCompanyCode 接收机构行政区划代码
*/
private void justGenerateEquCode(IdxBizJgRegisterInfo registerInfo, String receiveCompanyCode, JgInstallationNotice jgInstallationNotice) {
if (EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(registerInfo.getEquCodeType())) {
// 更新注册信息表的设备代码字段
String equCode = this.getEquCode(registerInfo, receiveCompanyCode);
registerInfo.setEquCode(equCode);
updateHisDataEquCode(registerInfo, jgInstallationNotice, equCode);
}
}
private void updateHisDataEquCode(IdxBizJgRegisterInfo registerInfo, JgInstallationNotice jgInstallationNotice, String equCode) {
JSONObject his = commonService.queryHistoryData(jgInstallationNotice.getSequenceNbr());
his.put("equCode", equCode);
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(his), registerInfo.getRecord(), jgInstallationNotice.getSequenceNbr().toString());
}
private String getEquCode(IdxBizJgRegisterInfo registerInfo, String receiveCompanyCode) {
ProduceInfo produceInfo = produceInfoMapper.selectOne(new LambdaQueryWrapper<ProduceInfo>().eq(AbstractEquipBaseEntity::getRecord, registerInfo.getRecord()));
CodeGenerateDto codeGenerateDto = new CodeGenerateDto();
codeGenerateDto.setEquList(registerInfo.getEquList());
codeGenerateDto.setEquCategory(registerInfo.getEquCategory());
codeGenerateDto.setEquDefine(registerInfo.getEquDefine());
codeGenerateDto.setProduceDate(produceInfo.getProduceDate());
codeGenerateDto.setReceiveCompanyCode(receiveCompanyCode);
return codeUtil.generateEquipmentCode(codeGenerateDto);
}
private void updateJgUseInfo(JgInstallationNotice jgInstallationNotice, JgInstallationNoticeEq jgRelationEquip) {
LambdaUpdateWrapper<IdxBizJgUseInfo> lambda = new LambdaUpdateWrapper<>();
lambda.eq(IdxBizJgUseInfo::getRecord, jgRelationEquip.getEquId());
......
......@@ -915,7 +915,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
/**
* 系统类型的code 自动生成设备代码
*
* @param lambda lambda
* @param registerInfo 注册信息
* @param receiveCompanyCode 接收机构行政区划代码
......@@ -923,7 +922,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
* @param jgRegistrationHistory 历史数据行数据
*/
public void justGenerateEquCode(LambdaUpdateWrapper<IdxBizJgRegisterInfo> lambda, IdxBizJgRegisterInfo registerInfo, String receiveCompanyCode, JSONObject mapData, JgRegistrationHistory jgRegistrationHistory) {
if (EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(registerInfo.getEquCodeType())) {
// 新增设备时选择无设备代码且在设备代码为空【未做安装告知(使用登记、安装告知会生成设备代码)】
if (EquCodeTypeEnum.SYSTEM_GENERATED.getCode().equals(registerInfo.getEquCodeType()) && StringUtils.isEmpty(registerInfo.getEquCode())) {
// 更新注册信息表的设备代码字段
String equCode = this.getEquCode(registerInfo, receiveCompanyCode);
registerInfo.setEquCode(equCode);
......
......@@ -562,18 +562,7 @@ public class TzBaseEnterpriseInfoServiceImpl
baseUnitLicence.setUnitName(ObjectUtils.isEmpty(map.get("useUnit")) ? null : (String)map.get("useUnit"));
// 处理许可字典值对应名称
List<DataDictionary> dictionaries = regUnitInfoService.initAllDataDictionaryList();
baseUnitLicence.setCertType(dictionaries.stream().filter(d -> d.getType().equals("UNIT_TYPE_NEW") && d.getCode().equals(baseUnitLicence.getCertTypeCode())).findFirst().get().getName());
baseUnitLicence.setItemCodeName(dictionaries.stream().filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getItemCode())).findFirst().get().getName());
baseUnitLicence.setSubItemName(dictionaries.stream().filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getSubItemCode())).findFirst().get().getName());
if (ValidationUtil.isEmpty(baseUnitLicence.getParameterCode())) {
baseUnitLicence.setParameter(null);
} else {
baseUnitLicence.setParameter(dictionaries.stream().filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getParameterCode())).findFirst().get().getName());
}
baseUnitLicence.setApprovedOrgan(dictionaries.stream().filter(d -> d.getType().equals("DJJG") && baseUnitLicence.getApprovedOrganCode().equals(d.getCode())).findFirst().get().getName());
baseUnitLicence.setApplyType(dictionaries.stream().filter(d -> d.getType().equals("xkfszt") && baseUnitLicence.getApplyTypeCode().equals(d.getCode())).findFirst().get().getName());
baseUnitLicence.setAppraisalType(dictionaries.stream().filter(d -> d.getType().equals("xkpsfs") && baseUnitLicence.getAppraisalTypeCode().equals(d.getCode())).findFirst().get().getName());
handleDictName(baseUnitLicence);
licences.add(baseUnitLicence);
});
......@@ -607,6 +596,74 @@ public class TzBaseEnterpriseInfoServiceImpl
}
/**
* 处理单位许可证书名称。
* 该方法通过查询数据字典,根据给定的许可证书代码,设置许可证书的类型、项目代码名称、子项目名称、参数名称、
* 审批机构名称、申请类型名称和评估方式名称。
*
* @param baseUnitLicence 包含许可证书信息的基类单位许可证书对象。
*/
private void handleDictName(BaseUnitLicence baseUnitLicence) {
// 初始化所有数据字典列表
List<DataDictionary> dictionaries = regUnitInfoService.initAllDataDictionaryList();
// 根据新的单位类型代码查询许可证书类型名称
Optional<String> certTypeOptional = dictionaries.stream()
.filter(d -> "UNIT_TYPE_NEW".equals(d.getType()) && baseUnitLicence.getCertTypeCode().startsWith(d.getCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置许可证书类型
certTypeOptional.ifPresent(baseUnitLicence::setCertType);
// 查询项目代码对应的名称
Optional<String> itemCodeOptional = dictionaries.stream()
.filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getItemCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置项目代码名称
itemCodeOptional.ifPresent(baseUnitLicence::setItemCodeName);
// 查询子项目代码对应的名称
Optional<String> subItemOptional = dictionaries.stream()
.filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getSubItemCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置子项目名称
subItemOptional.ifPresent(baseUnitLicence::setSubItemName);
// 查询参数代码对应的名称
Optional<String> parameterOptional = dictionaries.stream()
.filter(d -> !ValidationUtil.isEmpty(d.getExtend()) && d.getExtend().startsWith("XK-") && d.getCode().equals(baseUnitLicence.getParameterCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置参数名称
parameterOptional.ifPresent(baseUnitLicence::setParameter);
// 查询审批机构代码对应的名称
Optional<String> approvedOrgenOptional = dictionaries.stream()
.filter(d -> d.getType().equals("DJJG") && d.getCode().equals(baseUnitLicence.getApprovedOrganCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置审批机构名称
approvedOrgenOptional.ifPresent(baseUnitLicence::setApprovedOrgan);
// 查询申请类型代码对应的名称
Optional<String> applyTypeOptional = dictionaries.stream()
.filter(d -> d.getType().equals("xkfszt") && d.getCode().equals(baseUnitLicence.getApplyTypeCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置申请类型名称
applyTypeOptional.ifPresent(baseUnitLicence::setApplyType);
// 查询评估方式代码对应的名称
Optional<String> appraisalTypeOptional = dictionaries.stream()
.filter(d -> d.getType().equals("xkpsfs") && d.getCode().equals(baseUnitLicence.getAppraisalTypeCode()))
.map(DataDictionary::getName)
.findFirst();
// 设置评估方式名称
appraisalTypeOptional.ifPresent(baseUnitLicence::setAppraisalType);
}
private void updateUserInfo(ArrayList<String> newDate, String creditCode) {
LambdaQueryWrapper<TzsUserInfo> lambda = new QueryWrapper<TzsUserInfo>().lambda();
lambda.eq(TzsUserInfo::getUnitCode, creditCode);
......
......@@ -163,4 +163,18 @@ public class RegistrationInfo extends AbstractEquipBaseEntity {
private String motorNumber;
/**
*
*/
@TableField("\"OTHER_ACCESSORIES_REG\"")
private String otherAccessoriesReg;
/**
* 是否车用气瓶(特种气瓶用于区分“内装填料气瓶、纤维缠绕气瓶、低温绝热气瓶”和车用气瓶)
* 1:是
* 0:不是
*/
@TableField("\"WHETHER_VEHICLE_CYLINDER\"")
private String whetherVehicleCylinder;
}
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