Commit 500b1226 authored by tianbo's avatar tianbo

feat:大屏应急接口迁移至统计服务

parent dd322395
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.common.api.entity.AlertStatistics;
import com.yeejoin.amos.boot.module.ymt.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.Elevator;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
......@@ -60,4 +61,6 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
Page<AlertCalledQueryDto> getAlertCalledRecords(IPage<AlertCalledQueryDto> page, @Param("dto")AlertCalledQueryDto dto, @Param("orgCode") String orgCode);
List<AlertPaperInfoDto> getAlertPaperInfoList(@Param("regionCodes") List<String> regionCodes, @Param("isHistory") Boolean isHistory);
}
......@@ -408,4 +408,44 @@
</if>
ORDER BY a.call_time desc
</select>
<select id="getAlertPaperInfoList" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.AlertPaperInfoDto">
SELECT
a.sequence_nbr AS alertId,
a.region_code AS regionCode,
ibjoi.CODE96333 AS rescueCode,
a.alarm_type_code AS alarmTypeCode,
a.alarm_type AS alarmType,
CONCAT(ibjui.PROVINCE_NAME ,ibjui.CITY_NAME ,ibjui.COUNTY_NAME) AS area,
a.address AS address,
a.call_time AS callTime,
ifnull ( ibjui."LONGITUDE_LATITUDE"::json->> 'latitude', null ) AS latitude,
ifnull ( ibjui."LONGITUDE_LATITUDE"::json->> 'longitude', null ) AS longitude,
a.alert_stage AS alertStatus,
ibjui.RECORD AS elevatorId,
ibjoi.SUPERVISORY_CODE AS elevatorCode
FROM tz_alert_called a
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjoi.RECORD = a.equipment_id
LEFT JOIN idx_biz_jg_use_info ibjui ON ibjui.RECORD = ibjoi.RECORD
WHERE a.is_delete = 0
<choose>
<when test="isHistory == true">
AND a.alert_status = 1
AND
DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[ <= ]]> a.call_time
</when>
<otherwise>
AND a.alert_status = 0
</otherwise>
</choose>
<if test="regionCodes != null">
AND
<foreach collection="regionCodes" index="index" item="item" open="(" separator=" OR " close=")">
a.region_code LIKE CONCAT('%', #{item}, '%')
</foreach>
</if>
order by a.call_time desc
</select>
</mapper>
......@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.statistcs.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.EmergencyBizServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.VoiceRecordFileDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
......@@ -11,6 +13,8 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
@RestController
@RequestMapping(value = "/dp/biz/emergency")
@Api(tags = "大屏-应急-业务API")
......@@ -93,4 +97,40 @@ public class EmergencyBizController {
page.setSize(pageSize);
return ResponseHelper.buildResponse(emergencyBizService.getAlertCalledRecords(page, alertCalledQueryDto, cityCode));
}
/**
* 根据警情id 查找通话记录信息
*
* @return VoiceRecordFileDto
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据id获取通话记录信息", notes = "根据id获取通话记录信息")
@GetMapping(value = "/voiceRecordFile/{sequenceNbr}")
public ResponseModel<VoiceRecordFileDto> getRecordById(@PathVariable Long sequenceNbr) {
VoiceRecordFileDto record = emergencyBizService.getRecordById(sequenceNbr);
return ResponseHelper.buildResponse(record);
}
/**
* 根据id查询
*
* @param id 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/alertCalled/{id}")
@ApiOperation(httpMethod = "GET", value = "根据id查询单个警情接警填报记录", notes = "根据id查询单个警情接警填报记录")
public ResponseModel<Object> selectOne(@PathVariable Long id) {
return ResponseHelper.buildResponse(emergencyBizService.selectAlertCalledById(id));
}
/**
* 根据regionCode 获取区域内实时警情
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getActualAlert")
@ApiOperation(httpMethod = "GET", value = "根据regionCode 获取区域内实时警情", notes = "根据regionCode 获取区域内实时警情")
public ResponseModel<List<AlertPaperInfoDto>> getActualAlert(@RequestParam(name = "regionCodes", required = false) List<String> regionCodes) {
return ResponseHelper.buildResponse(emergencyBizService.getAlertPaperInfoList(emergencyBizService.authRegionCodeList(regionCodes),false));
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CommonBaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.*;
......@@ -12,6 +15,11 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.ymt.api.enums.TzsCommonParam;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -59,13 +67,16 @@ public class EmergencyBizServiceImpl {
@Value("classpath:/json/repairFollow.json")
private Resource repairFollowJson;
@Value("${redis.cache.failure.time:10800}")
private long time;
@Autowired
public EmergencyBizServiceImpl(AlertStatisticsMapper alertStatisticsMapper,
AlertCalledMapper alertCalledMapper,
RepairConsultMapper repairConsultMapper,
AlertFormValueMapper alertFormValueMapper,
VoiceRecordFileMapper voiceRecordFileMapper,
RescueProcessMapper rescueProcessMapper, DataDictionaryServiceImpl dataDictionaryService, CommonBaseMapper commonMapper, RescueStationMapper rescueStationMapper, DispatchTaskMapper dispatchTaskMapper, DispatchPaperMapper dispatchPaperMapper, ElevatorMapper elevatorMapper) {
RescueProcessMapper rescueProcessMapper, DataDictionaryServiceImpl dataDictionaryService, CommonBaseMapper commonMapper, RescueStationMapper rescueStationMapper, DispatchTaskMapper dispatchTaskMapper, DispatchPaperMapper dispatchPaperMapper, ElevatorMapper elevatorMapper, RedisUtils redisUtils) {
this.alertStatisticsMapper = alertStatisticsMapper;
this.alertCalledMapper = alertCalledMapper;
this.repairConsultMapper = repairConsultMapper;
......@@ -78,6 +89,7 @@ public class EmergencyBizServiceImpl {
this.dispatchTaskMapper = dispatchTaskMapper;
this.dispatchPaperMapper = dispatchPaperMapper;
this.elevatorMapper = elevatorMapper;
this.redisUtils = redisUtils;
}
private final AlertStatisticsMapper alertStatisticsMapper;
......@@ -92,6 +104,7 @@ public class EmergencyBizServiceImpl {
private final DispatchTaskMapper dispatchTaskMapper;
private final DispatchPaperMapper dispatchPaperMapper;
private final ElevatorMapper elevatorMapper;
private final RedisUtils redisUtils;
private static final Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
public Object getDetail(Long id) {
......@@ -675,4 +688,78 @@ public class EmergencyBizServiceImpl {
// 警情动态表单数据
return dispatchPaperMapper.selectOne(queryWrapper);
}
public VoiceRecordFileDto getRecordById(Long sequenceNbr) {
return voiceRecordFileMapper.getRecordById(sequenceNbr);
}
public Object selectAlertCalledById(Long id) {
if (redisUtils.hasKey(RedisKey.TZS_ALERTCALLED_ID + id)) {
return redisUtils.get(RedisKey.TZS_ALERTCALLED_ID + id);
}
AlertCalledFormDto alertCalledFormVo = getAlertCalledFormDto(id);
redisUtils.set(RedisKey.TZS_ALERTCALLED_ID + id, JSON.toJSON(alertCalledFormVo), time);
return alertCalledFormVo;
}
public List<AlertPaperInfoDto> getAlertPaperInfoList(List<String> regionCodes, Boolean isHistory) {
List<AlertPaperInfoDto> temp = alertStatisticsMapper.getAlertPaperInfoList(regionCodes, isHistory);
temp.forEach(t -> {
DispatchPaper paper = dispatchPaperMapper.selectOne(new LambdaQueryWrapper<DispatchPaper>().eq(DispatchPaper::getIsDelete,false).eq(DispatchPaper::getAlertId,t.getAlertId()));
if(paper != null) {
t.setFinishTime(paper.getFeedbackFinishTime());
}
});
return temp;
}
public List<String> authRegionCodeList(List<String> regionCodes) {
// 警情id 警情地址 警情状态 警情类型 警情发生时间
List<String> useRegionCode = this.getUserRegionCode();
if(regionCodes == null) {
regionCodes = useRegionCode;
} else {
// 判断传入regionCodes 是否越权
List<String> tempList = new ArrayList<>();
Iterator<String> regionIt = regionCodes.iterator();
while(regionIt.hasNext()) {
String tempCode = regionIt.next();
String districtCode = tempCode.substring(4,6);
String provinceCode = tempCode.substring(2,6);
if("0000".equals(provinceCode)) {// 为省则默认使用用户现有权限查询数据
regionCodes = useRegionCode;
} else {
if("00".equals(districtCode)) { // 为市
if(!useRegionCode.contains(tempCode)) { // 不包含该市权限 需要移除市搜索条件 添加 该市下区搜索条件
for(String tempUsercode : useRegionCode) {
if(tempUsercode.contains(tempCode.substring(0, 4))) {
tempList.add(tempUsercode);
}
}
regionIt.remove();
}
} else { // 为区 不会出现越权情况
}
}
}
regionCodes.addAll(tempList);
}
return regionCodes;
}
public List<String> getUserRegionCode() {
List<String> regionList = new ArrayList<>();
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
CompanyModel userCompany = me.getCompanys().get(0);
String regions = userCompany.getRegionSeq();
if(regions != null) {
String[] regionsId = regions.split(",");
for(String regionId:regionsId) {
RegionModel region = Systemctl.regionClient.getRegion(Long.valueOf(regionId)).getResult();
regionList.add(region.getRegionCode() + "");
}
}
return regionList;
}
}
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