Commit fc63c15c authored by 麻笑宇's avatar 麻笑宇

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into…

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into develop_tzs_register_to_0715
parents 7ebe3e37 a3ef9dda
......@@ -96,7 +96,7 @@
<where>
<if
test="tzBaseEnterpriseInfoDto.unitType!=null and tzBaseEnterpriseInfoDto.unitType!='' ">
AND unit_type = #{tzBaseEnterpriseInfoDto.unitType}
AND unit_type LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.unitType},'%')
</if>
<if
test="tzBaseEnterpriseInfoDto.useUnit!=null and tzBaseEnterpriseInfoDto.useUnit!='' ">
......
......@@ -42,4 +42,14 @@ public class SecurityIndexCountItemDto {
* 充装检查率
*/
String czjchege;
/**
* 人员合规率(资质有效期统计)
*/
String ryhg;
/**
* 数据合规率
*/
String sjhg;
}
......@@ -38,7 +38,7 @@
and date_le(CAST(problem_time as date),#{dto.endDate})
</if>
AND source_type_code = #{sourceTypeCode}
<if test="null != equipType">
<if test="null != equListCode">
AND equip_list_code = #{equListCode}
</if>
AND problem_type IN
......@@ -69,9 +69,9 @@
GROUP BY t.problem_type
</select>
<select id="getIssueCountByMonth" resultType="java.util.Map">
SELECT COUNT
( 1 ),
DATE_FORMAT(problem_time,'%Y-%m') AS time
SELECT
COUNT(1),
DATE_FORMAT(problem_time,'%Y-%m') AS time
FROM
tzs_safety_problem_tracing
WHERE
......@@ -215,7 +215,7 @@
FROM
tzs_safety_problem_tracing
WHERE
governing_body_org_code LIKE concat ( #{orgCode}, '%' )
governing_body_org_code LIKE concat ( #{orgCode}, '%')
<if test="null != status">
AND problem_status_code = #{status}
</if>
......
......@@ -19,11 +19,12 @@
count(DISTINCT(a.use_unit_credit_code)) as num
FROM
"tzs_jg_use_registration_manage" a,
privilege_company c
"tz_base_enterprise_info" tbei
where
a.receive_company_code = c.company_code
and a.certificate_status='已登记'
and c.org_code like concat(#{orgCode},'%')) s1,
a.use_unit_credit_code = tbei.use_code
AND tbei.unit_type LIKE'%充装单位%'
and a.certificate_status='已登记'
and tbei.supervise_org_code like concat(#{orgCode},'%')) s1,
(SELECT
count(1) as total
FROM "tz_base_enterprise_info"
......
......@@ -123,12 +123,12 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按月统计近12个月的问题数量趋势")
@PostMapping(value = "/issueCountByMonth")
public ResponseModel<Map<String, Object>> issueCountByMonth(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
public ResponseModel<Map<String, Object>> issueCountByMonth(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
Map<String, Object> result = statisticsService.issueCountByMonth(regionCode.toString());
Map<String, Object> result = statisticsService.issueCountByMonth(dpFilterParamDto);
return ResponseHelper.buildResponse(result);
}
......@@ -161,7 +161,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-中屏-当前区域子区域数据统计")
@PostMapping(value = "/issueChildrenCityCountOld")
public ResponseModel<List<Map<String, Object>>> issueChildrenCityCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<List<Map<String, Object>>> issueChildrenCityCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -186,24 +186,24 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-当年问题等级分类统计")
@PostMapping(value = "/issueProblemLevelCount")
public ResponseModel<Map<String, Object>> issueProblemLevelCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
public ResponseModel<Map<String, Object>> issueProblemLevelCount(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
Map<String, Object> result = statisticsService.issueProblemLevelCount(regionCode.toString());
Map<String, Object> result = statisticsService.issueProblemLevelCount(dpFilterParamDto);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按问题类型排名top 10")
@ApiOperation(value = "大屏-安全追溯-右屏-当年主体单位问题排名(Top10)")
@PostMapping(value = "/issueCompanyTop")
public ResponseModel<List<Map<String, Object>>> issueCompanyTop(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
public ResponseModel<List<Map<String, Object>>> issueCompanyTop(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
List<Map<String, Object>> result = statisticsService.issueCompanyTop(regionCode.toString());
List<Map<String, Object>> result = statisticsService.issueCompanyTop(dpFilterParamDto);
return ResponseHelper.buildResponse(result);
}
......@@ -221,12 +221,12 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-当年下级区域问题闭环率排名")
@PostMapping(value = "/issueChildrenCityCountTop")
public ResponseModel<List<Map<String, Object>>> issueChildrenCityCountTop(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
public ResponseModel<List<Map<String, Object>>> issueChildrenCityCountTop(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
List<Map<String, Object>> result = statisticsService.issueChildrenCityCountTop(regionCode.toString());
List<Map<String, Object>> result = statisticsService.issueChildrenCityCountTop(dpFilterParamDto);
return ResponseHelper.buildResponse(result);
}
......
......@@ -13,26 +13,17 @@ import com.yeejoin.amos.boot.module.statistics.api.dto.EquipQuestionNumCountDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AQZSDPStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipTechParamPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
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.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -166,13 +157,15 @@ public class AQZSDPStatisticsServiceImpl {
public Map<String, Object> getChildEarlyWarning(DPFilterParamDto dpFilterParamDto) {
List<RegionModel> regionModels = stCommonService.setRegionIfRootParentAndNoAccessIf3Level(dpFilterParamDto.getCityCode());
Map<String, SecurityIndexCountItemDto> regionCodeSecurityIndexMap = getSecurityIndexCountItemDtoMap(regionModels);
Set<String> legendData = getLegendForCyArea();
Set<Map<String,String>> legendData = getLegendForCyArea();
List<String> xuke = new ArrayList<>();
List<String> shiyongdengji = new ArrayList<>();
List<String> jianyanchaoqi = new ArrayList<>();
List<String> jianyanhege = new ArrayList<>();
List<String> czjc = new ArrayList<>();
List<String> czjchege = new ArrayList<>();
List<String> ryhg = new ArrayList<>();
List<String> sjhg = new ArrayList<>();
//TODO 多线程处理后,regionCodeSecurityIndexMap顺序与regionModels的顺序不一致,需让数据和x轴的顺序保存一致
List<String> xdata = stCommonService.buildXData(regionModels);
regionModels.forEach(r -> {
......@@ -183,6 +176,8 @@ public class AQZSDPStatisticsServiceImpl {
jianyanhege.add(this.castScore2Percent(countItemDto.getJianyanhege()));
czjc.add(this.castScore2Percent(countItemDto.getCzjc()));
czjchege.add(this.castScore2Percent(countItemDto.getCzjchege()));
ryhg.add(this.castScore2Percent(countItemDto.getRyhg()));
sjhg.add(this.castScore2Percent(countItemDto.getSjhg()));
});
Map<String, Object> result = new HashMap<>();
result.put("xdata", xdata);
......@@ -193,6 +188,8 @@ public class AQZSDPStatisticsServiceImpl {
result.put("jianyanhege", jianyanhege);
result.put("czjc", czjc);
result.put("czjchege", czjchege);
result.put("ryhg", ryhg);
result.put("sjhg", sjhg);
return result;
}
......@@ -202,14 +199,37 @@ public class AQZSDPStatisticsServiceImpl {
return percent.toPlainString();
}
private Set<String> getLegendForCyArea() {
Set<String> legendData = new HashSet<>();
legendData.add("许可有效率");
legendData.add("使用登记办理率");
legendData.add("检验超期率");
legendData.add("检验合格率");
legendData.add("充装检查率");
legendData.add("充装检查合格率");
private Set<Map<String,String>> getLegendForCyArea() {
Set<Map<String,String>> legendData = new HashSet<>();
for (int i = 0; i < 8; i++) {
Map<String, String> map = new HashMap<>();
if (i == 0) {
map.put("dataKey", "xuke");
map.put("value", "许可有效率");
} else if (i == 1) {
map.put("dataKey", "shiyongdengji");
map.put("value", "使用登记办理率");
} else if (i == 2) {
map.put("dataKey", "jianyanchaoqi");
map.put("value", "检验超期率");
} else if (i == 3) {
map.put("dataKey", "jianyanhege");
map.put("value", "检验合格率");
} else if (i == 4) {
map.put("dataKey", "czjc");
map.put("value", "充装检查");
} else if (i == 5) {
map.put("dataKey", "czjchege");
map.put("value", "充装检查合格率");
} else if (i == 6) {
map.put("dataKey", "ryhg");
map.put("value", "人员合规率(资质有效期统计)");
} else if (i == 7) {
map.put("dataKey", "sjhg");
map.put("value", "数据合规率");
}
legendData.add(map);
}
return legendData;
}
......@@ -219,20 +239,34 @@ public class AQZSDPStatisticsServiceImpl {
Map<String, SecurityIndexCountItemDto> regionCodeSecurityIndexMap = getSecurityIndexCountItemDtoMap(regionModels);
List<Map<String, String>> data = new ArrayList<>();
List<Map<String, String>> finalData = data;
/**
* 计算权重,总分100分:
* 检验超期率、检验合格率、充装检查率、充装检查合格率,占15%
* 许可有效率、使用登记办理率、人员合规率(资质有效期统计)、数据合规率,占10%
*/
double weightTen = 0.10;
double weightFifteen = 0.15;
regionCodeSecurityIndexMap.forEach((k, v) -> {
Map<String, String> item = new HashMap<>();
item.put("name", v.getRegionName());
// 计算xuke的加权值
double xukeWeighted = Double.parseDouble(v.getXuke()) * 0.10;
// 剩余权重平均分配给四个因素,每个因素大约22.5%(但为了简化,我们这里用25%的剩余权重)
double remainingWeightPerFactor = 0.90 / 4;
// 计算其他四个因素的加权值
double jianyanchaoqiWeighted = Double.parseDouble(v.getJianyanchaoqi()) * remainingWeightPerFactor;
double jianyanhegeWeighted = Double.parseDouble(v.getJianyanhege()) * remainingWeightPerFactor;
double czjcWeighted = Double.parseDouble(v.getCzjc()) * remainingWeightPerFactor;
double czjchegeWeighted = Double.parseDouble(v.getCzjchege()) * remainingWeightPerFactor;
// 许可有效率的加权值
double xukeWeighted = Double.parseDouble(v.getXuke()) * weightTen;
// 使用登记办理率的加权值
double sydjWeighted = Double.parseDouble(v.getShiyongdengji()) * weightTen;
// 人员合规率(资质有效期统计)的加权值
double ryhgWeighted = Double.parseDouble(v.getRyhg()) * weightTen;
// 数据合规率的加权值
double sjhgWeighted = Double.parseDouble(v.getSjhg()) * weightTen;
// 检验超期率的加权值
double jianyanchaoqiWeighted = Double.parseDouble(v.getJianyanchaoqi()) * weightFifteen;
// 检验合格率的加权值
double jianyanhegeWeighted = Double.parseDouble(v.getJianyanhege()) * weightFifteen;
// 充装检查率的加权值
double czjcWeighted = Double.parseDouble(v.getCzjc()) * weightFifteen;
// 充装检查合格率的加权值
double czjchegeWeighted = Double.parseDouble(v.getCzjchege()) * weightFifteen;
// 计算总指数
double totalIndex = xukeWeighted + jianyanchaoqiWeighted + jianyanhegeWeighted + czjcWeighted + czjchegeWeighted;
double totalIndex = xukeWeighted + sydjWeighted + ryhgWeighted + sjhgWeighted + jianyanchaoqiWeighted + jianyanhegeWeighted + czjcWeighted + czjchegeWeighted;
item.put("value", String.format("%.2f", totalIndex));
finalData.add(item);
});
......@@ -303,6 +337,11 @@ public class AQZSDPStatisticsServiceImpl {
} else {
countItemDto.setCzjchege("0");
}
// todo: 7.人员合规率(资质有效期统计) 8.数据合规率需求未明确暂时都为0
// 7.人员合规率(资质有效期统计)
countItemDto.setRyhg("0");
// 8.数据合规率
countItemDto.setSjhg("0");
}
return countItemDto;
}).collect(Collectors.toList());
......@@ -467,7 +506,7 @@ public class AQZSDPStatisticsServiceImpl {
return resultMap;
}
public Map<String, Object> issueCountByMonth(String cityCode) {
public Map<String, Object> issueCountByMonth(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> resultMap = new HashMap<>();
List<Object> legendData = new ArrayList<>();
for (int i = 0; i < 2; i++) {
......@@ -482,7 +521,7 @@ public class AQZSDPStatisticsServiceImpl {
legendData.add(map);
}
resultMap.put("legendData", legendData);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
Map<String, Object> allIssueMap = new HashMap<>();
Map<String, Object> endIssueMap = new HashMap<>();
if(orgCode != null){
......@@ -634,9 +673,9 @@ public class AQZSDPStatisticsServiceImpl {
return statisticsMapper.issueMonthList(orgCode, time);
}
public Map<String, Object> issueProblemLevelCount(String cityCode) {
public Map<String, Object> issueProblemLevelCount(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> resultMap = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
String time = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
Map<String, Long> problemLevelNumMap = new LinkedHashMap<>();
if(orgCode != null){
......@@ -655,9 +694,9 @@ public class AQZSDPStatisticsServiceImpl {
return resultMap;
}
public List<Map<String, Object>> issueCompanyTop(String cityCode) {
public List<Map<String, Object>> issueCompanyTop(DPFilterParamDto dpFilterParamDto) {
List<Map<String, Object>> resultList = new ArrayList<>();
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if(orgCode == null){
return new ArrayList<>();
}
......@@ -674,12 +713,12 @@ public class AQZSDPStatisticsServiceImpl {
return resultList;
}
public List<Map<String, Object>> issueChildrenCityCountTop(String cityCode) {
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
public List<Map<String, Object>> issueChildrenCityCountTop(DPFilterParamDto dpFilterParamDto) {
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if(orgCode == null){
return new ArrayList<>();
}
List<RegionModel> regionModels = stCommonService.setRegionIfRootParentAndNoAccessIf3Level(cityCode);
List<RegionModel> regionModels = stCommonService.setRegionIfRootParentAndNoAccessIf3Level(dpFilterParamDto.getCityCode());
List<Integer> regionCodeList = regionModels.stream().map(RegionModel::getRegionCode).collect(Collectors.toList());
List<Map<String, String>> orgCodeAndCompanyCodesByCompanyCodes = statisticsMapper.getOrgCodeAndCompanyCodesByCompanyCodes(regionCodeList);
List<String> orgCodes = orgCodeAndCompanyCodesByCompanyCodes.stream().map(m -> m.get("orgCode")).collect(Collectors.toList());
......@@ -710,17 +749,14 @@ public class AQZSDPStatisticsServiceImpl {
allIssuedataMap.forEach((k, v) -> {
if (k.startsWith(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode() + ""))) {
if (null != v) {
allCount.addAndGet(Integer.valueOf(v + ""));
allCount.addAndGet(Integer.parseInt(v + ""));
}
}
});
}
if (StringUtils.isNotBlank(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode() + ""))) {
endIssuedataMap.forEach((k, v) -> {
if (k.startsWith(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode() + ""))) {
if (null != v) {
endCount.addAndGet(Integer.valueOf(v + ""));
endCount.addAndGet(Integer.parseInt(v + ""));
}
}
});
......@@ -732,7 +768,8 @@ public class AQZSDPStatisticsServiceImpl {
}
resultList.add(map);
}
resultList.sort(Comparator.comparing(m -> Double.valueOf(m.get("rate") + ""), Comparator.reverseOrder()));
resultList.sort(Comparator.comparingDouble(m -> Double.parseDouble(m.get("rate").toString())));
Collections.reverse(resultList);
for (int i = 0; i < resultList.size(); i++) {
resultList.get(i).put("sequenceNbr", (i + 1) + "");
}
......@@ -751,16 +788,17 @@ public class AQZSDPStatisticsServiceImpl {
});
}
List<Map<String, Object>> resultList = new ArrayList<>();
for (int i = 0; i < allList.size(); i++) {
for (Map<String, Object> stringObjectMap : allList) {
Map<String, Object> map = new HashMap<>();
map.put("name", IssueTypeEnum.getNameByCode(allList.get(i).get("problemTypeCode").toString()));
map.put("count", allList.get(i).get("count"));
if (null != endIssueDataMap.get(allList.get(i).get("problemTypeCode").toString())) {
map.put("rate", new DecimalFormat("0.00").format(Double.parseDouble(endIssueDataMap.get(allList.get(i).get("problemTypeCode").toString()) + "") / (Double.parseDouble(allList.get(i).get("count") + ""))));
map.put("name", IssueTypeEnum.getNameByCode(stringObjectMap.get("problemTypeCode").toString()));
map.put("count", stringObjectMap.get("count"));
if (null != endIssueDataMap.get(stringObjectMap.get("problemTypeCode").toString())) {
map.put("rate", new DecimalFormat("0.00").format(Double.parseDouble(endIssueDataMap.get(stringObjectMap.get("problemTypeCode").toString()) + "") / (Double.parseDouble(stringObjectMap.get("count") + ""))));
} else {
map.put("rate", "0");
}
resultList.add(map);
}
return resultList;
}
......
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