Commit ea058d29 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register_to_0715' of…

Merge branch 'develop_tzs_register_to_0715' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_tzs_register_to_0715
parents a3fcbbac 7de04d0c
......@@ -8,7 +8,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
......@@ -91,6 +90,16 @@ public class AlertStatistics extends BaseEntity {
private String failureRate;
/**
* 平均救援时长(分钟)
*/
private String avgTime;
/**
* 30分钟内到达次数
*/
private Integer withinThirtyRescue;
/**
* 统计日期
*/
@TableField("statistics_date")
......
......@@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Param;
*/
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")String regionCode, @Param("startDate")String startDate , @Param("endDate")String endDate);
}
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 java.text.ParseException;
import java.time.LocalDate;
import java.util.List;
public interface IAlertStatisticsService {
......@@ -11,4 +13,6 @@ public interface IAlertStatisticsService {
void statisticalGeneration(String type);
List<AlertStatistics> getList(String date) throws ParseException;
JSONArray statisticInfoByRegionAndDate(String regionCode, LocalDate startDate, LocalDate endDate);
}
<?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.AlertStatisticsMapper">
<select id="getStatissticsMessage"
<select id="getStatisticsMessage"
resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics">
SELECT temp.*,
CASE
......@@ -57,4 +57,46 @@
) temp
</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>
package com.yeejoin.amos.boot.module.elevator.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
......@@ -23,6 +24,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -346,4 +348,11 @@ public class StatisticsController extends BaseController {
}
ExcelUtil.createTemplate(response, "困人救援超时情况统计", "困人救援超时情况统计", exportVos, AlertDispatchStatisticsExportVo.class, null, false);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/region/info")
@ApiOperation(httpMethod = "GET", value = "查询区域统计信息", notes = "查询区域统计信息")
public ResponseModel<JSONArray> statisticsRegionInfo(@RequestParam(value = "cityCode") String regionCode, @RequestParam(value = "startDate", required = false) LocalDate startDate, @RequestParam(value = "endDate", required = false) LocalDate endDate) {
return ResponseHelper.buildResponse(alertStatisticsService.statisticInfoByRegionAndDate(regionCode, startDate, endDate));
}
}
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.elevator.biz.service.impl;
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.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
......@@ -14,12 +16,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
......@@ -54,7 +59,7 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
if (!ObjectUtils.isEmpty(supervisionList)) {
supervisionList.forEach(item -> {
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.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode")));
statissticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr")));
......@@ -158,4 +163,54 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
alertStatistics.add(avg);
return alertStatistics;
}
@Override
public JSONArray statisticInfoByRegionAndDate(String regionCode, LocalDate startDate, LocalDate endDate) {
LocalDate today = LocalDate.now();
if (ObjectUtils.isEmpty(startDate) || ObjectUtils.isEmpty(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;
}
......@@ -46,4 +46,6 @@ public interface JgScrapCancelMapper extends BaseMapper<JgScrapCancel> {
Map<String, Object> queryEquipInformation(@Param("sequenceNbr") long sequenceNbr);
List<EquipBizCountDto> queryScrappedDeviceStaticListData(DPFilterParamDto dpFilterParamDto);
Integer getScrappedDeviceCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
}
......@@ -79,4 +79,6 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
String getEquCategoryNameByCode(String code);
List<EquipBizCountDto> queryNewDeviceStaticListData(DPFilterParamDto dpFilterParamDto);
Integer getUseRegisterCount(@Param("dpFilterParamDto") DPFilterParamDto dpFilterParamDto);
}
......@@ -289,4 +289,33 @@
c.equ_category,
c.equ_define
</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>
......@@ -592,4 +592,33 @@
c.equ_category,
c.equ_define
</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>
......@@ -59,4 +59,15 @@ public class DPStatisticsController {
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForGlobal(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));
}
}
......@@ -30,6 +30,12 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilde
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.stereotype.Service;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.util.ArrayList;
......@@ -303,4 +309,41 @@ public class DPStatisticsServiceImpl {
DPMapStatisticsItemEnum itemEnum = DPMapStatisticsItemEnum.getInstanceByCategory(category);
return itemEnum.getCode();
}
public Map<String, Object> useRegisterCount(DPFilterParamDto dpFilterParamDto) {
// 2.按照前端约定格式返回数据
Map<String, Object> result = new HashMap<>();
List legendDataList = new ArrayList();
Map<String,Object> newDeviceMap = new HashMap<>();
newDeviceMap.put("dataKey","newDevice");
newDeviceMap.put("value","新增登记设备");
legendDataList.add(newDeviceMap);
Map<String,Object> scrappedDeviceMap = new HashMap<>();
scrappedDeviceMap.put("dataKey","scrappedDevice");
scrappedDeviceMap.put("value","报废设备");
legendDataList.add(scrappedDeviceMap);
result.put("legendData",legendDataList);
LocalDate today = LocalDate.now();
List xDataList = new ArrayList();
List<Integer> newDeviceList = new ArrayList();
List<Integer> scrappedDeviceList = 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 useRegisterCount = useRegistrationMapper.getUseRegisterCount(dpFilterParamDto);
Integer scrappedDeviceCount = scrapCancelMapper.getScrappedDeviceCount(dpFilterParamDto);
xDataList.add(firstDayOfPrevMonth.getMonthValue()+"月");
newDeviceList.add(null == useRegisterCount ? 0 : useRegisterCount);
scrappedDeviceList.add(null == scrappedDeviceCount ? 0 : scrappedDeviceCount);
}
result.put("xdata",xDataList);
result.put("newDevice",newDeviceList);
result.put("scrappedDevice",scrappedDeviceList);
return result;
}
}
......@@ -26,14 +26,13 @@ public class ESEquipmentCategoryDto {
@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.Text)
@Field(type = FieldType.Keyword)
private String EQU_LIST_CODE;
@Field(type = FieldType.Text)
......@@ -42,7 +41,10 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text)
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;
@Field(type = FieldType.Text)
......@@ -51,7 +53,7 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Text)
private String EQU_CODE;
@Field(type = FieldType.Text)
@Field(type = FieldType.Keyword)
private String SUPERVISORY_CODE;
@Field(type = FieldType.Text)
......@@ -63,11 +65,85 @@ public class ESEquipmentCategoryDto {
@Field(type = FieldType.Integer)
private Integer EQU_STATE;
@Field(type = FieldType.Text)
@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;
}
......@@ -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.EquipmentCategoryDto;
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.vo.EquipExportVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -50,4 +50,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
List<EquipExportVo> getEquipExportData(@Param("dto") EquipExportDto dto);
List<Map<String, Object>> selectJgUseInfo();
}
......@@ -362,4 +362,8 @@
</where>
</select>
<select id="selectJgUseInfo" resultType="java.util.Map">
select record, PROVINCE, CITY, COUNTY, USE_PLACE from idx_biz_jg_use_info
</select>
</mapper>
......@@ -25,15 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
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.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -45,12 +37,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -76,7 +63,6 @@ public class EquipmentCategoryController extends BaseController {
@Value("${regulatory_code_prefix}")
String REGULATORY_CODE_PREFIX;
/**
* 新增装备分类
*
......@@ -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;
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.stereotype.Repository;
......
......@@ -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.utils.RedisKey;
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.EquipExportDto;
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.entity.CategoryOtherInfo;
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.entity.*;
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.EquipmentClassifityEnum;
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.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.mapper.*;
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.biz.dao.ESEquipmentCategory;
......@@ -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.model.CompanyModel;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.ClearScrollRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
......@@ -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.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
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.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
......@@ -126,6 +112,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String LEVEL = "company";
private static final String EQUSTATE = "EQU_STATE";
private static final String USEPLACE = "USE_PLACE";
private static final int BATCH_SIZE = 1000;
private static String USE_CODE = "use_code";
private static String ORG_BRANCH_CODE = "supervise_org_code";
......@@ -162,6 +149,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired
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
}
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 {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//设置模糊搜索
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)));
searchSourceBuilder.aggregation(
AggregationBuilders.terms("USE_SITE_CODE").field("USE_SITE_CODE")
......
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