Commit 97d4e993 authored by 李腾威's avatar 李腾威

地图接口开发

parent be3c1a32
package com.yeejoin.amos.boot.module.tzs.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author litw
* @date 2021-09-28.
*/
@Data
public class AlertPaperInfoDto {
@ApiModelProperty(value = "警情id")
private Long alertId;
@ApiModelProperty(value = "所属区域代码")
private String regionCode;
@ApiModelProperty(value = "电梯应急救援识别码")
private Integer rescueCode;
@ApiModelProperty(value = "警情类别code")
private String alarmTypeCode;
@ApiModelProperty(value = "所属区域")
private String area;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "报警时间")
private Date callTime;
@ApiModelProperty(value = "救援倒计时")
private String rescueTime;
@ApiModelProperty(value = "被困人数")
private String trappedNum;
@ApiModelProperty(value = "死亡人数")
private String dieNum;
@ApiModelProperty(value = "受伤人数")
private String injuredNum;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "停留时间")
private String stopTime;
}
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author litw
* @date 2021-09-26.
......@@ -17,6 +19,13 @@ public class EsElevatorDto {
*
*/
private static final long serialVersionUID = 1L;
/**
* 电梯id
*/
@ApiModelProperty(value = "电梯id")
private Long sequenceNbr;
/**
* 注册编码
*/
......@@ -83,4 +92,16 @@ public class EsElevatorDto {
@ApiModelProperty(value = "警情id")
private String alertId;
/**
* 是否当天
*/
@ApiModelProperty(value = "是否当天")
private Boolean isToday ;
/**
* 发生时间
*/
@ApiModelProperty(value = "发生时间")
private Date happenTime ;
}
......@@ -48,7 +48,7 @@ public class EsElevator {
/**
* 所属区域代码
*/
@Field(type = FieldType.Text)
@Field(type = FieldType.Text, searchAnalyzer = "ik_max_word", analyzer = "ik_max_word")
private String regionCode;
/**
......
......@@ -62,10 +62,13 @@ public interface AlertCalledMapper extends BaseMapper<AlertCalled> {
String alertStage,
String alertStatus,
String address);
Map<String, Integer> getTodayEmergencyCount();
Map<String, Integer> getTodayEmergencyCount(String regionCode);
Map<String, Integer> getImportantEventCount();
Map<String, Integer> getImportantEventDetail();
Map<String, Integer> getImportantEventCount(String regionCode);
List<Map<String, Object>> getImportantEventDetail(String type,String regionCode);
List<Map<String, Object>> getTodayEmergencyDetail(String rescueTotal,String rescueComplete, String regionCode);
}
......@@ -63,4 +63,6 @@ public interface IAlertCalledService {
AlertHandlerDto getHandlerInfo(String alertId);
Object getCalledInfo();
}
......@@ -260,12 +260,12 @@
<select id="getTodayEmergencyCount" resultType="java.util.Map">
SELECT
COUNT(alarm_type_code = '960') as sleepyTncidentTotal,
COUNT(tz.alarm_type_code = '960') as sleepyTncidentTotal,
sum(
CASE
WHEN
alarm_type_code = '960'
AND alert_stage_code IN ('861', '862')
tz.alarm_type_code = '960'
AND alert_stage_code IN ('860','861', '862')
THEN
1
ELSE
......@@ -274,9 +274,9 @@
) as rescueTotal ,
sum(
CASE
WHEN alarm_type_code = '960'
WHEN tz.alarm_type_code = '960'
AND
alert_stage_code in
tz.alert_stage_code in
('864','865','866') THEN
1
ELSE
......@@ -285,45 +285,147 @@
) as
rescueComplete
FROM
tz_alert_called where is_delete=0
tz_alert_called tz left join tcb_elevator el on tz.equipment_id = el.sequence_nbr where tz.is_delete=0
and tz.call_time >= (select current_date())
and (select date_add(current_date(), interval 1 day)) >= tz.call_time
<if test="regionCode != null and regionCode != ''">
AND el.region_code like CONCAT(CONCAT('%',#{regionCode}),'%')
</if>
</select>
<select id="getImportantEventCount" resultType="java.util.Map">
select count(1) as importantEventCount from (
SELECT
count(afv.alert_called_id) as importantEventCount
ac.*
FROM
tz_alert_called ac
LEFT JOIN (
INNER JOIN (
SELECT
*
alert_called_id
FROM
tz_alert_form_value
WHERE
tz_alert_form_value.field_value IS NOT NULL
AND tz_alert_form_value.field_value != ''
AND field_code IN ('injured_num', 'die_num')
AND tz_alert_form_value.field_value != '0'
AND field_code IN ('injured_num', 'die_num')
and tz_alert_form_value.is_delete=0
group by alert_called_id
) afv ON ac.sequence_nbr = afv.alert_called_id
WHERE
ac.alarm_type_code = '960' and ac.is_delete=0
) tzs left join tcb_elevator te on tzs.equipment_id = te.sequence_nbr
where 1=1
and tzs.call_time >= (select current_date())
and (select date_add(current_date(), interval 1 day)) >= tzs.call_time
<if test="regionCode != null and regionCode != ''">
AND te.region_code like CONCAT(CONCAT('%',#{regionCode}),'%')
</if>
</select>
<select id="getImportantEventDetail" resultType="java.util.Map">
select tzs.contact_phone,tzs.rec_user_name,
tzs.type,tzs.emergency_person,tzs.alarm_type,tzs.alert_source,tzs.address,
tzs.device_id,tzs.contact_user,tzs.alarm_type_code,tzs.sequence_nbr,date_format(tzs.call_time,"%Y-%m-%d %H:%i:%S") call_time,
tzs.rec_user_id,tzs.registration_code,tzs.emergency_call,tzs.type_code,tzs.equipment_id
,te.latitude ,te.region_code ,te.longitude,tzs.injured from (
SELECT
ac.*
ac.*,'有伤亡' as injured
FROM
tz_alert_called ac
LEFT JOIN (
INNER JOIN (
SELECT
*
alert_called_id
FROM
tz_alert_form_value
WHERE
tz_alert_form_value.field_value IS NOT NULL
AND tz_alert_form_value.field_value != ''
AND field_code IN ('injured_num', 'die_num')
AND tz_alert_form_value.field_value != '0'
AND field_code IN ('injured_num', 'die_num')
and tz_alert_form_value.is_delete=0
group by alert_called_id
) afv ON ac.sequence_nbr = afv.alert_called_id
WHERE
ac.alarm_type_code = '960' and ac.is_delete=0
) tzs left join tcb_elevator te on tzs.equipment_id = te.sequence_nbr
where 1=1
and tzs.call_time >= (select current_date())
and (select date_add(current_date(), interval 1 day)) >= tzs.call_time
<if test="regionCode != null and regionCode != ''">
AND te.region_code like CONCAT(CONCAT('%',#{regionCode}),'%')
</if>
</select>
<select id="getTodayEmergencyDetail" resultType="java.util.Map">
select tzs.contact_phone,tzs.rec_user_name,
tzs.type,tzs.emergency_person,tzs.alarm_type,tzs.alert_source,tzs.address,
tzs.device_id,tzs.contact_user,tzs.alarm_type_code,tzs.sequence_nbr,date_format(tzs.call_time,"%Y-%m-%d %H:%i:%S") call_time,
tzs.rec_user_id,tzs.registration_code,tzs.emergency_call,tzs.type_code,tzs.equipment_id
,te.latitude ,te.region_code ,te.longitude,tzs.injured from (
SELECT
ac.*,'有伤亡' as injured
FROM
tz_alert_called ac
INNER JOIN (
SELECT
alert_called_id
FROM
tz_alert_form_value
WHERE
tz_alert_form_value.field_value IS NOT NULL
AND tz_alert_form_value.field_value != ''
AND field_code IN ('injured_num', 'die_num')
and tz_alert_form_value.is_delete=0
group by alert_called_id
) afv ON ac.sequence_nbr = afv.alert_called_id
WHERE
ac.alarm_type_code = '960' and ac.is_delete=0
) tzs left join tcb_elevator te on tzs.equipment_id = te.sequence_nbr
where 1=1
and tzs.call_time >= (select current_date())
and (select date_add(current_date(), interval 1 day)) >= tzs.call_time
<if test="regionCode != null and regionCode != ''">
AND te.region_code like CONCAT(CONCAT('%',#{regionCode}),'%')
</if>
<if test="rescueTotal != null and rescueTotal != ''">
AND tzs.alert_stage_code in ('861','862')
</if>
<if test="rescueComplete != null and rescueComplete != ''">
AND tzs.alert_stage_code in ('864','865','866')
</if>
union all
select tzs.contact_phone,tzs.rec_user_name,
tzs.type,tzs.emergency_person,tzs.alarm_type,tzs.alert_source,tzs.address,
tzs.device_id,tzs.contact_user,tzs.alarm_type_code,tzs.sequence_nbr,date_format(tzs.call_time,"%Y-%m-%d %H:%i:%S") call_time,
tzs.rec_user_id,tzs.registration_code,tzs.emergency_call,tzs.type_code,tzs.equipment_id
,te.latitude ,te.region_code ,te.longitude,tzs.injured from (
select *,'无伤亡' as injured from tz_alert_called where sequence_nbr not in (
SELECT
alert_called_id
FROM
tz_alert_form_value
WHERE
tz_alert_form_value.field_value IS NOT NULL
AND tz_alert_form_value.field_value != ''
AND field_code IN ('injured_num', 'die_num')
and tz_alert_form_value.is_delete=0
group by alert_called_id
)
) tzs left join tcb_elevator te on tzs.equipment_id = te.sequence_nbr
where 1=1
and tzs.call_time >= (select current_date())
and (select date_add(current_date(), interval 1 day)) >= tzs.call_time
<if test="regionCode != null and regionCode != ''">
AND te.region_code like CONCAT(CONCAT('%',#{regionCode}),'%')
</if>
<if test="rescueTotal != null and rescueTotal != ''">
AND tzs.alert_stage_code in ('861','862')
</if>
<if test="rescueComplete != null and rescueComplete != ''">
AND tzs.alert_stage_code in ('864','865','866')
</if>
</select>
</mapper>
......
......@@ -9,6 +9,8 @@
tcb_rescue_station.address,
tcb_rescue_station.rescue_leader_id,
tcb_rescue_station.rescue_leader,
tcb_rescue_station.longitude,
tcb_rescue_station.latitude,
tcb_rescue_station.rescue_leader_phone,
(
ACOS(
......
......@@ -17,6 +17,7 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCallInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
......@@ -92,6 +93,9 @@ public class AlertCalledController extends BaseController {
@Autowired
WechatRelationServiceImpl wechatRelationService;
@Autowired
ElevatorServiceImpl elevatorService;
/**
* 新增警情接警填报记录
*
......@@ -155,6 +159,39 @@ public class AlertCalledController extends BaseController {
return ResponseHelper.buildResponse(alertCalledDtoReturn);
}
/**
* 警情信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getAlertInfo")
@ApiOperation(httpMethod = "GET", value = "警情信息", notes = "警情信息")
public ResponseModel<AlertPaperInfoDto> getAlertInfo(@RequestParam Long alertId
) {
AlertCalled alertCalled = iAlertCalledService.getById(alertId);
AlertPaperInfoDto alertPaperInfoDto = new AlertPaperInfoDto();
alertPaperInfoDto.setAlertId(alertCalled.getSequenceNbr());
iAlertCalledService.selectAlertCalledByIdNew(alertPaperInfoDto);
LambdaQueryWrapper<Elevator> queryWrapper1= new LambdaQueryWrapper<>();
queryWrapper1.eq(Elevator::getSequenceNbr,alertCalled.getEquipmentId());
Elevator elevator = elevatorService.getOne(queryWrapper1);
alertPaperInfoDto.setArea(elevator.getProvince() + elevator.getCity() + elevator.getDistrict());
alertPaperInfoDto.setAddress(alertCalled.getAddress());
alertPaperInfoDto.setCallTime(alertCalled.getCallTime());
alertPaperInfoDto.setLatitude(elevator.getLatitude());
alertPaperInfoDto.setLongitude(elevator.getLongitude());
alertPaperInfoDto.setAlarmTypeCode(alertCalled.getAlarmTypeCode());
alertPaperInfoDto.setRegionCode(elevator.getRegionCode());
alertPaperInfoDto.setRescueCode(elevator.getRescueCode());
return ResponseHelper.buildResponse(alertPaperInfoDto);
}
/**
*
* <pre>
......@@ -458,21 +495,21 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getTodayEmergencyCount")
@ApiOperation(httpMethod = "GET", value = "今日应急统计", notes = "今日应急统计")
public ResponseModel<Object> getTodayEmergencyCount() {
return ResponseHelper.buildResponse(iAlertCalledService.getTodayEmergencyCount());
}
/**
* 重大事件
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getImportantEventCount")
@ApiOperation(httpMethod = "GET", value = "重要大事件统计", notes = "重要大事件统计")
public ResponseModel<Object> getImportantEventCount() {
return ResponseHelper.buildResponse(iAlertCalledService.getImportantEventCount());
public ResponseModel<Object> getTodayEmergencyCount(@RequestParam String regionCode) {
return ResponseHelper.buildResponse(iAlertCalledService.getTodayEmergencyCount(regionCode));
}
//
// /**
// * 重大事件
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @GetMapping(value = "/getImportantEventCount")
// @ApiOperation(httpMethod = "GET", value = "重要大事件统计", notes = "重要大事件统计")
// public ResponseModel<Object> getImportantEventCount() {
// return ResponseHelper.buildResponse(iAlertCalledService.getImportantEventCount());
//
// }
/**
* 获取重大事件或者今日应急的统计详情信息
......@@ -480,8 +517,8 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getImportantEventOrTodayEmergencyCount")
@ApiOperation(httpMethod = "GET", value = "重要大事件统计", notes = "重要大事件统计")
public ResponseModel<Object> getImportantEventOrTodayEmergencyCount(@RequestParam String type) {
return ResponseHelper.buildResponse(iAlertCalledService.getImportantEventOrTodayEmergencyCount(type));
public ResponseModel<Object> getImportantEventOrTodayEmergencyCount(@RequestParam String type,@RequestParam String regionCode) {
return ResponseHelper.buildResponse(iAlertCalledService.getImportantEventOrTodayEmergencyCount(type,regionCode));
}
......@@ -495,4 +532,15 @@ public class AlertCalledController extends BaseController {
public ResponseModel<Object> getHandlerInfo(@RequestParam String alertId) {
return ResponseHelper.buildResponse(iAlertCalledService.getHandlerInfo(alertId));
}
/**
* 获取接警未派遣事件
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCalledInfo")
@ApiOperation(httpMethod = "GET", value = "获取接警未派遣事件", notes = "获取接警未派遣事件")
public ResponseModel<Object> getCalledInfo() {
return ResponseHelper.buildResponse(iAlertCalledService.getCalledInfo());
}
}
......@@ -356,7 +356,7 @@ public class ElevatorController extends BaseController {
public void init() {
IPage<Elevator> elevatorPage = new Page<>();
Integer count = elevatorService.count();
for(int i = 0; i <= count % 500 ; i ++ ) {
for(int i = 0; i <= 2 ; i ++ ) {
elevatorPage.setCurrent(i);
elevatorPage.setSize(500);
elevatorPage = elevatorService.page(elevatorPage);
......@@ -369,19 +369,17 @@ public class ElevatorController extends BaseController {
/**
* ES分页查询电梯信息
* ES查询电梯信息
*
* @param current 当前页
* @param size 每页大小
* @param elevatorDto 查询参数
* @return 查询结果
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/query_elevator_list_es", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "ES分页查询电梯信息", notes = "ES分页查询电梯信息")
public ResponseModel<IPage<EsElevatorDto>> queryElevatorListEs(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size,
@ApiOperation(httpMethod = "POST", value = "ES查询电梯信息", notes = "ES查询电梯信息")
public ResponseModel<List<EsElevatorDto>> queryElevatorListEs(
@RequestBody EsElevatorDto elevatorDto){
Page<EsElevatorDto> page = esElevatorService.queryByKeys(elevatorDto,current,size);
List<EsElevatorDto> page = esElevatorService.queryByKeys(elevatorDto);
return ResponseHelper.buildResponse(page);
}
}
......
......@@ -30,6 +30,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -241,5 +243,29 @@ public class RescueStationController extends BaseController {
return ResponseHelper.buildResponse(iRescueStationService.getListByLatLonDistance(latitude,longitude,distance));
}
/**
* 根据警情id和距离返回救援机构信息
* @param alertId
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/alert/{alertId}/distance", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据警情id和距离返回5个救援机构信息", notes = "根据警情id和距离返回5个救援机构信息")
public ResponseModel<Object> selectByAlertIdDistance(@PathVariable Long alertId) {
// 获取根据警情获取电梯信息
Elevator elevator = elevatorServiceImpl.selectByAlertId(alertId);
String longitude = elevator.getLongitude();
String latitude = elevator.getLatitude();
// 根据经纬度和距离返回救援机构信息
List<RescueStationDto> rescueStationDtos = new LinkedList<>();
List<RescueStationDto> list = iRescueStationService.getListByLatLonDistance(latitude,longitude,1000);
if(list.size() > 5) {
for(int i = 0 ; i < 5 ; i ++ ) {
rescueStationDtos.add(list.get(i));
}
}
return ResponseHelper.buildResponse(list.size() > 5 ? rescueStationDtos: list);
}
}
......@@ -18,6 +18,7 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertHandlerDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertHandlerInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.FormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
......@@ -43,7 +44,6 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -139,6 +139,28 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
}
}
public void selectAlertCalledByIdNew(AlertPaperInfoDto alertCalled) {
// 警情基本信息
LambdaQueryWrapper<AlertFormValue> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, alertCalled.getAlertId());
// 警情动态表单数据
List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
if(list!=null&&list.size()>0) {
for (AlertFormValue alertFormValue : list) {
if(alertFormValue.getFieldCode().equals("trapped_num")) {
alertCalled.setTrappedNum(alertFormValue.getFieldValue());
}
if(alertFormValue.getFieldCode().equals("injured_num")) {
alertCalled.setInjuredNum(alertFormValue.getFieldValue());
}
if(alertFormValue.getFieldCode().equals("die_num")) {
alertCalled.setDieNum(alertFormValue.getFieldValue());
}
}
}
}
@Override
public AlertCalledFormDto selectAlertCalledByIdNoCache(Long id) {
// 警情基本信息
......@@ -258,8 +280,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
if(null == called) {
throw new BadRequest("警情不存在");
}
map.put("接警",called.getCallTime());
map.put("上报",called.getRecDate());
map.put("answerThePolice",called.getCallTime());
map.put("report",called.getRecDate());
LambdaQueryWrapper<DispatchPaper> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(DispatchPaper::getAlertId,Long.valueOf(alertId));
......@@ -278,9 +300,9 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
if(null != dispatchTask &&dispatchTask.size() > 0 ) {
List<DispatchTask> taskList = dispatchTask.stream().filter(e->e.getOrgType().equals(s)).collect(Collectors.toList());
if(taskList.size() > 0) {
map.put("派遣/通知",called.getRecDate());
map.put("到达",dispatchTask.get(0).getArriveTime());
map.put("完成",dispatchTask.get(0).getSaveTime());
map.put("notice",called.getRecDate());
map.put("arrive",dispatchTask.get(0).getArriveTime());
map.put("complete",dispatchTask.get(0).getSaveTime());
dataInit(alertHandlerInfoDto,s,"", "","已派遣",
dispatchTask.get(0).getArriveTime() == null ? "" : "已到达" ,dispatchTask.get(0).getSaveTime() == null ? "" : "已完成",
dispatchPaper.getFeedbackTime() != null || dispatchPaper.getFeedbackFinishTime() != null ? "已回访" : "");
......@@ -290,7 +312,7 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
}
list.add(alertHandlerInfoDto);
}
map.put("回访",dispatchPaper.getFeedbackTime());
map.put("returnVisit",dispatchPaper.getFeedbackTime());
} else {
for(String s:str) {
AlertHandlerInfoDto alertHandlerInfoDto = new AlertHandlerInfoDto();
......@@ -303,6 +325,14 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
return alertHandlerDto;
}
@Override
public Object getCalledInfo() {
LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(AlertCalled::getAlertStageCode,"860");
Object list = this.list(queryWrapper);
return list;
}
private void dataInit(AlertHandlerInfoDto alertHandlerInfoDto, String process,String answerThePolice, String report, String notice, String arrive, String complete,String returnVisit) {
alertHandlerInfoDto.setProcess(process);
alertHandlerInfoDto.setAnswerThePolice(answerThePolice);
......@@ -363,6 +393,10 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
alertCalled.setAlertStageCode(AlertStageEnums.JJ.getId());
alertCalled.setType(AlertStageEnums.JQCB.getValue());
alertCalled.setTypeCode(AlertStageEnums.JQCB.getId());
LambdaQueryWrapper<Elevator> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Elevator::getRescueCode,alertCalled.getDeviceId());
Elevator elevator = iElevatorService.getOne(queryWrapper);
alertCalled.setEquipmentId(elevator.getSequenceNbr());
this.save(alertCalled);
// 动态表单
......@@ -495,27 +529,56 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
return result;
}
public Object getTodayEmergencyCount() {
return alertCalledMapper.getTodayEmergencyCount();
}
public Object getImportantEventCount() {
return alertCalledMapper.getImportantEventCount();
public Object getTodayEmergencyCount(String regionCode) {
Map<String,Integer> map = alertCalledMapper.getTodayEmergencyCount(regionCode);
Map<String,Integer> map1 = alertCalledMapper.getImportantEventCount(regionCode);
map.put("importantEventCount",map1.get("importantEventCount"));
return map;
}
public Object getImportantEventOrTodayEmergencyCount(String type) {
List<Map<String, Object>> map=null;
LambdaQueryWrapper<AlertCalled> queryWrapper=new LambdaQueryWrapper<AlertCalled>();
queryWrapper.eq(AlertCalled::getIsDelete, 0);
queryWrapper.eq(AlertCalled::getAlarmTypeCode, "960");
if("rescueTotal".equals(type)) {
queryWrapper.in(AlertCalled::getAlertStageCode,Arrays.asList("861","862"));
}else if("rescueComplete".equals(type)) {
queryWrapper.in(AlertCalled::getAlertStageCode,Arrays.asList("864","865","866"));
}
// public Object getImportantEventCount() {
// return
// }
public Object getImportantEventOrTodayEmergencyCount(String type,String regionCode) {
// List<Map<String, Object>> map=null;
// List<Map<String, Object>> map1= new LinkedList<>();
// LambdaQueryWrapper<AlertCalled> queryWrapper=new LambdaQueryWrapper<AlertCalled>();
// queryWrapper.eq(AlertCalled::getIsDelete, 0);
// queryWrapper.eq(AlertCalled::getAlarmTypeCode, "960");
// if("rescueTotal".equals(type)) {
// queryWrapper.in(AlertCalled::getAlertStageCode,Arrays.asList("861","862"));
// }else if("rescueComplete".equals(type)) {
// queryWrapper.in(AlertCalled::getAlertStageCode,Arrays.asList("864","865","866"));
// }
if("importantEventCount".equals(type)) {
return alertCalledMapper.getImportantEventDetail();
}
return this.baseMapper.selectMaps(queryWrapper);
}
return alertCalledMapper.getImportantEventDetail(type,regionCode);
} else {
if("rescueTotal".equals(type)) {
return alertCalledMapper.getTodayEmergencyDetail(type,null,regionCode);
} else if("rescueComplete".equals(type)) {
return alertCalledMapper.getTodayEmergencyDetail(null,type,regionCode);
} else {
return alertCalledMapper.getTodayEmergencyDetail(null,null,regionCode);
}
}
// for (Map<String,Object> m: map
// ) {
// LambdaQueryWrapper<Elevator> queryWrapper1=new LambdaQueryWrapper<>();
// queryWrapper1.eq(Elevator::getIsDelete, 0);
// queryWrapper1.eq(Elevator::getSequenceNbr, m.get("equipment_id"));
// Elevator elevator = iElevatorService.getOne(queryWrapper1);
// m.put("injured","无伤亡");
// if(null != elevator) {
// m.put("longitude",elevator.getLongitude());
// m.put("latitude",elevator.getLatitude());
// m.put("regionCode",elevator.getRegionCode());
//
// if(elevator.getRegionCode().contains(regionCode)) {
// map1.add(m);
// }
// }
// }
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.EsElevatorDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
......@@ -13,7 +12,6 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
......@@ -25,6 +23,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
*
......@@ -69,8 +68,10 @@ public class ESElevatorServiceImpl {
esElevator.setCity(elevator.getCity());
esElevator.setDistrict(elevator.getDistrict());
esElevator.setLatitude(elevator.getLatitude());
esElevator.setLongitude(elevator.getLongitude());
esElevator.setRegisterCode(elevator.getRegisterCode());
esElevator.setRegionCode(elevator.getRegionCode());
esElevator.setRescueCode(elevator.getRescueCode());
esElavtorRepository.save(esElevator);
return esElevator;
......@@ -81,38 +82,49 @@ public class ESElevatorServiceImpl {
* 根据关键字查询文档,关键字不为空时按相关性从大到小排序
*
* @param elevatorDto 关键字
* @param current 当前页码
* @param size 页面大小
* @return
*/
@SuppressWarnings({ "rawtypes" })
public Page<EsElevatorDto> queryByKeys(EsElevatorDto elevatorDto, int current, int size) {
Page<EsElevatorDto> result = new Page<>(current, size);
public List<EsElevatorDto> queryByKeys(EsElevatorDto elevatorDto) {
String alarmTypeCode = elevatorDto.getAlarmTypeCode();
String address = elevatorDto.getAddress();
String regionCode = elevatorDto.getRegionCode();
String alertId = elevatorDto.getAlertId();
/**
* 通用匹配规则,条件构建
*/
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper();
if(!ValidationUtil.isEmpty(alarmTypeCode)) {
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(AlertCalled::getAlarmTypeCode,alarmTypeCode);
}
if(!ValidationUtil.isEmpty(alertId)) {
AlertCalled alertCalled = iAlertCalledService.getById(elevatorDto.getAlertId());
BoolQueryBuilder qb4 = QueryBuilders.boolQuery();
qb4.must(QueryBuilders.termQuery("sequenceNbr", alertCalled.getEquipmentId()));
boolMust.must(qb4);
}
if(elevatorDto.getIsToday() != null && elevatorDto.getIsToday()) {
queryWrapper.ge(AlertCalled::getCallTime, DateUtils.stampToDate(System.currentTimeMillis(),DateUtils.DATE_PATTERN));
queryWrapper.le(AlertCalled::getCallTime, DateUtils.stampToDate(DateUtils.dateAddDays(new Date(),1).getTime(),DateUtils.DATE_PATTERN));
List<AlertCalled> alertCalleds = iAlertCalledService.list(queryWrapper);
List<Long> stringList = new ArrayList<>();
for (AlertCalled al: alertCalleds
) {
stringList.add(al.getEquipmentId());
}
qb0.must(QueryBuilders.termsQuery("sequenceNbr", stringList.toArray()));
boolMust.must(qb0);
}
List<AlertCalled> alertCalleds = iAlertCalledService.list(queryWrapper);
List<Long> stringList = new ArrayList<>();
for (AlertCalled al: alertCalleds
) {
stringList.add(al.getEquipmentId());
}
List<Long> listL = stringList.stream().distinct().collect(Collectors.toList());
qb0.should(QueryBuilders.termsQuery("sequenceNbr", listL.toArray()));
boolMust.must(qb0);
if(!ValidationUtil.isEmpty(address)) {
BoolQueryBuilder boolMustAddress = QueryBuilders.boolQuery();
......@@ -124,22 +136,20 @@ public class ESElevatorServiceImpl {
if(!ValidationUtil.isEmpty(regionCode)) {
BoolQueryBuilder qb2= QueryBuilders.boolQuery().
filter(QueryBuilders. termQuery("regionCode", regionCode));
filter(QueryBuilders. matchPhraseQuery("regionCode", regionCode));
boolMust.must(qb2);
}
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页
.withPageable(PageRequest.of(current, size))
// .withPageable(PageRequest.of(current, size))
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.withQuery(boolMust);
List<EsElevatorDto> list = new LinkedList<>();
long totle = 0;
try
{
SearchHits<EsElevator> searchHits =elasticsearchTemplate.search(queryBuilder.build(), EsElevator.class);
......@@ -148,17 +158,22 @@ public class ESElevatorServiceImpl {
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
EsElevatorDto esElevatorDto =JSONObject.toJavaObject(jsonObject, EsElevatorDto.class);
for (AlertCalled al: alertCalleds
) {
if(al.getEquipmentId().equals(esElevatorDto.getSequenceNbr())) {
esElevatorDto.setHappenTime(al.getCallTime());
esElevatorDto.setAlertId(String.valueOf(al.getSequenceNbr()));
esElevatorDto.setAlarmTypeCode(al.getAlarmTypeCode());
break;
}
}
list.add(esElevatorDto);
}
totle =searchHits.getTotalHits();
}
catch (Exception e)
{
// TODO: handle exception
}
result.setRecords(list);
result.setTotal(totle);
return result;
return list;
}
}
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