Commit 82b8a984 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 78944699 ca1aa81f
......@@ -43,6 +43,23 @@ public interface AlertCalledMapper extends BaseMapper<AlertCalled> {
* @param endDate
* @return
*/
List<Map<String, Object>> queryNearlyList(@Param("beginDate") String beginDate,
@Param("endDate") String endDate,
@Param("regionCode") String regionCode
);
/**
* 接警情况统计(按场所)
*
* @return
*/
List<Map<String, Object>> queryListByLocation(@Param("regionCode") String regionCode);
/**
* 接警情况统计
*
* @param beginDate
* @param endDate
* @return
*/
Map<String, Long> queryAlertStatusCount(@Param("beginDate") String beginDate,
@Param("endDate") String endDate,
@Param("groupCode") String groupCode,
......
......@@ -20,4 +20,6 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
Long countProblemByTypeDateAndOrgCode(@Param("problemType") String problemType,@Param("dto") DPFilterParamDto params, @Param("orgCode") String orgCode);
String getOrgCodeByCompanyCode(String cityCode);
Long countEmergencyEventsByOrgCodeAndDate(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto);
}
package com.yeejoin.amos.boot.module.elevator.api.mapper;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-12-13
*/
@Mapper
public interface YjBaseMapper {
CompanyModel selectOneCompanyByCode(String companyCode);
String getOrgCodeByCompanyCode(String companyCode);
}
......@@ -122,6 +122,41 @@
</if>
</select>
<select id="queryNearlyList" resultType="java.util.Map">
SELECT
date_format (call_time, '%Y-%m-%d') AS day,
alarm_type as alarmType,
ifnull ( SUM ( CASE WHEN father_alert IS NULL THEN 1 ELSE 0 END ), 0) AS majorAlertCount
FROM
tz_alert_called
WHERE
biz_org_code like concat(#{regionCode}, '%')
AND day BETWEEN #{beginDate} AND #{endDate}
GROUP BY
day, alarm_type
ORDER BY
day ASC
</select>
<select id="queryListByLocation" resultType="java.util.Map">
SELECT
ifnull ( SUM ( CASE WHEN father_alert IS NULL THEN 1 ELSE 0 END ), 0 ) AS majorAlertCount,
cdd.NAME as name
FROM
tz_alert_called tac
LEFT JOIN idx_biz_jg_use_info ibjuj ON tac.equipment_id = ibjuj.RECORD
LEFT JOIN cb_data_dictionary cdd ON ibjuj.USE_PLACE = cdd.sequence_nbr
WHERE
biz_org_code LIKE concat(#{regionCode}, '%')
AND (tac.alarm_type_code = '960' or tac.alarm_type_code = '961')
AND
ibjuj.USE_PLACE is NOT NULL
AND cdd.NAME is NOT NULL
GROUP BY
cdd.NAME
ORDER BY ibjuj.USE_PLACE ASC
</select>
<select id="queryAlertListByQueryDto" resultType="java.util.Map">
SELECT
a.sequence_nbr AS sequenceNbr,
......
......@@ -112,4 +112,19 @@
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{companyCode} limit 1
</select>
<select id="countEmergencyEventsByOrgCodeAndDate" resultType="java.lang.Long">
SELECT
ifnull (SUM ( CASE WHEN father_alert IS NULL THEN 1 ELSE 0 END ), 0) AS total
FROM
tz_alert_called
WHERE
biz_org_code like concat(#{orgCode}, '%')
and (alarm_type_code = '960' or alarm_type_code = '961')
<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>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.elevator.api.mapper.YjBaseMapper">
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{companyCode} limit 1
</select>
</mapper>
package com.yeejoin.amos.boot.module.elevator.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertMaintenanceUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertMsgDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertUseUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.biz.service.impl.DPStatisticsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
/**
* 大屏统计controller
*
* @author Administrator
*/
@RestController
@RequestMapping("/db/statistics")
@Api(tags = "大屏统计")
public class DPStatisticsController {
private DPStatisticsServiceImpl statisticsService;
public DPStatisticsController(DPStatisticsServiceImpl statisticsService) {
this.statisticsService = statisticsService;
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-办理量 (近7日)", notes = "大屏-应急-办理量 (近7日)")
@PostMapping(value = "/yj/eventStatByDay")
public ResponseModel<JSONObject> eventStatByDay(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.eventStatByDay(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-电梯数量统计 (按区域)", notes = "大屏-应急-电梯数量统计 (按区域)")
@PostMapping(value = "/yj/elevatorCountStat")
public ResponseModel<JSONObject> elevatorCountStat(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.elevatorCountStat(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-事件分布 (按场所)", notes = "大屏-应急-事件分布 (按场所)")
@PostMapping(value = "/yj/eventStatByLocation")
public ResponseModel<JSONObject> eventStatByLocation(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.eventStatByLocation(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-困人救援月度情况", notes = "大屏-应急-困人救援月度情况")
@PostMapping(value = "/yj/trappedUserCount")
public ResponseModel<JSONObject> trappedUserCount(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.trappedUserCount(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-即时警情列表", notes = "大屏-应急-即时警情列表")
@PostMapping(value = "/yj/instantAlert")
public ResponseModel<List<AlertPaperInfoDto>> instantAlert(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.instantAlert(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-月度困人故障高发使用单位", notes = "大屏-应急-月度困人故障高发使用单位")
@PostMapping(value = "/yj/trappedUserHighCompanyCount")
public ResponseModel<List<AlertUseUnitStatisticsDto>> trappedUserHighCompanyCount(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.trappedUserHighCompanyCount(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-维保单位平均救援时间排名", notes = "大屏-应急-维保单位平均救援时间排名")
@PostMapping(value = "/yj/rankUnitByRescueTime")
public ResponseModel<List<AlertMaintenanceUnitStatisticsDto>> rankUnitByRescueTime(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.rankUnitByRescueTime(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-各地市应急事件总数排名", notes = "大屏-应急-各地市应急事件总数排名")
@PostMapping(value = "/yj/regionEventRank")
public ResponseModel<JSONObject> regionEventRank(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.regionEventRank(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-中间地图图列统计", notes = "大屏-应急-中间地图图列统计")
@PostMapping(value = "/yj/center-map/legend")
public ResponseModel<Map<String, Object>> centerMapCountForGlobal(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForGlobal(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-中间地图地市统计", notes = "大屏总览中间-地图地市统计")
@PostMapping(value = "/yj/center-map/overview")
public ResponseModel<List<Map<String, Object>>> centerMapCountForOverview(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForOverview(dpFilterParamDto));
}
}
package com.yeejoin.amos.boot.module.elevator.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.enums.ReginStepEnum;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertMaintenanceUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertUseUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertMaintenanceUnitStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertRescueStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertUseUnitStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.Elevator;
import com.yeejoin.amos.boot.module.elevator.api.mapper.*;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 大屏统计实现类
*
* @author Administrator
*/
@Service
@Slf4j
public class DPStatisticsServiceImpl {
private YjBaseMapper yjBaseMapper;
private AlertCalledMapper alertCalledMapper;
private ElevatorMapper elevatorMapper;
private AlertRescueStatisticsMapper alertRescueStatisticsMapper;
private AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper;
private AlertMaintenanceUnitStatisticsMapper alertMaintenanceUnitStatisticsMapper;
private AlertStatisticsMapper alertStatisticsMapper;
@Autowired
AlertCalledServiceImpl alertCalledService;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
private static Map<String, List<RegionModel>> regionChildRegionMap = new ConcurrentHashMap<>();
public DPStatisticsServiceImpl(YjBaseMapper yjBaseMapper, AlertCalledMapper alertCalledMapper, ElevatorMapper elevatorMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertMaintenanceUnitStatisticsMapper alertMaintenanceUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper) {
this.yjBaseMapper = yjBaseMapper;
this.alertCalledMapper = alertCalledMapper;
this.elevatorMapper = elevatorMapper;
this.alertRescueStatisticsMapper = alertRescueStatisticsMapper;
this.alertUseUnitStatisticsMapper = alertUseUnitStatisticsMapper;
this.alertMaintenanceUnitStatisticsMapper = alertMaintenanceUnitStatisticsMapper;
this.alertStatisticsMapper = alertStatisticsMapper;
}
public JSONObject eventStatByDay(DPFilterParamDto dpFilterParamDto) throws Exception {
String beginDate = DateUtil.formatDate(DateTimeUtil.addDays(new Date(), -6), DateUtil.Y_M_D);
String endDate = DateUtil.getNow(DateUtil.Y_M_D);
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
List<String> everyDay = this.getEveryDay(beginDate, endDate);
JSONObject jsonObject = this.buildLegendData(null, "trapped", "困人");
this.buildLegendData(jsonObject, "complaint", "投诉");
this.buildLegendData(jsonObject, "fault", "故障");
List<String> xdata = new ArrayList<>();
List<Object> trapped = new ArrayList<>();
List<Object> complaint = new ArrayList<>();
List<Object> fault = new ArrayList<>();
List<Map<String, Object>> maps = alertCalledMapper.queryNearlyList(beginDate, endDate, orgCode);
everyDay.stream().forEach(day -> {
try {
xdata.add(DateUtil.formatDate(DateUtil.formatStringToDate(day, DateUtil.Y_M_D), "MM.dd"));
} catch (Exception e) {
throw new RuntimeException(e);
}
Map<String, Object> map = maps.stream().filter(x -> day.equals(x.get("day"))).collect(Collectors.toMap(
item -> (String) item.get("alarmType"),
item -> item.get("majorAlertCount")));
trapped.add(!ValidationUtil.isEmpty(map.get("困人救援")) ? Integer.valueOf(map.get("困人救援").toString()) : 0);
complaint.add(!ValidationUtil.isEmpty(map.get("投诉咨询")) ? Integer.valueOf(map.get("投诉咨询").toString()) : 0);
fault.add(!ValidationUtil.isEmpty(map.get("故障维修")) ? Integer.valueOf(map.get("故障维修").toString()) : 0);
});
jsonObject.put("xdata", xdata);
jsonObject.put("trapped", trapped);
jsonObject.put("complaint", complaint);
jsonObject.put("fault", fault);
return jsonObject;
}
public JSONObject elevatorCountStat(DPFilterParamDto dpFilterParamDto) throws Exception {
String regionCode = dpFilterParamDto.getCityCode();
List<RegionModel> regionList = this.getRegionList(dpFilterParamDto);
List<String> xdata = regionList.stream().map(r -> r.getRegionName().toString()).collect(Collectors.toList());
if (!regionCode.equals("610000")){
regionCode = "610000#" + regionCode;
}
List<Integer> ydata = new ArrayList<>();
String finalRegionCode = regionCode;
regionList.stream().forEach(x -> {
LambdaQueryWrapper<Elevator> lambda = new QueryWrapper<Elevator>().lambda();
lambda.eq(Elevator::getRegionCode, finalRegionCode + "#" + x.getRegionCode());
ydata.add(elevatorMapper.selectCount(lambda));
});
JSONObject jsonObject = new JSONObject();
jsonObject.put("xdata", xdata);
jsonObject.put("ydata", ydata);
return jsonObject;
}
public JSONObject eventStatByLocation(DPFilterParamDto dpFilterParamDto) throws Exception {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
List<Map<String, Object>> maps = alertCalledMapper.queryListByLocation(orgCode);
List<Object> xdata = maps.stream().map(item -> item.get("name")).collect(Collectors.toList());
List<Object> ydata = maps.stream().map(item -> item.get("majorAlertCount")).collect(Collectors.toList());
JSONObject jsonObject = new JSONObject();
jsonObject.put("xdata", xdata);
jsonObject.put("ydata", ydata);
return jsonObject;
}
public List<AlertPaperInfoDto> instantAlert(DPFilterParamDto dpFilterParamDto) throws Exception {
List<String> regionCodes = new ArrayList<>();
regionCodes.add(dpFilterParamDto.getCityCode());
List<AlertPaperInfoDto> alertPaperInfoDtoList = alertCalledService.getAlertPaperInfoList(alertCalledService.authRegionCodeList(regionCodes), false);
return alertPaperInfoDtoList;
}
public JSONObject trappedUserCount(DPFilterParamDto dpFilterParamDto) throws Exception {
String date = DateUtil.formatDate(new Date(), "yyyy-MM");
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
LambdaQueryWrapper<AlertRescueStatistics> lambda = new QueryWrapper<AlertRescueStatistics>().lambda();
lambda.likeLeft(AlertRescueStatistics::getSupervisoryUnitOrgCode, orgCode);
lambda.eq(AlertRescueStatistics::getStatisticsDate, date);
List<AlertRescueStatistics> alertRescueStatistics = alertRescueStatisticsMapper.selectList(lambda);
List<Long> ydata = new ArrayList<>();
ydata.add(alertRescueStatistics.stream().collect(Collectors.summingLong(AlertRescueStatistics::getLessNum)));
ydata.add(alertRescueStatistics.stream().collect(Collectors.summingLong(AlertRescueStatistics::getGreaterNum)));
ydata.add(alertRescueStatistics.stream().collect(Collectors.summingLong(AlertRescueStatistics::getLevelOne)));
ydata.add(alertRescueStatistics.stream().collect(Collectors.summingLong(AlertRescueStatistics::getLevelTwo)));
ydata.add(alertRescueStatistics.stream().collect(Collectors.summingLong(AlertRescueStatistics::getLevelThree)));
JSONObject jsonObject = new JSONObject();
jsonObject.put("xdata", Arrays.asList("30分钟内到达次数", "超过30分钟到次数", "一级救援次数", "二级救援次数", "三级救援次数"));
jsonObject.put("ydata", ydata);
return jsonObject;
}
public List<AlertUseUnitStatisticsDto> trappedUserHighCompanyCount(DPFilterParamDto dpFilterParamDto) throws Exception {
String date = DateUtil.formatDate(new Date(), "yyyy-MM");
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
LambdaQueryWrapper<AlertUseUnitStatistics> lambda = new QueryWrapper<AlertUseUnitStatistics>().lambda();
lambda.likeLeft(AlertUseUnitStatistics::getSupervisoryUnitOrgCode, orgCode);
lambda.eq(AlertUseUnitStatistics :: getStatisticsDate, date);
List<AlertUseUnitStatistics> alertUseUnitStatistics = alertUseUnitStatisticsMapper.selectList(lambda);
return Bean.toModels(alertUseUnitStatistics, AlertUseUnitStatisticsDto.class);
}
public List<AlertMaintenanceUnitStatisticsDto> rankUnitByRescueTime(DPFilterParamDto dpFilterParamDto) throws Exception {
String date = DateUtil.formatDate(new Date(), "yyyy-MM");
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
LambdaQueryWrapper<AlertMaintenanceUnitStatistics> lambda = new QueryWrapper<AlertMaintenanceUnitStatistics>().lambda();
lambda.likeLeft(AlertMaintenanceUnitStatistics::getSupervisoryUnitOrgCode, orgCode);
lambda.eq(AlertMaintenanceUnitStatistics :: getStatisticsDate, date);
List<AlertMaintenanceUnitStatistics> alertMaintenanceUnitStatistics = alertMaintenanceUnitStatisticsMapper.selectList(lambda);
List<AlertMaintenanceUnitStatisticsDto> models = Bean.toModels(alertMaintenanceUnitStatistics, AlertMaintenanceUnitStatisticsDto.class);
return models;
}
public JSONObject regionEventRank(DPFilterParamDto dpFilterParamDto) throws Exception {
List<RegionModel> childRegion = this.getRegionList(dpFilterParamDto);
JSONObject jsonObject = new JSONObject();
Map<String, Long> map = new HashMap<>();
childRegion.stream().forEach(x -> {
String orgCode = this.getAndSetOrgCode(x.getRegionCode().toString());
if (ValidationUtil.isEmpty(orgCode)) {
map.put(x.getRegionName(), 0L);
} else {
Long num = alertStatisticsMapper.countEmergencyEventsByOrgCodeAndDate(orgCode, dpFilterParamDto);
map.put(x.getRegionName(), num);
}
});
List<String> xdata = new ArrayList<>(map.keySet());
List<Long> ydata = new ArrayList<>();
xdata.sort(Comparator.comparingLong(map::get).reversed());
xdata.stream().forEach(x -> {
ydata.add(map.get(x));
});
jsonObject.put("xdata", xdata);
jsonObject.put("ydata", ydata);
return jsonObject;
}
private List<RegionModel> getRegionList(DPFilterParamDto dpFilterParamDto) {
try {
if (regionChildRegionMap.get(dpFilterParamDto.getCityCode()) == null) {
List<RegionModel> regionModels = this.setRegionIfRootParent(dpFilterParamDto.getCityCode());
regionChildRegionMap.put(dpFilterParamDto.getCityCode(), regionModels);
return regionModels;
} else {
return regionChildRegionMap.get(dpFilterParamDto.getCityCode());
}
} catch (Exception e) {
log.error("查询行政区域失败:{}", e.getMessage());
}
return new ArrayList<>();
}
private List<RegionModel> setRegionIfRootParent(String regionCode) throws Exception {
List<RegionModel> regionList = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
// 陕西省时需要在地图返回独立的地级市:韩城、杨凌、西咸
if (regionCode.equals(TZSCommonConstant.SHAN_XI_REGION_CODE)) {
List<RegionModel> independentRegions = ReginStepEnum.enum2RegionList("map");
regionList.addAll(independentRegions);
}
regionList = regionList.stream().sorted(Comparator.comparing(RegionModel::getRegionCode, Comparator.naturalOrder())).collect(Collectors.toList());
return regionList;
}
private String getAndSetOrgCode(DPFilterParamDto dpFilterParamDto) {
this.getRegionList(dpFilterParamDto);
String orgCode = regionCodeOrgCodeMap.get(dpFilterParamDto.getCityCode());
if (orgCode == null) {
orgCode = yjBaseMapper.getOrgCodeByCompanyCode(dpFilterParamDto.getCityCode());
if (orgCode == null) {
return "";
}
regionCodeOrgCodeMap.put(dpFilterParamDto.getCityCode(), orgCode);
}
return orgCode;
}
private String getAndSetOrgCode(String cityCode) {
String orgCode = regionCodeOrgCodeMap.get(cityCode);
if (orgCode == null) {
orgCode = yjBaseMapper.getOrgCodeByCompanyCode(cityCode);
if (orgCode == null) {
return "";
}
regionCodeOrgCodeMap.put(cityCode, orgCode);
}
return orgCode;
}
/**
* 获取两个时间段之间的每一天
* @param startTime 开始时间
* @param endTime 结束时间
* @return 结果
*/
public List<String> getEveryDay(String startTime, String endTime) {
List<String> dateList = new ArrayList<>();
LocalDate startDate = LocalDate.parse(startTime);
LocalDate endDate = LocalDate.parse(endTime);
long numOfDays = ChronoUnit.DAYS.between(startDate, endDate);
for (int i = 0; i <= numOfDays; i++) {
LocalDate currentDate = startDate.plusDays(i);
String format = currentDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dateList.add(format);
}
return dateList;
}
private JSONObject buildLegendData(JSONObject jsonObject, String dataKey, String value) {
if (ValidationUtil.isEmpty(jsonObject)){
jsonObject = new JSONObject();
}
JSONObject legendData = jsonObject.getJSONObject("legendData");
if (ValidationUtil.isEmpty(legendData)){
legendData = new JSONObject();
jsonObject.put("legendData", legendData);
}
legendData.put(dataKey, value);
return jsonObject;
}
public List<Map<String, Object>> getCenterMapCountDataForOverview(DPFilterParamDto dpFilterParamDto) {
return getRegionList(dpFilterParamDto).parallelStream().map(r -> {
DPFilterParamDto filterParamDto = new DPFilterParamDto();
filterParamDto.setCityCode(r.getRegionCode().toString());
String orgCode = this.getAndSetOrgCode(filterParamDto);
this.setDefaultFilter(filterParamDto);
Map<String, Object> itemResult = getCenterMapOverviewData(orgCode, filterParamDto);
itemResult.put("regionCode", r.getRegionCode());
itemResult.put("regionName", r.getRegionName());
return itemResult;
}).collect(Collectors.toList());
}
private Map<String, Object> getCenterMapOverviewData(String orgCode, DPFilterParamDto filterParamDto) {
Map<String, Object> result = new HashMap<>();
// 统计完成的事件包括困人、故障
Long num = alertStatisticsMapper.countEmergencyEventsByOrgCodeAndDate(orgCode,filterParamDto);
result.put("alarmCount",num);
return result;
}
public Map<String, Object> getCenterMapCountDataForGlobal(DPFilterParamDto dpFilterParamDto) {
this.setDefaultFilter(dpFilterParamDto);
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
// 1.报检数量统计
return this.getCenterMapOverviewData(orgCode, dpFilterParamDto);
}
private void setDefaultFilter(DPFilterParamDto dpFilterParamDto) {
if (StringUtils.isEmpty(dpFilterParamDto.getBeginDate())) {
dpFilterParamDto.setBeginDate(cn.hutool.core.date.DateUtil.lastMonth().toDateStr());
}
if (StringUtils.isEmpty(dpFilterParamDto.getEndDate())) {
dpFilterParamDto.setEndDate(cn.hutool.core.date.DateUtil.today());
}
}
}
......@@ -411,7 +411,6 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
jgEnableDisable.setAuditStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getName()));
}
jgEnableDisable.setEquList(String.valueOf(map.get("equListDesc")));
jgEnableDisable.setSupervisoryCode(String.valueOf(map.get("supervisoryCode")));
jgEnableDisable.setCreateUserName(reginParams.getUserModel().getRealName());
jgEnableDisable.setCreateUserId(reginParams.getUserModel().getUserId());
......
......@@ -2135,8 +2135,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
*/
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
if (!(jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())
|| jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()))
if (!(FlowStatusEnum.TO_BE_FINISHED.getName().equals(jgUseRegistration.getStatus())
|| FlowStatusEnum.TO_BE_DISCARD.getName().equals(jgUseRegistration.getStatus()))
|| "1".equals(jgUseRegistration.getRegType())) {
// 基本信息 + 制造信息
Map<String, Object> detail = this.baseMapper.getDetail(record);
......
......@@ -20,10 +20,11 @@ public interface JyjcInspectionApplicationEquipMapper extends BaseMapper<JyjcIns
/**
* 检验检测次数统计维度按照设备种类、检验类型进行统计
*
* @param dpFilterParamDto g过滤条件
* @param dpFilterParamDto 过滤条件时间
* @param orgCode 过滤条件区域对应的公司的orgCode
* @return 统计列表
*/
List<InspectTimeCountDto> countInspectTimeCountByTypeAndEquList(DPFilterParamDto dpFilterParamDto);
List<InspectTimeCountDto> countInspectTimeCountByTypeAndEquList(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
Integer inspectTimeCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
}
......@@ -21,27 +21,25 @@
c.equ_define,
count(1) as num
from
(SELECT
(
SELECT
ae.equ_list,
ae.equ_category,
ae.equ_define,
a.biz_type,
concat(u.PROVINCE,'#', u.CITY,'#', u.COUNTY) as areaCode
s.ORG_BRANCH_CODE as orgBranchCode
FROM
"tz_jyjc_inspection_application_equip" ae,
tz_jyjc_inspection_application a,
"idx_biz_jg_use_info" u
"idx_biz_jg_supervision_info" s
where
ae.equip_unicode = u."RECORD"
s."RECORD" = ae.equip_unicode
and a.sequence_nbr = ae.application_seq
and (a.application_date between #{beginDate} and #{endDate})
and a.application_date between #{dto.beginDate} and #{dto.endDate}
and a.status='6616'
and u."PROVINCE" <![CDATA[<>]]> ''
and u."CITY" <![CDATA[<>]]> ''
and u."COUNTY" <![CDATA[<>]]> ''
) c
where
c.areaCode like concat('%',#{cityCode}, '%')
c.orgBranchCode like concat(#{orgCode}, '%')
group by c.biz_type,
c.equ_list,
c.equ_category,
......
......@@ -114,8 +114,9 @@ public class DPStatisticsServiceImpl {
}
private void buildYData(Map<String, Object> result, List<BizTypeEnum> bizTypeEnums, DPFilterParamDto dpFilterParamDto, List<EquipmentCategoryDto> equipmentCategoryDtos) {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 待统计的数据本来sql可以单独统计,但是要求气瓶单独从压力容器里拎出来,与八大类同级,故java处理
List<InspectTimeCountDto> inspectTimeCountDtos = inspectionApplicationEquipMapper.countInspectTimeCountByTypeAndEquList(dpFilterParamDto);
List<InspectTimeCountDto> inspectTimeCountDtos = inspectionApplicationEquipMapper.countInspectTimeCountByTypeAndEquList(orgCode,dpFilterParamDto);
bizTypeEnums.forEach(bizTypeEnum -> {
result.put(bizTypeEnum.getCode(), this.countNumByBizTypeAndEquList(equipmentCategoryDtos, bizTypeEnum.getCode(), inspectTimeCountDtos));
});
......
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