Commit 03ac6887 authored by suhuiguang's avatar suhuiguang

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents ac2964cd 08bd15e1
......@@ -47,6 +47,18 @@
<artifactId>easypoi-annotation</artifactId>
<version>3.0.3</version>
</dependency>
<!-- itext pdf相关 -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
<!-- itext asian 字体相关 -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.boot.biz.common.utils;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import javax.servlet.http.HttpServletResponse;
/**
* PDF工具类
*/
public class PdfUtils {
private static int maxWidth = 520;
public static Document createFile(HttpServletResponse response) { // 设置页面大小,联系文件
Document document=new Document();
document.setPageSize(PageSize.A4);
document.setPageCount(3);
try {
PdfWriter.getInstance(document, response.getOutputStream());
document.open();
} catch (Exception e) {
e.printStackTrace();
}
return document;
}
public static PdfPCell createCell(Object value, Font font, int align, int colspan, int row, int size,int top,int right,int bottom,int left){
String cellValue;
if (value == null) {
cellValue = "";
} else {
cellValue = value.toString();
}
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(cellValue,font));
cell.setFixedHeight(size);
if (row != 1) {
cell.setRowspan(row);
}
cell.setBorderWidthLeft(left);
cell.setBorderWidthRight(right);
cell.setBorderWidthTop(top);
cell.setBorderWidthBottom(bottom);
return cell;
}
public static PdfPCell createCell(Image image, int align, int colspan){
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setImage(image);
cell.setPadding(3.0f);
cell.setBorderWidthLeft(0);
cell.setBorderWidthRight(0);
cell.setBorderWidthTop(0);
cell.setBorderWidthBottom(1);
return cell;
}
// 创建一个几列的Table
public static PdfPTable createTable(int colNumber){
PdfPTable table = new PdfPTable(colNumber);
try{
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
}catch(Exception e){
e.printStackTrace();
}
return table;
}
}
......@@ -24,4 +24,7 @@ spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#mqtt-警情初报消息主题
mqtt.topic.alert.reporting=alertReporting
\ No newline at end of file
mqtt.topic.alert.reporting=alertReporting
#实战指挥新警情通报主题
mqtt.topic.command.alert.notice=alertNotice
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-api</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-command-api</artifactId>
<dependencies>
</dependencies>
</project>
......@@ -143,7 +143,8 @@
d.*,
ps.shift_id as shiftId,
ps.duty_date as dutyDate,
ds.name as shiftName
ds.name as shiftName,
'在岗' state
from
(
select
......
......@@ -35,4 +35,7 @@ public class PowerTransferCompanyResourcesDto extends BaseDto {
@ApiModelProperty(value = "操作人名称")
private String recUserName;
@ApiModelProperty(value = "调派关联部门id")
protected Long powerTransferCompanyId;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("接警情况详情")
public class ShiftChangeDutyDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "重大警情")
private String majorAlertCount="0";
@ApiModelProperty(value = "已结案")
private String finishedCount="0";
@ApiModelProperty(value = "接警")
private String calledCount="0";
@ApiModelProperty(value = "未结案")
private String unFinishedCount="0";
@ApiModelProperty(value = "接警情况列表")
private List<String> alertInfoList;
@ApiModelProperty(value = "备注")
private String alarmRemark;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("力量出动详情")
public class ShiftChangePowerDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "未归队车辆数")
private String no_return_car_count="0";
@ApiModelProperty(value = "调派任务数")
private String transfer_count="0";
@ApiModelProperty(value = "调派车辆数")
private String car_count="0";
@ApiModelProperty(value = "已完成任务数")
private String end_count="0";
@ApiModelProperty(value = "力量出动详情")
private List<String> transferContent;
@ApiModelProperty(value = "备注")
private String powerRemark;
}
......@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* 警情接警记录 Mapper 接口
......@@ -11,4 +14,12 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
*/
public interface AlertCalledMapper extends BaseMapper<AlertCalled> {
/**
* 接警情况统计-交接班用
*
* @param beginDate
* @param endDate
* @return
*/
Map<String, Integer> queryAlertStatusCount(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
}
......@@ -23,10 +23,12 @@ public interface AlertFormValueMapper extends BaseMapper<AlertFormValue> {
*
* @param fieldCodes 列
* @param groupCode 分组code
* @param params 查询参数
* @return List<Map>
*/
List<Map<String, Object>> listAll(
@Param("fieldCodes") List<String> fieldCodes,
@Param("groupCode") String groupCode
@Param("groupCode") String groupCode,
@Param("params") Map<String, String> params
);
}
......@@ -3,10 +3,12 @@ package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.PowerTransfer;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 力量调派 Mapper 接口
......@@ -26,4 +28,35 @@ public interface PowerTransferMapper extends BaseMapper<PowerTransfer> {
* @return
*/
List<String> queryTransferCarIdsByAlertCalledId(@Param("alertCalledId") Long alertCalledId);
/**
* 根据起止时间获取力量调派信息
*
* @param beginDate
* @param endDate
* @return
*/
List<PowerTransferDto> getPowerTransferInfo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
/**
* 根据起止时间获取力量调派单位信息
*
* @param beginDate
* @param endDate
* @return
*/
List<PowerTransferCompanyDto> getPowerTransferCompanyInfo(@Param("beginDate") String beginDate,
@Param("endDate") String endDate);
/**
*
* @param beginDate
* @param endDate
* @return
*/
List<PowerTransferCompanyResourcesDto> getPowerTransferCompanyResourcesInfo(@Param("beginDate") String beginDate,
@Param("endDate") String endDate);
Map<String, Object> getPowerTransferInfoCount(@Param("beginDate") String beginDate,
@Param("endDate") String endDate);
}
......@@ -2,7 +2,10 @@ package com.yeejoin.amos.boot.module.jcs.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itextpdf.text.DocumentException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -59,4 +62,9 @@ public interface IShiftChangeService {
* @return Map<String, Object>
*/
Map<String, Object> lastRecord();
/**
* 根据交接班记录id生成pdf
*/
void exportPdfById(HttpServletResponse response, Long shiftChangeId) throws IOException, DocumentException;
}
......@@ -2,4 +2,19 @@
<!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.jcs.api.mapper.AlertCalledMapper">
<select id="queryAlertStatusCount" resultType="java.util.Map">
SELECT
count( 1 ) calledCount,
sum( CASE WHEN alert_status = 1 THEN 1 ELSE 0 END ) finishedCount,
sum( CASE WHEN alert_type_code = 230 THEN 1 ELSE 0 END ) majorAlertCount
FROM
jc_alert_called
WHERE 1 = 1
<if test="beginDate != null and beginDate != ''">
and call_time >= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and call_time <![CDATA[ <= ]]> #{endDate}
</if>
</select>
</mapper>
......@@ -30,14 +30,26 @@
select
i.alert_called_id instanceId,
i.alert_type_code groupCode,
i.rec_date recDate,
<foreach collection="fieldCodes" item="item" index="key" separator=",">
MAX(CASE WHEN i.FIELD_CODE = #{item} THEN i.FIELD_VALUE END) as ${item}
MAX(CASE WHEN i.FIELD_CODE = #{item} THEN i.FIELD_VALUE ELSE '' END) as ${item}
</foreach>
from
jc_alert_form_value i
where i.alert_type_code = #{groupCode}
GROUP by
i.alert_called_id)d
<if test="params != null and params.size > 0 ">
where 1=1
<foreach collection="params" index="key" item="value">
<if test="key != null and key == 'beginDate' and value != null and value != ''">
and d.recDate >= #{value}
</if>
<if test="key != null and key == 'endDate'">
and d.recDate <![CDATA[<=]]> #{value}
</if>
</foreach>
</if>
order by instanceId
</select>
</mapper>
......@@ -36,13 +36,75 @@
having rec_date = (select rec_date from jc_power_transfer_company_resources order by rec_date desc limit 1)
</select>
<select id="queryTransferCarIdsByAlertCalledId" resultType="java.lang.String">
SELECT
ptcr.resources_id carId
FROM
`jc_power_transfer` pt
LEFT JOIN jc_power_transfer_company ptc ON ptc.power_transfer_id = pt.sequence_nbr
LEFT JOIN jc_power_transfer_company_resources ptcr ON ptcr.power_transfer_company_id = ptc.sequence_nbr
WHERE
pt.alert_called_id = #{alertCalledId}
SELECT ptcr.resources_id carId
FROM `jc_power_transfer` pt
LEFT JOIN jc_power_transfer_company ptc ON ptc.power_transfer_id = pt.sequence_nbr
LEFT JOIN jc_power_transfer_company_resources ptcr ON ptcr.power_transfer_company_id = ptc.sequence_nbr
WHERE pt.alert_called_id = #{alertCalledId}
</select>
<select id="getPowerTransferInfoCount" resultType="java.util.Map">
select count(distinct pt.sequence_nbr) transfer_count, count(distinct ptcr.sequence_nbr) car_count, 0 end_count, 0
no_return_car_count
from jc_power_transfer pt
left join jc_power_transfer_company ptc on pt.sequence_nbr = ptc.power_transfer_id
left join jc_power_transfer_company_resources ptcr on ptc.sequence_nbr = ptcr.power_transfer_company_id
<where>
<if test="beginDate != null and beginDate != ''">
AND pt.rec_date &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
AND pt.rec_date &lt;= #{endDate}
</if>
</where>
order by pt.rec_date asc
</select>
<select id="getPowerTransferInfo" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto">
select sequence_nbr, rescue_grid
from jc_power_transfer pt
<where>
<if test="beginDate != null and beginDate != ''">
AND pt.rec_date &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
AND pt.rec_date &lt;= #{endDate}
</if>
</where>
order by pt.rec_date asc
</select>
<select id="getPowerTransferCompanyInfo"
resultType="com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto">
select ptc.sequence_nbr, ptc.company_name, ptc.is_distribution_agencies, ptc.power_transfer_id
from jc_power_transfer pt
left join jc_power_transfer_company ptc on pt.sequence_nbr = ptc.power_transfer_id
<where>
<if test="beginDate != null and beginDate != ''">
AND pt.rec_date &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
AND pt.rec_date &lt;= #{endDate}
</if>
</where>
order by pt.rec_date asc
</select>
<select id="getPowerTransferCompanyResourcesInfo"
resultType="com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto">
select ptcr.power_transfer_company_id, ptcr.type, ptcr.resources_num, ptcr.resources_id
from jc_power_transfer pt
left join jc_power_transfer_company ptc on pt.sequence_nbr = ptc.power_transfer_id
left join jc_power_transfer_company_resources ptcr on ptc.sequence_nbr = ptcr.power_transfer_company_id
where ptc.is_distribution_agencies = 0
<if test="beginDate != null and beginDate != ''">
AND pt.rec_date &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
AND pt.rec_date &lt;= #{endDate}
</if>
order by pt.rec_date asc
</select>
</mapper>
......@@ -18,6 +18,7 @@
<module>amos-boot-module-tzs-api</module>
<module>amos-boot-module-jcs-api</module>
<!-- <module>amos-boot-module-demo-api</module>-->
<module>amos-boot-module-common-api</module>
<module>amos-boot-module-common-api</module>
<module>amos-boot-module-command-api</module>
</modules>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-command-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-command-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
</dependencies>
</project>
......@@ -112,7 +112,7 @@ public class DynamicFormColumnController extends BaseController {
*列表全部数据查询
*@return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET",value = "动态表单树形分组字段表列表全部数据查询", notes = "动态表单树形分组字段表列表全部数据查询")
@GetMapping(value = "/{groupCode}/list")
public ResponseModel<List<DynamicFormInitDto>> selectForList(@PathVariable("groupCode") String groupCode)
......
......@@ -324,7 +324,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
if (userId.equals(String.valueOf(usr.get("sequenceNbr")))) {
item.put("personImg", usr.get("personImg"));
item.put("telephone", usr.get("telephone"));
orgUsrList.remove(usr);
break;
}
}
});
......
......@@ -163,9 +163,12 @@ public class DynamicFormColumnServiceImpl extends BaseService<DynamicFormColumnD
default:
vo = new DynamicFormInitDto(dynamicForm.getFieldCode(), dynamicForm.getFieldName(),
dynamicForm.getFieldType(), new SelectItems(new ArrayList<>()), null);
dynamicFormValue = new DynamicFormInstanceDto(dynamicForm.getSequenceNbr(), dynamicForm.getFieldName(),
dynamicForm.getFieldCode(), dynamicForm.getBlock(), dynamicForm.getGroupCode());
dynamicFormValue = new DynamicFormInstanceDto();
BeanUtils.copyProperties(dynamicForm, dynamicFormValue);
dynamicFormValue.setSequenceNbr(null);
dynamicFormValue.setFormColumnId(dynamicForm.getSequenceNbr());
dynamicFormValue.setAppKey(appKey);
vo.setFormItemDescr(dynamicFormValue);
vo.setSort(dynamicFormValue.getSort());
listfrom.add(vo);
......
......@@ -130,7 +130,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
Object entity = clazz.cast(ob);
parentId = PARENTIDMethodNameme.invoke(entity) != null
parentId = !ObjectUtils.isEmpty(PARENTIDMethodNameme.invoke(entity))
? Long.valueOf(String.valueOf(PARENTIDMethodNameme.invoke(entity)))
: null;
......@@ -181,7 +181,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
for (Object ob : entityList) {
Object entity = clazz.cast(ob);
parentId = PARENTIDMethodNameme.invoke(entity) != null
parentId = !ObjectUtils.isEmpty(PARENTIDMethodNameme.invoke(entity))
? Long.valueOf(String.valueOf(PARENTIDMethodNameme.invoke(entity)))
: null;
......
package com.yeejoin.amos.boot.module.jcs.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}")
private String uris;
@Bean
@Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() {
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
throw new IllegalStateException("Invalid ES nodes " + "property '" + uris + "'", e);
}
}
}
......@@ -303,8 +303,8 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/dateRange/list")
@ApiOperation(httpMethod = "GET", value = "查询指定日期内警情列表", notes = "查询指定日期内警情列表")
public ResponseModel<List<Map<String, Object>>> listByDateRange(@RequestParam("beginDate") String beginDate,
public ResponseModel<Map<String, Object>> listByDateRange(@RequestParam(value = "beginDate", required = false) String beginDate,
@RequestParam("endDate") String endDate) {
return ResponseHelper.buildResponse(iAlertCalledService.listByDateRange(beginDate, endDate));
return ResponseHelper.buildResponse(iAlertCalledService.getAlertInfoList(beginDate, endDate));
}
}
\ No newline at end of file
......@@ -4,15 +4,11 @@ import java.util.Arrays;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.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;
......@@ -157,7 +153,8 @@ public class PowerTransferController extends BaseController {
@RequestMapping(value = "/list/{alert_called_id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据警情id获取力量调派列表", notes = "根据警情id获取力量调派列表")
public ResponseModel<PowerTransferSimpleDto> list(@PathVariable String alert_called_id) {
PowerTransferSimpleDto powerTransferSimpleDto = powerTransferService.getPowerTransferList(Long.parseLong(alert_called_id));
PowerTransferSimpleDto powerTransferSimpleDto =
powerTransferService.getPowerTransferList(Long.parseLong(alert_called_id));
return ResponseHelper.buildResponse(powerTransferSimpleDto);
}
......@@ -187,5 +184,15 @@ public class PowerTransferController extends BaseController {
public ResponseModel<Object> getPowerTree() {
return ResponseHelper.buildResponse(powerTransferService.getPowerTree());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/power/list")
@ApiOperation(value = "力量出动列表", notes = "力量调派资源树")
public ResponseModel<Object> getPowerTransferList(@ApiParam(value = "开始日期") @RequestParam(defaultValue = "") String beginDate,
@ApiParam(value = "结束日期") @RequestParam(defaultValue = "") String endDate) {
return ResponseHelper.buildResponse(powerTransferService.getPowerTransferList(beginDate, endDate));
}
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.itextpdf.text.DocumentException;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.service.IShiftChangeService;
......@@ -14,6 +15,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
......@@ -100,8 +102,13 @@ public class ShiftChangeController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "pdf下载", notes = "pdf下载")
@GetMapping("/pdf/export")
public void exportPdf(HttpServletResponse response,@RequestParam Long shiftChangeId){
public void exportPdf(HttpServletResponse response,@RequestParam Long shiftChangeId) {
try {
iShiftChangeService.exportPdfById(response, shiftChangeId);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -2,24 +2,37 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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.jcs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.jcs.api.enums.DutyInfoEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.TemplateMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertCalledService;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -45,7 +58,14 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Autowired
RuleAlertCalledService ruleAlertCalledService;
public static String GROUP_CODE = "229";
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.command.alert.notice}")
private String topic;
@Autowired
TemplateMapper templateMapper;
/**
*
......@@ -56,8 +76,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
* @param alertCalledObjsDto
* @return
*/
@Transactional
public AlertCalledObjsDto createAlertCalled(AlertCalledObjsDto alertCalledObjsDto) {
@Transactional(rollbackFor = RuntimeException.class)
public AlertCalledObjsDto createAlertCalled(AlertCalledObjsDto alertCalledObjsDto) {
try {
// 警情基本信息
AlertCalled alertCalled = alertCalledObjsDto.getAlertCalled();
......@@ -109,7 +129,10 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
alertCalledObjsDto.setAlertFormValue(alertFormValuelist);
//调用规则
ruleAlertCalledService.fireAlertCalledRule(alertCalledObjsDto);
}
//通知实战指挥页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
emqKeeper.getMqttClient().publish(topic, "0".getBytes(), RuleConfig.DEFAULT_QOS, true);
}
/**
......@@ -170,11 +193,79 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
* @param endDate 结束时间
*/
public List<Map<String, Object>> listByDateRange(String beginDate, String endDate) {
List<AlertCalled> alertCalledDtoList =
this.list(new LambdaQueryWrapper<AlertCalled>().between(AlertCalled::getCallTime, beginDate, endDate));
Map<String, List<AlertCalled>> alertCalledMap =
alertCalledDtoList.stream().collect(Collectors.groupingBy(AlertCalled::getAlertTypeCode));
List<Map<String, Object>> formValueList = iAlertFormValueService.listAll(GROUP_CODE);
return null;
// 查询指定日期内的警情列表
List<AlertCalled> alertCalledList =
this.list(new LambdaQueryWrapper<AlertCalled>().apply(!ValidationUtil.isEmpty(beginDate),
"call_time >= " + beginDate).le(true, AlertCalled::getCallTime, endDate));
Map<String, String> queryParams = Maps.newHashMap();
queryParams.put("beginDate", beginDate);
queryParams.put("endDate", endDate);
List<Map<String, Object>> allList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(alertCalledList)) {
Map<String, List<AlertCalled>> alertCalledMap =
alertCalledList.stream().collect(Collectors.groupingBy(AlertCalled::getAlertTypeCode));
Map<Long, AlertCalled> calledMap =
alertCalledList.stream().collect(Collectors.toMap(AlertCalled::getSequenceNbr, Function.identity()));
alertCalledMap.forEach((alertTypeCode, list) -> {
allList.addAll(iAlertFormValueService.listAll(alertTypeCode, queryParams));
});
allList.forEach(i -> {
AlertCalled alertCalled = calledMap.get(Long.parseLong(i.get("instanceId").toString()));
i.putAll(Bean.BeantoMap(alertCalled));
});
}
return allList;
}
public Map<String, Object> getAlertInfoList(String beginDate, String endDate) {
Map<String, Object> result = Maps.newHashMap();
List<Map<String, Object>> list = listByDateRange(beginDate, endDate);
// 获取接警情况模板
List<Template> templateList =
templateMapper.selectList(new LambdaQueryWrapper<Template>().eq(Template::getFormat, false).like(Template::getTypeCode,
DutyInfoEnum.接警情况.getKey() + "-"));
Map<String, Template> templateMap = templateList.stream().collect(Collectors.toMap(Template::getTypeCode,
Function.identity()));
List<String> contentList = Lists.newArrayList();
list.forEach(i -> {
String tempContent =
templateMap.get(DutyInfoEnum.接警情况.getKey() + "-" + i.get("alertTypeCode")).getContent();
contentList.add(replaceTemplate(tempContent, i));
});
Map<String, Integer> statusCountMap = alertCalledMapper.queryAlertStatusCount(beginDate, endDate);
Integer unFinishedCount =
this.count(new LambdaQueryWrapper<AlertCalled>().eq(AlertCalled::getAlertStatus, "0"));
result.put("alertInfoList", contentList);
result.putAll(statusCountMap);
result.put("unFinishedCount", unFinishedCount);
return result;
}
/**
* 替换模板
*
* @param tempContent 模板
* @param objMap 对象map
* @return
*/
private String replaceTemplate(String tempContent, Map<String, Object> objMap) {
int size = objMap.size();
String[] keys = objMap.keySet().toArray(new String[size]);
Object[] values = objMap.values().toArray(new Object[size]);
List<String> strList = Lists.newArrayList();
for (Object obj : values) {
if (!ValidationUtil.isEmpty(obj)) {
if (obj instanceof Date) {
obj = DateUtils.date2LongStr((Date) obj);
}
strList.add(obj.toString());
} else {
strList.add("");
}
}
return StringUtils.replaceEach(tempContent, keys, strList.toArray(new String[strList.size()]));
}
}
......@@ -46,10 +46,10 @@ public class AlertFormValueServiceImpl extends BaseService<AlertFormValueDto,Al
* @param groupCode
* @return List<Map <String, Object>>
*/
public List<Map<String, Object>> listAll(String groupCode) {
public List<Map<String, Object>> listAll(String groupCode, Map<String, String> queryParams) {
List<AlertForm> columns =
alertFormService.list(new LambdaQueryWrapper<AlertForm>().eq(AlertForm::getAlertTypeCode, groupCode));
List<String> fieldCodes = Lists.transform(columns, AlertForm::getFieldCode);
return this.baseMapper.listAll(fieldCodes, groupCode);
return this.baseMapper.listAll(fieldCodes, groupCode, queryParams);
}
}
......@@ -27,12 +27,6 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
/**
*
* <pre>
......@@ -274,18 +268,26 @@ public class ESAlertCalledService {
//过滤条件
.withQuery(boolMust);
// 对高亮词条进行操作
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
List<ESAlertCalledDto> list = new LinkedList<>();
for (SearchHit searchHit : searchHits.getSearchHits())
long totle = 0;
try
{
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
for (SearchHit searchHit : searchHits.getSearchHits())
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
list.add(eSAlertCalled);
}
totle =searchHits.getTotalHits();
}
catch (Exception e)
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
list.add(eSAlertCalled);
// TODO: handle exception
}
result.setRecords(list);
result.setTotal(searchHits.getTotalHits());
result.setTotal(totle);
return result;
}
......
......@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.jcs.api.enums.DutyInfoEnum;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -126,7 +127,8 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
fireCarListMapList.stream().filter(car -> ObjectUtils.isNotEmpty(car.get("teamId"))).filter(car ->
FireCarStatusEnum.执勤.getCode().equals(car.get("carState")) //TODO 后续如果需要多个状态需要删掉这个过滤条件
|| FireCarStatusEnum.出动.getCode().equals(car.get("carState"))).forEach(car -> {
FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car, FireBrigadeResourceDto.class);
FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car,
FireBrigadeResourceDto.class);
// TODO 后期根据车物联状态来返回,现在为"在位=执勤","执勤=出动"
if (FireCarStatusEnum.执勤.getCode().equals(fireCarDto.getCarState())) {
fireCarDto.setCarStateDesc(FireCarStatusEnum.执勤.getName());
......@@ -151,7 +153,8 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
FireBrigadeResourceDto fireCarResourceDto = new FireBrigadeResourceDto();
List<FireBrigadeResourceDto> fireBrigadeResourceDtoList =
resultMap.get(brigade.getSequenceNbr().toString());
long onDutyCarCount = fireBrigadeResourceDtoList.stream().filter(car -> FireCarStatusEnum.执勤.getCode().equals(car.getCarState())).count();
long onDutyCarCount =
fireBrigadeResourceDtoList.stream().filter(car -> FireCarStatusEnum.执勤.getCode().equals(car.getCarState())).count();
long outCarCount = fireBrigadeResourceDtoList.size() - onDutyCarCount;
fireCarResourceDto.setId(brigade.getSequenceNbr().toString());
fireCarResourceDto.setType(FireBrigadeTypeEnum.专职消防队.getKey());
......@@ -270,4 +273,50 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
public List<String> queryTransferCarIdsByAlertCalledId(Long alertCalledId) {
return this.baseMapper.queryTransferCarIdsByAlertCalledId(alertCalledId);
}
public Map<String, Object> getPowerTransferList(String beginDate, String endDate) {
// 获取力量调派信息
List<PowerTransferDto> powerTransferInfo = this.baseMapper.getPowerTransferInfo(beginDate, endDate);
List<PowerTransferCompanyDto> powerTransferCompanyInfo =
this.baseMapper.getPowerTransferCompanyInfo(beginDate, endDate);
List<PowerTransferCompanyResourcesDto> powerTransferCompanyResourcesInfo =
this.baseMapper.getPowerTransferCompanyResourcesInfo(beginDate, endDate);
Map<String, Object> transferInfo = this.baseMapper.getPowerTransferInfoCount(beginDate, endDate);
// 获取力量出动模板
Template template = templateService.getOne(new QueryWrapper<Template>().eq("type_code",
DutyInfoEnum.力量出动.getKey()).eq("format", false));
String templateContent = template.getContent();
List<String> transferContent = new ArrayList<>();
powerTransferInfo.forEach(pt -> {
StringBuilder transferDetail = new StringBuilder();
Long powerTransferId = pt.getSequenceNbr();
String rescueGrid = pt.getRescueGrid();
powerTransferCompanyInfo.forEach(ptc -> {
if (powerTransferId.equals(ptc.getPowerTransferId())) {
transferDetail.append(ptc.getCompanyName());
if (!ptc.getIsDistributionAgencies()) {
Long powerTransferCompanyId = ptc.getSequenceNbr();
transferDetail.append("车辆车牌号");
powerTransferCompanyResourcesInfo.forEach(ptcr -> {
if (powerTransferCompanyId.equals(ptcr.getPowerTransferCompanyId())) {
transferDetail.append(ptcr.getResourcesNum()).append("、");
}
});
transferDetail.deleteCharAt(transferDetail.length() - 1);
}
transferDetail.append(";");
}
});
transferDetail.deleteCharAt(transferDetail.length() - 1);
String transferDetails = templateContent.replace("departmentName-type-resourcesNum",
transferDetail.toString()).replace("rescueGrid", rescueGrid == null ? "" : rescueGrid).replace(
"taskStatus", "");
transferContent.add(transferDetails);
});
transferInfo.put("transferContent", transferContent);
return transferInfo;
}
}
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