Commit feb43acc authored by tianyiming's avatar tianyiming

1、一码通总览bug修改

2、一码通行政区划查询重构 3、一码通生成重复码修改
parent f261347d
...@@ -41,6 +41,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder; ...@@ -41,6 +41,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -48,6 +49,7 @@ import org.springframework.http.HttpStatus; ...@@ -48,6 +49,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -129,10 +131,18 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -129,10 +131,18 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String PROVINCE = "PROVINCE"; private static final String PROVINCE = "PROVINCE";
private static final String CITY = "CITY"; private static final String CITY = "CITY";
private static final String REGION = "REGION"; private static final String REGION = "REGION";
private static final String STREET = "STREET";
//行政区划level
private static final String PROVINCE_LEVEL = "1";
private static final String CITY_LEVEL = "2";
private static final String REGION_LEVEL = "3";
private static final String STREET_LEVEL = "4";
//西安行政区划code //西安行政区划code
private static final String XIAN = "610100"; private static final String XIAN = "610100";
//判断行政区划查询市还是区 //判断行政区划查询市还是区
private static final String END_CODE = "0000"; private static final String END_CODE = "0000";
//判断行政区划查询街道
private static final String STREET_END_CODE = "00";
//一码通监督管理表单id //一码通监督管理表单id
private static final String SUPERVISION_FROM_ID = "1627903532906602497"; private static final String SUPERVISION_FROM_ID = "1627903532906602497";
...@@ -262,10 +272,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -262,10 +272,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
} }
//生成码 //生成码
Map<String, String> codeMap; EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
synchronized (EquipmentCategoryServiceImpl.class) { Map<String, String> codeMap = categoryService.creatCode(city, county, equipCategory, null, null);
codeMap = creatCode(city, county, equipCategory, null,null);
}
if (ObjectUtils.isEmpty(codeMap)) { if (ObjectUtils.isEmpty(codeMap)) {
return new HashMap<>(); return new HashMap<>();
} }
...@@ -283,7 +291,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -283,7 +291,6 @@ 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) {
// categoryOtherInfoMapper.updateCode(supervisorCode, equState);
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);
...@@ -365,57 +372,49 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -365,57 +372,49 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override @Override
public List<LinkedHashMap> getRegion(String level, String parentId) { public List<LinkedHashMap> getRegion(String level, String parentId) {
List<LinkedHashMap> list; List<LinkedHashMap> list = new ArrayList<>();
if (!ObjectUtils.isEmpty(level)) { if (!ObjectUtils.isEmpty(level)) {
list = (List<LinkedHashMap>) redisUtils.get(PROVINCE); list = (List<LinkedHashMap>) redisUtils.get(PROVINCE);
return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list; return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list;
} else if (!ObjectUtils.isEmpty(parentId)) { } else if (!ObjectUtils.isEmpty(parentId)) {
String regionCode = parentId.split("_")[0]; String regionCode = parentId.split("_")[0];
//regionCode以0000结果查询市、否则查询区 //regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
Map<String, Object> map = regionCode.endsWith(END_CODE) ? (Map<String, Object>) redisUtils.get(CITY) : (Map<String, Object>) redisUtils.get(REGION); if (!regionCode.endsWith(STREET_END_CODE)) {
if (ObjectUtils.isEmpty(map)) { list = ObjectUtils.isEmpty(redisUtils.get(STREET)) ? getProvinceList(STREET_LEVEL) : (List<LinkedHashMap>) redisUtils.get(STREET);
map = getRegionList(); } else if (regionCode.endsWith(END_CODE)) {
list = ObjectUtils.isEmpty(redisUtils.get(CITY)) ? getProvinceList(CITY_LEVEL) : (List<LinkedHashMap>) redisUtils.get(CITY);
} else {
list = ObjectUtils.isEmpty(redisUtils.get(REGION)) ? getProvinceList(REGION_LEVEL) : (List<LinkedHashMap>) redisUtils.get(REGION);
} }
list = (List<LinkedHashMap>) map.get(regionCode); return list.stream().filter(r -> regionCode.equals(r.get("parentRegionCode").toString())).collect(Collectors.toList());
return list;
} else { } else {
return new ArrayList<>(); return new ArrayList<>();
} }
} }
public Map<String, Object> getRegionList() {
//查询省下所有的行政区划市,封装并存入redis
Map<String, Object> map1 = new HashMap<>();
List<LinkedHashMap> cityList;
FeignClientResult tree = privilegeFeginService.getTree();
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
//获取陕西省regionCode
String regionCode = ((List<LinkedHashMap>) privilegeFeginService.getProvince("1").getResult()).get(0).get("regionCode").toString();
cityList = deleteTreeData(result, regionCode);
Map<String, Object> cityMap = new HashMap<>();
cityMap.put(regionCode, cityList);
map1.put(regionCode, cityList);
redisUtils.set(CITY, cityMap);
//查询市下所有的行政区划区,封装并存入redis
if (!ObjectUtils.isEmpty(cityList)) {
List<LinkedHashMap> region = (List<LinkedHashMap>) privilegeFeginService.getTree().getResult();
Map<String, Object> map = new HashMap<>();
for (LinkedHashMap linkedHashMap : cityList) {
List<LinkedHashMap> regionList = deleteTreeData(region, linkedHashMap.get("regionCode").toString());
map.put(linkedHashMap.get("regionCode").toString(), regionList);
map1.put(linkedHashMap.get("regionCode").toString(), regionList);
}
redisUtils.set(REGION, map);
}
return map1;
}
public List<LinkedHashMap> getProvinceList(String level) { public List<LinkedHashMap> getProvinceList(String level) {
List<LinkedHashMap> list;
FeignClientResult result = privilegeFeginService.getProvince(level); FeignClientResult result = privilegeFeginService.getProvince(level);
list = (List<LinkedHashMap>) result.getResult(); List<LinkedHashMap> list = (List<LinkedHashMap>) result.getResult();
list.get(0).put("sequenceNbr", list.get(0).get("regionCode")); for (LinkedHashMap linkedHashMap : list) {
linkedHashMap.put("sequenceNbr", linkedHashMap.get("regionCode"));
}
switch (level) {
case PROVINCE_LEVEL:
redisUtils.set(PROVINCE, list); redisUtils.set(PROVINCE, list);
break;
case CITY_LEVEL:
redisUtils.set(CITY, list);
break;
case REGION_LEVEL:
redisUtils.set(REGION, list);
break;
case STREET_LEVEL:
redisUtils.set(STREET, list);
break;
default:
log.error("不支持的行政区划:{}", level);
break;
}
return list; return list;
} }
...@@ -454,35 +453,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -454,35 +453,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
/** /**
* 获取行政区划以市或区的list集合
*
* @param result 需要删除的源数据
* @param type 匹配行政区划的regionCode,获取市则需要传省的regionCode,获取区则需要传市的regionCode
* @return 对应市或区的list集合
*/
private List<LinkedHashMap> deleteTreeData(List<LinkedHashMap> result, String type) {
Iterator it = result.iterator();
List<LinkedHashMap> list = new ArrayList<>();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//修改数据
if (type.equals(e.get("parentRegionCode").toString())) {
e.put("children", null);
e.put("sequenceNbr", e.get("regionCode"));
list.add(e);
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
List<LinkedHashMap> children = deleteTreeData((List<LinkedHashMap>) e.get("children"), type);
list.addAll(children);
}
}
return list;
}
/**
* 具体生成监管码和电梯96333识别码逻辑 * 具体生成监管码和电梯96333识别码逻辑
*/ */
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) { @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
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();
...@@ -551,7 +525,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -551,7 +525,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* @param county 行政区划区 * @param county 行政区划区
* @return 监管码 * @return 监管码
*/ */
private String createSupervisorCode(String city, String county, String equipCategory) { public String createSupervisorCode(String city, String county, String equipCategory) {
StringBuilder supervisorCode = new StringBuilder(); StringBuilder supervisorCode = new StringBuilder();
//生成监管码前缀 //生成监管码前缀
Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county); Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county);
...@@ -585,7 +559,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -585,7 +559,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* @param county 行政区划区 * @param county 行政区划区
* @return 96333电梯识别码 * @return 96333电梯识别码
*/ */
private String createElevatorCode(String city, String county) { public String createElevatorCode(String city, String county) {
StringBuilder elevatorCode = new StringBuilder(); StringBuilder elevatorCode = new StringBuilder();
//生成生成96333电梯码前缀 //生成生成96333电梯码前缀
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county); Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
...@@ -870,7 +844,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -870,7 +844,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
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) {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
List<EquipmentCategoryData> list = new ArrayList<>(); List<EquipmentCategoryData> list = new ArrayList<>();
...@@ -889,18 +863,20 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -889,18 +863,20 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
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->r.getUseUnitCreditCode().equals(map.get(USE_CODE).toString())).collect(Collectors.toList()); List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r->map.get(USE_CODE).toString().equals(r.getUseUnitCreditCode())).collect(Collectors.toList());
unitEquipCountList = unitEquipCountList.stream().filter(r->r.getOrgBranchCode().equals(map.get(ORG_BRANCH_CODE).toString())).collect(Collectors.toList()); if (!ObjectUtils.isEmpty(unitEquipCountList)) {
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) {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("waitClaim", unitEquipCountList.stream().filter(r->r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.DRL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum()); data.put("waitClaim", unitEquipCountList.stream().filter(r -> r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.DRL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum());
data.put("alreadyClaim", unitEquipCountList.stream().filter(r->r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.YRL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum()); data.put("alreadyClaim", unitEquipCountList.stream().filter(r -> r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.YRL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum());
data.put("refuseClaim", unitEquipCountList.stream().filter(r->r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.YJL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum()); data.put("refuseClaim", unitEquipCountList.stream().filter(r -> r.getEquList().equals(category.getCode()) && EquipmentCategoryEnum.YJL.getName().equals(r.getClaimStatus())).collect(Collectors.summarizingLong(UseUnitCreditCodeCategoryDto::getTotal)).getSum());
this.set8CategoryCountData(equipmentCategoryData, category, data); this.set8CategoryCountData(equipmentCategoryData, category, data);
} }
equipmentCategoryData.setRecDate(new Date()); equipmentCategoryData.setRecDate(new Date());
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));
} }
...@@ -1034,8 +1010,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1034,8 +1010,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String county = String.valueOf(superviseMap.get("county")); String county = String.valueOf(superviseMap.get("county"));
String equCategory = String.valueOf(superviseMap.get("equCategory")); String equCategory = String.valueOf(superviseMap.get("equCategory"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode")); String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
//生成码 //生成码
codeMap = creatCode(city, county, equCategory, code96333, supervisionCode); codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码"); log.info("已生成对应监管码或96333电梯识别码");
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据 //删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data"); map.remove("data");
...@@ -1075,8 +1052,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1075,8 +1052,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setStatus(HttpStatus.BAD_REQUEST.value()); response.setStatus(HttpStatus.BAD_REQUEST.value());
return response; return response;
} finally { } finally {
log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE"));
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
updateEquipmentCategoryData(unitCode,orgBranchCode); updateEquipmentCategoryData(unitCode,orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode())); supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisionMap.get("SUPERVISORY_CODE")));
} }
return responseModel; return responseModel;
} }
......
package com.yeejoin.amos.boot.module.ymt.biz.utils;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration
@ComponentScan("com.yeejoin.amos.boot.module.ymt.biz.service.impl")
@EnableAspectJAutoProxy(exposeProxy = true)//开启spring注解aop配置的支持
public class SpringConfiguration {
}
\ 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