Commit 7832b5df authored by tianyiming's avatar tianyiming

一码通总览功能优化

parent 252b35af
...@@ -33,7 +33,7 @@ public class ESEquipmentCategoryDto { ...@@ -33,7 +33,7 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String USE_UNIT_CREDIT_CODE; private String USE_UNIT_CREDIT_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String EQU_LIST_CODE; private String EQU_LIST_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
...@@ -63,7 +63,7 @@ public class ESEquipmentCategoryDto { ...@@ -63,7 +63,7 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Integer) @Field(type = FieldType.Integer)
private Integer EQU_STATE; private Integer EQU_STATE;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String STATUS; private String STATUS;
@Field(type = FieldType.Long) @Field(type = FieldType.Long)
......
...@@ -38,8 +38,6 @@ public interface IEquipmentCategoryService { ...@@ -38,8 +38,6 @@ public interface IEquipmentCategoryService {
void checkEsData(String id); void checkEsData(String id);
void createEquipmentCategoryData();
List<String> deleteBatch(Map<String, Object> map); List<String> deleteBatch(Map<String, Object> map);
ResponseModel submit(Map<String, Object> map); ResponseModel submit(Map<String, Object> map);
......
package com.yeejoin.amos.boot.module.ymt.biz.controller; package com.yeejoin.amos.boot.module.ymt.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -12,7 +11,6 @@ import com.yeejoin.amos.boot.biz.common.utils.Menu; ...@@ -12,7 +11,6 @@ import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser; import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.enums.ImageSizeEnums; import com.yeejoin.amos.boot.module.ymt.api.enums.ImageSizeEnums;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
...@@ -20,7 +18,6 @@ import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService; ...@@ -20,7 +18,6 @@ import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo; import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.biz.service.impl.EquipmentCategoryServiceImpl; import com.yeejoin.amos.boot.module.ymt.biz.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.ymt.biz.utils.ImageUtils; import com.yeejoin.amos.boot.module.ymt.biz.utils.ImageUtils;
import com.yeejoin.amos.component.robot.BadRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -35,7 +32,10 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -35,7 +32,10 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -265,16 +265,6 @@ public class EquipmentCategoryController extends BaseController { ...@@ -265,16 +265,6 @@ public class EquipmentCategoryController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/createEquipmentCategoryData", method = RequestMethod.GET)
@ApiOperation(httpMethod = "get", value = "初始化一码通总览数据", notes = "初始化一码通总览数据")
public ResponseModel<Object> createEquipmentCategoryData(){
equipmentCategoryService.createEquipmentCategoryData();
return ResponseHelper.buildResponse("SUCCESS");
}
/** /**
* 批量一码通删除数据 * 批量一码通删除数据
* *
......
package com.yeejoin.amos.boot.module.ymt.biz.service.impl; package com.yeejoin.amos.boot.module.ymt.biz.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -11,7 +9,10 @@ import com.google.common.collect.Lists; ...@@ -11,7 +9,10 @@ import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.ymt.api.dto.*; import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum;
...@@ -21,11 +22,12 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*; ...@@ -21,11 +22,12 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService; import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo; import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.biz.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.ymt.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.biz.utils.JsonUtils; import com.yeejoin.amos.boot.module.ymt.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.IdxFeignService; import com.yeejoin.amos.boot.module.ymt.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.PrivilegeFeginService; import com.yeejoin.amos.boot.module.ymt.flc.api.feign.PrivilegeFeginService;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.queryparser.classic.QueryParser;
...@@ -35,9 +37,11 @@ import org.elasticsearch.client.RequestOptions; ...@@ -35,9 +37,11 @@ import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
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.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.aop.framework.AopContext; import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,7 +49,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -45,7 +49,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus; 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.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -56,6 +59,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -56,6 +59,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.DateUtil; import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -65,7 +69,6 @@ import java.text.SimpleDateFormat; ...@@ -65,7 +69,6 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
...@@ -110,6 +113,100 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -110,6 +113,100 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired @Autowired
EquipmentCategoryDataServiceImpl equipmentCategoryDataService; EquipmentCategoryDataServiceImpl equipmentCategoryDataService;
@Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
@Autowired
IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
@Autowired
IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
@Autowired
IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
@Autowired
IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
@Autowired
IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
IdxBizJgTechParamsElevatorServiceImpl idxBizJgTechParamsElevatorService;
@Autowired
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper;
@Autowired
IdxBizJgTechParamsVehicleServiceImpl idxBizJgTechParamsVehicleService;
@Autowired
IdxBizJgTechParamsVehicleMapper idxBizJgTechParamsVehicleMapper;
@Autowired
IdxBizJgTechParamsRopewayServiceImpl idxBizJgTechParamsRopewayService;
@Autowired
IdxBizJgTechParamsRopewayMapper idxBizJgTechParamsRopewayMapper;
@Autowired
IdxBizJgTechParamsRidesServiceImpl idxBizJgTechParamsRidesService;
@Autowired
IdxBizJgTechParamsRidesMapper idxBizJgTechParamsRidesMapper;
@Autowired
IdxBizJgTechParamsBoilerServiceImpl idxBizJgTechParamsBoilerService;
@Autowired
IdxBizJgTechParamsBoilerMapper idxBizJgTechParamsBoilerMapper;
@Autowired
IdxBizJgTechParamsVesselServiceImpl idxBizJgTechParamsVesselService;
@Autowired
IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
@Autowired
IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
@Autowired
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
@Autowired
IdxBizJgTechParamsLiftingServiceImpl idxBizJgTechParamsLiftingService;
@Autowired
IdxBizJgTechParamsLiftingMapper idxBizJgTechParamsLiftingMapper;
@Autowired
IdxBizJgMainPartsServiceImpl idxBizJgMainPartsService;
@Autowired
IdxBizJgMainPartsMapper idxBizJgMainPartsMapper;
@Autowired
IdxBizJgProtectionDevicesServiceImpl idxBizJgProtectionDevicesService;
@Autowired
IdxBizJgProtectionDevicesMapper idxBizJgProtectionDevicesMapper;
@Autowired @Autowired
PrivilegeFeginService privilegeFeginService; PrivilegeFeginService privilegeFeginService;
@Autowired @Autowired
...@@ -238,29 +335,65 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -238,29 +335,65 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(equipCategory); Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(equipCategory);
List<Map<String, Object>> mapList = resourceJson.get(EquipmentClassifityEnum.BDLS.getCode()); List<Map<String, Object>> mapList = resourceJson.get(EquipmentClassifityEnum.BDLS.getCode());
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); List<CompanyModel> companyModels = FeignUtil.remoteCall(() -> Privilege.companyClient.queryListByChild(RequestContext.getExeUserId()));
if (ObjectUtils.isEmpty(reginParams)) { if (companyModels.isEmpty()) {
return null; throw new BadRequest("未指定人员归属单位信息");
} }
String level = reginParams.getUserModel().getCompanys().get(0).getLevel(); String level = companyModels.get(0).getLevel();
String orgCode = reginParams.getUserModel().getCompanys().get(0).getOrgCode(); String orgCode = companyModels.get(0).getOrgCode();
String companyCode = reginParams.getUserModel().getCompanys().get(0).getCompanyCode(); String companyCode = companyModels.get(0).getCompanyCode();
List<Map<String, Object>> listMap = equipmentCategoryMapper.getCategoryData(level, orgCode, companyCode); SearchSourceBuilder builder = new SearchSourceBuilder();
for (Map<String, Object> map : mapList) { builder.trackTotalHits(true);
for (Map<String, Object> map1 : listMap) { SearchRequest request = new SearchRequest();
for (String s : map1.keySet()) { request.indices("idx_biz_view_jg_all");
HashMap<String, Object> jsonMap = JSON.parseObject(map1.get(s).toString(), new TypeReference<HashMap<String, Object>>() { BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
});
if (s.equals(map.get("type"))) { if ("company".equals(level)) {
map.put("waitClaim", Long.valueOf(map.get("waitClaim").toString()) + Long.valueOf(jsonMap.get("waitClaim").toString())); BoolQueryBuilder query = QueryBuilders.boolQuery();
map.put("alreadyClaim", Long.valueOf(map.get("alreadyClaim").toString()) + Long.valueOf(jsonMap.get("alreadyClaim").toString())); query.must(QueryBuilders.matchPhraseQuery("USE_UNIT_CREDIT_CODE", companyCode));
map.put("refuseClaim", Long.valueOf(map.get("refuseClaim").toString()) + Long.valueOf(jsonMap.get("refuseClaim").toString())); boolMust.must(query);
Long sum = Long.valueOf(jsonMap.get("waitClaim").toString()) + Long.valueOf(jsonMap.get("alreadyClaim").toString()) + Long.valueOf(jsonMap.get("refuseClaim").toString()); } else {
map.put("sum", Long.valueOf(map.get("sum").toString()) + sum); BoolQueryBuilder query = QueryBuilders.boolQuery();
} query.must(QueryBuilders.matchPhrasePrefixQuery("ORG_BRANCH_CODE", orgCode));
boolMust.must(query);
}
TermsAggregationBuilder field1Aggregation = AggregationBuilders
.terms("group_by_code")
.field("EQU_LIST_CODE")
.size(1000);
TermsAggregationBuilder field2Aggregation = AggregationBuilders
.terms("group_by_status")
.field("STATUS")
.size(1000);
builder.query(boolMust);
field1Aggregation.subAggregation(field2Aggregation);
builder.aggregation(field1Aggregation);
builder.size(0);
request.source(builder);
Map<String,Object> statusCountMap = new HashMap<>();
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms field1Terms = response.getAggregations().get("group_by_code");
for (Terms.Bucket field1Bucket : field1Terms.getBuckets()) {
Terms field2Terms = field1Bucket.getAggregations().get("group_by_status");
for (Terms.Bucket field2Bucket : field2Terms.getBuckets()) {
String field1Value = field1Bucket.getKeyAsString();
String field2Value = "已认领".equals(field2Bucket.getKeyAsString()) ? "alreadyClaim" :
"待认领".equals(field2Bucket.getKeyAsString()) ? "waitClaim" : "refuseClaim";
long docCount = field2Bucket.getDocCount();
statusCountMap.put(field1Value + "|" + field2Value, docCount);
} }
} }
list.add(map); } catch (IOException e) {
throw new BadRequest("es数据查询失败");
}
for (Map<String, Object> item : mapList) {
item.put("waitClaim", this.getCountNumber(item.get("code").toString(), "waitClaim", statusCountMap));
item.put("alreadyClaim", this.getCountNumber(item.get("code").toString(), "alreadyClaim", statusCountMap));
item.put("refuseClaim", this.getCountNumber(item.get("code").toString(), "refuseClaim", statusCountMap));
item.put("sum", Long.parseLong(item.get("waitClaim").toString()) + Long.parseLong(item.get("alreadyClaim").toString()) + Long.parseLong(item.get("refuseClaim").toString()));
list.add(item);
} }
page.setCurrent(1); page.setCurrent(1);
page.setTotal(list.size()); page.setTotal(list.size());
...@@ -268,6 +401,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -268,6 +401,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return page; return page;
} }
private Long getCountNumber(String type, String status, Map<String, Object> statusCountMap) {
String key = type + "|" + status;
return Long.parseLong(statusCountMap.getOrDefault(key,"0").toString());
}
/** /**
* 生成监管码和电梯96333识别码 * 生成监管码和电梯96333识别码
*/ */
...@@ -1136,117 +1274,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1136,117 +1274,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
} }
@Override
@Async
public void createEquipmentCategoryData() {
if (log.isInfoEnabled()) {
log.info("初始化一码通总览数据开始");
}
equipmentCategoryDataService.remove(new QueryWrapper<>());
getCategoryData(null, null);
}
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<UseUnitCreditCodeCategoryDto> equipCountList = equipmentCategoryMapper.useUnitCreditCodeCategoryCount(unitCodes, orgBranchCodes);
// 查询8大类设备定义
List<EquipmentCategory> equipmentCategories = getEquipmentCategories();
// 组织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))) {
continue;
}
equipmentCategoryData.setOrgBranchCode(map.get("supervise_org_code").toString());
equipmentCategoryData.setUnitCode(map.get(USE_CODE).toString());
// 指定单位的设备统计信息
List<UseUnitCreditCodeCategoryDto> unitEquipCountList = equipCountList.stream().filter(r -> map.get(USE_CODE).toString().equals(r.getUseUnitCreditCode())).collect(Collectors.toList());
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) {
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());
this.set8CategoryCountData(equipmentCategoryData, category, data);
}
equipmentCategoryData.setRecDate(new Date());
list.add(equipmentCategoryData);
}
}
if (!ObjectUtils.isEmpty(unitCodes) && !ObjectUtils.isEmpty(orgBranchCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes)
.in("org_branch_code", orgBranchCodes));
}
if (!ObjectUtils.isEmpty(unitCodes) && ObjectUtils.isEmpty(orgBranchCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes));
}
if (!ObjectUtils.isEmpty(list)) {
equipmentCategoryDataService.saveOrUpdateBatch(list);
}
stopWatch.stop();
if (log.isInfoEnabled()) {
log.info("总览数据刷新结束,耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
return list;
}
private void set8CategoryCountData(EquipmentCategoryData equipmentCategoryData, EquipmentCategory category, Map<String, Object> data) {
switch (category.getCode()) {
case "1000":
equipmentCategoryData.setBoiler(toJSONString(data));
break;
case "2000":
equipmentCategoryData.setVessel(toJSONString(data));
break;
case "3000":
equipmentCategoryData.setElevator(toJSONString(data));
break;
case "4000":
equipmentCategoryData.setLifting(toJSONString(data));
break;
case "5000":
equipmentCategoryData.setVehicle(toJSONString(data));
break;
case "6000":
equipmentCategoryData.setRides(toJSONString(data));
break;
case "8000":
equipmentCategoryData.setPipeline(toJSONString(data));
break;
case "9000":
equipmentCategoryData.setRopeway(toJSONString(data));
break;
default:
log.error("不支持的分类:{}", toJSONString(category));
break;
}
}
private List<EquipmentCategory> getEquipmentCategories() {
LambdaQueryWrapper<EquipmentCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
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) {
List<String> unitCodeList = new ArrayList<>();
unitCodeList.add(unitCode);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, null);
return equipmentCategoryData;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<String> deleteBatch(Map<String, Object> map) { public List<String> deleteBatch(Map<String, Object> map) {
...@@ -1283,10 +1310,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1283,10 +1310,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//删除涉及的19张表的数据 //删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(records); superviseInfoMapper.deleteDataAll(records);
// 根据统一信用代码更新总览表
if (!ObjectUtils.isEmpty(unitCodeList)) {
getCategoryData(unitCodeList, orgBranchCodeList);
}
//删除es中的数据 //删除es中的数据
esEquipmentCategory.deleteAll(list); esEquipmentCategory.deleteAll(list);
return records; return records;
...@@ -1325,7 +1348,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1325,7 +1348,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
log.info("准备生成监管码或96333电梯识别码"); log.info("准备生成监管码或96333电梯识别码");
String city = String.valueOf(superviseMap.get("city")); String city = String.valueOf(superviseMap.get("city"));
String county = String.valueOf(superviseMap.get("county")); String county = String.valueOf(superviseMap.get("county"));
;
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode")); String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy(); EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
//生成码 //生成码
...@@ -1396,7 +1418,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1396,7 +1418,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333")); log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE"))); supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE")));
log.info("unitCode-------->>>>>>>>>>{}", unitCode); log.info("unitCode-------->>>>>>>>>>{}", unitCode);
// updateEquipmentCategoryData(unitCode);
}); });
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -1418,100 +1439,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1418,100 +1439,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return ResponseHelper.buildResponse(record); return ResponseHelper.buildResponse(record);
} }
@Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
@Autowired
IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
@Autowired
IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
@Autowired
IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
@Autowired
IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
@Autowired
IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
IdxBizJgTechParamsElevatorServiceImpl idxBizJgTechParamsElevatorService;
@Autowired
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper;
@Autowired
IdxBizJgTechParamsVehicleServiceImpl idxBizJgTechParamsVehicleService;
@Autowired
IdxBizJgTechParamsVehicleMapper idxBizJgTechParamsVehicleMapper;
@Autowired
IdxBizJgTechParamsRopewayServiceImpl idxBizJgTechParamsRopewayService;
@Autowired
IdxBizJgTechParamsRopewayMapper idxBizJgTechParamsRopewayMapper;
@Autowired
IdxBizJgTechParamsRidesServiceImpl idxBizJgTechParamsRidesService;
@Autowired
IdxBizJgTechParamsRidesMapper idxBizJgTechParamsRidesMapper;
@Autowired
IdxBizJgTechParamsBoilerServiceImpl idxBizJgTechParamsBoilerService;
@Autowired
IdxBizJgTechParamsBoilerMapper idxBizJgTechParamsBoilerMapper;
@Autowired
IdxBizJgTechParamsVesselServiceImpl idxBizJgTechParamsVesselService;
@Autowired
IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
@Autowired
IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
@Autowired
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
@Autowired
IdxBizJgTechParamsLiftingServiceImpl idxBizJgTechParamsLiftingService;
@Autowired
IdxBizJgTechParamsLiftingMapper idxBizJgTechParamsLiftingMapper;
@Autowired
IdxBizJgMainPartsServiceImpl idxBizJgMainPartsService;
@Autowired
IdxBizJgMainPartsMapper idxBizJgMainPartsMapper;
@Autowired
IdxBizJgProtectionDevicesServiceImpl idxBizJgProtectionDevicesService;
@Autowired
IdxBizJgProtectionDevicesMapper idxBizJgProtectionDevicesMapper;
private String batchSubmitOrUpdate(Map<String, Object> map, String equCategory, String type) { private String batchSubmitOrUpdate(Map<String, Object> map, String equCategory, String type) {
Date date = new Date(); Date date = new Date();
String record = null; String record = null;
......
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