Commit da458e36 authored by 刘林's avatar 刘林

fix(JG):气瓶导入功能开发

parent ecd08578
...@@ -39,6 +39,7 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -39,6 +39,7 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
List<String> useInnerCodeList = new ArrayList<>();//单位内部编号集合 List<String> useInnerCodeList = new ArrayList<>();//单位内部编号集合
List<String> equCodeList = new ArrayList<>();//设备代码集合 List<String> equCodeList = new ArrayList<>();//设备代码集合
List<String> records = new ArrayList<>();//设备代码集合 List<String> records = new ArrayList<>();//设备代码集合
List<String> factoryNumList = new ArrayList<>();//出厂编码集合
List<IdxBizJgUseInfo> useInfoList = new ArrayList<>(); List<IdxBizJgUseInfo> useInfoList = new ArrayList<>();
List<IdxBizJgRegisterInfo> registerInfoList = new ArrayList<>(); List<IdxBizJgRegisterInfo> registerInfoList = new ArrayList<>();
List<IdxBizJgDesignInfo> designInfoList = new ArrayList<>(); List<IdxBizJgDesignInfo> designInfoList = new ArrayList<>();
...@@ -85,18 +86,21 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -85,18 +86,21 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
this.checkEquCodeUniqueness(data.getEquCode()); this.checkEquCodeUniqueness(data.getEquCode());
checkNotBlank(data.getDesignUnitCreditCode(), "设计单位统一社会信用代码不能为空"); checkNotBlank(data.getDesignUnitCreditCode(), "设计单位统一社会信用代码不能为空");
checkNotBlank(data.getDesignUnitName(), "设计单位名称不能为空"); checkNotBlank(data.getDesignUnitName(), "设计单位名称不能为空");
Optional.ofNullable(data.getDesignDate()).ifPresent(v -> checkDateFormatCorrect(v,"设计日期格式不正确")); Optional.ofNullable(data.getDesignDate()).ifPresent(v -> checkDateFormatCorrect(v, "设计日期格式不正确"));
Optional.ofNullable(data.getAppraisalDate()).ifPresent(v -> checkDateFormatCorrect(v, "设计文件鉴定日期格式不正确")); Optional.ofNullable(data.getAppraisalDate()).ifPresent(v -> checkDateFormatCorrect(v, "设计文件鉴定日期格式不正确"));
checkNotBlank(data.getProduceUnitCreditCode(), "制造单位统一社会信用代码不能为空"); checkNotBlank(data.getProduceUnitCreditCode(), "制造单位统一社会信用代码不能为空");
checkNotBlank(data.getProduceUnitName(), "制造单位名称不能为空"); checkNotBlank(data.getProduceUnitName(), "制造单位名称不能为空");
checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空"); checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空");
checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空"); checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空");
if ("0".equals(data.getWhetherVehicleCylinder()) && factoryNumList.contains(data.getFactoryNum()))
result.append("出厂编号/产品编码不能重复;");
checkFactoryNumUniqueness(data.getFactoryNum(), null);
checkNotBlank(data.getProduceDate(), "制造日期不能为空"); checkNotBlank(data.getProduceDate(), "制造日期不能为空");
checkDateFormatCorrect(data.getProduceDate(),"制造日期格式不正确"); checkDateFormatCorrect(data.getProduceDate(), "制造日期格式不正确");
checkNotBlank(data.getInspectOrgName(), "检测机构名称不能为空"); checkNotBlank(data.getInspectOrgName(), "检测机构名称不能为空");
checkNotBlank(data.getInspectStaff(), "检测人员名称不能为空"); checkNotBlank(data.getInspectStaff(), "检测人员名称不能为空");
checkNotBlank(data.getInspectDate(), "检测日期不能为空"); checkNotBlank(data.getInspectDate(), "检测日期不能为空");
checkDateFormatCorrect(data.getInspectDate(),"检测日期格式不正确"); checkDateFormatCorrect(data.getInspectDate(), "检测日期格式不正确");
checkNotBlank(data.getSingleBottleVolume(), "单瓶容积不能为空"); checkNotBlank(data.getSingleBottleVolume(), "单瓶容积不能为空");
checkNotBlank(data.getChargingMedium(), "充装介质不能为空"); checkNotBlank(data.getChargingMedium(), "充装介质不能为空");
checkNotBlank(data.getNominalWorkingPressure(), "公称工作压力不能为空"); checkNotBlank(data.getNominalWorkingPressure(), "公称工作压力不能为空");
...@@ -106,13 +110,10 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -106,13 +110,10 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
result.insert(0, "Excel第[" + rowIndex + "]行 -> "); result.insert(0, "Excel第[" + rowIndex + "]行 -> ");
throw new BadRequest(result.toString()); throw new BadRequest(result.toString());
} }
this.dealExcelData(data); this.dealExcelData(data);
} catch (BadRequest e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
log.error(String.format("行索引数: [%s] -> 失败的 Excel 数据: [%s]", rowIndex, JSON.toJSONString(data)), e); log.error(String.format("行索引数: [%s] -> 失败的 Excel 数据: [%s]", rowIndex, JSON.toJSONString(data)), e);
throw new BadRequest(result.toString()); throw e;
} }
} }
...@@ -140,15 +141,22 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -140,15 +141,22 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
} }
} }
private void checkFactoryNumUniqueness(String factoryNum, String sequenceNbr) {
// 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
if (commonService.checkFactoryNumUniquenessForVehicleCylinder(factoryNum, sequenceNbr) > 0) {
result.append("出厂编号/产品编码系统中已存在!");
}
}
/** /**
* 处理导入数据 * 处理导入数据
* *
* @param data excelData * @param data excelData
*/ */
private void dealExcelData(EquipInfoCylinderExcelDto data) { private void dealExcelData(EquipInfoCylinderExcelDto data) {
useInnerCodeList.add(data.getUseInnerCode()); useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode()); equCodeList.add(data.getEquCode());
factoryNumList.add("0".equals(data.getWhetherVehicleCylinder()) ? data.getFactoryNum() : null);
Date date = new Date(); Date date = new Date();
String record = UUID.randomUUID().toString(); String record = UUID.randomUUID().toString();
...@@ -194,12 +202,13 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -194,12 +202,13 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
//检验检测 //检验检测
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = new IdxBizJgInspectionDetectionInfo(); IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = new IdxBizJgInspectionDetectionInfo();
BeanUtils.copyProperties(data, inspectionDetectionInfo); BeanUtils.copyProperties(data, inspectionDetectionInfo);
List<Map<String, Object>> InspectOrgList = commonService.getUnitListByType("inspection"); List<Map<String, Object>> InspectOrgList = commonService.getUnitListByType("inspection", "");
inspectionDetectionInfo.setInspectOrgCode(findUseCode(InspectOrgList, data.getInspectOrgName())); inspectionDetectionInfo.setInspectOrgCode(findUseCode(InspectOrgList, data.getInspectOrgName()));
inspectionDetectionInfo.setRecord(record); inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(date); inspectionDetectionInfo.setRecDate(date);
inspectionDetectionInfo.setInspectType("ZZJDJY"); inspectionDetectionInfo.setInspectType("ZZJDJY");
inspectionDetectionInfo.setInspectDate(DateUtil.parse(data.getInspectDate(),"yyyy-MM-dd")); inspectionDetectionInfo.setInspectConclusion("6040");//默认合格
inspectionDetectionInfo.setInspectDate(DateUtil.parse(data.getInspectDate(), "yyyy-MM-dd"));
inspectionDetectionInfo.setNextInspectDate(Date.from( inspectionDetectionInfo.setNextInspectDate(Date.from(
LocalDate.parse(data.getInspectDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")) LocalDate.parse(data.getInspectDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"))
.plusYears(3) .plusYears(3)
...@@ -267,8 +276,10 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin ...@@ -267,8 +276,10 @@ public class PressureVesselListener extends AnalysisEventListener<EquipInfoCylin
@Override @Override
public void onException(Exception exception, AnalysisContext context) throws Exception { public void onException(Exception exception, AnalysisContext context) throws Exception {
superviseInfoMapper.deleteDataAll(records); if (!esEquipmentCategoryList.isEmpty()) {
esEquipmentCategory.deleteAll(esEquipmentCategoryList); superviseInfoMapper.deleteDataAll(records);
esEquipmentCategory.deleteAll(esEquipmentCategoryList);
}
throw exception; throw exception;
} }
......
...@@ -184,4 +184,6 @@ public interface ICommonService { ...@@ -184,4 +184,6 @@ public interface ICommonService {
* @return CompanyBo * @return CompanyBo
*/ */
CompanyBo getOneCompany(String companyCode); CompanyBo getOneCompany(String companyCode);
Integer checkFactoryNumUniquenessForVehicleCylinder(String factoryNum,String sequenceNbr);
} }
...@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -35,4 +35,6 @@ public interface IIdxBizJgRegisterInfoService { ...@@ -35,4 +35,6 @@ public interface IIdxBizJgRegisterInfoService {
Page<JSONObject> queryForUnitEquipmentPage(JSONObject jsonObject); Page<JSONObject> queryForUnitEquipmentPage(JSONObject jsonObject);
Page<JSONObject> queryEquipCanUsedByVesselPage(JSONObject jsonObject); Page<JSONObject> queryEquipCanUsedByVesselPage(JSONObject jsonObject);
String importPressureVesselData(MultipartFile file, Map<String, Object> paramMap);
} }
...@@ -1762,6 +1762,11 @@ public class CommonServiceImpl implements ICommonService { ...@@ -1762,6 +1762,11 @@ public class CommonServiceImpl implements ICommonService {
return companyBo == null ? new CompanyBo() : companyBo; return companyBo == null ? new CompanyBo() : companyBo;
} }
@Override
public Integer checkFactoryNumUniquenessForVehicleCylinder(String factoryNum, String sequenceNbr) {
return commonMapper.checkFactoryNumUniquenessForVehicleCylinder(factoryNum, sequenceNbr);
}
/** /**
* 根据设备列表代码选择对应的 PDF 模板 * 根据设备列表代码选择对应的 PDF 模板
* *
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -12,10 +13,12 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary; ...@@ -12,10 +13,12 @@ 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.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; 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.RedisUtils;
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.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum; import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper; 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.JgUseRegistrationMapper;
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.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.jg.biz.service.*; import com.yeejoin.amos.boot.module.jg.biz.service.*;
...@@ -48,6 +51,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -48,6 +51,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -164,6 +168,17 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -164,6 +168,17 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Value("${add.equip.dict.code.suffix:CATEGORY_LIST_ADD}") @Value("${add.equip.dict.code.suffix:CATEGORY_LIST_ADD}")
private String equipAddDictCodeSuffix; private String equipAddDictCodeSuffix;
@Autowired
private IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgTechParamsVesselServiceImpl idxBizJgTechParamsVesselService;
@Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
/** /**
* 将对象的属性由驼峰转为纯大写下划线格式 * 将对象的属性由驼峰转为纯大写下划线格式
* *
...@@ -1439,12 +1454,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1439,12 +1454,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
/** /**
* 设置安装告知使用的设备不能包括正在进行中的流程 * 设置安装告知使用的设备不能包括正在进行中的流程
*
* @param boolMust * @param boolMust
* @param companyCode * @param companyCode
*/ */
private void setRepeatUsedCheckFilterParam(BoolQueryBuilder boolMust, String companyCode, String bizType) { private void setRepeatUsedCheckFilterParam(BoolQueryBuilder boolMust, String companyCode, String bizType) {
Set<String> records = EquipUsedCheckStrategyContext.getUsedStrategy(bizType).getEquipInFlow(companyCode); Set<String> records = EquipUsedCheckStrategyContext.getUsedStrategy(bizType).getEquipInFlow(companyCode);
if(records.size() >0){ if (records.size() > 0) {
boolMust.mustNot(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records)); boolMust.mustNot(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
} }
} }
...@@ -1478,7 +1494,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1478,7 +1494,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
* *
* @return code * @return code
*/ */
private String getRegCode() { public String getRegCode() {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>(); QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "ZC"); queryWrapper.eq("type", "ZC");
queryWrapper.eq("name", "未注册"); queryWrapper.eq("name", "未注册");
...@@ -1874,4 +1890,40 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1874,4 +1890,40 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}); });
return result; return result;
} }
@Override
public String importPressureVesselData(MultipartFile file, Map<String, Object> paramMap) {
try {
PressureVesselListener pressureVesselListener = new PressureVesselListener();
injectDependencies(pressureVesselListener, paramMap);
EasyExcel.read(file.getInputStream(), EquipInfoCylinderExcelDto.class, pressureVesselListener)
.headRowNumber(4)
.sheet()
.doRead();
return pressureVesselListener.getResult();
} catch (Exception e) {
return (e.getCause() instanceof BadRequest) ? "模版数据填写有误:" + e.getCause().getMessage() : "导入时出现异常:" + e.getMessage();
}
}
// 注入依赖
private void injectDependencies(PressureVesselListener listener, Map<String, Object> paramMap) {
listener.setIdxBizJgRegisterInfoService(idxBizJgRegisterInfoService);
listener.setJgInstallationNoticeService(jgInstallationNoticeService);
listener.setIdxBizJgUseInfoService(idxBizJgUseInfoService);
listener.setIdxBizJgDesignInfoService(idxBizJgDesignInfoService);
listener.setIdxBizJgFactoryInfoService(idxBizJgFactoryInfoService);
listener.setIdxBizJgTechParamsVesselService(idxBizJgTechParamsVesselService);
listener.setIdxBizJgInspectionDetectionInfoService(idxBizJgInspectionDetectionInfoService);
listener.setCommonService(commonService);
listener.setTzsJgRegistrationInfoMapper(tzsJgRegistrationInfoMapper);
listener.setTzsJgRegistrationInfoMapper(tzsJgRegistrationInfoMapper);
listener.setEsEquipmentCategory(esEquipmentCategory);
listener.setCategoryOtherInfoMapper(categoryOtherInfoMapper);
listener.setSuperviseInfoMapper(superviseInfoMapper);
listener.setParamMap(paramMap);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
listener.setCompany(company);
}
} }
\ 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