Commit 535c7909 authored by 韩桐桐's avatar 韩桐桐

fix(设备注销):流程修改

parent 3e1d3a52
......@@ -25,17 +25,9 @@ import com.yeejoin.amos.boot.module.elevator.flc.api.feign.PrivilegeFeginService
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -123,39 +115,39 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired
private RedisUtils redisUtils;
//管辖机构redis缓存key
// 管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
//行政区划redis缓存key
// 行政区划redis缓存key
private static final String PROVINCE = "PROVINCE";
private static final String CITY = "CITY";
private static final String REGION = "REGION";
//西安行政区划code
// 西安行政区划code
private static final String XIAN = "610100";
//判断行政区划查询市还是区
// 判断行政区划查询市还是区
private static final String END_CODE = "0000";
//一码通监督管理表单id
// 一码通监督管理表单id
private static final String SUPERVISION_FROM_ID = "1627903532906602497";
//一码通使用信息表单id
// 一码通使用信息表单id
private static final String USE_INFO_FROM_ID = "1627903393253056514";
//一码通码自动生成
// 一码通码自动生成
final static String CREATE = "1";
//一码通码手动输入
// 一码通码手动输入
final static String NOT_CREATE = "0";
//一码通复制功能url参数key
// 一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
//判断行政区划查询街道
// 判断行政区划查询街道
private static final String STREET_END_CODE = "00";
private static final String STREET = "STREET";
private static final String STREET_LEVEL = "4";
private static final String CITY_LEVEL = "2";
private static final String REGION_LEVEL = "3";
@Autowired
RestHighLevelClient restHighLevelClient;
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -242,14 +234,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String city, county, equipCategory;
EquInfoDto equInfoDto = new EquInfoDto();
if (ObjectUtils.isEmpty(record)) {
//获取对应行政区划
// 获取对应行政区划
county = EquipmentCategoryEnum.XZQH.getCode();
city = map.get("regionCode").toString();
//获取对应设备分类
// 获取对应设备分类
equipCategory = map.get("equCategory").toString();
} else {
equInfoDto = categoryOtherInfoMapper.selectEquipInfo(record);
//判断这条数据认领状态是否为已认领,否则直接返回
// 判断这条数据认领状态是否为已认领,否则直接返回
if (!ObjectUtils.isEmpty(equInfoDto) && EquipmentCategoryEnum.YRL.getName().equals(equInfoDto.getStatus())) {
city = equInfoDto.getCity();
county = equInfoDto.getCounty();
......@@ -258,10 +250,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return new HashMap<>();
}
}
//生成码
// 生成码
Map<String, String> codeMap;
synchronized (EquipmentCategoryServiceImpl.class) {
codeMap = creatCode(city, county, equipCategory, null,null);
codeMap = creatCode(city, county, equipCategory, null, null);
}
if (ObjectUtils.isEmpty(codeMap)) {
return new HashMap<>();
......@@ -274,19 +266,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisoryCodeInfo.setStatus(equState);
if (!ObjectUtils.isEmpty(record)) {
String supervisorCode, elevatorCode;
//设备状态为报废,对应电梯码作废
// 设备状态为报废,对应电梯码作废
equState = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? EquipmentCategoryEnum.WSY.getCode() : EquipmentCategoryEnum.YSY.getCode();
supervisorCode = codeMap.get("superviseCode");
elevatorCode = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? null : codeMap.get("code96333");
List<CategoryOtherInfo> categoryOtherInfo = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisorCode));
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 {
supervisoryCodeInfo.setStatus(equState);
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
}
//修改源数据的电梯码
// 修改源数据的电梯码
categoryOtherInfoMapper.updateSupervisorCode(supervisorCode, elevatorCode, record);
} else {
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
......@@ -297,13 +289,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<LinkedHashMap> getTree() {
List<LinkedHashMap> result = (List<LinkedHashMap>) redisUtils.get(REGULATOR_UNIT_TREE);
//判断redis是否存在管辖机构树
// 判断redis是否存在管辖机构树
return !ObjectUtils.isEmpty(result) ? result : creatTree();
}
@Override
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> treeData = deleteRegulatorTreeData(result);
List<LinkedHashMap> supervisionTree = treeData.stream().filter(e -> code.equals(e.get("orgCode"))).collect(Collectors.toList());
......@@ -322,7 +314,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//将管辖机构树中children为[]的修改为null
// 将管辖机构树中children为[]的修改为null
if (e.get("children") != null) {
if (((List<LinkedHashMap>) e.get("children")).size() == 0) {
e.put("children", null);
......@@ -345,7 +337,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//删除使用单位
// 删除使用单位
if ("company".equals(e.get("level"))) {
it.remove();
}
......@@ -368,7 +360,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list;
} else if (!ObjectUtils.isEmpty(parentId)) {
String regionCode = parentId.split("_")[0];
//regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
// regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
if (!regionCode.endsWith(STREET_END_CODE)) {
list = ObjectUtils.isEmpty(redisUtils.get(STREET)) ? getProvinceList(STREET_LEVEL) : (List<LinkedHashMap>) redisUtils.get(STREET);
} else if (regionCode.endsWith(END_CODE)) {
......@@ -383,19 +375,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
public Map<String, Object> getRegionList() {
//查询省下所有的行政区划市,封装并存入redis
// 查询省下所有的行政区划市,封装并存入redis
Map<String, Object> map1 = new HashMap<>();
List<LinkedHashMap> cityList;
FeignClientResult tree = privilegeFeginService.getTree();
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
//获取陕西省regionCode
// 获取陕西省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
// 查询市下所有的行政区划区,封装并存入redis
if (!ObjectUtils.isEmpty(cityList)) {
List<LinkedHashMap> region = (List<LinkedHashMap>) privilegeFeginService.getTree().getResult();
Map<String, Object> map = new HashMap<>();
......@@ -464,7 +456,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
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"));
......@@ -481,33 +473,33 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 具体生成监管码和电梯96333识别码逻辑
*/
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) {
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333, String supervisionCode) {
Map<String, String> resultMap = new HashMap<>();
StringBuilder supervisorCode = new StringBuilder();
StringBuilder elevatorCode = new StringBuilder();
CategoryOtherInfo categoryOtherInfo = new CategoryOtherInfo();
String prefix;
//判断是否需要生成96333电梯码
// 判断是否需要生成96333电梯码
if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
//判断数据是否携带96333电梯码,携带则使用,不携带则生成
if("null".equals(code96333)){
// 判断数据是否携带96333电梯码,携带则使用,不携带则生成
if ("null".equals(code96333)) {
prefix = getPrefix(EquipmentCategoryEnum.XZQHDT.getCode(), city);
//查询未使用的电梯码
// 查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
//如果存在未使用的电梯码则启用未使用的否则创建
// 如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
if(!ObjectUtils.isEmpty(categoryOtherInfo)){
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333",categoryOtherInfo.getCode()));
if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
}
elevatorCode.append(elevator);
resultMap.put("creatStatus",CREATE);
resultMap.put("creatStatus", CREATE);
} else {
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);
supervisorCode.append(supervisor);
} else {
......@@ -520,18 +512,18 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode));
//将生成的码添加到码表中,码的使用状态为初始状态
// 将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
supervisoryCodeInfo.setCreateStatus(resultMap.get("creatStatus"));
supervisoryCodeInfo.setSupervisoryCode(String.valueOf(supervisorCode));
supervisoryCodeInfo.setStatus(equState);
if(ObjectUtils.isEmpty(selectOne)){
if (ObjectUtils.isEmpty(selectOne)) {
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
} else {
selectOne.setCode96333(String.valueOf(elevatorCode));
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("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
......@@ -552,15 +544,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
private String createSupervisorCode(String city, String county, String equipCategory) {
StringBuilder supervisorCode = new StringBuilder();
//生成监管码前缀
// 生成监管码前缀
Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county);
String division = ObjectUtils.isEmpty(divisionMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), city).get("code").toString() : divisionMap.get("code").toString();
supervisorCode.append(division).append(equipCategory).append("-");
//获取行政区划区县、市是否存在历史监管码
// 获取行政区划区县、市是否存在历史监管码
CategoryOtherInfo supervisor = categoryOtherInfoMapper.selectSupervisorCode(supervisorCode.toString());
//生成对应监管码
// 生成对应监管码
if (!ObjectUtils.isEmpty(supervisor) && supervisor.getSupervisoryCode() != null) {
//获取补零位长度
// 获取补零位长度
String supervisoryCode = supervisor.getSupervisoryCode().substring(6);
long num = Long.valueOf(supervisoryCode) + 1;
int numLength = String.valueOf(num).length();
......@@ -586,7 +578,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
private String createElevatorCode(String city, String county) {
StringBuilder elevatorCode = new StringBuilder();
//生成生成96333电梯码前缀
// 生成生成96333电梯码前缀
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
String elevator = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), city).get("code").toString() : elevatorMap.get("code").toString();
elevatorCode.append(elevator);
......@@ -595,10 +587,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (ValidationUtil.isEmpty(initSupervisoryCode)) {
elevatorCode.append(EquipmentCategoryEnum.getValue.get(elevator));
} else {
//获取行政区划区县、市是否存在历史96333电梯码
// 获取行政区划区县、市是否存在历史96333电梯码
CategoryOtherInfo elevatorOtherInfo = categoryOtherInfoMapper.selectElevatorCode(elevatorCode.toString(), null);
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
//获取补零位长度
// 获取补零位长度
String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
long num = Long.parseLong(elevatorCode1) + 1;
int numLength = String.valueOf(num).length();
......@@ -735,12 +727,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ValidationUtil.isEmpty(level)) {
Page<Map<String, Object>> m = new Page<>();
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
m = this.getPage(map);
map.remove("USE_UNIT_CREDIT_CODE");
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
m = this.getPage(map);
map.remove("ORG_BRANCH_CODE");
......@@ -758,7 +750,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
objectPage.setSize(Long.valueOf(map.get("size").toString()));
objectPage.setCurrent(Long.valueOf(map.get("number").toString()));
model.setResult(objectPage);
//设备状态码对应枚举值
// 设备状态码对应枚举值
List<Map<String, Object>> records = model.getResult().getRecords();
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> record : records) {
......@@ -799,7 +791,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return list;
}
public List<EquipExportVo> getEquipExportData(EquipExportDto dto){
public List<EquipExportVo> getEquipExportData(EquipExportDto dto) {
ArrayList<EquipExportVo> list = new ArrayList<>();
List<JSONObject> objectList = getCompanyType();
if (!ValidationUtil.isEmpty(dto.getEQU_STATE())) {
......@@ -811,14 +803,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String companyCode = object.getString("companyCode");
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
dto.setUSE_UNIT_CREDIT_CODE(companyCode);
} else {
//监管单位
// 监管单位
dto.setORG_BRANCH_CODE(orgCode);
}
List<EquipExportVo> equipExportData = equipmentCategoryMapper.getEquipExportData(dto);
if (!ObjectUtils.isEmpty(equipExportData) ) {
if (!ObjectUtils.isEmpty(equipExportData)) {
list.addAll(equipExportData);
}
}
......@@ -858,23 +850,22 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
@Override
@Async
public void createEquipmentCategoryData() {
if(log.isInfoEnabled()){
if (log.isInfoEnabled()) {
log.info("初始化一码通总览数据开始");
}
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) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
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();
// 查询8大类设备定义
......@@ -882,31 +873,31 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
// 组织EquipmentCategoryData表数据
for (Map<String, Object> map : allUnitList) {
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;
}
equipmentCategoryData.setOrgBranchCode(map.get("supervise_org_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());
unitEquipCountList = unitEquipCountList.stream().filter(r->r.getOrgBranchCode().equals(map.get(ORG_BRANCH_CODE).toString())).collect(Collectors.toList());
List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r -> r.getUseUnitCreditCode().equals(map.get(USE_CODE).toString())).collect(Collectors.toList());
unitEquipCountList = unitEquipCountList.stream().filter(r -> r.getOrgBranchCode().equals(map.get(ORG_BRANCH_CODE).toString())).collect(Collectors.toList());
for (EquipmentCategory category : equipmentCategories) {
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("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("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("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);
}
equipmentCategoryData.setRecDate(new Date());
list.add(equipmentCategoryData);
}
if(!ObjectUtils.isEmpty(unitCodes)){
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code",unitCodes));
if (!ObjectUtils.isEmpty(unitCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code", unitCodes));
}
equipmentCategoryDataService.saveOrUpdateBatch(list);
stopWatch.stop();
if(log.isInfoEnabled()){
log.info("总览数据刷新结束,耗时:{} 秒",stopWatch.getTotalTimeSeconds());
if (log.isInfoEnabled()) {
log.info("总览数据刷新结束,耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
return list;
}
......@@ -945,19 +936,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private List<EquipmentCategory> getEquipmentCategories() {
LambdaQueryWrapper<EquipmentCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode,"000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"7000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"F000");
lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode, "000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode, "7000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode, "F000");
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<>();
unitCodeList.add(unitCode);
List<String> orgBranchCodeList = new ArrayList<>();
orgBranchCodeList.add(orgBranchCode);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList,null);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, null);
return equipmentCategoryData;
}
......@@ -968,7 +959,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<String> records = new ArrayList<>();
List<ESEquipmentCategoryDto> list = new ArrayList<>();
if(recordList.toString().contains("[")){
if (recordList.toString().contains("[")) {
for (String record : (List<String>) recordList) {
records.add(record);
ESEquipmentCategoryDto esEquipmentCategoryDto = new ESEquipmentCategoryDto();
......@@ -981,7 +972,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
esEquipmentCategoryDto.setSEQUENCE_NBR(recordList.toString());
list.add(esEquipmentCategoryDto);
}
//删除监管码表数据
// 删除监管码表数据
List<String> superviseCodeList = superviseInfoMapper.selectSuperviseCodeList(records);
List<Map<String, Object>> unitCodeAndOrgBranchCodeList = superviseInfoMapper.selectUnitCodeList(records);
List<String> unitCodeList = new ArrayList<>();
......@@ -991,17 +982,17 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
orgBranchCodeList.add(String.valueOf(objectMap.get("orgBranchCode")));
}
if(!ObjectUtils.isEmpty(superviseCodeList)){
if (!ObjectUtils.isEmpty(superviseCodeList)) {
supervisoryCodeInfoMapper.updateStatus(superviseCodeList);
}
//删除涉及的19张表的数据
// 删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(records);
// 根据统一信用代码更新总览表
if(!ObjectUtils.isEmpty(unitCodeList)){
getCategoryData(unitCodeList,orgBranchCodeList);
if (!ObjectUtils.isEmpty(unitCodeList)) {
getCategoryData(unitCodeList, orgBranchCodeList);
}
//删除es中的数据
// 删除es中的数据
esEquipmentCategory.deleteAll(list);
return records;
}
......@@ -1025,7 +1016,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String claimStatus = String.valueOf(superviseMap.get("claimStatus"));
String code96333 = String.valueOf(superviseMap.get("code96333"));
String operateType = String.valueOf(superviseMap.get("operateType"));
//生成码
// 生成码
Map<String, String> codeMap;
if (EquipmentCategoryEnum.YRL.getName().equals(claimStatus)) {
log.info("准备生成监管码或96333电梯识别码");
......@@ -1033,15 +1024,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String county = String.valueOf(superviseMap.get("county"));
String equCategory = String.valueOf(superviseMap.get("equCategory"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
//生成码
// 生成码
codeMap = creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码");
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
// 删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
// 根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
......@@ -1053,7 +1044,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
map.remove("data");
supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333);
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
// 根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
} else {
......@@ -1061,11 +1052,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
responseModel = idxFeignService.batchUpdate(null, null, map);
}
stopWatch.stop();
if(log.isInfoEnabled()){
log.info("通用提交耗时:{} 秒",stopWatch.getTotalTimeSeconds());
if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode());
ResponseModel<Object> response = new ResponseModel<>();
response.setDevMessage(e.getMessage());
......@@ -1074,14 +1065,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
} finally {
updateEquipmentCategoryData(unitCode,orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode()));
updateEquipmentCategoryData(unitCode, orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisoryCodeInfo.getSupervisoryCode()));
}
return responseModel;
}
//分页查询所有数据
// 分页查询所有数据
public Page<Map<String, Object>> getAll(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
......@@ -1099,7 +1090,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return page;
}
//查询总条数
// 查询总条数
public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
......@@ -1107,6 +1098,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count;
}
/**
* es数据同步
*
......@@ -1182,15 +1174,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* es保存设备数据
*/
public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) {
//处理时间问题
String recDate1 = map.get("REC_DATE").toString().substring(0,19);
// 处理时间问题
String recDate1 = map.get("REC_DATE").toString().substring(0, 19);
long time = Timestamp.valueOf(recDate1).getTime();
map.put("REC_DATE",time);
map.put("REC_DATE", time);
ESEquipmentCategoryDto dto = JSONObject.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
ESEquipmentCategoryDto save = esEquipmentCategory.save(dto);
if (!ObjectUtils.isEmpty(save)) {
//同步到es后修改
// 同步到es后修改
UseInfo useInfo = new UseInfo();
useInfo.setIsNotEs(1);
useInfoMapper.update(useInfo, new QueryWrapper<UseInfo>().eq("RECORD",
......@@ -1198,6 +1190,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
......@@ -1209,10 +1202,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String companyCode = object.getString("companyCode");
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
}
}
......@@ -1222,16 +1215,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//通用匹配规则,条件构建
//SEQUENCE_NBR
// 通用匹配规则,条件构建
// SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
......@@ -1241,12 +1234,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
......@@ -1256,23 +1249,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_ORG_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
......@@ -1283,7 +1276,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) {
......@@ -1296,14 +1289,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
query.must(QueryBuilders.matchPhraseQuery("ADDRESS", "*" + map.getString("ADDRESS") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE")) ) {
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_STATE", map.getLong("EQU_STATE")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("STATUS"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*"+map.getString("STATUS")+"*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*" + map.getString("STATUS") + "*"));
boolMust.must(meBuilder);
}
builder.query(boolMust);
......@@ -1335,7 +1328,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return result;
}
//es统计总记录数
// es统计总记录数
public Long getCount(String indexs, RestHighLevelClient esClient) {
Long totle = 0L;
SearchRequest searchRequest = new SearchRequest(indexs);
......
......@@ -10,8 +10,6 @@ import com.google.common.collect.Lists;
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.RedisUtils;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.cylinder.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.cylinder.api.dto.*;
import com.yeejoin.amos.boot.module.cylinder.api.entity.*;
import com.yeejoin.amos.boot.module.cylinder.api.enums.EquimentEnum;
......@@ -20,22 +18,16 @@ import com.yeejoin.amos.boot.module.cylinder.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.cylinder.api.mapper.*;
import com.yeejoin.amos.boot.module.cylinder.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.cylinder.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.cylinder.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.cylinder.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.cylinder.flc.api.feign.PrivilegeFeginService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -123,33 +115,33 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired
private RedisUtils redisUtils;
//管辖机构redis缓存key
// 管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
//行政区划redis缓存key
// 行政区划redis缓存key
private static final String PROVINCE = "PROVINCE";
private static final String CITY = "CITY";
private static final String REGION = "REGION";
//西安行政区划code
// 西安行政区划code
private static final String XIAN = "610100";
//判断行政区划查询市还是区
// 判断行政区划查询市还是区
private static final String END_CODE = "0000";
//一码通监督管理表单id
// 一码通监督管理表单id
private static final String SUPERVISION_FROM_ID = "1627903532906602497";
//一码通使用信息表单id
// 一码通使用信息表单id
private static final String USE_INFO_FROM_ID = "1627903393253056514";
//一码通码自动生成
// 一码通码自动生成
final static String CREATE = "1";
//一码通码手动输入
// 一码通码手动输入
final static String NOT_CREATE = "0";
//一码通复制功能url参数key
// 一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Autowired
RestHighLevelClient restHighLevelClient;
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -236,14 +228,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String city, county, equipCategory;
EquInfoDto equInfoDto = new EquInfoDto();
if (ObjectUtils.isEmpty(record)) {
//获取对应行政区划
// 获取对应行政区划
county = EquipmentCategoryEnum.XZQH.getCode();
city = map.get("regionCode").toString();
//获取对应设备分类
// 获取对应设备分类
equipCategory = map.get("equCategory").toString();
} else {
equInfoDto = categoryOtherInfoMapper.selectEquipInfo(record);
//判断这条数据认领状态是否为已认领,否则直接返回
// 判断这条数据认领状态是否为已认领,否则直接返回
if (!ObjectUtils.isEmpty(equInfoDto) && EquipmentCategoryEnum.YRL.getName().equals(equInfoDto.getStatus())) {
city = equInfoDto.getCity();
county = equInfoDto.getCounty();
......@@ -252,10 +244,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return new HashMap<>();
}
}
//生成码
// 生成码
Map<String, String> codeMap;
synchronized (EquipmentCategoryServiceImpl.class) {
codeMap = creatCode(city, county, equipCategory, null,null);
codeMap = creatCode(city, county, equipCategory, null, null);
}
if (ObjectUtils.isEmpty(codeMap)) {
return new HashMap<>();
......@@ -268,19 +260,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisoryCodeInfo.setStatus(equState);
if (!ObjectUtils.isEmpty(record)) {
String supervisorCode, elevatorCode;
//设备状态为报废,对应电梯码作废
// 设备状态为报废,对应电梯码作废
equState = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? EquipmentCategoryEnum.WSY.getCode() : EquipmentCategoryEnum.YSY.getCode();
supervisorCode = codeMap.get("superviseCode");
elevatorCode = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? null : codeMap.get("code96333");
List<CategoryOtherInfo> categoryOtherInfo = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisorCode));
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 {
supervisoryCodeInfo.setStatus(equState);
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
}
//修改源数据的电梯码
// 修改源数据的电梯码
categoryOtherInfoMapper.updateSupervisorCode(supervisorCode, elevatorCode, record);
} else {
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
......@@ -291,13 +283,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<LinkedHashMap> getTree() {
List<LinkedHashMap> result = (List<LinkedHashMap>) redisUtils.get(REGULATOR_UNIT_TREE);
//判断redis是否存在管辖机构树
// 判断redis是否存在管辖机构树
return !ObjectUtils.isEmpty(result) ? result : creatTree();
}
@Override
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> treeData = deleteRegulatorTreeData(result);
List<LinkedHashMap> supervisionTree = treeData.stream().filter(e -> code.equals(e.get("orgCode"))).collect(Collectors.toList());
......@@ -316,7 +308,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//将管辖机构树中children为[]的修改为null
// 将管辖机构树中children为[]的修改为null
if (e.get("children") != null) {
if (((List<LinkedHashMap>) e.get("children")).size() == 0) {
e.put("children", null);
......@@ -339,7 +331,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//删除使用单位
// 删除使用单位
if ("company".equals(e.get("level"))) {
it.remove();
}
......@@ -362,7 +354,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list;
} else if (!ObjectUtils.isEmpty(parentId)) {
String regionCode = parentId.split("_")[0];
//regionCode以0000结果查询市、否则查询区
// regionCode以0000结果查询市、否则查询区
Map<String, Object> map = regionCode.endsWith(END_CODE) ? (Map<String, Object>) redisUtils.get(CITY) : (Map<String, Object>) redisUtils.get(REGION);
if (ObjectUtils.isEmpty(map)) {
map = getRegionList();
......@@ -375,19 +367,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
public Map<String, Object> getRegionList() {
//查询省下所有的行政区划市,封装并存入redis
// 查询省下所有的行政区划市,封装并存入redis
Map<String, Object> map1 = new HashMap<>();
List<LinkedHashMap> cityList;
FeignClientResult tree = privilegeFeginService.getTree();
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
//获取陕西省regionCode
// 获取陕西省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
// 查询市下所有的行政区划区,封装并存入redis
if (!ObjectUtils.isEmpty(cityList)) {
List<LinkedHashMap> region = (List<LinkedHashMap>) privilegeFeginService.getTree().getResult();
Map<String, Object> map = new HashMap<>();
......@@ -456,7 +448,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
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"));
......@@ -473,33 +465,33 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 具体生成监管码和电梯96333识别码逻辑
*/
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) {
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333, String supervisionCode) {
Map<String, String> resultMap = new HashMap<>();
StringBuilder supervisorCode = new StringBuilder();
StringBuilder elevatorCode = new StringBuilder();
CategoryOtherInfo categoryOtherInfo = new CategoryOtherInfo();
String prefix;
//判断是否需要生成96333电梯码
// 判断是否需要生成96333电梯码
if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
//判断数据是否携带96333电梯码,携带则使用,不携带则生成
if("null".equals(code96333)){
// 判断数据是否携带96333电梯码,携带则使用,不携带则生成
if ("null".equals(code96333)) {
prefix = getPrefix(EquipmentCategoryEnum.XZQHDT.getCode(), city);
//查询未使用的电梯码
// 查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
//如果存在未使用的电梯码则启用未使用的否则创建
// 如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
if(!ObjectUtils.isEmpty(categoryOtherInfo)){
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333",categoryOtherInfo.getCode()));
if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
}
elevatorCode.append(elevator);
resultMap.put("creatStatus",CREATE);
resultMap.put("creatStatus", CREATE);
} else {
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);
supervisorCode.append(supervisor);
} else {
......@@ -512,18 +504,18 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode));
//将生成的码添加到码表中,码的使用状态为初始状态
// 将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
supervisoryCodeInfo.setCreateStatus(resultMap.get("creatStatus"));
supervisoryCodeInfo.setSupervisoryCode(String.valueOf(supervisorCode));
supervisoryCodeInfo.setStatus(equState);
if(ObjectUtils.isEmpty(selectOne)){
if (ObjectUtils.isEmpty(selectOne)) {
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
} else {
selectOne.setCode96333(String.valueOf(elevatorCode));
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("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
......@@ -544,15 +536,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
private String createSupervisorCode(String city, String county, String equipCategory) {
StringBuilder supervisorCode = new StringBuilder();
//生成监管码前缀
// 生成监管码前缀
Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county);
String division = ObjectUtils.isEmpty(divisionMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), city).get("code").toString() : divisionMap.get("code").toString();
supervisorCode.append(division).append(equipCategory).append("-");
//获取行政区划区县、市是否存在历史监管码
// 获取行政区划区县、市是否存在历史监管码
CategoryOtherInfo supervisor = categoryOtherInfoMapper.selectSupervisorCode(supervisorCode.toString());
//生成对应监管码
// 生成对应监管码
if (!ObjectUtils.isEmpty(supervisor) && supervisor.getSupervisoryCode() != null) {
//获取补零位长度
// 获取补零位长度
String supervisoryCode = supervisor.getSupervisoryCode().substring(6);
long num = Long.valueOf(supervisoryCode) + 1;
int numLength = String.valueOf(num).length();
......@@ -578,7 +570,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
private String createElevatorCode(String city, String county) {
StringBuilder elevatorCode = new StringBuilder();
//生成生成96333电梯码前缀
// 生成生成96333电梯码前缀
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
String elevator = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), city).get("code").toString() : elevatorMap.get("code").toString();
elevatorCode.append(elevator);
......@@ -587,10 +579,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (ValidationUtil.isEmpty(initSupervisoryCode)) {
elevatorCode.append(EquipmentCategoryEnum.getValue.get(elevator));
} else {
//获取行政区划区县、市是否存在历史96333电梯码
// 获取行政区划区县、市是否存在历史96333电梯码
CategoryOtherInfo elevatorOtherInfo = categoryOtherInfoMapper.selectElevatorCode(elevatorCode.toString(), null);
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
//获取补零位长度
// 获取补零位长度
String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
long num = Long.parseLong(elevatorCode1) + 1;
int numLength = String.valueOf(num).length();
......@@ -727,12 +719,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ValidationUtil.isEmpty(level)) {
Page<Map<String, Object>> m = new Page<>();
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
m = this.getPage(map);
map.remove("USE_UNIT_CREDIT_CODE");
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
m = this.getPage(map);
map.remove("ORG_BRANCH_CODE");
......@@ -750,7 +742,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
objectPage.setSize(Long.valueOf(map.get("size").toString()));
objectPage.setCurrent(Long.valueOf(map.get("number").toString()));
model.setResult(objectPage);
//设备状态码对应枚举值
// 设备状态码对应枚举值
List<Map<String, Object>> records = model.getResult().getRecords();
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> record : records) {
......@@ -791,7 +783,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return list;
}
public List<EquipExportVo> getEquipExportData(EquipExportDto dto){
public List<EquipExportVo> getEquipExportData(EquipExportDto dto) {
ArrayList<EquipExportVo> list = new ArrayList<>();
List<JSONObject> objectList = getCompanyType();
if (!ValidationUtil.isEmpty(dto.getEQU_STATE())) {
......@@ -803,14 +795,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String companyCode = object.getString("companyCode");
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
dto.setUSE_UNIT_CREDIT_CODE(companyCode);
} else {
//监管单位
// 监管单位
dto.setORG_BRANCH_CODE(orgCode);
}
List<EquipExportVo> equipExportData = equipmentCategoryMapper.getEquipExportData(dto);
if (!ObjectUtils.isEmpty(equipExportData) ) {
if (!ObjectUtils.isEmpty(equipExportData)) {
list.addAll(equipExportData);
}
}
......@@ -850,23 +842,22 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
@Override
@Async
public void createEquipmentCategoryData() {
if(log.isInfoEnabled()){
if (log.isInfoEnabled()) {
log.info("初始化一码通总览数据开始");
}
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) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
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();
// 查询8大类设备定义
......@@ -874,31 +865,31 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
// 组织EquipmentCategoryData表数据
for (Map<String, Object> map : allUnitList) {
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;
}
equipmentCategoryData.setOrgBranchCode(map.get("supervise_org_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());
unitEquipCountList = unitEquipCountList.stream().filter(r->r.getOrgBranchCode().equals(map.get(ORG_BRANCH_CODE).toString())).collect(Collectors.toList());
List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r -> r.getUseUnitCreditCode().equals(map.get(USE_CODE).toString())).collect(Collectors.toList());
unitEquipCountList = unitEquipCountList.stream().filter(r -> r.getOrgBranchCode().equals(map.get(ORG_BRANCH_CODE).toString())).collect(Collectors.toList());
for (EquipmentCategory category : equipmentCategories) {
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("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("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("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);
}
equipmentCategoryData.setRecDate(new Date());
list.add(equipmentCategoryData);
}
if(!ObjectUtils.isEmpty(unitCodes)){
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code",unitCodes));
if (!ObjectUtils.isEmpty(unitCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>().in("unit_code", unitCodes));
}
equipmentCategoryDataService.saveOrUpdateBatch(list);
stopWatch.stop();
if(log.isInfoEnabled()){
log.info("总览数据刷新结束,耗时:{} 秒",stopWatch.getTotalTimeSeconds());
if (log.isInfoEnabled()) {
log.info("总览数据刷新结束,耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
return list;
}
......@@ -937,19 +928,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private List<EquipmentCategory> getEquipmentCategories() {
LambdaQueryWrapper<EquipmentCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode,"000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"7000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode,"F000");
lambdaQueryWrapper.likeLeft(EquipmentCategory::getCode, "000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode, "7000");
lambdaQueryWrapper.ne(EquipmentCategory::getCode, "F000");
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<>();
unitCodeList.add(unitCode);
List<String> orgBranchCodeList = new ArrayList<>();
orgBranchCodeList.add(orgBranchCode);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList,null);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, null);
return equipmentCategoryData;
}
......@@ -960,7 +951,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<String> records = new ArrayList<>();
List<ESEquipmentCategoryDto> list = new ArrayList<>();
if(recordList.toString().contains("[")){
if (recordList.toString().contains("[")) {
for (String record : (List<String>) recordList) {
records.add(record);
ESEquipmentCategoryDto esEquipmentCategoryDto = new ESEquipmentCategoryDto();
......@@ -973,7 +964,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
esEquipmentCategoryDto.setSEQUENCE_NBR(recordList.toString());
list.add(esEquipmentCategoryDto);
}
//删除监管码表数据
// 删除监管码表数据
List<String> superviseCodeList = superviseInfoMapper.selectSuperviseCodeList(records);
List<Map<String, Object>> unitCodeAndOrgBranchCodeList = superviseInfoMapper.selectUnitCodeList(records);
List<String> unitCodeList = new ArrayList<>();
......@@ -983,17 +974,17 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
orgBranchCodeList.add(String.valueOf(objectMap.get("orgBranchCode")));
}
if(!ObjectUtils.isEmpty(superviseCodeList)){
if (!ObjectUtils.isEmpty(superviseCodeList)) {
supervisoryCodeInfoMapper.updateStatus(superviseCodeList);
}
//删除涉及的19张表的数据
// 删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(records);
// 根据统一信用代码更新总览表
if(!ObjectUtils.isEmpty(unitCodeList)){
getCategoryData(unitCodeList,orgBranchCodeList);
if (!ObjectUtils.isEmpty(unitCodeList)) {
getCategoryData(unitCodeList, orgBranchCodeList);
}
//删除es中的数据
// 删除es中的数据
esEquipmentCategory.deleteAll(list);
return records;
}
......@@ -1017,7 +1008,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String claimStatus = String.valueOf(superviseMap.get("claimStatus"));
String code96333 = String.valueOf(superviseMap.get("code96333"));
String operateType = String.valueOf(superviseMap.get("operateType"));
//生成码
// 生成码
Map<String, String> codeMap;
if (EquipmentCategoryEnum.YRL.getName().equals(claimStatus)) {
log.info("准备生成监管码或96333电梯识别码");
......@@ -1025,15 +1016,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String county = String.valueOf(superviseMap.get("county"));
String equCategory = String.valueOf(superviseMap.get("equCategory"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
//生成码
// 生成码
codeMap = creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码");
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
// 删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
// 根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
......@@ -1045,7 +1036,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
map.remove("data");
supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333);
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
// 根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
} else {
......@@ -1053,11 +1044,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
responseModel = idxFeignService.batchUpdate(null, null, map);
}
stopWatch.stop();
if(log.isInfoEnabled()){
log.info("通用提交耗时:{} 秒",stopWatch.getTotalTimeSeconds());
if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode());
ResponseModel<Object> response = new ResponseModel<>();
response.setDevMessage(e.getMessage());
......@@ -1066,14 +1057,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
} finally {
updateEquipmentCategoryData(unitCode,orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode()));
updateEquipmentCategoryData(unitCode, orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisoryCodeInfo.getSupervisoryCode()));
}
return responseModel;
}
//分页查询所有数据
// 分页查询所有数据
public Page<Map<String, Object>> getAll(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
......@@ -1091,7 +1082,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return page;
}
//查询总条数
// 查询总条数
public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
......@@ -1099,6 +1090,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count;
}
/**
* es数据同步
*
......@@ -1174,15 +1166,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* es保存设备数据
*/
public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) {
//处理时间问题
String recDate1 = map.get("REC_DATE").toString().substring(0,19);
// 处理时间问题
String recDate1 = map.get("REC_DATE").toString().substring(0, 19);
long time = Timestamp.valueOf(recDate1).getTime();
map.put("REC_DATE",time);
map.put("REC_DATE", time);
ESEquipmentCategoryDto dto = JSONObject.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
ESEquipmentCategoryDto save = esEquipmentCategory.save(dto);
if (!ObjectUtils.isEmpty(save)) {
//同步到es后修改
// 同步到es后修改
UseInfo useInfo = new UseInfo();
useInfo.setIsNotEs(1);
useInfoMapper.update(useInfo, new QueryWrapper<UseInfo>().eq("RECORD",
......@@ -1190,6 +1182,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
......@@ -1201,10 +1194,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String companyCode = object.getString("companyCode");
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
}
}
......@@ -1214,16 +1207,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//通用匹配规则,条件构建
//SEQUENCE_NBR
// 通用匹配规则,条件构建
// SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
......@@ -1233,12 +1226,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
......@@ -1248,23 +1241,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_ORG_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
......@@ -1275,7 +1268,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
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);
}
if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) {
......@@ -1288,14 +1281,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
query.must(QueryBuilders.matchPhraseQuery("ADDRESS", "*" + map.getString("ADDRESS") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE")) ) {
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_STATE", map.getLong("EQU_STATE")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("STATUS"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*"+map.getString("STATUS")+"*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*" + map.getString("STATUS") + "*"));
boolMust.must(meBuilder);
}
builder.query(boolMust);
......@@ -1327,7 +1320,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return result;
}
//es统计总记录数
// es统计总记录数
public Long getCount(String indexs, RestHighLevelClient esClient) {
Long totle = 0L;
SearchRequest searchRequest = new SearchRequest(indexs);
......
......@@ -96,7 +96,7 @@ public class JgScrapCancel extends BaseEntity {
private String receiveOrgName;
/**
* 接收机构公司代码
* 接收机构公司代码--暂时未用到
*/
@TableField("receive_company_code")
private String receiveCompanyCode;
......
package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancelEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgScrapCancelEq;
/**
* 报废注销设备关系表 Mapper 接口
......
......@@ -193,7 +193,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
dto.setProcessDefinitionKey("scrapCancelNew");
dto.setBusinessKey(applyNoList.get(0));
dto.setCompleteFirstTask(Boolean.TRUE);
//下一节点执行人单位(下节点接收机构code)
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(model.getReceiveOrgCode());
list.add(dto);
......@@ -314,9 +314,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
LambdaQueryWrapper<JgScrapCancel> lambda = new QueryWrapper<JgScrapCancel>().lambda();
lambda.eq(JgScrapCancel::getSequenceNbr, id);
JgScrapCancel jgScrapCancel = this.baseMapper.selectOne(lambda);
//删除代办消息
// 删除代办消息
commonService.deleteTaskModel(String.valueOf(jgScrapCancel.getSequenceNbr()));
//更新jgScrapCancel数据
// 更新jgScrapCancel数据
jgScrapCancel.setIsDelete(true);
this.updateById(jgScrapCancel);
}
......@@ -324,6 +324,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
}
public JgScrapCancelDto updateInfo(String submitType, JgScrapCancelDto jgScrapCancelDto, String op) {
if (Objects.isNull(jgScrapCancelDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空");
}
......@@ -335,7 +336,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
// 更新并提交
// 发起流程
if (!StringUtils.hasText(jgScrapCancelDto.getInstanceId())) {
//未进流程直接发起并执行
// 未进流程直接发起并执行
List<ProcessTaskDTO> processTasks;
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
......@@ -367,7 +368,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
createTaskModel(bean, taskName, "1", nextUserIds);
} else {
// 已经在流程中,执行一步
ProcessTaskDTO processTaskDTO = submit(jgScrapCancelDto.getNextTaskId());
ProcessTaskDTO processTaskDTO = submit(jgScrapCancelDto);
String nextTaskId = processTaskDTO.getNextTask().get(0).getId();
String taskName = processTaskDTO.getNextTask().get(0).getName();
this.buildRoleList(Collections.singletonList(processTaskDTO), roleListNext, roleListAll);
......@@ -408,7 +409,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
String supervisoryCode = otherInfo.getSupervisoryCode();
jgScrapCancelDto.setSupervisoryCode(supervisoryCode);
}
//更新操作
// 更新操作
JgScrapCancel bean = new JgScrapCancel();
BeanUtils.copyProperties(jgScrapCancelDto, bean);
bean.setCancelCertificate(JSON.toJSONString(jgScrapCancelDto.getCancelCertificateList()));
......@@ -428,9 +429,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
taskV2Model.setTaskDesc("");
taskV2Model.setTaskContent(this.buildTaskContent(jgScrapCancelDto.getEquList(), jgScrapCancelDto.getSupervisoryCode(), jgScrapCancelDto.getCancelType(), jgScrapCancelDto.getApplyNo()));
taskV2Model.setTaskName(taskName);
taskV2Model.setTaskDesc("");
taskV2Model.setTaskCode(jgScrapCancelDto.getApplyNo());
taskV2Model.setExecuteUserIds(nextUserIds);
taskV2Model.setRelationId(jgScrapCancelDto.getInstanceId());
FlowStatusEnum flowStatusEnum = this.getTaskStatus(operate);
taskV2Model.setTaskStatus(flowStatusEnum.getCode());
......@@ -449,6 +448,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
modelDto.setNextExecuteUser(jgScrapCancelDto.getNextExecuteIds());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgScrapCancelDto, taskMessageDto);
taskMessageDto.setNextExecuteUserIds(null);
modelDto.setModel(taskMessageDto);
modelDto.setPageType(this.getPageTypeForReject(operate, jgScrapCancelDto.getAuditStatus()));
commonService.buildTaskModel(Collections.singletonList(modelDto));
......@@ -490,15 +490,17 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
}
}
public ProcessTaskDTO submit(String taskId) {
//组装信息
public ProcessTaskDTO submit(JgScrapCancelDto jgScrapCancelDto) {
JgScrapCancel model = this.getById(jgScrapCancelDto.getSequenceNbr());
// 组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
dto.setTaskId(jgScrapCancelDto.getNextTaskId());
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", "提交");
dto.setNextExecuteUserCompanyCode(model.getReceiveOrgCode());
dto.setVariable(map);
return cmWorkflowService.complete(taskId, dto);
return cmWorkflowService.complete(jgScrapCancelDto.getNextTaskId(), dto);
}
public Map<String, Object> queryBySequenceNbr(Long sequenceNbr) {
......@@ -585,7 +587,7 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
public void flowExecute(String equList, Long id, String instanceId, String operate, String comment) {
JgScrapCancel jgScrapCancel = this.getBaseMapper().selectById(id);
String taskId = jgScrapCancel.getNextTaskId();
//组装信息
// 组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
......@@ -596,9 +598,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
map.put("approvalStatus", "提交");
}
dto.setVariable(map);
//下一节点执行人单位(下节点接收机构code)
// 下一节点执行人单位(下节点接收机构code)
dto.setNextExecuteUserCompanyCode(this.getNextUserOrgCode(operate, jgScrapCancel));
//执行流程
// 执行流程
ProcessTaskDTO processTaskDTO = cmWorkflowService.complete(taskId, dto);
// 更新下一步执行人、创建待办
updateExecuteIds(equList, instanceId, id, operate, processTaskDTO);
......@@ -701,8 +703,10 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
if ("0".equals(operate)) {
code = jgScrapCancel.getReceiveOrgCode();
} else {
//驳回
if (WorkFlowStatusEnum.CANCEL_RECEIVE.getPass().equals(jgScrapCancel.getAuditStatus()) || WorkFlowStatusEnum.CANCEL_RECEIVE.getReject().equals(jgScrapCancel.getAuditStatus()) || WorkFlowStatusEnum.CANCEL_RECEIVE.getRollBack().equals(jgScrapCancel.getAuditStatus())) {
// 驳回
if (WorkFlowStatusEnum.CANCEL_RECEIVE.getPass().equals(jgScrapCancel.getAuditStatus()) ||
WorkFlowStatusEnum.CANCEL_RECEIVE.getReject().equals(jgScrapCancel.getAuditStatus()) ||
WorkFlowStatusEnum.CANCEL_RECEIVE.getRollBack().equals(jgScrapCancel.getAuditStatus())) {
code = jgScrapCancel.getUseUnitCode();
}
}
......
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