Commit ba489051 authored by tangwei's avatar tangwei

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

parents a6968382 f352f85b
......@@ -50,6 +50,9 @@ public class AlertCalledRo implements Serializable{
@Label(value = "地址")
private String address;
@Label(value = "警情报送id")
private String alertSubmittedId;
/**
* 一般火灾
*/
......
......@@ -15,13 +15,18 @@ public enum AlertBusinessTypeEnum {
/**
* 警情续报,非警情确认,警情结案
*/
警情初报("reportAlert", "297", "警情初报"),
警情续报("reportAlert", "313", "警情续报"),
非警情确认("notAlert", "314", "非警情确认"),
警情结案("endAlert", "315", "警情结案");
一般火灾警情初报("fireReportAlert", "229", "SMS_JCS_0001", "一般火灾警情初报"),
航空器救援警情初报("aircraftReportAlert", "230", "SMS_JCS_0002", "航空器救援警情初报"),
突发事件救援警情初报("emergenciesReportAlert", "235", "SMS_JCS_0003", "突发事件救援警情初报"),
漏油现场安全保障警情初报("oilSpillReportAlert", "237", "SMS_JCS_0004", "漏油现场安全保障警情初报"),
专机保障警情初报("specialReportAlert", "238", "SMS_JCS_0005", "专机保障警情初报"),
警情续报("followReportAlert", "313", "SMS_JCS_0006", "警情续报"),
非警情确认("notAlert", "314", "SMS_JCS_0008", "非警情确认"),
警情结案("endAlert", "315", "SMS_JCS_0009", "警情结案");
private String key;
private String code;
private String sms_code;
private String name;
public String getKey() {
......@@ -47,4 +52,6 @@ public enum AlertBusinessTypeEnum {
public void setName(String name) {
this.name = name;
}
}
......@@ -11,6 +11,7 @@
FROM
cb_fire_team ft
LEFT JOIN cb_firefighters ff ON ff.fire_team_id = ft.sequence_nbr
WHERE ft.is_delete = 0
GROUP BY
ff.fire_team_id
</select>
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject;
import com.yeejoin.amos.boot.module.jcs.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSubmitTypeEnum;
......@@ -25,6 +22,7 @@ import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.PowerTransferCompanyVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.SchedulingReportingVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.TemplateVo;
import com.yeejoin.amos.boot.module.jcs.biz.rule.action.AlertCalledAction;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,22 +30,17 @@ import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
* 警情报送记录 服务实现类
*
* @author tb
* @date 2021-06-17
*/
* 警情报送记录 服务实现类
*
* @author tb
* @date 2021-06-17
*/
@Service
public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,AlertSubmitted,AlertSubmittedMapper> implements IAlertSubmittedService {
public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, AlertSubmitted, AlertSubmittedMapper> implements IAlertSubmittedService {
@Autowired
IAlertSubmittedObjectService iAlertSubmittedObjectService;
......@@ -63,6 +56,10 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
PowerTransferServiceImpl powerTransferService;
@Autowired
RuleAlertCalledService ruleAlertCalledService;
@Autowired
AlertCalledAction alertCalledAction;
@Autowired
OrgUsrServiceImpl orgUsrService;
@Override
public SchedulingReportingVo listSchedulingByParam(AlertSubmittedDto queryParam) {
......@@ -110,61 +107,85 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
@Override
public Boolean save(AlertSubmittedDto alertSubmittedDto, String userName) throws Exception {
saveAlertSubmitted(alertSubmittedDto, userName);
Long alertSubmittedId = saveAlertSubmitted(alertSubmittedDto, userName);
// 组装规则入参
AlertCalledVo alertCalledVo = new AlertCalledVo();
List<AlertFormValue> alertFormValue = new ArrayList<>();
AlertFormValue formValue = new AlertFormValue();
formValue.setFieldCode("alertSubmittedId");
formValue.setFieldValue(alertSubmittedId.toString());
alertFormValue.add(formValue);
alertCalledVo.setAlertFormValue(alertFormValue);
// TODO 调用规则
ruleAlertCalledService.fireAlertCalledRule(new AlertCalledVo(null,null));
ruleAlertCalledService.fireAlertCalledRule(alertCalledVo);
return true;
}
/**
* 规则回调
*/
public void ruleCallbackAction(Object obj) {
AlertSubmittedDto alertSubmittedDto = new AlertSubmittedDto();
alertSubmittedDto.setSubmissionMethodCode(SubmissionMethodEnum.SMS.getCode());
alertSubmittedDto.setSchedulingTypeCode(AlertSchedulingTypeEnum.融合调度.getCode());
// alertSubmittedDto.setBusinessTypeCode(AlertBusinessTypeEnum.警情初报.);
saveAlertSubmitted(alertSubmittedDto, "");
public void ruleCallbackAction(String smsCode,String sendIds, Object object) {
// 获取报送对象列表
List<AlertSubmittedObject> alertSubmittedObjectList = new ArrayList<>();
Set<String> mobiles = new HashSet<>();
// 根据id列表查询所有人员信息
ArrayList<String> list = new ArrayList<>(Arrays.asList(sendIds.split(",")));
Collection<OrgUsr> orgUsrs = orgUsrService.listByIds(list);
// 执行短信报送对象
saveAlertSubmittedObject(alertSubmittedObjectList, smsCode, mobiles, object);
}
/**
* 短信报送
*
* @param alertSubmittedDto 警情信息
* @param userName 用户名
* @param userName 用户名
*/
public void saveAlertSubmitted(AlertSubmittedDto alertSubmittedDto, String userName) {
// 1.保存警情记录主表
AlertSubmitted alertSubmitted = new AlertSubmitted();
alertSubmitted.setAlertCalledId(alertSubmittedDto.getAlertCalledId());
alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode());
Optional<AlertBusinessTypeEnum> businessTypeEnum = EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getBusinessTypeCode()));
alertSubmitted.setBusinessType(businessTypeEnum.get().getName());
alertSubmitted.setCallLogId(alertSubmittedDto.getCallLogId());
alertSubmitted.setSubmissionMethodCode(alertSubmittedDto.getSubmissionMethodCode());
Optional<SubmissionMethodEnum> submissionMethodEnum = EnumsUtils.getEnumObject(SubmissionMethodEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSubmissionMethodCode()));
alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName());
Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum = EnumsUtils.getEnumObject(AlertSchedulingTypeEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSchedulingTypeCode()));
alertSubmitted.setSchedulingTypeCode(alertSubmittedDto.getSchedulingTypeCode());
alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName());
alertSubmitted.setSubmissionContent(alertSubmittedDto.getSubmitContent().toJSONString());
alertSubmitted.setSender(userName);
alertSubmitted.setRecUserName(userName);
alertSubmitted.setUpdateTime(new Date());
alertSubmitted.setSubmissionTime(new Date());
public Long saveAlertSubmitted(AlertSubmittedDto alertSubmittedDto, String userName) {
Long alertSubmittedId = alertSubmittedDto.getSequenceNbr();
String smsCode = "";
Set<String> mobiles = new HashSet<>();
HashMap<String, String> smsParams;
if (alertSubmittedId == null) {
// 1.保存警情记录主表
AlertSubmitted alertSubmitted = new AlertSubmitted();
alertSubmitted.setAlertCalledId(alertSubmittedDto.getAlertCalledId());
alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode());
Optional<AlertBusinessTypeEnum> businessTypeEnum = EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getBusinessTypeCode()));
alertSubmitted.setBusinessType(businessTypeEnum.get().getName());
alertSubmitted.setCallLogId(alertSubmittedDto.getCallLogId());
alertSubmitted.setSubmissionMethodCode(alertSubmittedDto.getSubmissionMethodCode());
Optional<SubmissionMethodEnum> submissionMethodEnum = EnumsUtils.getEnumObject(SubmissionMethodEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSubmissionMethodCode()));
alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName());
Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum =
EnumsUtils.getEnumObject(AlertSchedulingTypeEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSchedulingTypeCode()));
alertSubmitted.setSchedulingTypeCode(alertSubmittedDto.getSchedulingTypeCode());
alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName());
alertSubmitted.setSubmissionContent(alertSubmittedDto.getSubmitContent().toJSONString());
alertSubmitted.setSender(userName);
alertSubmitted.setRecUserName(userName);
alertSubmitted.setUpdateTime(new Date());
alertSubmitted.setSubmissionTime(new Date());
this.baseMapper.insert(alertSubmitted);
this.baseMapper.insert(alertSubmitted);
alertSubmittedId = alertSubmitted.getSequenceNbr();
smsCode = businessTypeEnum.get().getSms_code();
}
// 2.保存任务表
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
Long finalAlertSubmittedId = alertSubmittedId;
// 报送给单位
if (AlertSubmitTypeEnum.Org.getKey().equals(alertSubmittedDto.getType())) {
alertSubmittedDto.getSubmitCompanyList().forEach(company -> {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(alertSubmitted.getSequenceNbr());
alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId);
alertSubmittedObject.setType(true);
alertSubmittedObject.setCompanyId(company.getCompanyId());
alertSubmittedObject.setCompanyName(company.getCompanyName());
......@@ -177,7 +198,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
alertSubmittedDto.getSubmitCompanyList().forEach(company -> {
company.getPersonList().forEach(person -> {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(alertSubmitted.getSequenceNbr());
alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId);
alertSubmittedObject.setType(false);
alertSubmittedObject.setCompanyId(company.getCompanyId());
alertSubmittedObject.setCompanyName(company.getCompanyName());
......@@ -185,7 +206,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
alertSubmittedObject.setUserName(person.getPersonName());
alertSubmittedObject.setUserPhone(person.getPersonPhone());
alertSubmittedObject.setRecUserName(userName);
mobiles.add(person.getPersonPhone());
alertSubmittedObjectList.add(alertSubmittedObject);
});
});
......@@ -198,7 +219,30 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
// 4.发送任务消息
// 4.1组织短信内容
smsParams = JSON.parseObject(JSON.toJSONString(alertSubmittedDto.getSubmitContent()), HashMap.class);
// 4.2调用短信发送接口
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
return finalAlertSubmittedId;
}
/**
* 短信报送对象
*
* @param alertSubmittedObjectList 报送对象列表
* @param smsCode 短信模板code
* @param mobiles 电话号码列表
* @param object 报送内容
*/
public void saveAlertSubmittedObject(List<AlertSubmittedObject> alertSubmittedObjectList, String smsCode,
Set<String> mobiles, Object object) {
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息
// 组织短信内容
HashMap<String, String> smsParams = new HashMap<String, String>();
Map<String, String> objectMap = JSON.parseObject(JSON.toJSONString(object), HashMap.class);
smsParams.putAll(objectMap);
// 调用短信发送接口
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
}
public void getAlertSubmittedContent(Long alertCalledId, ArrayList<TemplateVo> templateVos, String companyName) throws IllegalAccessException {
......@@ -216,7 +260,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
List<PowerTransferCompanyVo> lastPowerTransferCompany;
if ("警情续报".equals(template.getType()) && (lastPowerTransferCompany =
powerTransferService.getLastPowerTransferCompany(alertCalledId)).size() > 0) {
map.put("businessType",template.getType());
map.put("businessType", template.getType());
// 获取力量调派内容
StringBuilder companyNames = new StringBuilder();
StringBuilder resourcesInfo = new StringBuilder();
......@@ -226,6 +270,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto,Ale
}
map.put("companyNames", companyNames.deleteCharAt(companyNames.length() - 1).toString());
map.put("resourcesInfo", resourcesInfo.deleteCharAt(resourcesInfo.length() - 1).toString());
map.put("transferTime",lastPowerTransferCompany.get(0).getRecDate());
}
TemplateVo templateVo = new TemplateVo();
BeanUtils.copyProperties(template, templateVo);
......
......@@ -27,6 +27,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -137,23 +138,25 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
Long outCarCount = fireCarDtoList.size() - onDutyCarCount;
// 2.查询消防队伍列表
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code",
FireBrigadeTypeEnum.专职消防队.getCode()));
Map<String, List<FireBrigadeResourceDto>> resultMap =
fireCarDtoList.stream().collect(Collectors.groupingBy(FireBrigadeResourceDto::getTeamId));
resultMap.keySet().forEach(brigadeId -> {
FireBrigadeResourceDto fireCarResourceDto = new FireBrigadeResourceDto();
FireTeam fireTeam =
fullTimeFireBrigadeList.stream().filter(team -> brigadeId.equals(team.getSequenceNbr().toString())).findAny().orElse(new FireTeam());
if (ObjectUtils.isNotEmpty(fireTeam.getSequenceNbr())) {
fireCarResourceDto.setId(fireTeam.getSequenceNbr().toString());
fireCarResourceDto.setType(FireBrigadeTypeEnum.专职消防队.getKey());
fireCarResourceDto.setName(fireTeam.getName());
fireCarResourceDto.getChildren().addAll(resultMap.get(brigadeId));
fireCarResourceDto.setOutCount(outCarCount.intValue());
fireCarResourceDto.setOnDutyCount(onDutyCarCount.intValue());
fireBrigadeResourceList.add(fireCarResourceDto);
}
});
FireBrigadeTypeEnum.专职消防队.getCode()).eq("is_delete", 0));
if (!CollectionUtils.isEmpty(fullTimeFireBrigadeList)) {
Map<String, List<FireBrigadeResourceDto>> resultMap =
fireCarDtoList.stream().collect(Collectors.groupingBy(FireBrigadeResourceDto::getTeamId));
resultMap.keySet().forEach(brigadeId -> {
FireBrigadeResourceDto fireCarResourceDto = new FireBrigadeResourceDto();
FireTeam fireTeam =
fullTimeFireBrigadeList.stream().filter(team -> brigadeId.equals(team.getSequenceNbr().toString())).findAny().orElse(new FireTeam());
if (ObjectUtils.isNotEmpty(fireTeam.getSequenceNbr())) {
fireCarResourceDto.setId(fireTeam.getSequenceNbr().toString());
fireCarResourceDto.setType(FireBrigadeTypeEnum.专职消防队.getKey());
fireCarResourceDto.setName(fireTeam.getName());
fireCarResourceDto.getChildren().addAll(resultMap.get(brigadeId));
fireCarResourceDto.setOutCount(outCarCount.intValue());
fireCarResourceDto.setOnDutyCount(onDutyCarCount.intValue());
fireBrigadeResourceList.add(fireCarResourceDto);
}
});
}
// 3.消防队伍-监控大队
List<FireBrigadeResourceDto> monitorFireBrigadeList = fireTeamService.listMonitorFireBrigade();
......@@ -163,7 +166,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
monitorResourceDto.setType(FireBrigadeTypeEnum.监控大队.getKey());
monitorResourceDto.setChildren(monitorFireBrigadeList);
fireBrigadeResourceList.add(monitorResourceDto);
if (!CollectionUtils.isEmpty(monitorFireBrigadeList)) {
fireBrigadeResourceList.add(monitorResourceDto);
}
return fireBrigadeResourceList;
}
......
......@@ -56,6 +56,10 @@ public class RuleAlertCalledService {
List<AlertFormValue> alertFormValues = alertCalledVo.getAlertFormValue();
for (AlertFormValue alertFormValue : alertFormValues)
{
if (alertFormValue.getFieldCode().equals("alertSubmittedId"))
{
alertCalledRo.setAlertSubmittedId(alertFormValue.getFieldValue());
}
//一般火灾
if (alertFormValue.getFieldCode().equals("fireLocation"))
{
......
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