Commit 10dfc1ca authored by hcing's avatar hcing

feat(ymt):批量更新电梯的96333码

parent f8e8400f
...@@ -27,5 +27,5 @@ public interface RiskReportMapper extends BaseMapper<RiskReport> { ...@@ -27,5 +27,5 @@ public interface RiskReportMapper extends BaseMapper<RiskReport> {
Map<String, String> getCompanyBySeq(@Param("companySeq") String companySeq); Map<String, String> getCompanyBySeq(@Param("companySeq") String companySeq);
@Select("select all_risk_disposal_unit_org_code from tzs_risk_report where sequence_nbr = #{sequenceNbr}") @Select("select all_risk_disposal_unit_org_code from tzs_risk_report where sequence_nbr = #{sequenceNbr}")
String getRiskDisposalUnitOrgCode(Long sequenceNbr); String getAllRiskDisposalUnitOrgCode(Long sequenceNbr);
} }
...@@ -218,7 +218,7 @@ public class RiskReportServiceImpl extends BaseService<RiskReport, RiskReport, R ...@@ -218,7 +218,7 @@ public class RiskReportServiceImpl extends BaseService<RiskReport, RiskReport, R
private String buildAllRiskDisposalUnitOrgCode(String defaultOrgCode, Long sequenceNbr) { private String buildAllRiskDisposalUnitOrgCode(String defaultOrgCode, Long sequenceNbr) {
if (!ObjectUtils.isEmpty(sequenceNbr)) { if (!ObjectUtils.isEmpty(sequenceNbr)) {
String allRiskDisposalUnitOrgCode = riskReportMapper.getRiskDisposalUnitOrgCode(sequenceNbr); String allRiskDisposalUnitOrgCode = riskReportMapper.getAllRiskDisposalUnitOrgCode(sequenceNbr);
if (!ObjectUtils.isEmpty(allRiskDisposalUnitOrgCode)) { if (!ObjectUtils.isEmpty(allRiskDisposalUnitOrgCode)) {
return String.join(",", Stream.concat( return String.join(",", Stream.concat(
Arrays.stream(allRiskDisposalUnitOrgCode.split(",")), Arrays.stream(allRiskDisposalUnitOrgCode.split(",")),
......
...@@ -14,38 +14,41 @@ public enum EquipmentCategoryEnum { ...@@ -14,38 +14,41 @@ public enum EquipmentCategoryEnum {
* *行政区划分及对应初始监管码 * *行政区划分及对应初始监管码
*/ */
XZQHDT("行政区划电梯", "XZQHDT", "行政区划电梯"), XZQHDT("行政区划电梯", "XZQHDT", "行政区划电梯", null),
XZQH("行政区划", "XZQH", "行政区划"), XZQH("行政区划", "XZQH", "行政区划", null),
BLW("补零位", "0", "补零位"), BLW("补零位", "0", "补零位", null),
JGM("监管码初始码", "0000001", "监管码初始码"), JGM("监管码初始码", "0000001", "监管码初始码", null),
XXCSM("西咸96333初始码", "85000", "31"), XXCSM("西咸96333初始码", "85000", "31", "610100"),
BJCSM("宝鸡96333初始码", "13000", "32"), BJCSM("宝鸡96333初始码", "13000", "32", "610300"),
XYCSM("咸阳96333初始码", "75000", "33"), XYCSM("咸阳96333初始码", "75000", "33", "610400"),
TCCSM("铜川96333初始码", "05000", "34"), TCCSM("铜川96333初始码", "05000", "34", "610200"),
WNCSM("渭南96333初始码", "13000", "35"), WNCSM("渭南96333初始码", "13000", "35", "610500"),
YACSM("延安96333初始码", "11000", "36"), YACSM("延安96333初始码", "11000", "36", "610600"),
YUCSM("榆林96333初始码", "10000", "37"), YUCSM("榆林96333初始码", "10000", "37", "610800"),
HZCSM("汉中96333初始码", "09000", "38"), HZCSM("汉中96333初始码", "09000", "38", "610700"),
AKCSM("安康96333初始码", "11000", "39"), AKCSM("安康96333初始码", "11000", "39", "610900"),
SLCSM("商洛96333初始码", "06000", "40"), SLCSM("商洛96333初始码", "06000", "40", "611000"),
YLCSM("杨凌96333初始码", "70000", "41"), YLCSM("杨陵96333初始码", "70000", "41", "610403"),
HCCSM("韩城96333初始码", "08000", "42"), HCCSM("韩城96333初始码", "08000", "42", "610581"),
SMCSM("神木96333初始码", "06000", "43"), SMCSM("神木96333初始码", "06000", "43", "610881"),
FGCSM("府谷96333初始码", "02000", "44"), FGCSM("府谷96333初始码", "02000", "44", "610822"),
YJL("已拒领", "6037", "已拒领"), YJL("已拒领", "6037", "已拒领", null),
YRL("已认领", "6035", "已认领"), YRL("已认领", "6035", "已认领", null),
DRL("待认领", "6036", "待认领"), DRL("待认领", "6036", "待认领", null),
CSZT("初始状态", "0", "初始状态"), CSZT("初始状态", "0", "初始状态", null),
YSY("已使用", "1", "已使用"), YSY("已使用", "1", "已使用", null),
WSY("未使用", "2", "未使用"), WSY("未使用", "2", "未使用", null),
BF("报废", "6", "报废"); BF("报废", "6", "报废", null);
private String name; private String name;
private String code; private String code;
private String value; private String value;
private String cityCode;
public static Map<String, String> getName = new HashMap<>(); public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>(); public static Map<String, String> getCode = new HashMap<>();
public static Map<String, String> getValue = new HashMap<>(); public static Map<String, String> getValue = new HashMap<>();
public static Map<String, String> getCityCode = new HashMap<>();
public static final Map<String, String> getCodeValueMap = new HashMap<>();
private static final Map<String, String> valueToCodeMap = new HashMap<>(); private static final Map<String, String> valueToCodeMap = new HashMap<>();
static { static {
...@@ -53,7 +56,11 @@ public enum EquipmentCategoryEnum { ...@@ -53,7 +56,11 @@ public enum EquipmentCategoryEnum {
getName.put(e.code, e.name); getName.put(e.code, e.name);
getCode.put(e.value, e.code); getCode.put(e.value, e.code);
getValue.put(e.value, e.code); getValue.put(e.value, e.code);
valueToCodeMap.put("96333_"+ e.value, e.getValue() + e.getCode()); if (e.cityCode != null) {
getCityCode.put(e.cityCode, e.code);
}
getCodeValueMap.put(e.code, e.value);
valueToCodeMap.put("96333_" + e.value, e.getValue() + e.getCode());
} }
} }
...@@ -61,4 +68,9 @@ public enum EquipmentCategoryEnum { ...@@ -61,4 +68,9 @@ public enum EquipmentCategoryEnum {
public static String getCodeByValue(String value) { public static String getCodeByValue(String value) {
return valueToCodeMap.get(value); return valueToCodeMap.get(value);
} }
// 根据code获取对应的value
public static String getValueByCode(String code) {
return getCodeValueMap.get(code);
}
} }
...@@ -6,8 +6,9 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary; ...@@ -6,8 +6,9 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.entity.SupervisoryCodeInfo;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -109,5 +110,29 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> { ...@@ -109,5 +110,29 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
@Select("SELECT * FROM tz_equipment_category WHERE parent_id = #{parentId}") @Select("SELECT * FROM tz_equipment_category WHERE parent_id = #{parentId}")
List<EquipmentCategoryDto> getEquDefineByParentId(String parentId); List<EquipmentCategoryDto> getEquDefineByParentId(String parentId);
@Select("SELECT\n" +
"\tri.record,\n" +
"\tri.EQU_LIST equList,\n" +
"\tui.\"CITY\" city,\n" +
"\tui.\"COUNTY\" county,\n" +
"\tui.\"IS_NOT_XIXIAN\" isNotXixian,\n" +
"\toi.code96333,\n" +
"\toi.SUPERVISORY_CODE supervisoryCode \n" +
"FROM\n" +
"\tidx_biz_jg_register_info ri\n" +
"\tLEFT JOIN idx_biz_jg_use_info ui ON ui.record = ri.record\n" +
"\tLEFT JOIN idx_biz_jg_other_info oi ON oi.record = ri.record \n" +
"WHERE\n" +
"\tri.equ_list = '3000' \n" +
"\tAND ui.IS_INTO_MANAGEMENT = 1 \n" +
"\tAND oi.SUPERVISORY_CODE IS NOT NULL \n" +
"\tAND ( oi.code96333 IS NULL OR oi.code96333 = '' ) \n" +
"\tAND ( ui.city != '610100' OR ui.\"IS_NOT_XIXIAN\" = 1 )\n" +
"\tand oi.SUPERVISORY_CODE in ('A3100-0002769')\n")
List<Map<String, String>> selectExceptionCode96333();
@Select("select * from biz_jg_supervisory_code where supervisory_code = #{supervisoryCode} ORDER BY supervisory_code")
SupervisoryCodeInfo searchSupervisoryBySupervisoryCode(@Param("supervisoryCode") String supervisoryCode);
} }
package com.yeejoin.amos.boot.module.ymt.api.service; package com.yeejoin.amos.boot.module.ymt.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -49,4 +50,6 @@ public interface IEquipmentCategoryService { ...@@ -49,4 +50,6 @@ public interface IEquipmentCategoryService {
String selectExceedElevatorCode(String prefix); String selectExceedElevatorCode(String prefix);
String handleErrorElevatorCode(String supervisorCode, String elevatorCode); String handleErrorElevatorCode(String supervisorCode, String elevatorCode);
JSONObject batchHandlerCode96333();
} }
...@@ -680,4 +680,26 @@ public class EquipmentCategoryController extends BaseController { ...@@ -680,4 +680,26 @@ public class EquipmentCategoryController extends BaseController {
@RequestParam("elevatorCode") String elevatorCode) { @RequestParam("elevatorCode") String elevatorCode) {
return ResponseHelper.buildResponse(equipmentCategoryService.handleErrorElevatorCode(supervisorCode, elevatorCode)); return ResponseHelper.buildResponse(equipmentCategoryService.handleErrorElevatorCode(supervisorCode, elevatorCode));
} }
/**
* 批量更新电梯的96333码
* 1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库
* 2,码表没有直接生成后写入
*
* @return 程序处理的数据 + 异常的需要手动处理的数据集合
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT",
value = "批量更新电梯的96333码," +
"1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库," +
"2,码表没有直接生成后写入," +
"返回值:异常的需要手动处理的数据集合",
notes = "批量更新电梯的96333码," +
"1,先于【码表 biz_jg_supervisory_code】中进行匹配," +
"有的话使用码表的写入other_info数据库,2,码表没有直接生成后写入," +
"返回值:异常的需要手动处理的数据集合")
@PutMapping(value = "/batchHandlerCode96333")
public ResponseModel<JSONObject> batchHandlerCode96333() {
return ResponseHelper.buildResponse(equipmentCategoryService.batchHandlerCode96333());
}
} }
...@@ -11,7 +11,9 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams; ...@@ -11,7 +11,9 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
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.common.api.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentMessageDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentMessageDto;
...@@ -78,6 +80,7 @@ import java.time.format.DateTimeFormatter; ...@@ -78,6 +80,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
...@@ -114,6 +117,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -114,6 +117,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String XIAN = "610100"; private static final String XIAN = "610100";
// 咸阳行政区划code // 咸阳行政区划code
private static final String XIAN_YANG = "610400"; private static final String XIAN_YANG = "610400";
// 杨陵行政区划code
private static final String YANG_LING = "610403";
// 韩城行政区划code
private static final String HAN_CHENG = "610581";
// 神木行政区划code
private static final String SHEN_MU = "610881";
// 府谷行政区划code
private static final String FU_GU = "610822";
// 判断行政区划查询市还是区 // 判断行政区划查询市还是区
private static final String END_CODE = "0000"; private static final String END_CODE = "0000";
// 判断行政区划查询街道 // 判断行政区划查询街道
...@@ -189,7 +200,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -189,7 +200,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired @Autowired
EquipmentCategoryDataMapper equipmentCategoryDataMapper; EquipmentCategoryDataMapper equipmentCategoryDataMapper;
@Autowired @Autowired
EquipmentCategoryDataServiceImpl equipmentCategoryDataService; EsEquipmentDao esEquipmentDao;
@Autowired @Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService; IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired @Autowired
...@@ -913,16 +924,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -913,16 +924,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode.append(prefix).append(firstAvailableCode); elevatorCode.append(prefix).append(firstAvailableCode);
} else { } else {
//// 获取补零位长度 //// 获取补零位长度
//String elevatorCode1 = elevatorOtherInfo.getCode().substring(2); // String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
//long num = Long.parseLong(elevatorCode1) + 1; // long num = Long.parseLong(elevatorCode1) + 1;
//int numLength = String.valueOf(num).length(); // int numLength = String.valueOf(num).length();
//int a = 5 - numLength; // int a = 5 - numLength;
//StringBuilder zero = new StringBuilder(); // StringBuilder zero = new StringBuilder();
//for (int i = 0; i < a; i++) { // for (int i = 0; i < a; i++) {
// zero.append(EquipmentCategoryEnum.BLW.getCode()); // zero.append(EquipmentCategoryEnum.BLW.getCode());
//} //}
//zero.append(num); // zero.append(num);
//elevatorCode.append(zero); // elevatorCode.append(zero);
String newCode; String newCode;
Integer repeatCheck; Integer repeatCheck;
do { do {
...@@ -1028,13 +1039,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1028,13 +1039,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
result.put(equipmentMessage.getDesInfo(), desInfo); result.put(equipmentMessage.getDesInfo(), desInfo);
// 监督管理信息 // 监督管理信息
Map<String, Object> supInfo = getSupInfo(map); Map<String, Object> supInfo = getSupInfo(map);
if(!ValidationUtil.isEmpty(supInfo.get("produceDate"))){ if (!ValidationUtil.isEmpty(supInfo.get("produceDate"))) {
LocalDate produceDate = LocalDate.parse(supInfo.get("produceDate").toString().substring(0, 10), DateTimeFormatter.ofPattern("yyyy-MM-dd")); LocalDate produceDate = LocalDate.parse(supInfo.get("produceDate").toString().substring(0, 10), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate localDate = LocalDate.now().minusYears(15); LocalDate localDate = LocalDate.now().minusYears(15);
if(produceDate.isBefore(localDate)){ if (produceDate.isBefore(localDate)) {
supInfo.put("OVER_FIFTEEN_YEARS","0"); supInfo.put("OVER_FIFTEEN_YEARS", "0");
}else{ } else {
supInfo.put("OVER_FIFTEEN_YEARS","1"); supInfo.put("OVER_FIFTEEN_YEARS", "1");
} }
} }
if ("1".equals(useInfo.get("IS_NOT_XIXIAN"))) { if ("1".equals(useInfo.get("IS_NOT_XIXIAN"))) {
...@@ -1063,7 +1074,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1063,7 +1074,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
result.get(EquipmentTypeEnum.DT.getSupInfo()).remove("SUPERVISORY_CODE"); result.get(EquipmentTypeEnum.DT.getSupInfo()).remove("SUPERVISORY_CODE");
} }
Map<String,Object> resultMapNew = new HashMap<>(); Map<String, Object> resultMapNew = new HashMap<>();
result.forEach((key, value) -> { result.forEach((key, value) -> {
resultMapNew.putAll(value); resultMapNew.putAll(value);
}); });
...@@ -2613,7 +2624,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2613,7 +2624,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
// } // }
// return resultMap; // return resultMap;
// } // }
@Override @Override
public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) { public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
if (paramMap.isEmpty()) { if (paramMap.isEmpty()) {
return null; return null;
...@@ -2668,4 +2679,143 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2668,4 +2679,143 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return resultMap; return resultMap;
} }
/**
* 批量更新电梯的96333码
* 1,先于【码表 biz_jg_supervisory_code】中进行匹配,有的话使用码表的写入other_info数据库
* 2,码表没有直接生成后写入
*
* @return 异常的需要手动处理的数据集合
*/
@Override
public JSONObject batchHandlerCode96333() {
log.info("开始处理96333的异常数据。。。");
// 程序无法处理的,需要手动处理的数据,需要返回
AtomicReference<Integer> handlerDataNums = new AtomicReference<>(0);
StringBuilder handlerData = new StringBuilder();
List<JSONObject> manualProcessData = new ArrayList<>();
List<Map<String, String>> exceptionData = equipmentCategoryMapper.selectExceptionCode96333();
exceptionData.forEach(data -> {
JSONObject jsonObj = JSONObject.parseObject(toJSONString(data));
String city = jsonObj.getString("city");
String county = jsonObj.getString("county");
String isNotXixian = jsonObj.getString("isNotXixian");
if (StringUtils.isEmpty(city) || "null".equals(city)) {
manualProcessData.add(jsonObj);
return;
}
// 监管码
String supervisoryCode = jsonObj.getString("supervisoryCode");
// record
String record = jsonObj.getString("record");
String code96333 = "";
String createStatus = "";
// 1. 先查码表,有则使用码表中的code96333更新
SupervisoryCodeInfo supervisoryCodeInfo = equipmentCategoryMapper.searchSupervisoryBySupervisoryCode(supervisoryCode);
if (supervisoryCodeInfo != null && !ObjectUtils.isEmpty(supervisoryCodeInfo.getCode96333())) {
code96333 = supervisoryCodeInfo.getCode96333();
createStatus = NOT_CREATE;
} else {
// 2. 生成code96333
String prefix = "";
try {
prefix = this.cityCodeTo96333CodePrefix(city, county, isNotXixian);
} catch (Exception exception) {
log.error("cityCode转化地区初始码失败:{}", city);
log.error(exception.getMessage());
return;
}
code96333 = this.createElevatorCode(prefix);
createStatus = CREATE;
}
log.info("正在处理数据:{},96333码为:{},是否为新生成的96333:{}", record, code96333, "1".equals(createStatus) ? "是" : "否");
handlerDataNums.getAndSet(handlerDataNums.get() + 1);
handlerData.append(supervisoryCode).append(",");
// 更新数据库other_info 更新/新增码表
this.saveCode96333ForDataBase(supervisoryCode, createStatus, code96333, supervisoryCodeInfo);
// 更新es,索引:idx_biz_view_jg_all,idx_biz_equipment_info
this.saveCode96333ForEs(record, code96333);
});
return new JSONObject()
.fluentPut("总共异常数据:", exceptionData.size() + "条")
.fluentPut("程序处理数据条数:", handlerDataNums + "条")
.fluentPut("程序处理数据:", handlerData)
.fluentPut("异常数据,需手动处理:", JSONObject.toJSONString(manualProcessData));
}
private void saveCode96333ForEs(String record, String code96333) {
// idx_biz_view_jg_all
Optional<ESEquipmentCategoryDto> esEquipmentCategoryDto = esEquipmentCategory.findById(record);
esEquipmentCategoryDto.ifPresent(data -> {
data.setCODE96333(code96333);
esEquipmentCategory.save(data);
});
// idx_biz_equipment_info
Optional<ESEquipmentInfo> equipmentDaoById = esEquipmentDao.findById(record);
equipmentDaoById.ifPresent(data -> {
data.setCODE96333(code96333);
esEquipmentDao.save(data);
});
}
private void saveCode96333ForDataBase(String supervisoryCode, String createStatus, String code96333, SupervisoryCodeInfo supervisoryCodeInfo) {
if (supervisoryCodeInfo != null && !ObjectUtils.isEmpty(supervisoryCodeInfo.getSequenceNbr())) {
// 更新码表
supervisoryCodeInfoMapper.update(new SupervisoryCodeInfo().setCode96333(code96333),
new LambdaQueryWrapper<SupervisoryCodeInfo>()
.eq(SupervisoryCodeInfo::getSupervisoryCode, supervisoryCode));
} else {
// 新增码表
supervisoryCodeInfoMapper.insert(new SupervisoryCodeInfo()
.setCode96333(code96333)
.setSupervisoryCode(supervisoryCode)
.setStatus(EquipmentCategoryEnum.YSY.getCode())
.setCreateStatus(createStatus)
);
}
// otherInfo 表
IdxBizJgOtherInfo otherInfo = idxBizJgOtherInfoMapper.selectOne(
new LambdaQueryWrapper<IdxBizJgOtherInfo>()
.eq(IdxBizJgOtherInfo::getSupervisoryCode, supervisoryCode)
);
if (otherInfo != null) {
otherInfo.setCode96333(code96333);
idxBizJgOtherInfoService.update(otherInfo,
new LambdaQueryWrapper<IdxBizJgOtherInfo>().eq(IdxBizJgOtherInfo::getSupervisoryCode, supervisoryCode)
);
}
}
// 对应关系转化
// city --> EquipmentCategoryEnum.code --> EquipmentCategoryEnum.value
private String cityCodeTo96333CodePrefix(String city, String county, String isNotXixian) {
String code = EquipmentCategoryEnum.getCityCode.get(city);
if (StringUtils.isEmpty(code)) {
throw new RuntimeException("未匹配到对应的cityCode:" + city);
}
// 西咸
if (XIAN.equals(city) && "0".equals(isNotXixian)) {
return EquipmentCategoryEnum.XXCSM.getValue();
}
// 杨陵
if (YANG_LING.equals(county)) {
return EquipmentCategoryEnum.YLCSM.getValue();
}
// 韩城
if (HAN_CHENG.equals(county)) {
return EquipmentCategoryEnum.HCCSM.getValue();
}
// 神木
if (SHEN_MU.equals(county)) {
return EquipmentCategoryEnum.SMCSM.getValue();
}
// 府谷
if (FU_GU.equals(county)) {
return EquipmentCategoryEnum.FGCSM.getValue();
}
return EquipmentCategoryEnum.getValueByCode(code);
}
} }
\ 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