Commit fc1a16de authored by tangwei's avatar tangwei

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

parents 138904fa f16a348b
......@@ -27,26 +27,26 @@ public class PdfUtils {
return document;
}
/**
*
* @param value 单元格数据
* @param font 单元格样式
* @param align 位置
* @param colspan 占几列
* @param row 占几行
* @param size 高度
* @return
*/
public static PdfPCell createCell(String value, Font font, int align, int colspan, int row, int size){
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(value,font));
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){
......
<?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>
......@@ -76,7 +76,6 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc
* @param dutyDay 值班日期
* @param shiftIds 班次id
* @param fieldCodes 动态列
* @param appKey 应用标识
* @param groupCode 表单类型
* @return List<Map < String, Object>>
*/
......@@ -84,6 +83,5 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc
@Param("dutyDate") String dutyDay,
@Param("shiftId") String shiftIds,
@Param("fieldCodes") Map<String, Object> fieldCodes,
@Param("appKey") String appKey,
@Param("groupCode") String groupCode);
}
......@@ -48,6 +48,12 @@
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.${key} = #{value}
</when>
<when test="fieldCodes[key] == 'ge' and value !=null and value !=''">
and d.${key} >= #{value}
</when>
<when test="fieldCodes[key] == 'le' and value !=null and value !=''">
and d.${key} <![CDATA[<=]]> #{value}
</when>
</choose>
</foreach>
</if>
......@@ -72,7 +78,7 @@
and i.APP_KEY = #{appKey}
</if>
GROUP by
i.INSTANCE_ID)d
i.INSTANCE_ID) d
<if test="params != null and params.size() > 0">
where
1=1
......@@ -84,6 +90,12 @@
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.${key} = #{value}
</when>
<when test="fieldCodes[key] == 'ge' and value !=null and value !=''">
and d.${key} >= #{value}
</when>
<when test="fieldCodes[key] == 'le' and value !=null and value !=''">
and d.${key} <![CDATA[<=]]> #{value}
</when>
</choose>
</foreach>
</if>
......@@ -150,7 +162,6 @@
from
cb_dynamic_form_instance i
where i.GROUP_CODE = #{groupCode}
and i.APP_KEY = #{appKey}
GROUP by
i.INSTANCE_ID ) d,
cb_duty_person_shift ps,
......
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;
}
......@@ -16,6 +16,13 @@ import java.util.Map;
*/
public interface AlertCalledMapper extends BaseMapper<AlertCalled> {
/**
* 接警情况统计-交接班用
*
* @param beginDate
* @param endDate
* @return
*/
Map<String, Integer> queryAlertStatusCount(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
List<AlertCalledZhDto> alertCalledListByAlertStatus(@Param("address") String address);
......
......@@ -9,8 +9,13 @@
sum( CASE WHEN alert_type_code = 230 THEN 1 ELSE 0 END ) majorAlertCount
FROM
jc_alert_called
WHERE
call_time BETWEEN #{beginDate} AND #{endDate}
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>
......
......@@ -42,7 +42,7 @@
<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'">
<if test="key != null and key == 'beginDate' and value != null and value != ''">
and d.recDate >= #{value}
</if>
<if test="key != null and key == 'endDate'">
......
......@@ -44,17 +44,34 @@
</select>
<select id="getPowerTransferInfoCount" resultType="java.util.Map">
select count(distinct pt.sequence_nbr) transfer_count, count(distinct resources_id) car_count, 0 end_count, 0 no_return_car_count
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 pt.rec_date BETWEEN #{beginDate} AND #{endDate}
<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 pt.rec_date BETWEEN #{beginDate} AND #{endDate}
<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"
......@@ -62,7 +79,15 @@
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 pt.rec_date BETWEEN #{beginDate} AND #{endDate}
<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"
......@@ -71,8 +96,14 @@
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 pt.rec_date BETWEEN #{beginDate} AND #{endDate}
and ptc.is_distribution_agencies = 0
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>
......
......@@ -19,5 +19,6 @@
<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-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>
......@@ -149,9 +149,8 @@ public class DutyPersonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("查询当前值班人信息列表")
@GetMapping("/person/on_duty/list")
public ResponseModel listOnDutyPerson(HttpServletRequest request) {
String appKey = request.getHeader("appKey");
return ResponseHelper.buildResponse(iDutyPersonService.listOnDutyPerson(appKey));
public ResponseModel listOnDutyPerson() {
return ResponseHelper.buildResponse(iDutyPersonService.listOnDutyPerson());
}
......
......@@ -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)
......
......@@ -78,5 +78,5 @@ public interface IDutyCommonService {
*
* @return List<Map < String, Object>>
*/
List<Map<String, Object>> listOnDutyPerson(String appKey);
List<Map<String, Object>> listOnDutyPerson();
}
......@@ -300,11 +300,11 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
}
@Override
public List<Map<String, Object>> listOnDutyPerson(String appKey) {
public List<Map<String, Object>> listOnDutyPerson() {
String groupCode = this.getGroupCode();
// 获取当前班次列表
DateTime now = new DateTime();
List<Long> shiftIdList = getOnDuty(now, appKey);
List<Long> shiftIdList = getOnDuty(now);
String shiftIds = StringUtils.join(shiftIdList.toArray(), ",");
String dutyDay = now.toString("yyyy-MM-dd");
// 获取当前值班人员
......@@ -312,7 +312,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
List<Map<String, Object>> maps = dynamicFormInstanceService.getBaseMapper().listOnDutyPerson(dutyDay,
shiftIds, fieldCodes, RequestContext.getAppKey(), groupCode);
shiftIds, fieldCodes, groupCode);
// 获取人员照片和电话
List<Long> ids = new ArrayList<>();
maps.forEach(item -> ids.add(Long.valueOf(String.valueOf(item.get("userId")))));
......@@ -334,8 +334,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return maps;
}
private List<Long> getOnDuty(DateTime now, String appKey) {
List<DutyShiftDto> dutyShiftDtos = dutyShiftService.queryForDutyShiftList(appKey, false);
private List<Long> getOnDuty(DateTime now) {
List<DutyShiftDto> dutyShiftDtos = dutyShiftService.queryForDutyShiftList(false);
List<Long> shiftIds = new ArrayList<>();
int hour = now.getHourOfDay();
int minute = now.getMinuteOfHour();
......
......@@ -31,4 +31,8 @@ public class DutyShiftServiceImpl extends BaseService<DutyShiftDto, DutyShift, D
public List<DutyShiftDto> queryForDutyShiftList(String appKey, Boolean isDelete) {
return this.queryForList("", false, appKey, isDelete);
}
public List<DutyShiftDto> queryForDutyShiftList(Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
}
......@@ -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);
......
......@@ -139,8 +139,6 @@ public class DynamicFormInstanceServiceImpl extends BaseService<DynamicFormInsta
localMap.putAll(parameterMap);
localMap.remove("current");
localMap.remove("size");
localMap.remove("beginDate");
localMap.remove("endDate");
Map<String, String> params = new HashMap<>();
if (!ValidationUtil.isEmpty(localMap)) {
for (String key : localMap.keySet()) {
......
......@@ -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);
}
}
}
......@@ -283,7 +283,7 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/dateRange/list")
@ApiOperation(httpMethod = "GET", value = "查询指定日期内警情列表", notes = "查询指定日期内警情列表")
public ResponseModel<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.getAlertInfoList(beginDate, endDate));
}
......
......@@ -89,7 +89,7 @@ public class ExcelController extends BaseController {
@Autowired
IDutyPersonService iDutyPersonService;
private static final String NOT_DUTY = "休";
private static final String NOT_DUTY = "休";
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -677,20 +677,8 @@ public class ExcelController extends BaseController {
list.add(o.getPostTypeName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
HashMap<String, String> dutyShiftMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
dutyShift.forEach(item -> dutyShiftMap.put(format.format(item.getDutyDate()), item.getShiftName()));
if (!dutyShift.isEmpty()) {
for (int i = 0; i < dayByMonth.size(); i++) {
if (dutyShiftMap.containsKey(dayByMonth.get(i))) {
list.add(dutyShiftMap.get(dayByMonth.get(i)));
} else {
list.add(NOT_DUTY);
}
}
}
data.add(list);
});
}
......@@ -713,12 +701,19 @@ public class ExcelController extends BaseController {
list.add(o.getCarName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
data.add(list);
});
}
return data;
}
private void initDutyShift(List<String> dayByMonth, List<DutyPersonShiftDto> dutyShift, ArrayList<Object> list) {
HashMap<String, String> dutyShiftMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
dutyShift.forEach(item -> dutyShiftMap.put(format.format(item.getDutyDate()), item.getShiftName()));
if (!dutyShift.isEmpty()) {
for (int i = 0; i < dayByMonth.size(); i++) {
if (dutyShiftMap.containsKey(dayByMonth.get(i))) {
list.add(dutyShiftMap.get(dayByMonth.get(i)));
......@@ -727,11 +722,6 @@ public class ExcelController extends BaseController {
}
}
}
data.add(list);
});
}
return data;
}
private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth,
ExcelDto excelDto, List<? extends Object> data, Boolean flag) {
......
......@@ -188,8 +188,8 @@ public class PowerTransferController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/power/list")
@ApiOperation(value = "力量出动列表", notes = "力量调派资源树")
public ResponseModel<Object> getPowerTransferList(@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate,
@ApiParam(value = "结束日期", required = true) @RequestParam String endDate) {
public ResponseModel<Object> getPowerTransferList(@ApiParam(value = "开始日期") @RequestParam(defaultValue = "") String beginDate,
@ApiParam(value = "结束日期") @RequestParam(defaultValue = "") String endDate) {
return ResponseHelper.buildResponse(powerTransferService.getPowerTransferList(beginDate, endDate));
}
......
......@@ -245,6 +245,16 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
}
}
private static int comparingByGroupVal(Map<String, Object> map, Map<String, Object> map2, String key) {
int result = 0;
if (map.get(key) instanceof Date) {
long r1 = ((Date) map.get(key)).getTime();
long r2 = ((Date) map2.get(key)).getTime();
result = Long.compare(r1, r2);
}
return result;
}
/**
* 根据时间区间查询警情列表信息
*
......@@ -253,8 +263,10 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
*/
public List<Map<String, Object>> listByDateRange(String beginDate, String endDate) {
// 查询指定日期内的警情列表
List<AlertCalled> alertCalledList =
this.list(new LambdaQueryWrapper<AlertCalled>().between(AlertCalled::getCallTime, beginDate, endDate));
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);
......@@ -264,8 +276,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
alertCalledList.stream().collect(Collectors.groupingBy(AlertCalled::getAlertTypeCode));
Map<Long, AlertCalled> calledMap =
alertCalledList.stream().collect(Collectors.toMap(AlertCalled::getSequenceNbr, Function.identity()));
alertCalledMap.forEach((alert, list) -> {
allList.addAll(iAlertFormValueService.listAll(alert, queryParams));
alertCalledMap.forEach((alertTypeCode, list) -> {
allList.addAll(iAlertFormValueService.listAll(alertTypeCode, queryParams));
});
allList.forEach(i -> {
......@@ -273,6 +285,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
i.putAll(Bean.BeantoMap(alertCalled));
});
}
// 按接警时间正序排序
allList.sort((e, o) -> comparingByGroupVal(e, o, "callTime"));
return allList;
}
......
......@@ -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);
// 对高亮词条进行操作
List<ESAlertCalledDto> list = new LinkedList<>();
long totle = 0;
try
{
SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
List<ESAlertCalledDto> list = new LinkedList<>();
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)
{
// TODO: handle exception
}
result.setRecords(list);
result.setTotal(searchHits.getTotalHits());
result.setTotal(totle);
return result;
}
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.base.Joiner;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPTable;
......@@ -11,19 +12,26 @@ import com.yeejoin.amos.boot.biz.common.utils.PdfUtils;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DynamicFormInstanceServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeDutyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangeInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ShiftChangePowerDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.ShiftChange;
import com.yeejoin.amos.boot.module.jcs.api.mapper.ShiftChangeMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IShiftChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import springfox.documentation.spring.web.json.Json;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
......@@ -121,20 +129,29 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
@Override
public void exportPdfById(HttpServletResponse response, Long shiftChangeId) throws IOException, DocumentException {
// 告诉浏览器用什么软件可以打开此文件
response.setHeader("content-Type", "application/pdf");
response.setContentType("application/pdf;charset=UTF-8");
response.setHeader("content-Type", "application/pdf;charset=UTF-8");
// 下载文件的默认名称
response.setHeader("Content-Disposition", "attachment;filename=交接班记录表.pdf");
String fileName = "交接班记录表.pdf";
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName,
StandardCharsets.UTF_8.name()));
// 创建document对象
Document document = PdfUtils.createFile(response);
// 获取pdf文件数据
ShiftChangeDto shiftChange = this.queryBySeq(shiftChangeId);
ShiftChangeInfoDto ShiftChangeInfoDto = new ShiftChangeInfoDto();
if (shiftChange != null) {
Map<String, Object> baseInfo = dynamicFormInstanceService.getOneMap(shiftChange.getInstanceId(), GROUP_CODE);
ShiftChangeInfoDto ShiftChangeInfoDto = (ShiftChangeInfoDto) Bean.mapToBean(baseInfo, ShiftChangeInfoDto.class);
ShiftChangeInfoDto = (ShiftChangeInfoDto) Bean.mapToBean(baseInfo, ShiftChangeInfoDto.class);
} else {
shiftChange = new ShiftChangeDto();
}
// 创建pdf格式
createPDFReport(document,ShiftChangeInfoDto,shiftChange);
}
/**
* 创建pdf文件样式数据
*/
public void createPDFReport(Document document,ShiftChangeInfoDto shiftChangeInfoDto,ShiftChangeDto shiftChange) throws IOException, DocumentException {
document.open();
// 基本样式参数
......@@ -142,57 +159,107 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
Font cellContent = new Font(bfChinese, 11, Font.NORMAL);
Font cellTitle = new Font(bfChinese, 11, Font.BOLD);
Font title = new Font(bfChinese, 20, Font.BOLD);
int size = 35;
int size = 30;
int smallSize = 0;
// 表头
Paragraph docTitle = new Paragraph("119接警坐席交接班记录\n", title);
docTitle.setAlignment(Element.ALIGN_CENTER);
// docTitle.setSpacingBefore(20);
// 表格内容
PdfPTable table1 = PdfUtils.createTable(8);
int[] widths = { 12, 25, 25, 25, 25, 20, 25, 25 };
table1.setWidthPercentage(100);
table1.setSpacingBefore(10);
table1.setWidths(widths);
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
String recDare = shiftChange.getRecDate() != null ? sdf.format(shiftChange.getRecDate()) : "";
// 第一行
table1.addCell(PdfUtils.createCell("时间:", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChange.getRecDate().toString(), cellContent,Element.ALIGN_CENTER,3,1,size));
table1.addCell(PdfUtils.createCell("值班领导:", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getJsDutyLeader(), cellContent,Element.ALIGN_CENTER,3,1,size));
table1.addCell(PdfUtils.createCell("时间", cellTitle,Element.ALIGN_CENTER,1,1,
size,1,1,0,1));
table1.addCell(PdfUtils.createCell(recDare, cellContent,Element.ALIGN_CENTER,3,1,
size,1,1,0,0));
table1.addCell(PdfUtils.createCell("值班领导", cellTitle,Element.ALIGN_CENTER,1,1,
size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getJsDutyLeader(), cellContent,Element.ALIGN_CENTER,3,1,
size,1,1,0,0));
// 第二行
table1.addCell(PdfUtils.createCell("值班员", cellTitle,Element.ALIGN_CENTER,1,3,size));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("值班开始时间", cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("交接班时间", cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("接班员", cellTitle,Element.ALIGN_CENTER,1,3,size));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("值\n班\n员", cellTitle,Element.ALIGN_CENTER,1,3,
size,1,1,0,1));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,
size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,
size,1,1,0,0));
table1.addCell(PdfUtils.createCell("值班开始时间", cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("交接班时间", cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("接班员", cellTitle,Element.ALIGN_CENTER,1,3,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
// 第三行
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getBeginDate(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getEndDate(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getBeginDate(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getEndDate(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
// 第四行
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonLeader(), cellContent,Element.ALIGN_CENTER,3,1,size));
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonLeader(), cellContent,Element.ALIGN_CENTER,1,1,size));
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonLeader(), cellContent,Element.ALIGN_CENTER,3,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonLeader(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
JSONObject dutyJson = shiftChange.getDutyJson();
JSONObject powerJson = shiftChange.getPowerJson();
ShiftChangeDutyDto dutyDto = new ShiftChangeDutyDto();
ShiftChangePowerDto powerDto = new ShiftChangePowerDto();
if (dutyJson != null) {
dutyDto = JSONObject.toJavaObject(dutyJson, ShiftChangeDutyDto.class);
}
if (powerJson != null) {
powerDto = JSONObject.toJavaObject(powerJson, ShiftChangePowerDto.class);
}
List<String> infoList = dutyDto.getAlertInfoList();
List<String> powerList = powerDto.getTransferContent();
int infoSize = infoList != null ? infoList.size() : 0;
int powerSize = powerList != null ? powerList.size() : 0;
String alarmRemark = dutyDto.getAlarmRemark() == null ? "无" : dutyDto.getAlarmRemark();
String powerRemark = powerDto.getPowerRemark() == null ? "无" : powerDto.getPowerRemark();
// 值班情况
table1.addCell(PdfUtils.createCell("值班情况", cellTitle,Element.ALIGN_LEFT,1,4,size));
table1.addCell(PdfUtils.createCell("接警情况:", cellContent,Element.ALIGN_LEFT,7,1,size));
table1.addCell(PdfUtils.createCell(shiftChange.getDutyJson().toString(), cellContent,Element.ALIGN_LEFT,7,1,120));
table1.addCell(PdfUtils.createCell("力量出动:", cellContent,Element.ALIGN_LEFT,7,1,size));
table1.addCell(PdfUtils.createCell(shiftChange.getPowerJson().toString(), cellContent,Element.ALIGN_LEFT,7,1,120));
table1.addCell(PdfUtils.createCell("值\n班\n情\n况", cellTitle,Element.ALIGN_CENTER,1,6+powerSize+infoSize,size,1,1,0,1));
table1.addCell(PdfUtils.createCell("接警情况:", cellTitle,Element.ALIGN_LEFT,7,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("接警"+ dutyDto.getCalledCount() +"起", cellContent, Element.ALIGN_CENTER,1,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("未结案" + dutyDto.getUnFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("已结案" + dutyDto.getFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("重大警情" + dutyDto.getMajorAlertCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,1,0,0));
if (!ObjectUtils.isEmpty(infoList)) {
for (String info : infoList) {
table1.addCell(PdfUtils.createCell(info, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
}
}
table1.addCell(PdfUtils.createCell("备注:"+alarmRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
table1.addCell(PdfUtils.createCell("力量出动:", cellTitle,Element.ALIGN_LEFT,7,1,size,0,1,0,0));
table1.addCell(PdfUtils.createCell("调派任务"+ powerDto.getTransfer_count() +"起", cellContent,Element.ALIGN_CENTER,1,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("调派车辆" + powerDto.getCar_count() + "辆次", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("已完成任务" + powerDto.getEnd_count() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("未归队车辆" + powerDto.getNo_return_car_count() + "辆", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,1,0,0));
if (!ObjectUtils.isEmpty(powerList)) {
for (String powerInfo : powerList) {
table1.addCell(PdfUtils.createCell(powerInfo, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
}
}
table1.addCell(PdfUtils.createCell("备注:"+powerRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
// 移交事宜
table1.addCell(PdfUtils.createCell("移交事宜", cellTitle,Element.ALIGN_LEFT,1,1,size));
table1.addCell(PdfUtils.createCell(shiftChange.getRemark(), cellContent,Element.ALIGN_LEFT,7,1,120));
table1.addCell(PdfUtils.createCell("移\n交\n事\n宜", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,1,1));
table1.addCell(PdfUtils.createCell(shiftChange.getRemark(), cellContent,Element.ALIGN_LEFT,7,1,120,1,1,1,0));
try{
document.add(docTitle);
......
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