Commit 87f17677 authored by tianyiming's avatar tianyiming

一码通使用es

parent a47bd1a0
...@@ -31,4 +31,6 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> { ...@@ -31,4 +31,6 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
Map<String, Object> selectDataById(String id); Map<String, Object> selectDataById(String id);
CategoryOtherInfo queryInitCode(@Param("initCode") @NonNull String initCode); CategoryOtherInfo queryInitCode(@Param("initCode") @NonNull String initCode);
void updateEsStatus(String id);
} }
...@@ -47,7 +47,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> { ...@@ -47,7 +47,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
String getUnitCodeByRecord(String record); String getUnitCodeByRecord(String record);
List<UseUnitCreditCodeCategoryDto> useUnitCreditCodeCategoryCount(); List<UseUnitCreditCodeCategoryDto> useUnitCreditCodeCategoryCount(@Param("unitCodes") List<String> unitCodes, @Param("orgBranchCodes") List<String> orgBranchCodes);
List<EquipExportVo> getEquipExportData(@Param("dto") EquipExportDto dto); List<EquipExportVo> getEquipExportData(@Param("dto") EquipExportDto dto);
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
</select> </select>
<select id="selectDataById" resultType="java.util.Map"> <select id="selectDataById" resultType="java.util.Map">
SELECT SEQUENCE_NBR, SELECT SEQUENCE_NBR,
REC_DATE,
ORG_BRANCH_NAME, ORG_BRANCH_NAME,
ORG_BRANCH_CODE, ORG_BRANCH_CODE,
USE_UNIT_NAME, USE_UNIT_NAME,
...@@ -61,7 +62,7 @@ ...@@ -61,7 +62,7 @@
CODE96333, CODE96333,
EQU_CODE, EQU_CODE,
SUPERVISORY_CODE, SUPERVISORY_CODE,
USE_PLACE , USE_PLACE,
ADDRESS, ADDRESS,
EQU_STATE, EQU_STATE,
STATUS STATUS
...@@ -92,4 +93,10 @@ ...@@ -92,4 +93,10 @@
SET "EDIT_STATUS" = #{editStatus} SET "EDIT_STATUS" = #{editStatus}
WHERE "SUPERVISORY_CODE" = #{supervisorCode} WHERE "SUPERVISORY_CODE" = #{supervisorCode}
</update> </update>
<update id="updateEsStatus">
UPDATE idx_biz_jg_use_info
SET "IS_NOT_ES" = '1'
WHERE "RECORD" = #{id}
</update>
</mapper> </mapper>
...@@ -320,6 +320,18 @@ ...@@ -320,6 +320,18 @@
ibjoi."CLAIM_STATUS" <![CDATA[ <> ]]> '' ibjoi."CLAIM_STATUS" <![CDATA[ <> ]]> ''
and ibjui."USE_UNIT_CREDIT_CODE" <![CDATA[ <> ]]> '' and ibjui."USE_UNIT_CREDIT_CODE" <![CDATA[ <> ]]> ''
and ibjri."EQU_LIST" <![CDATA[ <> ]]> '' and ibjri."EQU_LIST" <![CDATA[ <> ]]> ''
<if test="unitCodes !=null and unitCodes.size>0">
and ibjui.USE_UNIT_CREDIT_CODE in
<foreach collection="unitCodes" separator="," item="unitCode" open="(" close=")">
#{unitCode}
</foreach>
</if>
<if test="orgBranchCodes !=null and orgBranchCodes.size>0">
and ibjsi.ORG_BRANCH_CODE in
<foreach collection="orgBranchCodes" separator="," item="orgBranchCode" open="(" close=")">
#{orgBranchCode}
</foreach>
</if>
GROUP BY ibjui."USE_UNIT_CREDIT_CODE",ibjsi."ORG_BRANCH_CODE", ibjoi."CLAIM_STATUS",ibjri."EQU_LIST" GROUP BY ibjui."USE_UNIT_CREDIT_CODE",ibjsi."ORG_BRANCH_CODE", ibjoi."CLAIM_STATUS",ibjri."EQU_LIST"
</select> </select>
<select id="getEquipExportData" resultType="com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo"> <select id="getEquipExportData" resultType="com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo">
......
...@@ -368,9 +368,9 @@ public class EquipmentCategoryController extends BaseController { ...@@ -368,9 +368,9 @@ public class EquipmentCategoryController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/test") @GetMapping(value = "saveEquipmentCategoryToEs")
@ApiOperation(httpMethod = "GET", value = "test", notes = "test") @ApiOperation(httpMethod = "GET", value = "一码通数据初始化至es", notes = "一码通数据初始化至es")
public ResponseModel<String> test() { public ResponseModel<String> saveEquipmentCategoryToEs() {
equipmentCategoryServiceImpl.saveEs(); equipmentCategoryServiceImpl.saveEs();
return ResponseHelper.buildResponse("success"); return ResponseHelper.buildResponse("success");
} }
......
...@@ -291,7 +291,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -291,7 +291,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? null : codeMap.get("code96333"); elevatorCode = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? null : codeMap.get("code96333");
List<CategoryOtherInfo> categoryOtherInfo = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisorCode)); List<CategoryOtherInfo> categoryOtherInfo = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisorCode));
if (categoryOtherInfo.size() > 0) { if (categoryOtherInfo.size() > 0) {
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode())); supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisoryCodeInfo.getSupervisoryCode()));
} else { } else {
supervisoryCodeInfo.setStatus(equState); supervisoryCodeInfo.setStatus(equState);
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo); supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
...@@ -313,7 +313,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -313,7 +313,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override @Override
public List<LinkedHashMap> creatTree() { public List<LinkedHashMap> creatTree() {
FeignClientResult tree = privilegeFeginService.tree(RequestContext.getToken(),RequestContext.getAppKey(),RequestContext.getProduct()); FeignClientResult tree = privilegeFeginService.tree(RequestContext.getToken(), RequestContext.getAppKey(), RequestContext.getProduct());
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult(); List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
List<LinkedHashMap> treeData = deleteRegulatorTreeData(result); List<LinkedHashMap> treeData = deleteRegulatorTreeData(result);
List<LinkedHashMap> supervisionTree = treeData.stream().filter(e -> code.equals(e.get("orgCode"))).collect(Collectors.toList()); List<LinkedHashMap> supervisionTree = treeData.stream().filter(e -> code.equals(e.get("orgCode"))).collect(Collectors.toList());
...@@ -455,8 +455,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -455,8 +455,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/** /**
* 具体生成监管码和电梯96333识别码逻辑 * 具体生成监管码和电梯96333识别码逻辑
*/ */
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) { public synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333, String supervisionCode) {
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
StringBuilder supervisorCode = new StringBuilder(); StringBuilder supervisorCode = new StringBuilder();
StringBuilder elevatorCode = new StringBuilder(); StringBuilder elevatorCode = new StringBuilder();
...@@ -465,25 +465,25 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -465,25 +465,25 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//判断是否需要生成96333电梯码 //判断是否需要生成96333电梯码
if (equipCategory.startsWith("3") && !XIAN.equals(city)) { if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
//判断数据是否携带96333电梯码,携带则使用,不携带则生成 //判断数据是否携带96333电梯码,携带则使用,不携带则生成
if("null".equals(code96333)){ if ("null".equals(code96333)) {
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county); Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
prefix = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), city).get("code").toString() : elevatorMap.get("code").toString(); prefix = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), city).get("code").toString() : elevatorMap.get("code").toString();
//查询未使用的电梯码 //查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode()); categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
//如果存在未使用的电梯码则启用未使用的否则创建 //如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(prefix) : categoryOtherInfo.getCode(); String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(prefix) : categoryOtherInfo.getCode();
if(!ObjectUtils.isEmpty(categoryOtherInfo)){ if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333",categoryOtherInfo.getCode())); supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
} }
elevatorCode.append(elevator); elevatorCode.append(elevator);
resultMap.put("creatStatus",CREATE); resultMap.put("creatStatus", CREATE);
} else { } else {
elevatorCode.append(code96333); elevatorCode.append(code96333);
resultMap.put("creatStatus",NOT_CREATE); resultMap.put("creatStatus", NOT_CREATE);
} }
} }
//判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成 //判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
if("null".equals(supervisionCode)){ if ("null".equals(supervisionCode)) {
String supervisor = createSupervisorCode(city, county, equipCategory); String supervisor = createSupervisorCode(city, county, equipCategory);
supervisorCode.append(supervisor); supervisorCode.append(supervisor);
} else { } else {
...@@ -502,12 +502,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -502,12 +502,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisoryCodeInfo.setCreateStatus(resultMap.get("creatStatus")); supervisoryCodeInfo.setCreateStatus(resultMap.get("creatStatus"));
supervisoryCodeInfo.setSupervisoryCode(String.valueOf(supervisorCode)); supervisoryCodeInfo.setSupervisoryCode(String.valueOf(supervisorCode));
supervisoryCodeInfo.setStatus(equState); supervisoryCodeInfo.setStatus(equState);
if(ObjectUtils.isEmpty(selectOne)){ if (ObjectUtils.isEmpty(selectOne)) {
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo); supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
} else { } else {
selectOne.setCode96333(String.valueOf(elevatorCode)); selectOne.setCode96333(String.valueOf(elevatorCode));
supervisoryCodeInfoMapper.update(selectOne, supervisoryCodeInfoMapper.update(selectOne,
new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",selectOne.getSupervisoryCode())); new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", selectOne.getSupervisoryCode()));
} }
resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString()); resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString()); resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
...@@ -772,7 +772,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -772,7 +772,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return list; return list;
} }
public List<EquipExportVo> getEquipExportData(EquipExportDto dto){ public List<EquipExportVo> getEquipExportData(EquipExportDto dto) {
ArrayList<EquipExportVo> list = new ArrayList<>(); ArrayList<EquipExportVo> list = new ArrayList<>();
List<JSONObject> objectList = getCompanyType(); List<JSONObject> objectList = getCompanyType();
if (!ValidationUtil.isEmpty(dto.getEQU_STATE())) { if (!ValidationUtil.isEmpty(dto.getEQU_STATE())) {
...@@ -791,7 +791,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -791,7 +791,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
dto.setORG_BRANCH_CODE(orgCode); dto.setORG_BRANCH_CODE(orgCode);
} }
List<EquipExportVo> equipExportData = equipmentCategoryMapper.getEquipExportData(dto); List<EquipExportVo> equipExportData = equipmentCategoryMapper.getEquipExportData(dto);
if (!ObjectUtils.isEmpty(equipExportData) ) { if (!ObjectUtils.isEmpty(equipExportData)) {
list.addAll(equipExportData); list.addAll(equipExportData);
} }
} }
...@@ -844,30 +844,28 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -844,30 +844,28 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override @Override
public void checkEsData(String id) { public void checkEsData(String id) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(id); Map<String, Object> map = categoryOtherInfoMapper.selectDataById(id);
UseInfo useInfo = new UseInfo(); categoryOtherInfoMapper.updateEsStatus(id);
useInfo.setIsNotEs(1);
useInfoMapper.update(useInfo, new QueryWrapper<UseInfo>().eq("RECORD", id));
ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class); ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(id); Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(id);
if (!ObjectUtils.isEmpty(data)) { if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(id); esEquipmentCategory.deleteById(id);
} }
if (!ObjectUtils.isEmpty(dto)) { if (!ObjectUtils.isEmpty(dto)) {
dto.setREC_DATE(System.currentTimeMillis()); long time = Timestamp.valueOf(map.get("REC_DATE").toString().substring(0, 19)).getTime();
dto.setREC_DATE(time);
esEquipmentCategory.save(dto); esEquipmentCategory.save(dto);
} }
} }
@Override @Override
@Async @Async
public void createEquipmentCategoryData() { public void createEquipmentCategoryData() {
if(log.isInfoEnabled()){ if (log.isInfoEnabled()) {
log.info("初始化一码通总览数据开始"); log.info("初始化一码通总览数据开始");
} }
equipmentCategoryDataService.remove(new QueryWrapper<>()); equipmentCategoryDataService.remove(new QueryWrapper<>());
getCategoryData(null,null); getCategoryData(null, null);
} }
private List<EquipmentCategoryData> getCategoryData(List<String> unitCodes, List<String> orgBranchCodes) { private List<EquipmentCategoryData> getCategoryData(List<String> unitCodes, List<String> orgBranchCodes) {
...@@ -875,21 +873,21 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -875,21 +873,21 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
stopWatch.start(); stopWatch.start();
List<EquipmentCategoryData> list = new ArrayList<>(); List<EquipmentCategoryData> list = new ArrayList<>();
// 查询所有单位 // 查询所有单位
List<Map<String, Object>> allUnitList = equipmentCategoryMapper.getAllUnit(unitCodes,orgBranchCodes); List<Map<String, Object>> allUnitList = equipmentCategoryMapper.getAllUnit(unitCodes, orgBranchCodes);
// 统计查询不同单位、不同装备定义、不同状态下的设备数量 // 统计查询不同单位、不同装备定义、不同状态下的设备数量
List<UseUnitCreditCodeCategoryDto> equipCountList = equipmentCategoryMapper.useUnitCreditCodeCategoryCount(); List<UseUnitCreditCodeCategoryDto> equipCountList = equipmentCategoryMapper.useUnitCreditCodeCategoryCount(unitCodes, orgBranchCodes);
// 查询8大类设备定义 // 查询8大类设备定义
List<EquipmentCategory> equipmentCategories = getEquipmentCategories(); List<EquipmentCategory> equipmentCategories = getEquipmentCategories();
// 组织EquipmentCategoryData表数据 // 组织EquipmentCategoryData表数据
for (Map<String, Object> map : allUnitList) { for (Map<String, Object> map : allUnitList) {
EquipmentCategoryData equipmentCategoryData = new EquipmentCategoryData(); EquipmentCategoryData equipmentCategoryData = new EquipmentCategoryData();
if(ObjectUtils.isEmpty(map.get("supervise_org_code")) || ObjectUtils.isEmpty(map.get(USE_CODE))){ if (ObjectUtils.isEmpty(map.get("supervise_org_code")) || ObjectUtils.isEmpty(map.get(USE_CODE))) {
continue; continue;
} }
equipmentCategoryData.setOrgBranchCode(map.get("supervise_org_code").toString()); equipmentCategoryData.setOrgBranchCode(map.get("supervise_org_code").toString());
equipmentCategoryData.setUnitCode(map.get(USE_CODE).toString()); equipmentCategoryData.setUnitCode(map.get(USE_CODE).toString());
// 指定单位的设备统计信息 // 指定单位的设备统计信息
List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r->map.get(USE_CODE).toString().equals(r.getUseUnitCreditCode())).collect(Collectors.toList()); List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r -> map.get(USE_CODE).toString().equals(r.getUseUnitCreditCode())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(unitEquipCountList)) { if (!ObjectUtils.isEmpty(unitEquipCountList)) {
unitEquipCountList = unitEquipCountList.stream().filter(r -> map.get(ORG_BRANCH_CODE).toString().equals(r.getOrgBranchCode())).collect(Collectors.toList()); unitEquipCountList = unitEquipCountList.stream().filter(r -> map.get(ORG_BRANCH_CODE).toString().equals(r.getOrgBranchCode())).collect(Collectors.toList());
for (EquipmentCategory category : equipmentCategories) { for (EquipmentCategory category : equipmentCategories) {
...@@ -903,13 +901,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -903,13 +901,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
list.add(equipmentCategoryData); list.add(equipmentCategoryData);
} }
} }
if(!ObjectUtils.isEmpty(unitCodes)){ if (!ObjectUtils.isEmpty(unitCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code",unitCodes)); equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code", unitCodes));
} }
equipmentCategoryDataService.saveOrUpdateBatch(list); equipmentCategoryDataService.saveOrUpdateBatch(list);
stopWatch.stop(); stopWatch.stop();
if(log.isInfoEnabled()){ if (log.isInfoEnabled()) {
log.info("总览数据刷新结束,耗时:{} 秒",stopWatch.getTotalTimeSeconds()); log.info("总览数据刷新结束,耗时:{} 秒", stopWatch.getTotalTimeSeconds());
} }
return list; return list;
} }
...@@ -948,19 +946,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -948,19 +946,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private List<EquipmentCategory> getEquipmentCategories() { private List<EquipmentCategory> getEquipmentCategories() {
LambdaQueryWrapper<EquipmentCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EquipmentCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode,"000"); lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode, "000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"7000"); lambdaQueryWrapper.ne(EquipmentCategory::getCode, "7000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"F000"); lambdaQueryWrapper.ne(EquipmentCategory::getCode, "F000");
return equipmentCategoryMapper.selectList(lambdaQueryWrapper); return equipmentCategoryMapper.selectList(lambdaQueryWrapper);
} }
private List<EquipmentCategoryData> updateEquipmentCategoryData(String unitCode,String orgBranchCode) { private List<EquipmentCategoryData> updateEquipmentCategoryData(String unitCode, String orgBranchCode) {
List<String> unitCodeList = new ArrayList<>(); List<String> unitCodeList = new ArrayList<>();
unitCodeList.add(unitCode); unitCodeList.add(unitCode);
List<String> orgBranchCodeList = new ArrayList<>(); List<String> orgBranchCodeList = new ArrayList<>();
orgBranchCodeList.add(orgBranchCode); orgBranchCodeList.add(orgBranchCode);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList,null); List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, orgBranchCodeList);
return equipmentCategoryData; return equipmentCategoryData;
} }
...@@ -971,7 +969,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -971,7 +969,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<String> records = new ArrayList<>(); List<String> records = new ArrayList<>();
List<ESEquipmentCategoryDto> list = new ArrayList<>(); List<ESEquipmentCategoryDto> list = new ArrayList<>();
if(recordList.toString().contains("[")){ if (recordList.toString().contains("[")) {
for (String record : (List<String>) recordList) { for (String record : (List<String>) recordList) {
records.add(record); records.add(record);
ESEquipmentCategoryDto esEquipmentCategoryDto = new ESEquipmentCategoryDto(); ESEquipmentCategoryDto esEquipmentCategoryDto = new ESEquipmentCategoryDto();
...@@ -994,15 +992,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -994,15 +992,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
orgBranchCodeList.add(String.valueOf(objectMap.get("orgBranchCode"))); orgBranchCodeList.add(String.valueOf(objectMap.get("orgBranchCode")));
} }
if(!ObjectUtils.isEmpty(superviseCodeList)){ if (!ObjectUtils.isEmpty(superviseCodeList)) {
supervisoryCodeInfoMapper.updateStatus(superviseCodeList); supervisoryCodeInfoMapper.updateStatus(superviseCodeList);
} }
//删除涉及的19张表的数据 //删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(records); superviseInfoMapper.deleteDataAll(records);
// 根据统一信用代码更新总览表 // 根据统一信用代码更新总览表
if(!ObjectUtils.isEmpty(unitCodeList)){ if (!ObjectUtils.isEmpty(unitCodeList)) {
getCategoryData(unitCodeList,orgBranchCodeList); getCategoryData(unitCodeList, orgBranchCodeList);
} }
//删除es中的数据 //删除es中的数据
esEquipmentCategory.deleteAll(list); esEquipmentCategory.deleteAll(list);
...@@ -1065,11 +1063,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1065,11 +1063,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
responseModel = idxFeignService.batchUpdate(null, null, map); responseModel = idxFeignService.batchUpdate(null, null, map);
} }
stopWatch.stop(); stopWatch.stop();
if(log.isInfoEnabled()){ if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒",stopWatch.getTotalTimeSeconds()); log.info("通用提交耗时:{} 秒", stopWatch.getTotalTimeSeconds());
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(), e);
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode()); supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode());
ResponseModel<Object> response = new ResponseModel<>(); ResponseModel<Object> response = new ResponseModel<>();
response.setDevMessage(e.getMessage()); response.setDevMessage(e.getMessage());
...@@ -1080,8 +1078,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1080,8 +1078,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} finally { } finally {
log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE")); log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE"));
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333")); log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
updateEquipmentCategoryData(unitCode,orgBranchCode); if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisionMap.get("SUPERVISORY_CODE"))); log.info("responseModel.getResult().toString()->>>>>>>>>>>>>>",responseModel.getResult().toString());
checkEsData(responseModel.getResult().toString());
}
updateEquipmentCategoryData(unitCode, orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE")));
} }
return responseModel; return responseModel;
} }
...@@ -1113,6 +1115,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1113,6 +1115,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class); Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count; return count;
} }
/** /**
* es数据同步 * es数据同步
* *
...@@ -1136,11 +1139,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1136,11 +1139,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Page<Map<String, Object>> page = getAll(map); Page<Map<String, Object>> page = getAll(map);
total = total + page.getTotal(); total = total + page.getTotal();
saveBatchEquipment2Es(page.getRecords()); saveBatchEquipment2Es(page.getRecords());
// for (Map<String, Object> record : page.getRecords()) {
// if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
// saveESEquipmentCategory(record);
// }
// }
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
log.info("本次一码通同步设备数据:【" + total + "】条,耗时:" + (end - start) + " 毫秒"); log.info("本次一码通同步设备数据:【" + total + "】条,耗时:" + (end - start) + " 毫秒");
...@@ -1184,26 +1182,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1184,26 +1182,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
System.out.println("批量更新1000条业务数据耗时:" + cost1); System.out.println("批量更新1000条业务数据耗时:" + cost1);
} }
/**
* es保存设备数据
*/
public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) {
//处理时间问题
String recDate1 = map.get("REC_DATE").toString().substring(0,19);
long time = Timestamp.valueOf(recDate1).getTime();
map.put("REC_DATE",time);
ESEquipmentCategoryDto dto = JSONObject.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
ESEquipmentCategoryDto save = esEquipmentCategory.save(dto);
if (!ObjectUtils.isEmpty(save)) {
//同步到es后修改
UseInfo useInfo = new UseInfo();
useInfo.setIsNotEs(1);
useInfoMapper.update(useInfo, new QueryWrapper<UseInfo>().eq("RECORD",
map.get("SEQUENCE_NBR").toString()));
}
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) { public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询 //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) { if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
...@@ -1246,12 +1224,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1246,12 +1224,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//SEQUENCE_NBR //SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) { if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("SEQUENCE_NBR", "*"+map.getString("SEQUENCE_NBR")+"*")); meBuilder.must(QueryBuilders.matchPhraseQuery("SEQUENCE_NBR", "*" + map.getString("SEQUENCE_NBR") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) { if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_NAME", "*"+map.getString("ORG_BRANCH_NAME")+"*" )); query.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_NAME", "*" + map.getString("ORG_BRANCH_NAME") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
...@@ -1261,12 +1239,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1261,12 +1239,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) { if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("USE_UNIT_NAME", "*"+map.getString("USE_UNIT_NAME")+"*")); query.must(QueryBuilders.matchPhraseQuery("USE_UNIT_NAME", "*" + map.getString("USE_UNIT_NAME") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("USE_UNIT_CREDIT_CODE", "*"+map.getString("USE_UNIT_CREDIT_CODE")+"*")); meBuilder.must(QueryBuilders.matchPhraseQuery("USE_UNIT_CREDIT_CODE", "*" + map.getString("USE_UNIT_CREDIT_CODE") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
...@@ -1276,23 +1254,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1276,23 +1254,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST", "*"+map.getString("EQU_LIST")+"*")); meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST", "*" + map.getString("EQU_LIST") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_CATEGORY", "*"+map.getString("EQU_CATEGORY")+"*")); meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_CATEGORY", "*" + map.getString("EQU_CATEGORY") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("USE_ORG_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("USE_ORG_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*"+map.getString("USE_ORG_CODE").toLowerCase()+"*")); meBuilder.must(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*" + map.getString("USE_ORG_CODE").toLowerCase() + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) { if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("CODE96333", "*"+map.getString("CODE96333").toLowerCase()+"*")); meBuilder.must(QueryBuilders.wildcardQuery("CODE96333", "*" + map.getString("CODE96333").toLowerCase() + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
...@@ -1303,7 +1281,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1303,7 +1281,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*"+map.getString("SUPERVISORY_CODE").toLowerCase()+"*")); meBuilder.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*" + map.getString("SUPERVISORY_CODE").toLowerCase() + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) { if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) {
...@@ -1316,14 +1294,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1316,14 +1294,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
query.must(QueryBuilders.matchPhraseQuery("ADDRESS", "*" + map.getString("ADDRESS") + "*")); query.must(QueryBuilders.matchPhraseQuery("ADDRESS", "*" + map.getString("ADDRESS") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE")) ) { if (!ObjectUtils.isEmpty(map.getString("EQU_STATE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_STATE", map.getLong("EQU_STATE"))); meBuilder.must(QueryBuilders.matchQuery("EQU_STATE", map.getLong("EQU_STATE")));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("STATUS"))) { if (!ObjectUtils.isEmpty(map.getString("STATUS"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*"+map.getString("STATUS")+"*")); meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*" + map.getString("STATUS") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
builder.query(boolMust); builder.query(boolMust);
......
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