Commit b870d9da authored by 刘林's avatar 刘林

fix(jg):西安数据导入接口修改

parent 86872532
...@@ -987,4 +987,8 @@ public class XiAnEquipInfoExcelDto extends BaseDto { ...@@ -987,4 +987,8 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ExcelProperty(value = "序号") @ExcelProperty(value = "序号")
private String xaSerial; private String xaSerial;
@ApiModelProperty(value = "资料是否齐全(0齐全, 1不齐全)-西安数据导入")
@ExcelIgnore
private Integer isCompleteXa;
} }
\ No newline at end of file
...@@ -27,6 +27,7 @@ import java.util.*; ...@@ -27,6 +27,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Stream;
@Slf4j @Slf4j
@Service @Service
...@@ -205,7 +206,7 @@ public class XiAnDataDockServiceImpl { ...@@ -205,7 +206,7 @@ public class XiAnDataDockServiceImpl {
// 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息 // 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息
this.commonFieldCheck(data, rowError); this.commonFieldCheck(data, rowError);
data.setIsCompleteXa(this.checkIsComplete(data) ? 0 : 1);
// 起重机械----技术参数 检查 // 起重机械----技术参数 检查
if (isQZJX) { if (isQZJX) {
this.QZJXTechnicalParamsCheck(data, rowError); this.QZJXTechnicalParamsCheck(data, rowError);
...@@ -259,6 +260,20 @@ public class XiAnDataDockServiceImpl { ...@@ -259,6 +260,20 @@ public class XiAnDataDockServiceImpl {
} }
/** /**
* 检查资料是否齐全,16个导入必填项
*
* @param data 导入项
*/
private boolean checkIsComplete(XiAnEquipInfoExcelDto data) {
return Stream.of(data.getEquList(), data.getEquCategory(), data.getUseInnerCode(),
data.getProductName(), data.getEquType(), data.getUseUnitCode(),
data.getUseUnit(), data.getDesignUnitCreditCode(), data.getDesignUnitName(),
data.getDesignUseDate(), data.getDesignDate(), data.getProduceUnitCreditCode(),
data.getProduceUnitName(), data.getProduceLicenseNum(), data.getFactoryNum(),
data.getProduceDate()).noneMatch(StringUtils::isBlank);
}
/**
* 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息 * 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息
* *
* @param data 源数据 * @param data 源数据
......
...@@ -173,10 +173,15 @@ public class ESEquipmentCategoryDto { ...@@ -173,10 +173,15 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String INFORMATION_SITUATION; private String INFORMATION_SITUATION;
/** /**
* 工程装置id(工业管道使用) * 工程装置id(工业管道使用)
*/ */
@Field(type = FieldType.Keyword, name = "PROJECT_CONTRAPTION_ID") @Field(type = FieldType.Keyword, name = "PROJECT_CONTRAPTION_ID")
private String projectContraptionId; private String projectContraptionId;
/**
* 资料是否齐全(0齐全, 1不齐全)-西安数据导入
*/
@Field(type = FieldType.Keyword, name = "IS_COMPLETE_XA")
private String IS_COMPLETE_XA;
} }
...@@ -60,6 +60,7 @@ import java.util.*; ...@@ -60,6 +60,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
@Slf4j @Slf4j
...@@ -120,7 +121,7 @@ public class DataDockServiceImpl { ...@@ -120,7 +121,7 @@ public class DataDockServiceImpl {
String product = RequestContext.getProduct(); String product = RequestContext.getProduct();
String token = RequestContext.getToken(); String token = RequestContext.getToken();
CompletableFuture.allOf( CompletableFuture.allOf(
equLists.stream().map(equ -> CompletableFuture.runAsync(() -> { equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(product); RequestContext.setProduct(product);
RequestContext.setToken(token); RequestContext.setToken(token);
...@@ -135,6 +136,7 @@ public class DataDockServiceImpl { ...@@ -135,6 +136,7 @@ public class DataDockServiceImpl {
// transactionTemplate.execute(status -> { // transactionTemplate.execute(status -> {
String record = UUID.randomUUID().toString(); String record = UUID.randomUUID().toString();
String equList = String.valueOf(equ.get("equList")); String equList = String.valueOf(equ.get("equList"));
String isCompleteXa = String.valueOf(equ.get("isCompleteXa"));
// 压力管道保存 工程装置表信息 必须在saveUseInfo之前进行,需要提前生成工程装置id // 压力管道保存 工程装置表信息 必须在saveUseInfo之前进行,需要提前生成工程装置id
saveProjectContraption(equ, equList); saveProjectContraption(equ, equList);
// 保存到设备表 // 保存到设备表
...@@ -147,7 +149,7 @@ public class DataDockServiceImpl { ...@@ -147,7 +149,7 @@ public class DataDockServiceImpl {
// 保存技术参数 // 保存技术参数
saveTechParams(equ, record, equList); saveTechParams(equ, record, equList);
// 保存到ES // 保存到ES
saveEquInfoToEs(record); saveEquInfoToEs(record, isCompleteXa);
// return null; // return null;
// }); // });
} catch (Exception e) { } catch (Exception e) {
...@@ -164,7 +166,7 @@ public class DataDockServiceImpl { ...@@ -164,7 +166,7 @@ public class DataDockServiceImpl {
idxBizJgSupervisionInfoService.lambdaUpdate().set(IdxBizJgSupervisionInfo::getOrgBranchCode, "50*74*160*12478").set(IdxBizJgSupervisionInfo::getOrgBranchName, "交口河镇市场监管所").in(IdxBizJgSupervisionInfo::getRecord, records).update(); idxBizJgSupervisionInfoService.lambdaUpdate().set(IdxBizJgSupervisionInfo::getOrgBranchCode, "50*74*160*12478").set(IdxBizJgSupervisionInfo::getOrgBranchName, "交口河镇市场监管所").in(IdxBizJgSupervisionInfo::getRecord, records).update();
records.forEach(record -> { records.forEach(record -> {
esEquipmentCategory.deleteById(record); esEquipmentCategory.deleteById(record);
this.saveEquInfoToEs(record); this.saveEquInfoToEs(record,"1");
}); });
return records.size(); return records.size();
} }
...@@ -350,15 +352,21 @@ public class DataDockServiceImpl { ...@@ -350,15 +352,21 @@ public class DataDockServiceImpl {
supervisionInfo.setRecDate(new Date()); supervisionInfo.setRecDate(new Date());
// 获取符合条件的公司 Map // 获取符合条件的公司 Map
Map<String, String> countyMap; Map<String, Map<String, String>> countyMap;
try { try {
countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult()) countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult())
.orElse(Collections.emptyList()) .orElse(Collections.emptyList())
.stream() .stream()
.filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId()))) .filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId())))
.collect(Collectors.toMap(CompanyModel::getCompanyCode, CompanyModel::getCompanyName, (a, b) -> a)); .collect(Collectors.toMap(
CompanyModel::getCompanyCode,
v -> Stream.of(new AbstractMap.SimpleEntry<>("companyName", v.getCompanyName()),
new AbstractMap.SimpleEntry<>("orgCode", v.getOrgCode()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(a, b) -> a
));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); countyMap = Collections.emptyMap();
} }
String companyCode = "1".equals(equ.get("equCodeType")) String companyCode = "1".equals(equ.get("equCodeType"))
? String.valueOf(equ.get("equCode")) ? String.valueOf(equ.get("equCode"))
...@@ -368,11 +376,14 @@ public class DataDockServiceImpl { ...@@ -368,11 +376,14 @@ public class DataDockServiceImpl {
if (companyCode.length() > 9) { if (companyCode.length() > 9) {
companyCode = companyCode.substring(4, 10); companyCode = companyCode.substring(4, 10);
} }
// 直接获取公司名称 Map<String, String> companyInfo = countyMap.get(companyCode);
String companyName = countyMap.get(companyCode); if (companyInfo != null) {
String companyName = companyInfo.get("companyName");
String orgCode = companyInfo.get("orgCode");
if (companyName != null && !companyName.trim().isEmpty()) { if (companyName != null && !companyName.trim().isEmpty()) {
supervisionInfo.setOrgBranchCode(companyCode); supervisionInfo.setOrgBranchCode(orgCode);
supervisionInfo.setOrgBranchName(companyName); supervisionInfo.setOrgBranchName(companyName);
}
} else { } else {
// 通过 useUnitCode 查询属地监管部门 // 通过 useUnitCode 查询属地监管部门
String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim(); String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim();
...@@ -586,12 +597,13 @@ public class DataDockServiceImpl { ...@@ -586,12 +597,13 @@ public class DataDockServiceImpl {
* *
* @param record 设备唯一编码 * @param record 设备唯一编码
*/ */
private void saveEquInfoToEs(String record) { private void saveEquInfoToEs(String record, String isCompleteXa) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record); Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record);
ESEquipmentCategoryDto equipmentCategoryDto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class); ESEquipmentCategoryDto equipmentCategoryDto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
if (!ObjectUtils.isEmpty(equipmentCategoryDto)) { if (!ObjectUtils.isEmpty(equipmentCategoryDto)) {
long time = Timestamp.valueOf(map.get("REC_DATE").toString().substring(0, 19)).getTime(); long time = Timestamp.valueOf(map.get("REC_DATE").toString().substring(0, 19)).getTime();
equipmentCategoryDto.setREC_DATE(time); equipmentCategoryDto.setREC_DATE(time);
equipmentCategoryDto.setIS_COMPLETE_XA(isCompleteXa);
esEquipmentCategory.save(equipmentCategoryDto); esEquipmentCategory.save(equipmentCategoryDto);
} }
} }
......
...@@ -233,4 +233,10 @@ public class IdxBizJgRegisterInfo extends TzsBaseEntity { ...@@ -233,4 +233,10 @@ public class IdxBizJgRegisterInfo extends TzsBaseEntity {
*/ */
@TableField("\"XA_SERIAL\"") @TableField("\"XA_SERIAL\"")
private String xaSerial; private String xaSerial;
/**
* 资料是否齐全(0齐全, 1不齐全)-西安数据导入
*/
@TableField("\"IS_COMPLETE_XA\"")
private String isCompleteXa;
} }
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