Commit 44985717 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 538bb26c f86789d7
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;
}
...@@ -8,7 +8,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; ...@@ -8,7 +8,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date;
/** /**
* *
...@@ -91,6 +90,16 @@ public class AlertStatistics extends BaseEntity { ...@@ -91,6 +90,16 @@ public class AlertStatistics extends BaseEntity {
private String failureRate; private String failureRate;
/** /**
* 平均救援时长(分钟)
*/
private String avgTime;
/**
* 30分钟内到达次数
*/
private Integer withinThirtyRescue;
/**
* 统计日期 * 统计日期
*/ */
@TableField("statistics_date") @TableField("statistics_date")
......
...@@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Param;
*/ */
public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> { public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
AlertStatistics getStatissticsMessage(@Param("orgCode")String orgCode, @Param("startDate")String startDate , @Param("endDate")String endDate); AlertStatistics getStatisticsMessage(@Param("orgCode")String orgCode, @Param("startDate")String startDate , @Param("endDate")String endDate);
AlertStatistics statisticsInfoByRegionAndDate(@Param("regionCode")Integer regionCode, @Param("startDate")String startDate , @Param("endDate")String endDate);
} }
package com.yeejoin.amos.boot.module.elevator.api.service; package com.yeejoin.amos.boot.module.elevator.api.service;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics; import com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
public interface IAlertStatisticsService { public interface IAlertStatisticsService {
void statisticalGeneration(String type); void statisticalGeneration(String type);
List<AlertStatistics> getList(String date) throws ParseException; List<AlertStatistics> getList(String date) throws ParseException;
JSONArray statisticInfoByRegionAndDate(Map<String, Object> queryParams);
} }
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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.AlertStatisticsMapper"> <mapper namespace="com.yeejoin.amos.boot.module.elevator.api.mapper.AlertStatisticsMapper">
<select id="getStatissticsMessage" <select id="getStatisticsMessage"
resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics"> resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics">
SELECT temp.*, SELECT temp.*,
CASE CASE
...@@ -57,4 +57,46 @@ ...@@ -57,4 +57,46 @@
) temp ) temp
</select> </select>
<select id="statisticsInfoByRegionAndDate" resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics">
select t.*, ROUND((avgNum/greaterNum)/60.0,2) avgTime from (SELECT
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as t1sn
) as trappedPeople,
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '961' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as n
) as breakdownRescue,
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '962' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as t1sn2
) as complaint,
(SELECT sum( field_value ) FROM tz_alert_form_value WHERE alert_called_id IN (SELECT sequence_nbr FROM tz_alert_called WHERE region_code LIKE concat ('%', #{regionCode}, '%' ) AND call_time BETWEEN #{startDate} and #{endDate} AND alarm_type_code = '960' AND father_alert IS NULL) AND field_code = 'trapped_num') as rescuedCount,
( SELECT count(1) from (
SELECT
t1.sequence_nbr,
(SELECT min(arrive_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and arrive_time is not null) as arr,
(SELECT min(dispatch_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and dispatch_time is not null ) as dis
from tz_alert_called t1 where t1.region_code like concat('%', #{regionCode}, '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as snad where extract(epoch from arr - dis ) > 1800
) as withinThirtyRescue,
(SELECT count(1) from tz_alert_called where region_code like concat('%', #{regionCode}, '%') and alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null) as greaterNum,
(
SELECT sum(extract(epoch from arr - dis )) from
( SELECT
t1.sequence_nbr,
(SELECT min(arrive_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and arrive_time is not null) as arr,
(SELECT min(dispatch_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and dispatch_time is not null ) as dis
from tz_alert_called t1 where t1.region_code like concat('%', #{regionCode}, '%') and t1.alarm_type_code = '960' and t1.call_time BETWEEN #{startDate} and #{endDate} and t1.father_alert is null
) as s ) as avgNum)t
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.elevator.biz.controller; package com.yeejoin.amos.boot.module.elevator.biz.controller;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil; import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
...@@ -11,10 +12,7 @@ import io.swagger.annotations.Api; ...@@ -11,10 +12,7 @@ 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;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -23,10 +21,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -23,10 +21,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@RestController @RestController
...@@ -346,4 +341,11 @@ public class StatisticsController extends BaseController { ...@@ -346,4 +341,11 @@ public class StatisticsController extends BaseController {
} }
ExcelUtil.createTemplate(response, "困人救援超时情况统计", "困人救援超时情况统计", exportVos, AlertDispatchStatisticsExportVo.class, null, false); ExcelUtil.createTemplate(response, "困人救援超时情况统计", "困人救援超时情况统计", exportVos, AlertDispatchStatisticsExportVo.class, null, false);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/region/info")
@ApiOperation(httpMethod = "POST", value = "查询区域统计信息", notes = "查询区域统计信息")
public ResponseModel<JSONArray> statisticsRegionInfo(@RequestBody Map<String, Object> queryParams) {
return ResponseHelper.buildResponse(alertStatisticsService.statisticInfoByRegionAndDate(queryParams));
}
} }
...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.elevator.biz.service.impl; ...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.elevator.biz.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
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.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
...@@ -14,12 +16,15 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,12 +16,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
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 java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
...@@ -54,7 +59,7 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto, ...@@ -54,7 +59,7 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
if (!ObjectUtils.isEmpty(supervisionList)) { if (!ObjectUtils.isEmpty(supervisionList)) {
supervisionList.forEach(item -> { supervisionList.forEach(item -> {
if (!ObjectUtils.isEmpty(item.get("orgCode"))) { if (!ObjectUtils.isEmpty(item.get("orgCode"))) {
AlertStatistics statissticsMessage = this.getBaseMapper().getStatissticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59"); AlertStatistics statissticsMessage = this.getBaseMapper().getStatisticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59");
statissticsMessage.setSupervisoryUnitName(String.valueOf(item.get("companyName"))); statissticsMessage.setSupervisoryUnitName(String.valueOf(item.get("companyName")));
statissticsMessage.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode"))); statissticsMessage.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode")));
statissticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr"))); statissticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr")));
...@@ -158,4 +163,57 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto, ...@@ -158,4 +163,57 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
alertStatistics.add(avg); alertStatistics.add(avg);
return alertStatistics; return alertStatistics;
} }
@Override
public JSONArray statisticInfoByRegionAndDate(Map<String, Object> params) {
LocalDate today = LocalDate.now();
LocalDate startDate = (LocalDate) params.get("startDate");
LocalDate endDate = (LocalDate) params.get("endDate");
Integer regionCode = (Integer) params.get("cityCode");
if (ObjectUtils.isEmpty(params.get("startDate")) || ObjectUtils.isEmpty(params.get("endDate"))) {
startDate = today.minusDays(6);
endDate = today;
}
AlertStatistics statistics = this.baseMapper.statisticsInfoByRegionAndDate(regionCode, startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
JSONArray jsonArray = new JSONArray();
if (!ObjectUtils.isEmpty(statistics)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "dtkr");
jsonObject.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject.put("name", "电梯困人");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts");
jsonObject1.put("value", ValidationUtil.isEmpty(statistics.getComplaint()) ? 0 : statistics.getComplaint());
jsonObject1.put("name", "受理投诉");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("key", "gzbx");
jsonObject2.put("value", ValidationUtil.isEmpty(statistics.getBreakdownRescue()) ? 0 : statistics.getBreakdownRescue());
jsonObject2.put("name", "故障维修");
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("key", "jjbkck");
jsonObject3.put("value", ValidationUtil.isEmpty(statistics.getRescuePersonnel()) ? 0 : statistics.getRescuePersonnel());
jsonObject3.put("name", "解救被困乘客");
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("key", "30fzdd");
jsonObject4.put("value", ValidationUtil.isEmpty(statistics.getWithinThirtyRescue()) ? 0 : statistics.getWithinThirtyRescue());
jsonObject4.put("name", "30分钟内到达");
JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("key", "pjjysj");
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间");
jsonArray.add(jsonObject);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5);
}
return jsonArray;
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.common.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
/**
* @Author cpp
* @Description
* @Date 2023/6/5
*/
@Data
@Accessors(chain = true)
@Document(indexName = "idx_biz_view_jg_all", shards = 6, replicas = 2)
public class ESEquipmentCategoryDto {
@Id
private String SEQUENCE_NBR;
@Field(type = FieldType.Text)
private String ORG_BRANCH_NAME;
@Field(type = FieldType.Text)
private String ORG_BRANCH_CODE;
@Field(type = FieldType.Text)
private String USE_UNIT_NAME;
@Field(type = FieldType.Text)
private String USE_UNIT_CREDIT_CODE;
@Field(type = FieldType.Keyword)
private String EQU_LIST_CODE;
@Field(type = FieldType.Text)
private String EQU_LIST;
@Field(type = FieldType.Text)
private String EQU_CATEGORY;
@Field(type = FieldType.Keyword)
private String EQU_CATEGORY_CODE;
@Field(type = FieldType.Keyword)
private String USE_ORG_CODE;
@Field(type = FieldType.Text)
private String CODE96333;
@Field(type = FieldType.Text)
private String EQU_CODE;
@Field(type = FieldType.Keyword)
private String SUPERVISORY_CODE;
@Field(type = FieldType.Text)
private String USE_PLACE;
@Field(type = FieldType.Text)
private String ADDRESS;
@Field(type = FieldType.Integer)
private Integer EQU_STATE;
@Field(type = FieldType.Keyword)
private String STATUS;
@Field(type = FieldType.Long)
private Long REC_DATE;
@Field(type = FieldType.Text)
private String SAFETY_MANAGER;
@Field(type = FieldType.Text)
private String PHONE;
@Field(type = FieldType.Text)
private String MAINTAIN_UNIT;
@Field(type = FieldType.Text)
private String USE_INNER_CODE;
@Field(type = FieldType.Text)
private String FACTORY_NUM;
@Field(type = FieldType.Text)
private String PRODUCE_UNIT_NAME;
@Field(type = FieldType.Text)
private String INSPECT_REPORT;
@Field(type = FieldType.Text)
private String NEXT_INSPECT_DATE;
@Field(type = FieldType.Text)
private String CONSTRUCTION_TYPE;
@Field(type = FieldType.Text)
private String USC_UNIT_CREDIT_CODE;
@Field(type = FieldType.Text)
private String USC_UNIT_NAME;
@Field(type = FieldType.Text)
private String USC_DATE;
@Field(type = FieldType.Text)
private String EQU_DEFINE;
@Field(type = FieldType.Text)
private String EQU_DEFINE_CODE;
@Field(type = FieldType.Text)
private String PRODUCT_NAME;
@Field(type = FieldType.Text)
private String BRAND_NAME;
@Field(type = FieldType.Text)
private String EQU_TYPE;
@Field(type = FieldType.Text)
private String PRODUCE_DATE;
@Field(type = FieldType.Text)
private String DATA_SOURCE;
@Field(type = FieldType.Text)
private String WHETHER_VEHICLE_CYLINDER;
@Field(type = FieldType.Text)
private String WHETHER_SKID_MOUNTED_PRESSURE_VESSEL;
/**
* 问题状态
*/
@Field(type = FieldType.Text)
private String problemStatus;
/**
* 是否纳管:true - 已纳管 false-未纳管
*/
@Field(type = FieldType.Boolean)
private Boolean IS_INTO_MANAGEMENT;
/**
* 设备使用地点区域码610000#610100#610101
*/
@Field(type = FieldType.Keyword)
private String USE_PLACE_CODE;
/**
* 设备使用场所代码-来源数据字典ADDRESS
*/
@Field(type = FieldType.Keyword)
private String USE_SITE_CODE;
}
...@@ -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("未知的类型"));
} }
} }
...@@ -46,4 +46,6 @@ public interface JgScrapCancelMapper extends BaseMapper<JgScrapCancel> { ...@@ -46,4 +46,6 @@ public interface JgScrapCancelMapper extends BaseMapper<JgScrapCancel> {
Map<String, Object> queryEquipInformation(@Param("sequenceNbr") long sequenceNbr); Map<String, Object> queryEquipInformation(@Param("sequenceNbr") long sequenceNbr);
List<EquipBizCountDto> queryScrappedDeviceStaticListData(DPFilterParamDto dpFilterParamDto); List<EquipBizCountDto> queryScrappedDeviceStaticListData(DPFilterParamDto dpFilterParamDto);
Integer getScrappedDeviceCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
} }
...@@ -79,4 +79,6 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> { ...@@ -79,4 +79,6 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
String getEquCategoryNameByCode(String code); String getEquCategoryNameByCode(String code);
List<EquipBizCountDto> queryNewDeviceStaticListData(DPFilterParamDto dpFilterParamDto); List<EquipBizCountDto> queryNewDeviceStaticListData(DPFilterParamDto dpFilterParamDto);
Integer getUseRegisterCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
} }
...@@ -289,4 +289,33 @@ ...@@ -289,4 +289,33 @@
c.equ_category, c.equ_category,
c.equ_define c.equ_define
</select> </select>
<select id="getScrappedDeviceCount" resultType="java.lang.Integer">
select
count(1) as num
from
(SELECT
ri.equ_list,
ri.equ_category,
ri.equ_define,
concat(u.PROVINCE,'#', u.CITY,'#', u.COUNTY) as areaCode
FROM
"tzs_jg_scrap_cancel_eq" ae,
tzs_jg_scrap_cancel a,
"idx_biz_jg_use_info" u,
idx_biz_jg_register_info ri
where
a.sequence_nbr = ae.equip_transfer_id
AND ri.EQU_CATEGORY = '2300'
and ae.equ_id = u."RECORD"
and u."RECORD" = ri."RECORD"
and (a.audit_pass_date between #{dpFilterParamDto.beginDate} and #{dpFilterParamDto.endDate})
and a.cancel_type ='1'
and a.audit_status='已完成'
) c
where
c.areaCode like concat('%',#{dpFilterParamDto.cityCode}, '%')
group by
c.equ_category
</select>
</mapper> </mapper>
...@@ -592,4 +592,33 @@ ...@@ -592,4 +592,33 @@
c.equ_category, c.equ_category,
c.equ_define c.equ_define
</select> </select>
<select id="getUseRegisterCount" resultType="java.lang.Integer">
SELECT COUNT(1) AS num
FROM
(
SELECT
ri.equ_list,
ri.equ_category,
ri.equ_define,
A.audit_pass_date,
concat ( u.PROVINCE, '#', u.CITY, '#', u.COUNTY ) AS areaCode
FROM
"tzs_jg_use_registration_eq" ae,
tzs_jg_use_registration A,
"idx_biz_jg_use_info" u,
idx_biz_jg_register_info ri
WHERE
ae.equ_id = u."RECORD"
AND ri.EQU_CATEGORY = '2300'
AND A.sequence_nbr = ae.equip_transfer_id
AND u."RECORD" = ri."RECORD"
and (a.audit_pass_date between #{dpFilterParamDto.beginDate} and #{dpFilterParamDto.endDate})
AND A.status = '已完成'
) C
WHERE
C.areaCode LIKE concat ( '%', #{dpFilterParamDto.cityCode}, '%' )
GROUP BY
C.equ_category
</select>
</mapper> </mapper>
...@@ -51,7 +51,7 @@ public class DPStatisticsController { ...@@ -51,7 +51,7 @@ public class DPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计", notes = "大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计") @ApiOperation(httpMethod = "POST", value = "大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计", notes = "大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计")
@PostMapping(value = "/zl/center-map/global/count") @PostMapping(value = "/zl/center-map/legend")
public ResponseModel<Map<String, Object>> centerMapCountForGlobal(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) { public ResponseModel<Map<String, Object>> centerMapCountForGlobal(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors(); List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) { if (!fieldErrors.isEmpty()) {
...@@ -59,4 +59,26 @@ public class DPStatisticsController { ...@@ -59,4 +59,26 @@ public class DPStatisticsController {
} }
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForGlobal(dpFilterParamDto)); return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForGlobal(dpFilterParamDto));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏总览中间-地图地市统计", notes = "大屏总览中间-地图地市统计")
@PostMapping(value = "/zl/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));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏八大类左侧-使用登记统计", notes = "大屏八大类左侧-使用登记统计")
@PostMapping(value = "/useRegisterCount")
public ResponseModel<Map<String, Object>> useRegisterCount(@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.useRegisterCount(dpFilterParamDto));
}
} }
...@@ -5,9 +5,11 @@ import com.yeejoin.amos.boot.module.jg.api.entity.*; ...@@ -5,9 +5,11 @@ import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.service.IEquipUsedCheck; import com.yeejoin.amos.boot.module.jg.api.service.IEquipUsedCheck;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.*; import com.yeejoin.amos.boot.module.jg.biz.service.impl.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.List; import java.util.List;
...@@ -48,6 +50,10 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -48,6 +50,10 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
private List<IEquipUsedCheck> equipUsedCheckList; private List<IEquipUsedCheck> equipUsedCheckList;
private DPStatisticsServiceImpl statisticsService;
private AmosRequestContext amosRequestContext;
public ApplicationRunnerImpl(JgUseRegistrationServiceImpl useRegistrationService, public ApplicationRunnerImpl(JgUseRegistrationServiceImpl useRegistrationService,
CommonServiceImpl commonService, CommonServiceImpl commonService,
JgInstallationNoticeServiceImpl installationNoticeService, JgInstallationNoticeServiceImpl installationNoticeService,
...@@ -63,7 +69,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -63,7 +69,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
JgScrapCancelServiceImpl scrapCancelService, JgScrapCancelServiceImpl scrapCancelService,
JgChangeRegistrationNameServiceImpl changeRegistrationNameService, JgChangeRegistrationNameServiceImpl changeRegistrationNameService,
ReportAnalysisServiceImpl reportAnalysisService, ReportAnalysisServiceImpl reportAnalysisService,
List<IEquipUsedCheck> equipUsedCheckList) { List<IEquipUsedCheck> equipUsedCheckList, DPStatisticsServiceImpl statisticsService, AmosRequestContext amosRequestContext) {
this.commonService = commonService; this.commonService = commonService;
this.useRegistrationService = useRegistrationService; this.useRegistrationService = useRegistrationService;
...@@ -95,6 +101,8 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -95,6 +101,8 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
this.reportAnalysisService = reportAnalysisService; this.reportAnalysisService = reportAnalysisService;
this.equipUsedCheckList = equipUsedCheckList; this.equipUsedCheckList = equipUsedCheckList;
this.statisticsService = statisticsService;
this.amosRequestContext = amosRequestContext;
} }
...@@ -184,5 +192,11 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -184,5 +192,11 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
// 流程中的设备统计数据预热 // 流程中的设备统计数据预热
equipUsedCheckList.forEach(IEquipUsedCheck::init); equipUsedCheckList.forEach(IEquipUsedCheck::init);
// 初始化数据到内存
RequestContext.setAppKey(amosRequestContext.getAppKey());
RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setToken(amosRequestContext.getToken());
statisticsService.init();
} }
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.jyjc.api.dto.InspectTimeCountDto; import com.yeejoin.amos.boot.module.jyjc.api.dto.InspectTimeCountDto;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationEquip; import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationEquip;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -23,4 +24,6 @@ public interface JyjcInspectionApplicationEquipMapper extends BaseMapper<JyjcIns ...@@ -23,4 +24,6 @@ public interface JyjcInspectionApplicationEquipMapper extends BaseMapper<JyjcIns
* @return 统计列表 * @return 统计列表
*/ */
List<InspectTimeCountDto> countInspectTimeCountByTypeAndEquList(DPFilterParamDto dpFilterParamDto); List<InspectTimeCountDto> countInspectTimeCountByTypeAndEquList(DPFilterParamDto dpFilterParamDto);
Integer inspectTimeCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
} }
...@@ -47,4 +47,27 @@ ...@@ -47,4 +47,27 @@
c.equ_category, c.equ_category,
c.equ_define c.equ_define
</select> </select>
<select id="inspectTimeCount" resultType="java.lang.Integer">
SELECT COUNT(1) AS num
FROM
(
SELECT
ae.equ_category,
concat ( u.PROVINCE, '#', u.CITY, '#', u.COUNTY ) AS areaCode
FROM
"tz_jyjc_inspection_application_equip" ae,
tz_jyjc_inspection_application A,
"idx_biz_jg_use_info" u
WHERE
ae.equip_unicode = u."RECORD"
AND A.sequence_nbr = ae.application_seq
AND ( A.application_date BETWEEN #{ dpFilterParamDto.beginDate } AND #{ dpFilterParamDto.endDate } )
AND A.status = '6616'
AND ae.equ_category = '2300'
) C
WHERE
C.areaCode LIKE concat ( '%', #{dpFilterParamDto.cityCode}, '%' )
GROUP BY
C.equ_category
</select>
</mapper> </mapper>
...@@ -47,4 +47,16 @@ public class DPStatisticsController { ...@@ -47,4 +47,16 @@ public class DPStatisticsController {
} }
return ResponseHelper.buildResponse(statisticsService.inspectTimeCountByTypeAndEquList(dpFilterParamDto)); return ResponseHelper.buildResponse(statisticsService.inspectTimeCountByTypeAndEquList(dpFilterParamDto));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "气瓶检验检测次数统计", notes = "气瓶检验检测次数统计")
@PostMapping(value = "/inspectTimeCount")
public ResponseModel<Map<String, Object>> inspectTimeCount(@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.inspectTimeCount(dpFilterParamDto));
}
} }
...@@ -10,6 +10,10 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; ...@@ -10,6 +10,10 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -113,4 +117,24 @@ public class DPStatisticsServiceImpl { ...@@ -113,4 +117,24 @@ public class DPStatisticsServiceImpl {
dpFilterParamDto.setEndDate(DateUtil.today()); dpFilterParamDto.setEndDate(DateUtil.today());
} }
} }
public Map<String, Object> inspectTimeCount(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> returnMap = new HashMap<>();
LocalDate today = LocalDate.now();
List xDataList = new ArrayList();
List<Integer> yDataList = new ArrayList();
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
for (int i = 2; i >= 0; i--) {
LocalDate firstDayOfPrevMonth = today.minusMonths(i).with(TemporalAdjusters.firstDayOfMonth());
LocalDate lastDayOfPrevMonth = today.minusMonths(i).with(TemporalAdjusters.lastDayOfMonth());
dpFilterParamDto.setBeginDate(LocalDateTime.of(firstDayOfPrevMonth, java.time.LocalTime.MIN).format(sdf));
dpFilterParamDto.setEndDate(LocalDateTime.of(lastDayOfPrevMonth, java.time.LocalTime.MAX).format(sdf));
Integer inspectTimeCount = inspectionApplicationEquipMapper.inspectTimeCount(dpFilterParamDto);
xDataList.add(firstDayOfPrevMonth.getMonthValue()+"月");
yDataList.add(null == inspectTimeCount ? 0 : inspectTimeCount);
}
returnMap.put("xData",xDataList);
returnMap.put("yData",yDataList);
return returnMap;
}
} }
...@@ -26,14 +26,13 @@ public class ESEquipmentCategoryDto { ...@@ -26,14 +26,13 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String ORG_BRANCH_CODE; private String ORG_BRANCH_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String USE_UNIT_NAME; private String USE_UNIT_NAME;
@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)
...@@ -42,7 +41,10 @@ public class ESEquipmentCategoryDto { ...@@ -42,7 +41,10 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String EQU_CATEGORY; private String EQU_CATEGORY;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String EQU_CATEGORY_CODE;
@Field(type = FieldType.Keyword)
private String USE_ORG_CODE; private String USE_ORG_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
...@@ -51,7 +53,7 @@ public class ESEquipmentCategoryDto { ...@@ -51,7 +53,7 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String EQU_CODE; private String EQU_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String SUPERVISORY_CODE; private String SUPERVISORY_CODE;
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
...@@ -63,11 +65,85 @@ public class ESEquipmentCategoryDto { ...@@ -63,11 +65,85 @@ 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)
private Long REC_DATE; private Long REC_DATE;
@Field(type = FieldType.Text)
private String SAFETY_MANAGER;
@Field(type = FieldType.Text)
private String PHONE;
@Field(type = FieldType.Text)
private String MAINTAIN_UNIT;
@Field(type = FieldType.Text)
private String USE_INNER_CODE;
@Field(type = FieldType.Text)
private String FACTORY_NUM;
@Field(type = FieldType.Text)
private String PRODUCE_UNIT_NAME;
@Field(type = FieldType.Text)
private String INSPECT_REPORT;
@Field(type = FieldType.Text)
private String NEXT_INSPECT_DATE;
@Field(type = FieldType.Text)
private String CONSTRUCTION_TYPE;
@Field(type = FieldType.Text)
private String USC_UNIT_CREDIT_CODE;
@Field(type = FieldType.Text)
private String USC_UNIT_NAME;
@Field(type = FieldType.Text)
private String USC_DATE;
@Field(type = FieldType.Text)
private String EQU_DEFINE;
@Field(type = FieldType.Text)
private String EQU_DEFINE_CODE;
@Field(type = FieldType.Text)
private String PRODUCT_NAME;
@Field(type = FieldType.Text)
private String BRAND_NAME;
@Field(type = FieldType.Text)
private String EQU_TYPE;
@Field(type = FieldType.Text)
private String PRODUCE_DATE;
@Field(type = FieldType.Text)
private String DATA_SOURCE;
@Field(type = FieldType.Text)
private String WHETHER_VEHICLE_CYLINDER;
@Field(type = FieldType.Text)
private String WHETHER_SKID_MOUNTED_PRESSURE_VESSEL;
/**
* 问题状态
*/
@Field(type = FieldType.Text)
private String problemStatus;
/**
* 是否纳管:true - 已纳管 false-未纳管
*/
@Field(type = FieldType.Boolean)
private Boolean IS_INTO_MANAGEMENT;
} }
...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquipExportDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.UseUnitCreditCodeCategoryDto; import com.yeejoin.amos.boot.module.tcm.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.tcm.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.tcm.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.tcm.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tcm.api.vo.EquipExportVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -50,4 +50,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> { ...@@ -50,4 +50,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
List<EquipExportVo> getEquipExportData(@Param("dto") EquipExportDto dto); List<EquipExportVo> getEquipExportData(@Param("dto") EquipExportDto dto);
List<Map<String, Object>> selectJgUseInfo();
} }
...@@ -362,4 +362,8 @@ ...@@ -362,4 +362,8 @@
</where> </where>
</select> </select>
<select id="selectJgUseInfo" resultType="java.util.Map">
select record, PROVINCE, CITY, COUNTY, USE_PLACE from idx_biz_jg_use_info
</select>
</mapper> </mapper>
...@@ -25,15 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -25,15 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -45,12 +37,7 @@ import java.io.File; ...@@ -45,12 +37,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -76,7 +63,6 @@ public class EquipmentCategoryController extends BaseController { ...@@ -76,7 +63,6 @@ public class EquipmentCategoryController extends BaseController {
@Value("${regulatory_code_prefix}") @Value("${regulatory_code_prefix}")
String REGULATORY_CODE_PREFIX; String REGULATORY_CODE_PREFIX;
/** /**
* 新增装备分类 * 新增装备分类
* *
...@@ -458,5 +444,10 @@ public class EquipmentCategoryController extends BaseController { ...@@ -458,5 +444,10 @@ public class EquipmentCategoryController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/jg/all/update")
@ApiOperation(httpMethod = "PUT", value = "更新监管设备es", notes = "更新监管设备es")
public void jgAllUpdate(){
equipmentCategoryServiceImpl.updateJgAllEs();
}
} }
package com.yeejoin.amos.boot.module.tcm.biz.dao; package com.yeejoin.amos.boot.module.tcm.biz.dao;
import com.yeejoin.amos.boot.module.tcm.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
......
...@@ -10,26 +10,17 @@ import com.google.common.collect.Lists; ...@@ -10,26 +10,17 @@ 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.tcm.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquInfoDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquipExportDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.UseUnitCreditCodeCategoryDto; import com.yeejoin.amos.boot.module.tcm.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.CategoryOtherInfo; import com.yeejoin.amos.boot.module.tcm.api.entity.*;
import com.yeejoin.amos.boot.module.tcm.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tcm.api.entity.EquipmentCategoryData;
import com.yeejoin.amos.boot.module.tcm.api.entity.SupervisoryCodeInfo;
import com.yeejoin.amos.boot.module.tcm.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.tcm.api.enums.EquimentEnum; import com.yeejoin.amos.boot.module.tcm.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentCategoryEnum; import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentClassifityEnum; import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.UnitTypeEnum; import com.yeejoin.amos.boot.module.tcm.api.enums.UnitTypeEnum;
import com.yeejoin.amos.boot.module.tcm.api.mapper.CategoryOtherInfoMapper; import com.yeejoin.amos.boot.module.tcm.api.mapper.*;
import com.yeejoin.amos.boot.module.tcm.api.mapper.EquipmentCategoryDataMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.SupervisoryCodeInfoMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.UseInfoMapper;
import com.yeejoin.amos.boot.module.tcm.api.service.IEquipmentCategoryService; import com.yeejoin.amos.boot.module.tcm.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.tcm.api.vo.EquipExportVo; import com.yeejoin.amos.boot.module.tcm.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.tcm.biz.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.tcm.biz.dao.ESEquipmentCategory;
...@@ -41,10 +32,13 @@ import com.yeejoin.amos.component.feign.utils.FeignUtil; ...@@ -41,10 +32,13 @@ import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege; 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.elasticsearch.action.search.ClearScrollRequest;
import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.core.TimeValue;
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.SearchHit; import org.elasticsearch.search.SearchHit;
...@@ -66,20 +60,12 @@ import org.typroject.tyboot.core.foundation.utils.DateUtil; ...@@ -66,20 +60,12 @@ 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.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar; import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -126,6 +112,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -126,6 +112,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String LEVEL = "company"; private static final String LEVEL = "company";
private static final String EQUSTATE = "EQU_STATE"; private static final String EQUSTATE = "EQU_STATE";
private static final String USEPLACE = "USE_PLACE"; private static final String USEPLACE = "USE_PLACE";
private static final int BATCH_SIZE = 1000;
private static String USE_CODE = "use_code"; private static String USE_CODE = "use_code";
private static String ORG_BRANCH_CODE = "supervise_org_code"; private static String ORG_BRANCH_CODE = "supervise_org_code";
...@@ -162,6 +149,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -162,6 +149,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
private final static String JG_ALL_ES_INDEX = "idx_biz_view_jg_all";
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -1374,4 +1363,98 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1374,4 +1363,98 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
return unitEquipCategoryList; return unitEquipCategoryList;
} }
public void updateJgAllEs() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<Map<String, Object>> jgAllEsPage = equipmentCategoryMapper.selectJgUseInfo();
stopWatch.stop();
log.info("查询selectJgUseInfo耗时:{}", stopWatch.getTotalTimeMillis());
stopWatch.start();
// 设置查询条件和scroll参数
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchSourceBuilder.size(BATCH_SIZE); // 每次滚动返回的结果数
searchSourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
// 发送初始搜索请求
SearchRequest searchRequest = new SearchRequest(JG_ALL_ES_INDEX);
searchRequest.scroll(new TimeValue(60, TimeUnit.SECONDS)); // 设置Scroll上下文的持续时间
searchRequest.source(searchSourceBuilder);
List<ESEquipmentCategoryDto> recordList = Lists.newArrayList();
int saveCount = 0;
String scrollId = null;
try {
SearchResponse searchResponse;
while (true) {
if (scrollId == null) {
searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
log.info("查询jg_all_es耗时:{}", stopWatch.getTotalTimeMillis());
scrollId = searchResponse.getScrollId();
} else {
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId);
scrollRequest.scroll(new TimeValue(60, TimeUnit.SECONDS));
searchResponse = restHighLevelClient.scroll(scrollRequest, RequestOptions.DEFAULT);
log.info("处理es scroll 耗时:{}", stopWatch.getTotalTimeMillis());
if (searchResponse.getHits().getHits().length == 0) {
break;
}
}
processSearchHits(searchResponse.getHits().getHits(), jgAllEsPage, recordList);
if (recordList.size() >= BATCH_SIZE) {
esEquipmentCategory.saveAll(recordList);
recordList.clear();
log.info("处理es saveAll 耗时:{}", stopWatch.getTotalTimeMillis());
}
if (!ValidationUtil.isEmpty(recordList)) {
esEquipmentCategory.saveAll(recordList);
log.info("处理最后剩余数据完成~~");
}
saveCount++;
}
if (!recordList.isEmpty()) {
esEquipmentCategory.saveAll(recordList);
}
log.info("更新jg_all_es saveAll 次数:{},总耗时:{},", saveCount, stopWatch.getTotalTimeMillis());
ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
clearScrollRequest.addScrollId(scrollId);
restHighLevelClient.clearScroll(clearScrollRequest, RequestOptions.DEFAULT);
} catch (Exception e) {
log.error("处理Elasticsearch数据时发生异常:", e);
}
}
private void processSearchHits(SearchHit[] hits, List<Map<String, Object>> jgAllEsPage, List<ESEquipmentCategoryDto> recordList) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (SearchHit hit : hits) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
if (dto2 != null) {
ESEquipmentCategoryDto esDto = JSONObject.parseObject(JSON.toJSONString(dto2), ESEquipmentCategoryDto.class);
Map<String, Object> resultMap = jgAllEsPage.stream()
.filter(i -> i.get("record").equals(esDto.getSEQUENCE_NBR()))
.findFirst()
.orElse(null);
if (resultMap != null) {
Object province = resultMap.get("PROVINCE");
Object city = resultMap.get("CITY");
Object county = resultMap.get("COUNTY");
Object usePlace = resultMap.get("USE_PLACE");
esDto.setUSE_PLACE_CODE((province != null ? province + "#" : "")
+ (city != null ? city + "#" : "")
+ (county != null ? county.toString() : ""));
esDto.setUSE_SITE_CODE(usePlace != null ? usePlace.toString() : "");
recordList.add(esDto);
}
}
}
stopWatch.stop();
log.info("处理es 数据耗时:{}", stopWatch.getTotalTimeMillis());
}
} }
\ No newline at end of file
...@@ -451,7 +451,7 @@ public class ScreenImpl implements IScreenService { ...@@ -451,7 +451,7 @@ public class ScreenImpl implements IScreenService {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//设置模糊搜索 //设置模糊搜索
searchSourceBuilder.query(QueryBuilders.boolQuery() searchSourceBuilder.query(QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("USE_PLACE_CODE", "##610324")) .must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*"+screenDto.getCityCode()+"*"))
.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true))); .must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true)));
searchSourceBuilder.aggregation( searchSourceBuilder.aggregation(
AggregationBuilders.terms("USE_SITE_CODE").field("USE_SITE_CODE") AggregationBuilders.terms("USE_SITE_CODE").field("USE_SITE_CODE")
......
...@@ -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);
} }
...@@ -64,4 +64,6 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -64,4 +64,6 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
* @author yangyang * @author yangyang
*/ */
TzBaseEnterpriseInfo selectBySeq(Long sequenceNbr); TzBaseEnterpriseInfo selectBySeq(Long sequenceNbr);
Long countByUnitTypeAndOrgCode(@Param("orgCode") String orgCode,@Param("unitType") String unitType);
} }
...@@ -11,4 +11,6 @@ import java.util.Set; ...@@ -11,4 +11,6 @@ import java.util.Set;
public interface TzsUserInfoMapper extends BaseMapper<TzsUserInfo> { public interface TzsUserInfoMapper extends BaseMapper<TzsUserInfo> {
Page<TzsUserInfoDto> selectPageMessage(@Param("page") Page<TzsUserInfoDto> page, @Param("dto") TzsUserInfoDto dto); Page<TzsUserInfoDto> selectPageMessage(@Param("page") Page<TzsUserInfoDto> page, @Param("dto") TzsUserInfoDto dto);
Long countUserByPostAndAreaCode(@Param("orgCode") String orgCode, @Param("post") String post);
} }
...@@ -25,4 +25,26 @@ ...@@ -25,4 +25,26 @@
WHERE WHERE
RECORD = #{record} RECORD = #{record}
</select> </select>
<select id="sumPipeLengthByArea" resultType="java.lang.String">
select
COALESCE(round(sum(p."PIPE_LENGTH"), 2),0) 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 a.areaCode like concat('%',#{cityCode}, '%')
</select>
</mapper> </mapper>
...@@ -196,4 +196,13 @@ ...@@ -196,4 +196,13 @@
<select id="selectBySeq" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo"> <select id="selectBySeq" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo">
select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr} select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr}
</select> </select>
<select id="countByUnitTypeAndOrgCode" resultType="java.lang.Long">
SELECT
count(1)
FROM
"tz_base_enterprise_info" a
where
a.supervise_org_code like concat(#{orgCode},'%')
and a.unit_type like concat('%', #{unitType},'%')
</select>
</mapper> </mapper>
...@@ -48,4 +48,16 @@ ...@@ -48,4 +48,16 @@
</where> </where>
order by rec_date order by rec_date
</select> </select>
<select id="countUserByPostAndAreaCode" resultType="java.lang.Long">
SELECT
count(1)
FROM
tzs_user_info tui,
tz_base_enterprise_info bi
WHERE
tui.unit_code = bi.use_code
and tui.post LIKE concat ( '%', #{post}, '%' )
and bi.supervise_org_code LIKE CONCAT ( #{orgCode}, '%' )
and tui.is_delete=false
</select>
</mapper> </mapper>
\ No newline at end of file
package com.yeejoin.amos.boot.module.ymt.biz.dao; package com.yeejoin.amos.boot.module.ymt.biz.dao;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
......
...@@ -10,7 +10,7 @@ import com.google.common.collect.Lists; ...@@ -10,7 +10,7 @@ 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.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
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.dto.EquipmentMessageDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentMessageDto;
......
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