Commit 54663138 authored by 麻笑宇's avatar 麻笑宇

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into…

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into develop_tzs_register_to_0715
parents 169249b5 1934648a
package com.yeejoin.amos.boot.module.jg.api.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @apiNote 设备基本情况
* @author LiuLin
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EquipmentInfoDto {
private String equListCode;
private String equCategoryCode;
private String equDefineCode;
private String equList;
private String equCategory;
private String equDefine;
private String dataSource;
private String useOrgCode;
private String receiveOrgCode;
private String receiveOrgName;
private String possession;
}
\ No newline at end of file
......@@ -48,7 +48,10 @@ public enum BusinessTypeEnum {
JG_VEHICLE_GAS_APPLICATION("118", "车用气瓶登记"),
JG_VEHICLE_GAS_CYLINDER_CHANGE("119", "车用气瓶变更登记");
JG_VEHICLE_GAS_CYLINDER_CHANGE("119", "车用气瓶变更登记"),
JG_HISTORY_USAGE_REGISTRATION("119", "历史设备登记");
private final String code;
private final String name;
......
......@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
......@@ -16,17 +17,22 @@ import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipSourceEnum;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipmentInfoDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgCertificateChangeRecord;
import com.yeejoin.amos.boot.module.jg.api.entity.JgCertificateChangeRecordEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.api.entity.JgVehicleInformation;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgVehicleInformationMapper;
import com.yeejoin.amos.boot.module.jg.biz.config.PressureVesselListener;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
......@@ -34,6 +40,7 @@ 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.ymt.api.dto.IdxBizJgRegisterInfoDto;
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;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
......@@ -57,6 +64,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.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -71,6 +79,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
......@@ -229,6 +239,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private CodeUtil codeUtil;
@Autowired
private TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
private JgUseRegistrationManageServiceImpl jgUseRegistrationManageService;
@Autowired
private JgVehicleInformationMapper jgVehicleInformationMapper;
@Autowired
private JgCertificateChangeRecordServiceImpl certificateChangeRecordService;
@Autowired
private Sequence sequence;
@Autowired
private JgCertificateChangeRecordEqServiceImpl certificateChangeRecordEqService;
/**
* 将对象的属性由驼峰转为纯大写下划线格式
......@@ -2082,19 +2102,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
}
public static String getUrlByKey(List<Map<String, Object>> dataList, String key) {
private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
if (dataList == null || dataList.isEmpty()) {
return null; // 如果 dataList 为空或 null,返回 null
return null;
}
for (Map<String, Object> item : dataList) {
if (key.equals(item.get("key"))) {
List<Map<String, String>> value = (List<Map<String, String>>) item.get("value");
if (value != null && !value.isEmpty()) {
return value.get(0).get("url");
}
return JSON.toJSONString(item.get("value"));
}
}
return null; // 如果找不到对应的 URL,返回 null
return null;
}
@Override
......@@ -2115,16 +2132,10 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD));
String equListCode = (String) equipmentInfoForm.get("EQU_LIST");
String equCategoryCode = (String) equipmentInfoForm.get("EQU_CATEGORY");
String equDefineCode = (String) equipmentInfoForm.get("EQU_DEFINE");
String dataSource = (String) equipmentInfoForm.get("DATA_SOURCE");
String useOrgCode = (String) equipmentInfoForm.get("USE_ORG_CODE");
String receiveOrgCode = (String) equipmentInfoForm.get("RECEIVE_ORG_CODE");
String possession = (String) equipmentInfoForm.get("VEHICLE_APANAGE");
EquipmentInfoDto equipInfoDto = this.createEquipmentInfoDto(equipmentInfoForm, jgVehicleInformationMapper);
// 登记证记录表主键
Long changeRecordId= sequence.nextId();
List<EquipInfoCylinderExcelDto> equipInfoCylinderExcelDtoList =JSON.parseArray(JSON.toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoCylinderExcelDto.class);
Date date = new Date();
equipInfoCylinderExcelDtoList.forEach(data->{
String record = UUID.randomUUID().toString();
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>)(data.getFileData());
......@@ -2142,10 +2153,10 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgUseInfo useInfo = new IdxBizJgUseInfo();
BeanUtils.copyProperties(data, useInfo);
useInfo.setRecord(record);
useInfo.setRecDate(date);
useInfo.setDataSource(dataSource.equals("his")? "jg_his" : "jg");//区分历史设备和新增设备
useInfo.setRecDate(new Date());
useInfo.setDataSource("his".equals(equipInfoDto.getDataSource())? "jg_his" : "jg");//区分历史设备和新增设备
useInfo.setEquState(null);
useInfo.setIsIntoManagement(dataSource.equals("his"));//历史气瓶导入为已纳管设备
useInfo.setIsIntoManagement("his".equals(equipInfoDto.getDataSource()));//历史气瓶导入为已纳管设备
// 使用单位信息
if("个人主体".equals(company.getCompanyType())){
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
......@@ -2160,7 +2171,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgDesignInfo designInfo = new IdxBizJgDesignInfo();
BeanUtils.copyProperties(data, designInfo);
designInfo.setRecord(record);
designInfo.setRecDate(date);
designInfo.setRecDate(new Date());
if (data.getDesignDate() != null){
designInfo.setDesignDate(DateUtil.parse(data.getDesignDate(), "yyyy-MM-dd"));
}
......@@ -2173,7 +2184,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgFactoryInfo factoryInfo = new IdxBizJgFactoryInfo();
BeanUtils.copyProperties(data, factoryInfo);
factoryInfo.setRecord(record);
factoryInfo.setRecDate(date);
factoryInfo.setRecDate(new Date());
factoryInfo.setProductQualityYieldProve(productQualityYieldProve);
factoryInfo.setFactoryStandard(factoryStandard);
factoryInfo.setInsUseMaintainExplain(insUseMaintainExplain);
......@@ -2187,17 +2198,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgRegisterInfo registerInfo = new IdxBizJgRegisterInfo();
BeanUtils.copyProperties(data, registerInfo);
registerInfo.setRecord(record);
registerInfo.setRecDate(date);
registerInfo.setEquCategory(equCategoryCode);
registerInfo.setEquDefine(equDefineCode);
registerInfo.setEquList(equListCode);
registerInfo.setRecDate(new Date());
registerInfo.setEquCategory(equipInfoDto.getEquCategoryCode());
registerInfo.setEquDefine(equipInfoDto.getEquDefineCode());
registerInfo.setEquList(equipInfoDto.getEquListCode());
registerInfo.setRegisterState(idxBizJgRegisterInfoService.getRegCode());
registerInfo.setProductPhoto(productPhoto);
registerInfo.setOtherAccessoriesReg(otherAccessoriesReg);
registerInfo.setUseOrgCode(useOrgCode);
if (dataSource.equals("his")){
registerInfo.setEquCode(this.getEquCode(registerInfo, factoryInfo, receiveOrgCode));
registerInfo.setUseOrgCode(equipInfoDto.getUseOrgCode());
if ("his".equals(equipInfoDto.getDataSource())){
registerInfo.setEquCode(this.getEquCode(registerInfo, factoryInfo, equipInfoDto.getReceiveOrgCode()));
}
registerInfoList.add(registerInfo);
......@@ -2206,14 +2216,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
BeanUtils.copyProperties(data, inspectionDetectionInfo);
inspectionDetectionInfo.setInspectOrgCode( data.getInspectOrgCode());
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(date);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setInspectType("ZZJDJY");
inspectionDetectionInfo.setInspectConclusion("6040");//默认合格
inspectionDetectionInfo.setInspectDate(DateUtil.parse(data.getInspectDate(), "yyyy-MM-dd"));
// 根据条件确定增加的年数
inspectionDetectionInfo.setNextInspectDate(Date.from(
LocalDate.parse(data.getInspectDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"))
.plusYears(SPECIAL_CYLINDER.getCode().equals(equDefineCode) ? 3 : 4)
.plusYears(SPECIAL_CYLINDER.getCode().equals(equipInfoDto.getEquDefineCode()) ? 3 : 4)
.atStartOfDay(ZoneId.systemDefault())
.toInstant()));
inspectionDetectionInfoList.add(inspectionDetectionInfo);
......@@ -2222,9 +2232,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgOtherInfo otherInfo = new IdxBizJgOtherInfo();
BeanUtils.copyProperties(data, otherInfo);
otherInfo.setRecord(record);
otherInfo.setRecDate(date);
if (dataSource.equals("his")){
otherInfo.setSupervisoryCode(this.getSupervisoryCode(possession, registerInfo));
otherInfo.setRecDate(new Date());
if ("his".equals(equipInfoDto.getDataSource())){
otherInfo.setSupervisoryCode(this.getSupervisoryCode(equipInfoDto.getPossession(), registerInfo));
otherInfo.setClaimStatus("已认领");
}
otherInfoList.add(otherInfo);
......@@ -2233,48 +2243,45 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
IdxBizJgTechParamsVessel paramsVessel = new IdxBizJgTechParamsVessel();
BeanUtils.copyProperties(data, paramsVessel);
paramsVessel.setRecord(record);
paramsVessel.setRecDate(date);
paramsVessel.setRecDate(new Date());
paramsVesselList.add(paramsVessel);
ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(data), ESEquipmentCategoryDto.class);
List<EquipmentCategory> equList = commonService.getEquipmentCategoryList(equListCode, null);
List<EquipmentCategory> equCategory = commonService.getEquipmentCategoryList(equCategoryCode, null);
List<EquipmentCategory> equDefine = commonService.getEquipmentCategoryList(equDefineCode, null);
ESEquipmentCategoryDto esEquipmentDto = JSON.parseObject(toJSONString(data), ESEquipmentCategoryDto.class);
esEquipmentDto.setDATA_SOURCE(useInfo.getDataSource());
esEquipmentDto.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getNextInspectDate() + "");
esEquipmentDto.setREC_DATE(System.currentTimeMillis());
esEquipmentDto.setSEQUENCE_NBR(record);
esEquipmentDto.setFACTORY_NUM(factoryInfo.getFactoryNum());
esEquipmentDto.setUSE_INNER_CODE(useInfo.getUseInnerCode());
esEquipmentDto.setUSE_ORG_CODE(equipInfoDto.getUseOrgCode());
esEquipmentDto.setIS_INTO_MANAGEMENT("his".equals(equipInfoDto.getDataSource()));
if ("his".equals(equipInfoDto.getDataSource())){
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
}
esEquipmentDto.setEQU_CATEGORY_CODE(equipInfoDto.getEquCategoryCode());
esEquipmentDto.setEQU_CATEGORY(equipInfoDto.getEquCategory());
esEquipmentDto.setEQU_LIST_CODE(equipInfoDto.getEquListCode());
esEquipmentDto.setEQU_LIST(equipInfoDto.getEquList());
esEquipmentDto.setEQU_DEFINE_CODE(equipInfoDto.getEquDefineCode());
esEquipmentDto.setEQU_DEFINE(equipInfoDto.getEquDefine());
// 使用单位信息
dto.setDATA_SOURCE(useInfo.getDataSource());
dto.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getNextInspectDate() + "");
dto.setREC_DATE(System.currentTimeMillis());
dto.setSEQUENCE_NBR(record);
dto.setFACTORY_NUM(factoryInfo.getFactoryNum());
dto.setUSE_INNER_CODE(useInfo.getUseInnerCode());
dto.setEQU_CATEGORY_CODE(equCategoryCode);
dto.setUSE_ORG_CODE(useOrgCode);
dto.setIS_INTO_MANAGEMENT(dataSource.equals("his"));
if (dataSource.equals("his")){
dto.setEQU_CODE(registerInfo.getEquCode());
}
if (CollectionUtils.isNotEmpty(equCategory)) {
dto.setEQU_CATEGORY(equCategory.get(0).getName());
}
dto.setEQU_LIST_CODE(equListCode);
if (CollectionUtils.isNotEmpty(equList)) {
dto.setEQU_LIST(equList.get(0).getName());
}
dto.setEQU_DEFINE_CODE(equDefineCode);
if (CollectionUtils.isNotEmpty(equDefine)) {
dto.setEQU_DEFINE(equDefine.get(0).getName());
}
// 使用单位信息
if("个人主体".equals(company.getCompanyType())){
dto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode().split("_")[1]);
dto.setUSE_UNIT_NAME(company.getCompanyName().split("_")[1]);
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode().split("_")[1]);
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName().split("_")[1]);
}else {
dto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode());
dto.setUSE_UNIT_NAME(company.getCompanyName());
esEquipmentDto.setUSE_UNIT_CREDIT_CODE(company.getCompanyCode());
esEquipmentDto.setUSE_UNIT_NAME(company.getCompanyName());
}
esEquipmentCategoryList.add(esEquipmentDto);
if ("his".equals(equipInfoDto.getDataSource())){
// 生成tzs_jg_certificate_change_record_eq记录
JgCertificateChangeRecordEq changeRecordEq = new JgCertificateChangeRecordEq();
changeRecordEq.setChangeRecordId(String.valueOf(changeRecordId));//登记证记录主键
changeRecordEq.setEquId(registerInfo.getRecord());//设备主键
changeRecordEq.setProductCode(factoryInfo.getFactoryNum());//产品编号
certificateChangeRecordEqService.save(changeRecordEq);
}
esEquipmentCategoryList.add(dto);
});
Optional.of(useInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgUseInfoService::saveBatch);
Optional.of(designInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgDesignInfoService::saveBatch);
......@@ -2284,9 +2291,116 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
Optional.of(paramsVesselList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgTechParamsVesselService::saveBatch);
Optional.of(inspectionDetectionInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgInspectionDetectionInfoService::saveBatch);
Optional.of(esEquipmentCategoryList).filter(list -> !list.isEmpty()).ifPresent(esEquipmentCategory::saveAll);
if ("his".equals(equipInfoDto.getDataSource())){
// 生成证书管理表记录
JgUseRegistrationManage registrationManage = this.saveRegistrationManage(equipInfoDto, company);
// 生成一条tzs_jg_certificate_change_record记录
generateCertificateChangeRecord(registrationManage, changeRecordId);
}
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
}
private EquipmentInfoDto createEquipmentInfoDto(Map<String, Object> equipmentInfoForm, JgVehicleInformationMapper jgVehicleInformationMapper) {
EquipmentInfoDto dto = new EquipmentInfoDto();
String equListCode = (String) equipmentInfoForm.get("EQU_LIST");
String equCategoryCode = (String) equipmentInfoForm.get("EQU_CATEGORY");
String equDefineCode = (String) equipmentInfoForm.get("EQU_DEFINE");
dto.setEquListCode(equListCode);
dto.setEquCategoryCode(equCategoryCode);
dto.setEquDefineCode(equDefineCode);
dto.setEquList(jgVehicleInformationMapper.getEquCategoryNameByCode(equListCode));
dto.setEquCategory(jgVehicleInformationMapper.getEquCategoryNameByCode(equCategoryCode));
dto.setEquDefine(jgVehicleInformationMapper.getEquCategoryNameByCode(equDefineCode));
dto.setDataSource((String) equipmentInfoForm.get("DATA_SOURCE"));
dto.setUseOrgCode((String) equipmentInfoForm.get("USE_ORG_CODE"));
dto.setReceiveOrgCode(((String) equipmentInfoForm.get("RECEIVE_ORG_CODE")).split("_")[0]);
dto.setReceiveOrgName(((String) equipmentInfoForm.get("RECEIVE_ORG_CODE")).split("_")[1]);
dto.setPossession((String) equipmentInfoForm.get("VEHICLE_APANAGE"));
return dto;
}
private JgUseRegistrationManage saveRegistrationManage(EquipmentInfoDto equipInfoDto, CompanyBo company) {
JgUseRegistrationManage jgUseRegistrationManage = new JgUseRegistrationManage();
jgUseRegistrationManage.setApplyNo(this.getApplicationNo());
jgUseRegistrationManage.setCertificateStatus("已登记");
jgUseRegistrationManage.setReceiveOrgName(equipInfoDto.getReceiveOrgName());
jgUseRegistrationManage.setAuditPassDate(new Date());
jgUseRegistrationManage.setRegType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName());
jgUseRegistrationManage.setRegDate(new Date());
jgUseRegistrationManage.setEquList(equipInfoDto.getEquList());
jgUseRegistrationManage.setEquListCode(equipInfoDto.getEquListCode());
jgUseRegistrationManage.setEquCategory(equipInfoDto.getEquCategory());
jgUseRegistrationManage.setEquCategoryCode(equipInfoDto.getEquCategoryCode());
jgUseRegistrationManage.setEquDefine(equipInfoDto.getEquDefine());
jgUseRegistrationManage.setEquDefineCode(equipInfoDto.getEquDefineCode());
jgUseRegistrationManage.setIsDelete(Boolean.FALSE);
jgUseRegistrationManage.setEquUseAddress("");
jgUseRegistrationManage.setManageType("unit");
jgUseRegistrationManage.setUseUnitAddress(company.getAddress());
jgUseRegistrationManage.setUseRegistrationCode(equipInfoDto.getUseOrgCode());
jgUseRegistrationManage.setUseUnitCreditCode(company.getCompanyCode());
jgUseRegistrationManage.setUseUnitName(company.getCompanyName());
jgUseRegistrationManage.setReceiveCompanyCode(equipInfoDto.getReceiveOrgCode());
jgUseRegistrationManage.setCertificateNo(generateCertificateNo(equipInfoDto, new Date(), equipInfoDto.getReceiveOrgCode()));
jgUseRegistrationManageService.save(jgUseRegistrationManage);
return jgUseRegistrationManage;
}
private void generateCertificateChangeRecord(JgUseRegistrationManage registrationManage, Long changeRecordId) {
JgCertificateChangeRecord changeRecord = new JgCertificateChangeRecord();
changeRecord.setApplyNo(registrationManage.getApplyNo());
changeRecord.setReceiveOrgName(registrationManage.getReceiveOrgName());
changeRecord.setAuditPassDate(new Date());
changeRecord.setRegType(BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName());
changeRecord.setRegDate(registrationManage.getCreateDate());
changeRecord.setChangeContent(this.buildRecordContent(registrationManage));//变更内容
changeRecord.setUseRegistrationCode(registrationManage.getUseRegistrationCode());//使用登记编号
changeRecord.setReceiveCompanyCode(registrationManage.getReceiveCompanyCode());//接收机构公司代码
changeRecord.setCertificateNo(registrationManage.getCertificateNo());//登记证书唯一码
changeRecord.setUseUnitCreditCode(registrationManage.getUseUnitCreditCode());//使用单位统一信用代码
changeRecord.setUseUnitName(registrationManage.getUseUnitName());//使用单位名称
changeRecord.setEquCategory(registrationManage.getEquCategory());//设备类别编码
changeRecord.setRoutePath("");
changeRecord.setCreateDate(new Date());
changeRecord.setSequenceNbr(changeRecordId);
certificateChangeRecordService.save(changeRecord);
}
private String buildRecordContent(JgUseRegistrationManage registrationManage) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
return registrationManage.getRecUserName() + "批量上传了【"+BusinessTypeEnum.JG_HISTORY_USAGE_REGISTRATION.getName()+"】," +
"单号【" + registrationManage.getApplyNo() + "】,上传日期" + simpleDateFormat.format(registrationManage.getRecDate());
}
/**
* 生成使用登记证书唯一标识
* @param dto 包含有 设备种类 & 设备类别 & 设备品种 的map
* @param date 生成证日期 (不传取当前时间)
* @param receiveCompanyCode 接收机构统一信用代码
* @return 使用登记证书唯一标识
*/
private String generateCertificateNo(EquipmentInfoDto dto,Date date,String receiveCompanyCode){
String ym = "";
try {
ym = Optional.of(DateUtils.dateFormat(date, DateUtils.DATE_PATTERN_MM)).orElse(DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN_MM));
} catch (ParseException e) {
log.error("日期转换失败:", e);
}
String equCode = Optional.ofNullable(dto.getEquCategoryCode()).orElse(dto.getEquDefineCode());
String registrationCode = equCode + receiveCompanyCode + ym;
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(registrationCode);
return responseModel.getResult();
}
private String getApplicationNo(){
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.SYDJ.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
log.error("车用气瓶使用登记申请单单号获取失败!");
throw new BadRequest("车用气瓶使用登记申请单单号获取失败!");
}
return listResponseModel.getResult().get(0);
}
public StringBuilder checkExcelData(EquipInfoCylinderExcelDto data, AnalysisContext context) {
StringBuilder result = new StringBuilder();
ReadRowHolder readRowHolder = context.readRowHolder();
......@@ -2451,7 +2565,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
listener.setCompany(company);
}
public String findUseCode(List<Map<String, Object>> unitList, String inspectOrgCode) {
Optional<Map<String, Object>> optional = unitList.stream()
.filter(map -> map.get("useCode").equals(inspectOrgCode))
......
......@@ -843,11 +843,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
Map<String, Map<String, Object>> resultMap = new HashMap<>();
// map1.put("USE_ORG_CODE", newUseRegistrationCertificateNumber);
if (CancelTypeEnum.SCRAPPED.getCode().equals(jgScrapCancel.getCancelType())) {
IdxBizJgUseInfo idxBizJgUseInfo = new IdxBizJgUseInfo();
idxBizJgUseInfo.setEquState(String.valueOf(EquimentEnum.BAOFEI.getCode()));
LambdaQueryWrapper<IdxBizJgUseInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.in(IdxBizJgUseInfo::getRecord, equipIds);
idxBizJgUseInfoMapper.update(idxBizJgUseInfo, wrapper);
idxBizJgUseInfoMapper.batchUpdateUseInfo(equipIds, EquimentEnum.BAOFEI.getCode());
map1.put("EQU_STATE", String.valueOf(EquimentEnum.BAOFEI.getCode()));
// 修改证管理表中的证的状态
......@@ -876,11 +872,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
map1.put("ORG_BRANCH_CODE", "");
map1.put("ORG_BRANCH_NAME", "");
map1.put("EQU_STATE", String.valueOf(EquimentEnum.ZHUXIAO.getCode()));
IdxBizJgUseInfo idxBizJgUseInfo = new IdxBizJgUseInfo();
idxBizJgUseInfo.setEquState(String.valueOf(EquimentEnum.ZHUXIAO.getCode()));
LambdaQueryWrapper<IdxBizJgUseInfo> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(IdxBizJgUseInfo::getRecord, equipIds);
idxBizJgUseInfoMapper.update(idxBizJgUseInfo, wrapper1);
idxBizJgUseInfoMapper.batchUpdateUseInfo(equipIds, EquimentEnum.ZHUXIAO.getCode());
// 修改证管理表中的证的状态
List<String> certificateIds = jgScrapCancelEqList.stream().map(JgScrapCancelEq::getCertificateSeq).collect(Collectors.toList());
......
......@@ -1203,7 +1203,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
useInfo.setIsIntoManagement(Boolean.TRUE);
useInfoMapper.updateById(useInfo);
// 更新es
updateEsData(usePlace, mapData, otherInfo, jgUseRegistration, jsonObject);
updateEsData(usePlace, mapData, otherInfo, jgUseRegistration, jsonObject, Boolean.FALSE);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
......@@ -1272,28 +1272,35 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return codeUtil.generateEquipmentCode(codeGenerateDto);
}
public void updateEsData(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo, JgUseRegistration jgUseRegistration,JSONObject jsonObject) {
// 属地监管部门拆分
String orgBranch = (String) dataMap.getOrDefault("orgBranchCode", "_");
String[] split = orgBranch.split("_");
public void updateEsData(String usePlace, JSONObject dataMap, IdxBizJgOtherInfo otherInfo,
JgUseRegistration jgUseRegistration,JSONObject jsonObject, Boolean rollBake) {
// 更新es
HashMap<String, Map<String, Object>> objMap = new HashMap<>();
HashMap<String, Object> param = new HashMap<>();
param.put("SUPERVISORY_CODE", otherInfo.getSupervisoryCode());
param.put("CODE96333", otherInfo.getCode96333());
param.put("USE_UNIT_CREDIT_CODE", dataMap.get("useUnitCreditCode"));
param.put("USE_UNIT_NAME", dataMap.get("useUnitName"));
param.put("ADDRESS", dataMap.getOrDefault("address", ""));
param.put("USE_PLACE", usePlace);
param.put("STATUS", "已认领");
param.put("EQU_STATE", 1);
param.put("IS_INTO_MANAGEMENT", true);
param.put("USE_SITE_CODE", jsonObject.get("province") + "#" + jsonObject.get("city") + "#" + jsonObject.get("county") + "#" + jsonObject.get("factoryUseSiteStreet"));
param.put("USE_PLACE_CODE", String.valueOf(jsonObject.get("usePlace")));
param.put("ORG_BRANCH_CODE", split[0]);
param.put("ORG_BRANCH_NAME", split[1]);
param.put("EQU_CODE", dataMap.get("equCode"));
param.put("USE_ORG_CODE", jgUseRegistration.getUseRegistrationCode());
if (rollBake) {
param.put("EQU_STATE", EquimentEnum.WEIDENGJI.getCode());
param.put("IS_INTO_MANAGEMENT", Boolean.FALSE);
param.put("USE_ORG_CODE", null);
} else {
// 属地监管部门拆分
String orgBranch = (String) dataMap.getOrDefault("orgBranchCode", "_");
String[] split = orgBranch.split("_");
param.put("SUPERVISORY_CODE", otherInfo.getSupervisoryCode());
param.put("CODE96333", otherInfo.getCode96333());
param.put("USE_UNIT_CREDIT_CODE", dataMap.get("useUnitCreditCode"));
param.put("USE_UNIT_NAME", dataMap.get("useUnitName"));
param.put("ADDRESS", dataMap.getOrDefault("address", ""));
param.put("USE_PLACE", usePlace);
param.put("STATUS", "已认领");
param.put("EQU_STATE", 1);
param.put("IS_INTO_MANAGEMENT", true);
param.put("USE_SITE_CODE", jsonObject.get("province") + "#" + jsonObject.get("city") + "#" + jsonObject.get("county") + "#" + jsonObject.get("factoryUseSiteStreet"));
param.put("USE_PLACE_CODE", String.valueOf(jsonObject.get("usePlace")));
param.put("ORG_BRANCH_CODE", split[0]);
param.put("ORG_BRANCH_NAME", split[1]);
param.put("EQU_CODE", dataMap.get("equCode"));
param.put("USE_ORG_CODE", jgUseRegistration.getUseRegistrationCode());
}
objMap.put((String) dataMap.get("equipId"), param);
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
}
......@@ -1352,6 +1359,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
public void flowExecute(Long id, String instanceId, String operate, String comment, String carNumber, String manageType, String nextTaskId, JSONObject jsonObject) {
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey);
JSONObject recordJsonObject = new JSONObject();
try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
......@@ -1362,12 +1370,12 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
commonService.checkForExecuteFlow(nextTaskId, instanceId);
JgUseRegistration jgUseRegistration = this.getBaseMapper().selectById(id);
LambdaQueryWrapper<JgUseRegistrationEq> eq = new QueryWrapper<JgUseRegistrationEq>().lambda()
.eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr());
JgUseRegistrationEq jgUseRegistrationEq = jgRelationEquipMapper.selectOne(eq);
recordJsonObject.put("equipId", jgUseRegistrationEq.getEquId());
if (!ObjectUtils.isEmpty(carNumber)) {
// 更新安全追溯-场内车辆中的“车牌号字段” 保证唯一性
LambdaQueryWrapper<JgUseRegistrationEq> eq = new QueryWrapper<JgUseRegistrationEq>().lambda()
.eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr());
JgUseRegistrationEq jgUseRegistrationEq = jgRelationEquipMapper.selectOne(eq);
LambdaQueryWrapper<IdxBizJgRegisterInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizJgRegisterInfo::getCarNumber, carNumber);
wrapper.ne(!ObjectUtils.isEmpty(jgUseRegistrationEq.getEquId()), IdxBizJgRegisterInfo::getRecord, jgUseRegistrationEq.getEquId());
......@@ -1375,7 +1383,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (count > 0) {
throw new BadRequest("车牌号已存在,请重新输入!");
}
LambdaUpdateWrapper<IdxBizJgRegisterInfo> updateWrapper = new UpdateWrapper<IdxBizJgRegisterInfo>().lambda()
.eq(IdxBizJgRegisterInfo::getRecord, jgUseRegistrationEq.getEquId());
IdxBizJgRegisterInfo idxBizJgRegisterInfo = new IdxBizJgRegisterInfo();
......@@ -1415,6 +1422,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
this.clearDataForCheckEquipRepeatUsed(jgUseRegistration);
} catch (InterruptedException e) {
updateEsData(null, recordJsonObject, null, null, null, Boolean.TRUE);
e.printStackTrace();
} finally {
if (lock.isHeldByCurrentThread()) {
......@@ -1817,7 +1825,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.in(JgRegistrationHistory::getCurrentDocumentId, useRegistrationSeqs);
List<JgRegistrationHistory> registrationHistoryList = jgRegistrationHistoryService.getBaseMapper().selectList(lambda);
if(!ValidationUtil.isEmpty(registrationHistoryList)){
if(ValidationUtil.isEmpty(registrationHistoryList)){
throw new BadRequest("没有查询到汇总信息!");
}
JSONArray allEquipment = new JSONArray();
......@@ -1830,7 +1838,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JSONObject equipmentItem = equipmentLists.getJSONObject(i);
equipmentItem.put("useDate", timeToMonths(useDateValue));
}
allEquipment.add(equipmentLists);
allEquipment.addAll(equipmentLists);
});
total = allEquipment.size();
......
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 使用信息表 Mapper 接口
......@@ -10,5 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @date 2023-08-16
*/
public interface IdxBizJgUseInfoMapper extends BaseMapper<IdxBizJgUseInfo> {
void batchUpdateUseInfo(@Param("records") List<String> records, Integer code);
}
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper">
<update id="batchUpdateUseInfo">
UPDATE idx_biz_jg_use_info SET "EQU_STATE" = #{code} WHERE "RECORD" IN
<foreach collection="records" separator="," item="record" open="(" close=")">
#{record}
</foreach>
</update>
</mapper>
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