Commit d6529315 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 04e2d972 8d669ef2
package com.yeejoin.amos.boot.biz.common.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Administrator
*/
@Data
@ApiModel
public class CountDto {
@ApiModelProperty(value = "数据标识")
private String key;
@ApiModelProperty(value = "描述")
private String label;
@ApiModelProperty(value = "值-字符串类型")
private String strValue;
@ApiModelProperty(value = "值-整型类型")
private int intValue;
@ApiModelProperty(value = "值-长整型类型")
private long longValue;
}
...@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.jg.api.enums; ...@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.jg.api.enums;
import lombok.Getter; import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
/** /**
* @author Administrator * @author Administrator
*/ */
...@@ -11,27 +14,35 @@ public enum DPMapStatisticsItemEnum { ...@@ -11,27 +14,35 @@ public enum DPMapStatisticsItemEnum {
* 大屏统计项 * 大屏统计项
*/ */
TOTAL("特种设备总量 (台)", "total"), TOTAL("特种设备总量 (台)", "total", ""),
GAS("气瓶 (台)", "gas"), GAS("气瓶 (台)", "gas", ""),
ELEVATORS("电梯 (台)", "elevators"), ELEVATORS("电梯 (台)", "elevators", "3000"),
PRESSURE_VESSELS("压力容器 (台)", "pressureVessels"), PRESSURE_VESSELS("压力容器 (台)", "pressureVessels", "2000"),
ON_SITE_MOTOR_VEHICLES("场(厂)内机动车 (台)", "onSiteMotorVehicles"), ON_SITE_MOTOR_VEHICLES("场(厂)内机动车 (台)", "onSiteMotorVehicles", "5000"),
BOILERS("锅炉 (台)", "boilers"), BOILERS("锅炉 (台)", "boilers", "1000"),
LIFTING_MACHINERY("起重机械 (台)", "liftingMachinery"), LIFTING_MACHINERY("起重机械 (台)", "liftingMachinery", "4000"),
LARGE_AMUSEMENT_FACILITIES("大型游乐设施 (台)", "largeAmusementFacilities"), LARGE_AMUSEMENT_FACILITIES("大型游乐设施 (台)", "largeAmusementFacilities", "6000"),
PRESSURE_PIPELINES("压力管道 (千米)", "pressurePipelines"), PRESSURE_PIPELINES("压力管道 (千米)", "pressurePipelines", "8000"),
PASSENGER_ROPEWAYS("客运索道 (台)", "passengerRopeways"), PASSENGER_ROPEWAYS("客运索道 (台)", "passengerRopeways", "9000"),
MANUFACTURING_UNITS("制造单位 (家)", "manufacturingUnits"), MANUFACTURING_UNITS("制造单位 (家)", "manufacturingUnits", ""),
CONSTRUCTION_UNITS("安改维单位 (家)", "constructionUnits"), CONSTRUCTION_UNITS("安改维单位 (家)", "constructionUnits", ""),
USERS_UNITS("使用单位 (家)", "usersUnits"), USERS_UNITS("使用单位 (家)", "usersUnits", ""),
GAS_UNITS("充装单位 (家)", "gasUnits"), GAS_UNITS("充装单位 (家)", "gasUnits", ""),
OPERATORS("作业人员 (人)", "operators"); OPERATORS("作业人员 (人)", "operators", "");
private String label; private String label;
private String code; private String code;
private String category;
DPMapStatisticsItemEnum(String label, String code) { DPMapStatisticsItemEnum(String label, String code, String category) {
this.label = label; this.label = label;
this.code = code; this.code = code;
this.category = category;
}
public static DPMapStatisticsItemEnum getInstanceByCategory(String category) {
Optional<DPMapStatisticsItemEnum> op = Arrays.stream(DPMapStatisticsItemEnum.values()).filter(e -> e.category.equals(category)).findAny();
return op.orElseThrow(() -> new RuntimeException("未知的类型"));
} }
} }
...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper; ...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgScrapCancelMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgScrapCancelMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
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.mapper.EquipTechParamPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -63,6 +64,8 @@ public class DPStatisticsServiceImpl { ...@@ -63,6 +64,8 @@ public class DPStatisticsServiceImpl {
private JgUseRegistrationMapper useRegistrationMapper; private JgUseRegistrationMapper useRegistrationMapper;
private EquipTechParamPipelineMapper techParamsPipelineMapper;
private JgEnableDisableMapper enableDisableMapper; private JgEnableDisableMapper enableDisableMapper;
private JgScrapCancelMapper scrapCancelMapper; private JgScrapCancelMapper scrapCancelMapper;
...@@ -72,9 +75,10 @@ public class DPStatisticsServiceImpl { ...@@ -72,9 +75,10 @@ public class DPStatisticsServiceImpl {
private static List<EquipmentCategoryDto> equipmentCategoryDtos; private static List<EquipmentCategoryDto> equipmentCategoryDtos;
public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient) { public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient) {
this.equipmentCategoryMapper = equipmentCategoryMapper; this.equipmentCategoryMapper = equipmentCategoryMapper;
this.useRegistrationMapper = useRegistrationMapper; this.useRegistrationMapper = useRegistrationMapper;
this.techParamsPipelineMapper = techParamsPipelineMapper;
this.enableDisableMapper = enableDisableMapper; this.enableDisableMapper = enableDisableMapper;
this.scrapCancelMapper = scrapCancelMapper; this.scrapCancelMapper = scrapCancelMapper;
this.restHighLevelClient = restHighLevelClient; this.restHighLevelClient = restHighLevelClient;
...@@ -174,8 +178,10 @@ public class DPStatisticsServiceImpl { ...@@ -174,8 +178,10 @@ public class DPStatisticsServiceImpl {
public Map<String, Object> getCenterMapCountDataForGlobal(DPFilterParamDto dpFilterParamDto) { public Map<String, Object> getCenterMapCountDataForGlobal(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
//1.8大类设备数量统计 // 1.气瓶数量统计
this.staticsCenterMapCountDataForEquip(result, dpFilterParamDto); long cylinderNum = this.staticsCenterMapCountDataForCylinder(result, dpFilterParamDto);
//1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
this.staticsCenterMapCountDataForEquip(result, dpFilterParamDto, cylinderNum);
//2.压力管道长度统计 //2.压力管道长度统计
this.staticsCenterMapCountDataForPipeline(result, dpFilterParamDto); this.staticsCenterMapCountDataForPipeline(result, dpFilterParamDto);
//3.单位数量统计 //3.单位数量统计
...@@ -191,7 +197,8 @@ public class DPStatisticsServiceImpl { ...@@ -191,7 +197,8 @@ public class DPStatisticsServiceImpl {
private void staticsCenterMapCountDataForCompany(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) { private void staticsCenterMapCountDataForCompany(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
} }
private void staticsCenterMapCountDataForPipeline(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) { private long staticsCenterMapCountDataForCylinder(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
long num = 0;
CountRequest request = new CountRequest(); CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
...@@ -203,14 +210,21 @@ public class DPStatisticsServiceImpl { ...@@ -203,14 +210,21 @@ public class DPStatisticsServiceImpl {
boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true)); boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true));
try { try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT); CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
result.put(DPMapStatisticsItemEnum.GAS.getCode(), response.getCount()); num = response.getCount();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
result.put(DPMapStatisticsItemEnum.GAS.getCode(), num);
return num;
}
private void staticsCenterMapCountDataForPipeline(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
String length = techParamsPipelineMapper.sumPipeLengthByArea(dpFilterParamDto.getCityCode());
result.put(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCode(), length);
} }
private void staticsCenterMapCountDataForEquip(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) { private void staticsCenterMapCountDataForEquip(Map<String, Object> result, DPFilterParamDto dpFilterParamDto, long cylinderNum) {
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
...@@ -226,13 +240,28 @@ public class DPStatisticsServiceImpl { ...@@ -226,13 +240,28 @@ public class DPStatisticsServiceImpl {
try { try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT); SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_list_code"); Terms terms = response.getAggregations().get("count_by_equ_list_code");
Map<String, Long> countMap = new HashMap<>();
for (Terms.Bucket bucket : terms.getBuckets()) { for (Terms.Bucket bucket : terms.getBuckets()) {
log.info(bucket.getKeyAsString()); // 压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
log.info(String.valueOf(bucket.getDocCount())); if (bucket.getKeyAsString().equals(EQU_LIST_CYLINDER)) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount() - cylinderNum);
} else {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
} }
// 按照8大类枚举,进行加工。目的:固定八大类防止没统计数据导致缺少分类、将设备种类的code换成前端定义的key
equipmentCategoryDtos.forEach(c -> {
result.put(this.castCategoryCode2WebCode(c.getCode()), countMap.getOrDefault(c.getCode(), 0L));
});
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
result.remove(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCategory());
}
private String castCategoryCode2WebCode(String category) {
DPMapStatisticsItemEnum itemEnum = DPMapStatisticsItemEnum.getInstanceByCategory(category);
return itemEnum.getCode();
} }
public Map<String, Object> useRegisterCount(DPFilterParamDto dpFilterParamDto) { public Map<String, Object> useRegisterCount(DPFilterParamDto dpFilterParamDto) {
......
...@@ -7,8 +7,17 @@ import org.apache.ibatis.annotations.Param; ...@@ -7,8 +7,17 @@ import org.apache.ibatis.annotations.Param;
public interface EquipTechParamPipelineMapper extends BaseMapper<EquipTechParamPipeline> { public interface EquipTechParamPipelineMapper extends BaseMapper<EquipTechParamPipeline> {
/** /**
* 在用的最新需求整理的技术参数--需求未出 * 在用的最新需求整理的技术参数--需求未出
*
* @param record 设备唯一标识 * @param record 设备唯一标识
* @return EquipTechParamVessel * @return EquipTechParamVessel
*/ */
EquipTechParamPipeline queryTechParamInUse(@Param("record") String record); EquipTechParamPipeline queryTechParamInUse(@Param("record") String record);
/**
* 统计压力管道长度
*
* @param cityCode 区域code
* @return 数量
*/
String sumPipeLengthByArea(String cityCode);
} }
...@@ -25,4 +25,26 @@ ...@@ -25,4 +25,26 @@
WHERE WHERE
RECORD = #{record} RECORD = #{record}
</select> </select>
<select id="sumPipeLengthByArea" resultType="java.lang.String">
select
round(sum(p."PIPE_LENGTH"), 2) as PIPE_LENGTH
from
idx_biz_jg_tech_params_pipeline p,
(
SELECT
ri."RECORD",
concat(ui.PROVINCE,'#', ui.CITY,'#', ui.COUNTY) as areaCode
FROM "idx_biz_jg_register_info" ri,
idx_biz_jg_use_info ui
where
ri."EQU_LIST" = '8000'
and ri."RECORD" = ui."RECORD"
and ui."PROVINCE" <![CDATA[<>]]> ''
and ui."CITY" <![CDATA[<>]]>''
and ui."COUNTY" <![CDATA[<>]]> ''
and ui.IS_INTO_MANAGEMENT =true
) a
where
p."RECORD" = a."RECORD" and c.areaCode like concat('%',#{cityCode}, '%')
</select>
</mapper> </mapper>
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