Commit 0b69f7cb 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 bef1e35b 74e28bcd
...@@ -555,6 +555,8 @@ ...@@ -555,6 +555,8 @@
-- 保证使用单位选择设备时(record为null) 能选择到本单位的设备 并且 监管单位在查看时(record 不为null)可以匹配到所有的设备 -- 保证使用单位选择设备时(record为null) 能选择到本单位的设备 并且 监管单位在查看时(record 不为null)可以匹配到所有的设备
<if test="jsonObject.useUnitCreditCode != null and jsonObject.useUnitCreditCode != '' and jsonObject.record == null"> <if test="jsonObject.useUnitCreditCode != null and jsonObject.useUnitCreditCode != '' and jsonObject.record == null">
and ui."USE_UNIT_CREDIT_CODE" = #{jsonObject.useUnitCreditCode} and ui."USE_UNIT_CREDIT_CODE" = #{jsonObject.useUnitCreditCode}
-- 限制 没有做过使用登记的
and (ri."USE_ORG_CODE" is null or ri."USE_ORG_CODE" = '')
</if> </if>
<choose> <choose>
<when test="jsonObject.record != null and jsonObject.record != ''"> <when test="jsonObject.record != null and jsonObject.record != ''">
......
package com.yeejoin.amos.boot.module.statistics.api.mapper; package com.yeejoin.amos.boot.module.statistics.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.entity.AlertStatistics; import com.yeejoin.amos.boot.module.common.api.entity.AlertStatistics;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* Mapper 接口 * Mapper 接口
* *
...@@ -24,4 +27,14 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> { ...@@ -24,4 +27,14 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
String getOrgCodeByCompanyCode(String cityCode); String getOrgCodeByCompanyCode(String cityCode);
Long countEmergencyEventsByOrgCodeAndDate(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto); Long countEmergencyEventsByOrgCodeAndDate(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto);
List<CountDto>countEmergencyEventsByOrgCodeAndDate2(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto);
/**
* 统计被困人数
* @param orgCode 区域对应的orgCode
* @param filterParamDto 日期
* @return 被困人数
*/
Long countRescuedPersonNum(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto);
} }
...@@ -127,4 +127,45 @@ ...@@ -127,4 +127,45 @@
and date_le(CAST(call_time as date),#{dto.endDate}) and date_le(CAST(call_time as date),#{dto.endDate})
</if> </if>
</select> </select>
<select id="countRescuedPersonNum" resultType="java.lang.Long">
SELECT
sum(field_value)
FROM tz_alert_form_value
WHERE
alert_called_id
IN (
SELECT
sequence_nbr
FROM
tz_alert_called
WHERE
biz_org_code like concat(#{orgCode}, '%')
<if test="dto.beginDate !=null and dto.beginDate !=''">
and date_ge(CAST(call_time as date),#{dto.beginDate})
</if>
<if test="dto.endDate !=null and dto.endDate !=''">
and date_le(CAST(call_time as date),#{dto.endDate})
</if>
AND alarm_type_code = '960'
AND father_alert IS NULL
)
AND field_code = 'trapped_num'
</select>
<select id="countEmergencyEventsByOrgCodeAndDate2" resultType="com.yeejoin.amos.boot.biz.common.dto.CountDto">
SELECT
ifnull (SUM ( CASE WHEN father_alert IS NULL THEN 1 ELSE 0 END ), 0) AS total as longValue,
alarm_type_code as keyStr,
FROM
tz_alert_called
WHERE
biz_org_code like concat(#{orgCode}, '%')
and (alarm_type_code = '960' or alarm_type_code = '961' or alarm_type_code = '962')
<if test="dto.beginDate !=null and dto.beginDate !=''">
and date_ge(CAST(call_time as date),#{dto.beginDate})
</if>
<if test="dto.endDate !=null and dto.endDate !=''">
and date_le(CAST(call_time as date),#{dto.endDate})
</if>
group by alarm_type_code
</select>
</mapper> </mapper>
...@@ -4,15 +4,20 @@ import cn.hutool.core.date.DateTime; ...@@ -4,15 +4,20 @@ import cn.hutool.core.date.DateTime;
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;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.entity.AlertRescueStatistics; import com.yeejoin.amos.boot.module.common.api.entity.AlertRescueStatistics;
import com.yeejoin.amos.boot.module.common.api.entity.AlertUseUnitStatistics; import com.yeejoin.amos.boot.module.common.api.entity.AlertUseUnitStatistics;
import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum;
import com.yeejoin.amos.boot.module.statistics.api.dto.AlertUseUnitStatisticsDto; import com.yeejoin.amos.boot.module.statistics.api.dto.AlertUseUnitStatisticsDto;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertRescueStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertRescueStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertUseUnitStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertUseUnitStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.AlertPaperInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.DispatchPaper; import com.yeejoin.amos.boot.module.ymt.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.ymt.api.entity.MainParts;
import com.yeejoin.amos.boot.module.ymt.api.enums.DispatchPaperEnums;
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.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.AlertCalledMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.DispatchPaperMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.DispatchPaperMapper;
...@@ -25,12 +30,18 @@ import com.yeejoin.amos.feign.systemctl.model.RegionModel; ...@@ -25,12 +30,18 @@ import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser; 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.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest; import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse; import org.elasticsearch.client.core.CountResponse;
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.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil; import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
...@@ -71,6 +82,11 @@ public class YJDPStatisticsServiceImpl { ...@@ -71,6 +82,11 @@ public class YJDPStatisticsServiceImpl {
private StCommonServiceImpl stCommonService; private StCommonServiceImpl stCommonService;
/**
* 电梯设备品种
*/
private final String ELEVATOR_EQU_DEFINE_CODES = "3410,3420,3430,3310,3320,3210,3220,3120,3130,3110";
public YJDPStatisticsServiceImpl(AlertCalledMapper alertCalledMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper, DispatchTaskMapper dispatchTaskMapper, DispatchPaperMapper dispatchPaperMapper, RestHighLevelClient restHighLevelClient, StCommonServiceImpl stCommonService) { public YJDPStatisticsServiceImpl(AlertCalledMapper alertCalledMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper, DispatchTaskMapper dispatchTaskMapper, DispatchPaperMapper dispatchPaperMapper, RestHighLevelClient restHighLevelClient, StCommonServiceImpl stCommonService) {
this.alertCalledMapper = alertCalledMapper; this.alertCalledMapper = alertCalledMapper;
...@@ -288,7 +304,7 @@ public class YJDPStatisticsServiceImpl { ...@@ -288,7 +304,7 @@ public class YJDPStatisticsServiceImpl {
return maps; return maps;
} }
public JSONObject regionEventRank(DPFilterParamDto dpFilterParamDto) throws Exception { public JSONObject regionEventRank(DPFilterParamDto dpFilterParamDto) {
List<RegionModel> childRegion = stCommonService.setRegionIfRootParent(dpFilterParamDto); List<RegionModel> childRegion = stCommonService.setRegionIfRootParent(dpFilterParamDto);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -364,40 +380,42 @@ public class YJDPStatisticsServiceImpl { ...@@ -364,40 +380,42 @@ public class YJDPStatisticsServiceImpl {
private Map<String, Object> getCenterMapOverviewData(String orgCode, DPFilterParamDto filterParamDto) { private Map<String, Object> getCenterMapOverviewData(String orgCode, DPFilterParamDto filterParamDto) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// 统计完成的事件包括困人、故障 // 统计完成的事件包括困人、故障、投诉咨询
Long num = alertStatisticsMapper.countEmergencyEventsByOrgCodeAndDate(orgCode, filterParamDto); List<CountDto> countDtos = alertStatisticsMapper.countEmergencyEventsByOrgCodeAndDate2(orgCode, filterParamDto);
Map<String, Long> alertTypeNumMap = countDtos.stream().collect(Collectors.toMap(CountDto::getKeyStr, CountDto::getLongValue));
Map<String, Long> equDefineNumMap = staticsElevatorByEquDefine(filterParamDto.getCityCode());
// 电梯总量(台) // 电梯总量(台)
result.put("dtCount", num); result.put("dtCount", equDefineNumMap.values().stream().mapToLong(e->e).sum());
// 曳引驱动乘客电梯(台) // 曳引驱动乘客电梯(台)
result.put("zyqdcjdtCount", num); result.put("zyqdcjdtCount", equDefineNumMap.getOrDefault("3110",0L));
// 曳引驱动载货电梯(台) // 曳引驱动载货电梯(台)
result.put("zyqdzhdtCount", num); result.put("zyqdzhdtCount",equDefineNumMap.getOrDefault("3120",0L));
// 强制驱动载货电梯(台) // 强制驱动载货电梯(台)
result.put("qzqdzgdtCount", num); result.put("qzqdzgdtCount", equDefineNumMap.getOrDefault("3130",0L));
// 液压乘客电梯(台) // 液压乘客电梯(台)
result.put("yackdtount", num); result.put("yackdtount", equDefineNumMap.getOrDefault("3210",0L));
// 液压载货电梯(台) // 液压载货电梯(台)
result.put("yyzhdtCount", num); result.put("yyzhdtCount", equDefineNumMap.getOrDefault("3220",0L));
// 自动扶梯(台) // 自动扶梯(台)
result.put("zdftCount", num); result.put("zdftCount", equDefineNumMap.getOrDefault("3310",0L));
// 自动人行道(台) // 自动人行道(台)
result.put("zdrxdCount", num); result.put("zdrxdCount", equDefineNumMap.getOrDefault("3320",0L));
// 防爆电梯(台) // 防爆电梯(台)
result.put("fbdtCount", num); result.put("fbdtCount", equDefineNumMap.getOrDefault("3410",0L));
// 消防员电梯(台) // 消防员电梯(台)
result.put("xfydtCount", num); result.put("xfydtCount", equDefineNumMap.getOrDefault("3420",0L));
// 杂物电梯(台) // 杂物电梯(台)
result.put("zhdtCount", num); result.put("zhdtCount", equDefineNumMap.getOrDefault("3430",0L));
// 应急事件(起) // 应急事件(起)
result.put("alarmCount", num); result.put("alarmCount", alertTypeNumMap.get(DispatchPaperEnums.KRJY.getId()) + alertTypeNumMap.get(DispatchPaperEnums.GZWX.getId()));
// 困人救援事件(起) // 困人救援事件(起)
result.put("krjysjCount", num); result.put("krjysjCount", alertTypeNumMap.get(DispatchPaperEnums.KRJY.getId()));
// 故障维修(起) // 故障维修(起)
result.put("gzwxCount", num); result.put("gzwxCount", alertTypeNumMap.get(DispatchPaperEnums.GZWX.getId()));
// 投诉咨询(起) // 投诉咨询(起)
result.put("tszxCount", num); result.put("tszxCount", alertTypeNumMap.get(DispatchPaperEnums.TSZX.getId()));
// 解救被困乘客数(人) // 解救被困乘客数(人)
result.put("jjbkcksCount", num); result.put("jjbkcksCount", alertStatisticsMapper.countRescuedPersonNum(orgCode,filterParamDto));
return result; return result;
} }
...@@ -435,4 +453,35 @@ public class YJDPStatisticsServiceImpl { ...@@ -435,4 +453,35 @@ public class YJDPStatisticsServiceImpl {
} }
return num; return num;
} }
private Map<String, Long> staticsElevatorByEquDefine(String regionCode) {
String orgCode = stCommonService.getAndSetOrgCode(regionCode);
Map<String, Long> countMap = new HashMap<>();
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 且在用状态设备
boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust);
// 原因默认10个,由于业务最多有10个,担心有脏数据,故多查询
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_define_code").field("EQU_DEFINE_CODE.keyword").size(20);
builder.aggregation(aggregationBuilder);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_define_code");
for (Terms.Bucket bucket : terms.getBuckets()) {
// 按照真实的过滤,防止有脏数据
if(ELEVATOR_EQU_DEFINE_CODES.contains(bucket.getKeyAsString())){
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return countMap;
}
} }
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