Commit d1bc6e3e authored by 刘林's avatar 刘林

fix(jg):【现场问题】压力管道-压力容器导入优化

parent 36b798e9
......@@ -128,7 +128,7 @@
<dependency>
<groupId>cn.com.vastdata</groupId>
<artifactId>vastbase-jdbc</artifactId>
<version>2.10p</version>
<version>2.12p</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
......
package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* @author LiuLin
*/
public interface CustomBaseMapper<T> extends BaseMapper<T> {
Integer insertBatchSomeColumn(List<T> entityList);
/**
* 分批批量插入
* @param entityList 数据集合
* @param batchSize 每批数量
* @return 插入总条数
*/
default int insertBatchSomeColumn(List<T> entityList, int batchSize) {
if (entityList == null || entityList.isEmpty()) {
return 0;
}
int total = 0;
for (int i = 0; i < entityList.size(); i += batchSize) {
int endIndex = Math.min(i + batchSize, entityList.size());
List<T> subList = entityList.subList(i, endIndex);
total += insertBatchSomeColumn(subList);
}
return total;
}
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.jg.api.converter.*;
import io.swagger.annotations.ApiModel;
......@@ -284,5 +285,5 @@ public class EquipInfoCylinderExcelDto extends BaseDto {
private String informationManageCode;
@ExcelIgnore
private List fileData;
private List<?> fileData;
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.Collection;
import java.util.List;
/**
* @author DELL
*/
public interface CustomBaseMapper<T> extends BaseMapper<T> {
Integer insertBatchSomeColumn(List<T> entityList);
}
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationUnitEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationUnit;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransferEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgEquipTransferDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgEquipTransfer;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PieLineEquipContraptionDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgNoticeToBeSubmitDto;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintainNoticeEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgMaintainNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintainNotice;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq;
import org.apache.ibatis.annotations.Param;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNoticeEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgReformNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNotice;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNoticeEq;
/**
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgTransferNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNotice;
......
......@@ -53,7 +53,7 @@
<dependency>
<groupId>cn.com.vastdata</groupId>
<artifactId>vastbase-jdbc</artifactId>
<version>2.10p</version>
<version>2.12p</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
......
......@@ -285,7 +285,6 @@ public class IdxBizJqEquipmentRegisterController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/importData")
@ApiOperation(httpMethod = "POST", value = "气瓶批量导入", notes = "气瓶批量导入")
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<?> importPressureData(@RequestPart("file") MultipartFile multipartFile) throws Exception {
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.importPressureData(multipartFile));
}
......
......@@ -58,7 +58,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
......@@ -92,7 +91,6 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterI
public class DataDockServiceImpl {
private final SnowflakeIdUtil sequence;
private final ESEquipmentCategory esEquipmentCategory;
private final SuperviseInfoMapper superviseInfoMapper;
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
private final IIdxBizJgUseInfoService idxBizJgUseInfoService;
private final IIdxBizJgProjectContraptionService idxBizJgProjectContraptionService;
......@@ -113,7 +111,6 @@ public class DataDockServiceImpl {
private final IdxBizJgProjectContraptionServiceImplService idxBizJgProjectContraptionServiceImpl;
private final IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
private final JgInstallationNoticeServiceImpl installationNoticeService;
private final TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageService;
private final RedisUtils redisUtils;
private final JgUseRegistrationServiceImpl jgUseRegistrationServiceImpl;
......@@ -133,7 +130,6 @@ public class DataDockServiceImpl {
private final JgResumeInfoServiceImpl jgResumeInfoService;
private final IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
private final Map<String, Object> resultError = new HashMap<>();
private final JgUseRegistrationMapper jgUseRegistrationMapper;
List<String> useInnerCodeList = new ArrayList<>();// 单位内部编号集合
List<String> equCodeList = new ArrayList<>();// 设备代码集合
List<String> factoryNumList = new ArrayList<>();// 出厂编码集合
......@@ -150,15 +146,19 @@ public class DataDockServiceImpl {
// 设备基本信息表单id
public static final String EQUIP_INFO_FORM_ID = "equipInfo";
// 设备技术参数表单id
public static final String EQUIP_PARAMS_FORM_ID = "equipParams";
private static final String ATTACHMENT_UPLOAD = "attachmentUpload";
// 模版上传集合
public static final String EQU_LISTS = "equLists";
@Autowired
private EventPublisher eventPublisher;
@Autowired
private JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
private final EventPublisher eventPublisher;
private final JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
private final IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private final IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
private final IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
private final IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
private final IdxBizJgConstructionInfoMapper idxBizJgConstructionInfoMapper;
private final IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
private final IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper;
/**
* 西安数据对接-保存设备信息
......@@ -1023,17 +1023,17 @@ public class DataDockServiceImpl {
.stream()
.map(item -> (String) item.get("pipelineNumber"))
.collect(Collectors.toList());
if (pipelineNumberList.contains(data.getPipelineNumber())) {
rowError.append(String.format("系统中工程装置(%s)下已经存在管道编号(%s);", data.getProjectContraption(), data.getPipelineNumber()));
}
// if (pipelineNumberList.contains(data.getPipelineNumber())) {
// rowError.append(String.format("系统中工程装置(%s)下已经存在管道编号(%s);", data.getProjectContraption(), data.getPipelineNumber()));
// }
});
List<String> list = projectContraptionMap.get(data.getProjectContraption());
if (null != list) {
// 判断该装置下是否已经存在该管道编号
if (list.contains(data.getPipelineNumber())) {
rowError.append(String.format("同一工程装置(%s)下管道编号不能重复;", data.getProjectContraption()));
}
// if (list.contains(data.getPipelineNumber())) {
// rowError.append(String.format("同一工程装置(%s)下管道编号不能重复;", data.getProjectContraption()));
// }
list.add(data.getPipelineNumber());
} else {
list = new ArrayList<>();
......@@ -1691,13 +1691,13 @@ public class DataDockServiceImpl {
//checkNotBlank(data.getMedium(), "设计-介质不能为空;", rowError);
//checkNotBlank(data.getTemperature(), "设计-温度不能为空;", rowError);
//checkNotBlank(data.getPipelineNumber(), "管道编号不能为空;", rowError);
Optional.ofNullable(data.getPipelineNumber()).ifPresent(v -> {
if (pipelineNumList.contains(v)) {
rowError.append("管道编号不能重复");
} else {
pipelineNumList.add(v);
}
});
// Optional.ofNullable(data.getPipelineNumber()).ifPresent(v -> {
// if (pipelineNumList.contains(v)) {
// rowError.append("管道编号不能重复");
// } else {
// pipelineNumList.add(v);
// }
// });
//checkNotBlank(data.getDeviceLevel(), "管道级别不能为空;", rowError);
......@@ -2063,6 +2063,7 @@ public class DataDockServiceImpl {
useInfo.setProjectContraption(paramsDto.getProjectContraption());
useInfo.setUseDate(paramsDto.getUseDate());
useInfo.setProjectContraptionId(paramsDto.getProjectContraptionSeq());
useInfo.setDataQualityScore(StringUtils.isEmpty(paramsDto.getUseOrgCode()) ? 3 : 1);
useInfoList.add(useInfo);
// 检验检测信息
......@@ -2189,17 +2190,38 @@ public class DataDockServiceImpl {
}
esEquipmentCategoryList.add(esEquipmentDto);
}
idxBizJgUseInfoService.saveBatch(useInfoList);
idxBizJgDesignInfoService.saveBatch(designInfoList);
idxBizJgConstructionInfoService.saveBatch(constructionInfoList);
idxBizJgFactoryInfoService.saveBatch(factoryInfoList);
idxBizJgRegisterInfoServiceImpl.saveBatch(registerInfoList);
idxBizJgOtherInfoService.saveBatch(otherInfoList);
idxBizJgSupervisionInfoService.saveBatch(supervisionInfoList);
iIdxBizJgTechParamsPipelineService.saveBatch(paramsPipelineList);
idxBizJgInspectionDetectionInfoService.saveBatch(inspectionDetectionInfoList);
esEquipmentCategory.saveAll(esEquipmentCategoryList);
CompletableFuture<Void> useInfoFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息"));
CompletableFuture<Void> designInfoFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息"));
CompletableFuture<Void> constructionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgConstructionInfoMapper, constructionInfoList, "施工信息"));
CompletableFuture<Void> factoryFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息"));
CompletableFuture<Void> registerFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "登记信息"));
CompletableFuture<Void> otherFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgOtherInfoMapper, otherInfoList, "其他信息"));
CompletableFuture<Void> supervisionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监管信息"));
CompletableFuture<Void> paramsPipelineFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgTechParamsPipelineMapper, paramsPipelineList, "管道参数信息"));
CompletableFuture<Void> inspectionFuture = CompletableFuture.runAsync(
() -> idxBizJgRegisterInfoServiceImpl.batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息"));
CompletableFuture<Void> esFuture = CompletableFuture.runAsync(() -> {
if (!esEquipmentCategoryList.isEmpty()) {
esEquipmentCategory.saveAll(esEquipmentCategoryList);
log.info("ES批量保存完成,数量:{}", esEquipmentCategoryList.size());
}
});
CompletableFuture.allOf(
useInfoFuture, designInfoFuture, constructionFuture, factoryFuture,
registerFuture, otherFuture, supervisionFuture, paramsPipelineFuture,
inspectionFuture, esFuture
).join();
log.info("所有批量操作完成");
return recordList;
}
......@@ -2438,6 +2460,7 @@ public class DataDockServiceImpl {
.supervisoryCode(idxBizJgRegisterInfoServiceImpl.getSupervisoryCode(paramsDto.getVehicleApanage(), paramsDto.getEquCategoryCode())).isIntoManagement(Boolean.TRUE).dataSource(paramsDto.getDataSource()).equCode(paramsDto.getEquCode()).isFirstMerge(Boolean.FALSE).build();
contraption.setSequenceNbr(seq);
contraption.setCreateDate(new Date());
contraption.setDataQualityScore(StringUtils.isEmpty(paramsDto.getUseOrgCode()) ? "3" : "1");
paramsDto.setProjectContraptionSeq(String.valueOf(seq));
idxBizJgProjectContraptionService.save(contraption);
return contraption;
......
......@@ -29,6 +29,7 @@ import com.yeejoin.amos.boot.biz.common.utils.*;
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.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EquipmentCategoryService;
import com.yeejoin.amos.boot.module.jg.api.common.DataDockTemplateVersionUtils;
......@@ -114,6 +115,8 @@ import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum.SPECIAL_CYLINDER;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XIAN_YANG;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XI_XIAN;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl.IDX_BIZ_EQUIPMENT_INFO;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl.IDX_BIZ_VIEW_JG_ALL;
/**
......@@ -210,7 +213,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
@Autowired
private IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
@Autowired
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
@Autowired
private IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
@Autowired
private IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
@Autowired
private IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
@Autowired
private IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper;
@Autowired
IdxBizJgOtherInfoMapper otherInfoMapper;
@Autowired
......@@ -4021,46 +4036,174 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
equCodeList.clear();
factoryNumList.clear();
try {
// 判断模板版本号
String templateVersionError = DataDockTemplateVersionUtils.checkTemplateVersion(multipartFile);
if (!ValidationUtil.isEmpty(templateVersionError)) {
resultError.add(templateVersionError);
throw new BadRequest(templateVersionError);
}
EasyExcel.read(multipartFile.getInputStream(), EquipInfoCylinderExcelDto.class, new AnalysisEventListener<EquipInfoCylinderExcelDto>() {
// 每读取一行就调用该方法
@Override
public void invoke(EquipInfoCylinderExcelDto data, AnalysisContext context) {
EquipInfoCylinderExcelDto fireExperts = new EquipInfoCylinderExcelDto();
BeanUtils.copyProperties(data, fireExperts);
resultError.add(checkExcelData(data, context).toString());
aircraftList.add(fireExperts);
useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode());
factoryNumList.add("0".equals(data.getWhetherVehicleCylinder()) ? data.getProduceUnitCreditCode() + "_" +data.getFactoryNum() : null);
}
// 全部读取完成就调用该方法
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtils.isEmpty(aircraftList)) {
log.info("你上传了一个空数据的Excel文档!");
resultError.add("你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
EasyExcel.read(multipartFile.getInputStream(), EquipInfoCylinderExcelDto.class,
new AnalysisEventListener<EquipInfoCylinderExcelDto>() {
@Override
public void invoke(EquipInfoCylinderExcelDto data, AnalysisContext context) {
EquipInfoCylinderExcelDto copy = new EquipInfoCylinderExcelDto();
BeanUtils.copyProperties(data, copy);
aircraftList.add(copy);
useInnerCodeList.add(data.getUseInnerCode());
String checkMsg = checkExcelData(data, context).toString();
if (!checkMsg.isEmpty()) {
resultError.add(checkMsg);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtils.isEmpty(aircraftList)) {
String msg = "你上传了一个空数据的Excel文档!";
resultError.add(msg);
throw new BadRequest(msg);
}
}
}).headRowNumber(4).sheet().doRead();
if (resultError.stream().anyMatch(s -> !s.isEmpty())) {
throw new BadRequest("上传失败!");
}
List<String> warnings = checkExcelDuplicates(aircraftList);
Set<String> nonVehicleKeys = new HashSet<>();
Set<String> vehicleFactoryNums = new HashSet<>();
Set<String> equCodeKeys = new HashSet<>();
for (EquipInfoCylinderExcelDto data : aircraftList) {
if ("1".equals(data.getEquCodeType()) && StringUtils.isNotEmpty(data.getEquCode())) {
equCodeKeys.add(data.getEquCode());
}
if ("0".equals(data.getWhetherVehicleCylinder())) { // 非车用
if (StringUtils.isNotEmpty(data.getProduceUnitCreditCode()) &&
StringUtils.isNotEmpty(data.getFactoryNum())) {
nonVehicleKeys.add(data.getProduceUnitCreditCode() + "_" + data.getFactoryNum());
}
} else { // 车用
if (StringUtils.isNotEmpty(data.getFactoryNum())) {
vehicleFactoryNums.add(data.getFactoryNum());
}
}
}).headRowNumber(4).sheet().doRead();
if (resultError.stream().anyMatch(input -> !input.isEmpty())) {
throw new BadRequest("上传失败!");
}
Map<String, String> nonVehicleMap = batchQueryEs(nonVehicleKeys, true);//普通气瓶
Map<String, String> vehicleMap = batchQueryEs(vehicleFactoryNums, false);//车用气瓶
List<String> equCodes = new ArrayList<>();
for (EquipInfoCylinderExcelDto data : aircraftList) {
String exist;
if ("0".equals(data.getWhetherVehicleCylinder())) {
exist = nonVehicleMap.get(data.getFactoryNum());
} else {
exist = vehicleMap.get(data.getFactoryNum());
}
if (exist != null) {
warnings.add(String.format("制造单位[%s]生产的出厂编号为[%s]的气瓶,已被[%s]录入系统,请核实!", data.getProduceUnitName(), data.getFactoryNum(), exist));
}
//校验设备代码重复
equCodes = this.checkEquCodeExist(equCodeKeys);
}
if (!equCodes.isEmpty()) {
resultError.add("导入气瓶模板中,以下设备代码系统中已存在: " + String.join(",", equCodes));
}
if (!warnings.isEmpty()) {
resultError.addAll(warnings);
throw new BadRequest(resultError.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("<br/>")));
}
return aircraftList;
} catch (Exception e) {
throw new Exception(resultError.stream()
.filter(s -> !s.isEmpty())
.collect(Collectors.joining("<br/>")));
throw new Exception(resultError.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("<br/>")));
}
}
private List<String> checkEquCodeExist(Set<String> equCodeKeys) throws IOException {
List<String> equCodes;
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
.must(QueryBuilders.termsQuery("EQU_CODE", equCodeKeys))
.must(QueryBuilders.termQuery("STATUS", "已认领"));
SearchRequest request = new SearchRequest(IDX_BIZ_VIEW_JG_ALL);
request.source(new SearchSourceBuilder()
.query(boolQuery)
.fetchSource(new String[]{"EQU_CODE"}, null)
.size(10000)
);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
equCodes = Arrays.stream(response.getHits().getHits())
.map(hit -> (String) hit.getSourceAsMap().get("EQU_CODE"))
.filter(Objects::nonNull)
.collect(Collectors.toList());
return equCodes;
}
/** Excel 内部重复校验 */
private List<String> checkExcelDuplicates(List<EquipInfoCylinderExcelDto> list) {
List<String> warnings = new ArrayList<>();
Set<String> nonVehicleSet = new HashSet<>();
Set<String> vehicleSet = new HashSet<>();
for (EquipInfoCylinderExcelDto data : list) {
if ("0".equals(data.getWhetherVehicleCylinder())) {
String key = data.getProduceUnitCreditCode() + "_" + data.getFactoryNum();
if (!nonVehicleSet.add(key)) {
warnings.add(String.format(
"您上传的Excel内部发现重复:制造单位[%s]生产的出厂编号为[%s]的气瓶重复!",
data.getProduceUnitName(), data.getFactoryNum()));
}
} else {
String key = data.getFactoryNum();
if (!vehicleSet.add(key)) {
warnings.add(String.format(
"您上传的Excel内部发现重复:车用气瓶出厂编号[%s]重复!",
data.getFactoryNum()));
}
}
}
return warnings;
}
/** 批量查询 ES */
private Map<String, String> batchQueryEs(Set<String> keys, boolean nonVehicle) throws IOException {
Map<String, String> resultMap = new HashMap<>();
if (CollectionUtils.isEmpty(keys)) return resultMap;
SearchRequest request = new SearchRequest(IDX_BIZ_EQUIPMENT_INFO);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().size(10000)
.fetchSource(new String[]{"FACTORY_NUM", "PRODUCE_UNIT_NAME"}, null);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("EQU_LIST_CODE", "2000"))
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.termQuery("STATUS", "已认领"));
if (nonVehicle) {
List<String> creditCodes = keys.stream().map(k -> k.split("_")[0]).collect(Collectors.toList());
List<String> factoryNums = keys.stream().map(k -> k.split("_")[1]).collect(Collectors.toList());
boolQuery.must(QueryBuilders.termsQuery("FACTORY_NUM", factoryNums))
.must(QueryBuilders.termsQuery("produceUnitCreditCode", creditCodes));
} else {
boolQuery.must(QueryBuilders.termsQuery("FACTORY_NUM", keys))
.must(QueryBuilders.termQuery("EQU_DEFINE_CODE", "23T0"))
.must(QueryBuilders.termQuery("WHETHER_VEHICLE_CYLINDER", "1"));
}
sourceBuilder.query(boolQuery);
request.source(sourceBuilder);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
Map<String, Object> src = hit.getSourceAsMap();
String factoryNum = Objects.toString(src.get("FACTORY_NUM"), "");
String produceUnitName = Objects.toString(src.get("PRODUCE_UNIT_NAME"), "");
resultMap.put(factoryNum, produceUnitName);
}
return resultMap;
}
private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
if (dataList == null || dataList.isEmpty()) {
return null;
......@@ -4151,6 +4294,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.orElse(String.valueOf(EquimentEnum.ZAIYONG.getCode())))
: String.valueOf(EquimentEnum.WEIDENGJI.getCode());
useInfo.setEquState(equState);
useInfo.setDataQualityScore(StringUtils.isEmpty(equipInfoDto.getUseOrgCode()) ? 3 : 1);
// 使用单位信息
if ("个人主体".equals(company.getCompanyType())) {
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
......@@ -4419,21 +4563,31 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.collect(Collectors.toList())
);
}
Optional.of(supervisionInfoList).filter(list -> !list.isEmpty()).ifPresent(iIdxBizJgSupervisionInfoService::saveBatch);
Optional.of(useInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgUseInfoService::saveBatch);
Optional.of(designInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgDesignInfoService::saveBatch);
Optional.of(registerInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgRegisterInfoService::saveBatch);
Optional.of(factoryInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgFactoryInfoService::saveBatch);
Optional.of(otherInfoList).filter(list -> !list.isEmpty()).ifPresent(idxBizJgOtherInfoService::saveBatch);
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);
batchInsert(idxBizJgSupervisionInfoMapper, supervisionInfoList, "监督信息");
batchInsert(idxBizJgUseInfoMapper, useInfoList, "使用信息");
batchInsert(idxBizJgDesignInfoMapper, designInfoList, "设计信息");
batchInsert(idxBizJgRegisterInfoMapper, registerInfoList, "注册信息");
batchInsert(idxBizJgFactoryInfoMapper, factoryInfoList, "制造信息");
batchInsert(otherInfoMapper, otherInfoList, "其他信息");
batchInsert(idxBizJgTechParamsVesselMapper, paramsVesselList, "容器参数信息");
batchInsert(idxBizJgInspectionDetectionInfoMapper, inspectionDetectionInfoList, "检验检测信息");
if (!esEquipmentCategoryList.isEmpty()) {
esEquipmentCategory.saveAll(esEquipmentCategoryList);
}
eventPublisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), recordSet, EquipCreateOrEditEvent.EquipType.equip));
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
}
/** 通用批量插入方法 */
public <T> void batchInsert(CustomBaseMapper<T> mapper, List<T> list, String name) {
if (list != null && !list.isEmpty()) {
mapper.insertBatchSomeColumn(list, 1000);
log.info("{} 批量插入完成,数量:{}", name, list.size());
} else {
log.info("{} 列表为空,无需插入", name);
}
}
public String buildTaskModel(JgUseRegistration jgUseRegistration, String equListCode) {
TaskModelDto modelDto = new TaskModelDto();
modelDto.setNextExecuteUser(jgUseRegistration.getNextExecuteUserIds());
......@@ -4725,12 +4879,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (!equCode.matches("[a-zA-Z0-9]+")) {
result.append("设备代码不能包含特殊字符;");
} else {
Stream.of(equCode.length() <= 17 ? "设备代码不能小于17位;" : "",
equCode.length() >= 20 ? "设备代码不能大于20位;" : "",
equCodeList.contains(equCode) ? "设备代码不能重复;" : ""
String code = equCode.trim();
Stream.of(code.length() < 17 ? "设备代码不能小于17位;" : "",
code.length() > 20 ? "设备代码不能大于20位;" : ""
).filter(msg -> !msg.isEmpty())
.forEach(result::append);
this.checkEquCodeUniqueness(equCode, result);
if (equCodeList.contains(code)) {
result.append("设备代码不能重复").append(code);
}
equCodeList.add(data.getEquCode());
//this.checkEquCodeUniqueness(equCode, result);
}
});
} else {
......@@ -4744,19 +4902,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//checkNotBlank(data.getProduceUnitName(), "制造单位名称不能为空;", result);
// checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空;", result);
//checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空;", result);
if ("0".equals(data.getWhetherVehicleCylinder())) {
// checkNotBlank(data.getCylinderCategory(), "气瓶分类不能为空;", result);
if (!StringUtils.isEmpty(data.getFactoryNum()) && !StringUtils.isEmpty(data.getProduceUnitCreditCode())){
checkFactoryNumUnique(data.getFactoryNum(), data.getProduceUnitCreditCode(), data.getProduceUnitName(), result);
if (factoryNumList.contains(data.getProduceUnitCreditCode() + "_" +data.getFactoryNum())){
result.append("同一制造单位下,出厂编码不能重复!;");
}
}
} else {
if (!StringUtils.isEmpty(data.getFactoryNum())){
checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum(), result);
}
}
// if ("0".equals(data.getWhetherVehicleCylinder())) {
//// checkNotBlank(data.getCylinderCategory(), "气瓶分类不能为空;", result);
// if (!StringUtils.isEmpty(data.getFactoryNum()) && !StringUtils.isEmpty(data.getProduceUnitCreditCode())){
// checkFactoryNumUnique(data.getFactoryNum(), data.getProduceUnitCreditCode(), data.getProduceUnitName(), result);
// if (factoryNumList.contains(data.getProduceUnitCreditCode() + "_" +data.getFactoryNum())){
// result.append("同一制造单位下,出厂编码不能重复!;");
// }
// }
// } else {
// if (!StringUtils.isEmpty(data.getFactoryNum())){
// checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum(), result);
// }
// }
// checkNotBlank(data.getProduceDate(), "制造日期不能为空;", result);
Optional.ofNullable(data.getProduceDate()).ifPresent(v -> checkDateFormatCorrect(v, "制造日期格式不正确;", result));
//checkNotBlank(data.getInspectOrgName(), "检测机构名称不能为空;", result);
......
......@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.IBaseChangeData;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.JdbcType;
import java.util.Date;
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgConstructionInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 施工信息表 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgConstructionInfoMapper extends BaseMapper<IdxBizJgConstructionInfo> {
public interface IdxBizJgConstructionInfoMapper extends CustomBaseMapper<IdxBizJgConstructionInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-设计信息表 Mapper 接口
......@@ -9,6 +9,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgDesignInfoMapper extends BaseMapper<IdxBizJgDesignInfo> {
public interface IdxBizJgDesignInfoMapper extends CustomBaseMapper<IdxBizJgDesignInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgFactoryInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-制造信息 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgFactoryInfoMapper extends BaseMapper<IdxBizJgFactoryInfo> {
public interface IdxBizJgFactoryInfoMapper extends CustomBaseMapper<IdxBizJgFactoryInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import org.apache.ibatis.annotations.Param;
......@@ -12,7 +12,7 @@ import java.util.List;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgInspectionDetectionInfoMapper extends BaseMapper<IdxBizJgInspectionDetectionInfo> {
public interface IdxBizJgInspectionDetectionInfoMapper extends CustomBaseMapper<IdxBizJgInspectionDetectionInfo> {
List<IdxBizJgInspectionDetectionInfo> selectLastedGroupByInspectType(@Param("record") String record);
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Select;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgOtherInfoMapper extends BaseMapper<IdxBizJgOtherInfo> {
public interface IdxBizJgOtherInfoMapper extends CustomBaseMapper<IdxBizJgOtherInfo> {
@Select("select SUPERVISORY_CODE from idx_biz_jg_other_info where record = #{equipmentCode}")
String getSupervisoryCodeByEquipmentCode(@Param("equipmentCode") String equipmentCode);
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -15,7 +14,7 @@ import java.util.Map;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgRegisterInfoMapper extends BaseMapper<IdxBizJgRegisterInfo> {
public interface IdxBizJgRegisterInfoMapper extends CustomBaseMapper<IdxBizJgRegisterInfo> {
@Select("select \"USE_ORG_CODE\" from idx_biz_jg_register_info where \"RECORD\" = #{equipCode}")
String getUseOrgCodeByEquip(@Param("equipCode") String equipCode);
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
/**
......@@ -9,6 +9,6 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgSupervisionInfo;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgSupervisionInfoMapper extends BaseMapper<IdxBizJgSupervisionInfo> {
public interface IdxBizJgSupervisionInfoMapper extends CustomBaseMapper<IdxBizJgSupervisionInfo> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsPipeline;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-压力管道 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgTechParamsPipelineMapper extends BaseMapper<IdxBizJgTechParamsPipeline> {
public interface IdxBizJgTechParamsPipelineMapper extends CustomBaseMapper<IdxBizJgTechParamsPipeline> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsVessel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 安全追溯-压力容器 Mapper 接口
......@@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author system_generator
* @date 2023-08-17
*/
public interface IdxBizJgTechParamsVesselMapper extends BaseMapper<IdxBizJgTechParamsVessel> {
public interface IdxBizJgTechParamsVesselMapper extends CustomBaseMapper<IdxBizJgTechParamsVessel> {
}
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.mapper.CustomBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -16,7 +15,7 @@ import java.util.Map;
* @author system_generator
* @date 2023-08-16
*/
public interface IdxBizJgUseInfoMapper extends BaseMapper<IdxBizJgUseInfo> {
public interface IdxBizJgUseInfoMapper extends CustomBaseMapper<IdxBizJgUseInfo> {
void batchUpdateUseInfo(@Param("records") List<String> records, Integer code);
List<IdxBizJgUseInfo> selectXAList();
......
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