Commit be9cb32a authored by H2T's avatar H2T

敬请报送和救援过程中修改数据产生历史记录

parent 37c8f0c8
......@@ -67,4 +67,10 @@ public class AlertFormRecordDto extends BaseDto {
@ApiModelProperty(value = "备注")
private String remarks;
@ApiModelProperty(value = "信息来源(1:警情报送,2:救援过程,3:警情编辑)")
private String sourcesInfo;
@ApiModelProperty(value = "操作人员真实姓名")
private String recUserRealName;
}
......@@ -111,4 +111,16 @@ public class AlertFormRecord extends BaseEntity {
@TableField("remarks")
private String remarks;
/**
* 信息来源(1:警情报送,2:救援过程,3:警情编辑)
*/
@TableField("sources_info")
private String sourcesInfo;
/**
* 操作人员真实姓名
*/
@TableField("rec_user_real_name")
private String recUserRealName;
}
package com.yeejoin.amos.boot.module.elevator.api.enums;
/**
* 信息来源枚举(1:警情报送,2:救援过程,3:警情编辑)
*/
public enum SourcesInfoEnum {
Submit(1, "警情报送"), Process(2, "救援过程"), Edit(3, "警情编辑");
/**
* 编码
*/
private final Integer code;
/**
* 名称
*/
private final String name;
// 构造方法
SourcesInfoEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static SourcesInfoEnum getEnum(Integer code) {
for (SourcesInfoEnum liftDirectionEnum : SourcesInfoEnum.values()) {
if (liftDirectionEnum.getCode().equals(code)) {
return liftDirectionEnum;
}
}
return null;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
......@@ -19,10 +19,9 @@ public interface IAlertFormRecordService {
/**
* 保存警情修改记录
*
* @param map 包含新旧数据的map
* @return
*/
ResponseModel<Object> saveAlertFormRecord(Map<String, AlertFormRecordDto> map);
ResponseModel<Object> saveAlertFormRecord(AlertFormRecordDto record);
/**
* 根据警情id查询所有修改记录
......
......@@ -4,6 +4,8 @@ package com.yeejoin.amos.boot.module.elevator.api.service;
import com.yeejoin.amos.boot.module.elevator.api.dto.RescueProcessDto;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import java.text.ParseException;
/**
* 救援过程表接口类
*
......@@ -24,7 +26,7 @@ public interface IRescueProcessService {
* @param rescueProcessDto
* @return
*/
Boolean updateByAlertId(RescueProcessDto rescueProcessDto, AgencyUserModel sendUser);
Boolean updateByAlertId(RescueProcessDto rescueProcessDto, AgencyUserModel sendUser) throws ParseException;
/**
* 根据警情id 更新救援过程表
......
......@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.common.biz.service.impl.MaintenanceCompanyServiceImpl;
import com.yeejoin.amos.boot.module.elevator.api.enums.SourcesInfoEnum;
import com.yeejoin.amos.boot.module.elevator.biz.service.impl.*;
import com.yeejoin.amos.boot.module.elevator.api.dto.*;
import com.yeejoin.amos.boot.module.elevator.api.entity.*;
......@@ -20,6 +21,7 @@ import com.yeejoin.amos.boot.module.elevator.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.elevator.api.service.TzsAuthService;
import com.yeejoin.amos.boot.module.elevator.biz.utils.AlertBeanDtoVoUtils;
import com.yeejoin.amos.boot.module.elevator.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.elevator.flc.biz.service.impl.AlertFormRecordServiceImpl;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
......@@ -51,6 +53,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
......@@ -112,6 +115,9 @@ public class AlertCalledController extends BaseController {
private ElevatorServiceImpl iElevatorService;
@Autowired
private AlertFormRecordServiceImpl alertFormRecordService;
@Autowired
CtiServiceImpl ctiService;
/**
......@@ -141,6 +147,31 @@ public class AlertCalledController extends BaseController {
}
AgencyUserModel userModel = reginParams.getUserModel();
alertCalledObjsDto = iAlertCalledService.createAlertCalled(alertCalledObjsDto, userModel);
try {
//更新警情历史记录表
AlertCalledDto alertCalledDto = alertCalledObjsDto.getAlertCalledDto();
List<AlertFormValue> alertFormValue = alertCalledObjsDto.getAlertFormValue();
HashMap<String, String> formMap = new HashMap<>();
alertFormValue.forEach(x-> formMap.put(x.getFieldCode(),x.getFieldValue()));
AlertFormRecordDto alertFormRecordDto = new AlertFormRecordDto();
alertFormRecordDto.setAlertCalledId(alertCalledDto.getSequenceNbr());
alertFormRecordDto.setAlertTypeCode(alertCalledDto.getAlertSourceCode());
alertFormRecordDto.setName(alertCalledDto.getEmergencyPerson());
alertFormRecordDto.setPhone(alertCalledDto.getContactPhone());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
alertFormRecordDto.setTrappedTime(sdf.parse(formMap.getOrDefault("trapped_time", new Date().toString())));
alertFormRecordDto.setTrappedNum(Integer.parseInt(formMap.getOrDefault("trapped_num", "0")));
alertFormRecordDto.setInjuredNum(Integer.parseInt(formMap.getOrDefault("injured_num", "0")));
alertFormRecordDto.setDieNum(Integer.parseInt(formMap.getOrDefault("die_num", "0")));
alertFormRecordDto.setTrappedFloorNum(Integer.parseInt(formMap.getOrDefault("trapped_floor_num", "0")));
alertFormRecordDto.setIsLight("是".equals(formMap.get("is_light")) ? 1 : 0);
alertFormRecordDto.setDescription((String) formMap.getOrDefault("desc", ""));
alertFormRecordDto.setSourcesInfo(SourcesInfoEnum.Submit.getCode().toString());
alertFormRecordService.saveAlertFormRecord(alertFormRecordDto);
}catch (Exception e){
e.printStackTrace();
}
// 坐席接警后,辅屏由常态化切换为处置态
JSONObject jsonObject = new JSONObject();
......@@ -221,8 +252,7 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getAlertInfo")
@ApiOperation(httpMethod = "GET", value = "警情信息", notes = "警情信息")
public ResponseModel<AlertPaperInfoDto> getAlertInfo(@RequestParam Long alertId
) {
public ResponseModel<AlertPaperInfoDto> getAlertInfo(@RequestParam Long alertId) {
AlertCalled alertCalled = iAlertCalledService.getById(alertId);
AlertPaperInfoDto alertPaperInfoDto = new AlertPaperInfoDto();
alertPaperInfoDto.setAlertId(alertCalled.getSequenceNbr());
......
......@@ -33,13 +33,8 @@ public class AlertFormRecordController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/saveRecord")
@ApiOperation(httpMethod = "POST", value = "新增警情接警填报记录", notes = "新增警情接警填报记录")
public ResponseModel<Object> saveRecord(@RequestBody Map<String, AlertFormRecordDto> map) {
if (ObjectUtil.isNotEmpty(map.get("oldData")) && ObjectUtil.isNotEmpty(map.get("newData"))) {
return ResponseHelper.buildResponse(iAlertFormRecordService.saveAlertFormRecord(map));
} else {
return ResponseHelper.buildResponse("缺少数据");
}
public ResponseModel<Object> saveRecord(@RequestBody AlertFormRecordDto record) {
return ResponseHelper.buildResponse(iAlertFormRecordService.saveAlertFormRecord(record));
}
......
......@@ -9,18 +9,18 @@ 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.elevator.api.dto.DispatchPaperFormDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.DispatchTaskDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.RescueProcessDto;
import com.yeejoin.amos.boot.module.elevator.api.dto.*;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.elevator.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.elevator.api.entity.DispatchTask;
import com.yeejoin.amos.boot.module.elevator.api.entity.RescueProcess;
import com.yeejoin.amos.boot.module.elevator.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.elevator.api.enums.SourcesInfoEnum;
import com.yeejoin.amos.boot.module.elevator.api.mapper.RescueProcessMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.IRescueProcessService;
import com.yeejoin.amos.boot.module.elevator.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.elevator.flc.biz.service.impl.AlertFormRecordServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +31,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/**
......@@ -58,6 +59,9 @@ public class RescueProcessServiceImpl extends BaseService<RescueProcessDto,Rescu
RepairConsultServiceImpl repairConsultServiceImpl;
@Autowired
private AlertFormRecordServiceImpl alertFormRecordService;
@Autowired
AlertCalledServiceImpl iAlertCalledService;
@Autowired
......@@ -178,6 +182,29 @@ public class RescueProcessServiceImpl extends BaseService<RescueProcessDto,Rescu
if (Boolean.TRUE.equals(rescueProcessDto.getCasualtiesStatus())){
updateMessage(rescueProcessDto, "injured_num");
updateMessage(rescueProcessDto, "die_num");
try {
//更新警情历史记录表
AlertCalledFormDto calledFormDto = (AlertCalledFormDto)iAlertCalledService.selectAlertCalledById(rescueProcessDto.getAlertId());
List<FormValue> dynamicFormAlert = calledFormDto.getDynamicFormAlert();
HashMap<String, String> formMap = new HashMap<>();
dynamicFormAlert.forEach(x->formMap.put(x.getKey(),x.getValue()));
AlertCalledDto alertCalledDto = calledFormDto.getAlertCalledDto();
AlertFormRecordDto alertFormRecordDto = new AlertFormRecordDto();
alertFormRecordDto.setAlertCalledId(rescueProcessDto.getAlertId());
alertFormRecordDto.setAlertTypeCode(alertCalledDto.getAlarmTypeCode());
alertFormRecordDto.setName(alertCalledDto.getEmergencyPerson());
alertFormRecordDto.setPhone(alertCalledDto.getEmergencyCall());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
alertFormRecordDto.setTrappedTime(sdf.parse(formMap.getOrDefault("trapped_time",new Date().toString())));
alertFormRecordDto.setTrappedNum(Integer.valueOf(formMap.getOrDefault("trapped_num","0")));
alertFormRecordDto.setTrappedFloorNum(Integer.parseInt(formMap.getOrDefault("trapped_floor_num","0")));
alertFormRecordDto.setInjuredNum(Integer.valueOf(rescueProcessDto.getCasualtiesInfo()));
alertFormRecordDto.setDieNum(Integer.valueOf(rescueProcessDto.getDieNum()));
alertFormRecordDto.setSourcesInfo(SourcesInfoEnum.Process.getCode().toString());
alertFormRecordService.saveAlertFormRecord(alertFormRecordDto);
}catch (Exception e){
e.printStackTrace();
}
redisUtils.del(RedisKey.TZS_ALERTCALLED_ID+rescueProcessDto.getAlertId());
}
rescueProcessDto.setDispatchTime(null);
......
package com.yeejoin.amos.boot.module.elevator.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
......@@ -11,23 +12,23 @@ import com.yeejoin.amos.boot.module.elevator.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertFormRecord;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.elevator.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.elevator.api.enums.SourcesInfoEnum;
import com.yeejoin.amos.boot.module.elevator.api.mapper.AlertFormRecordMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertFormRecordService;
import com.yeejoin.amos.boot.module.elevator.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.elevator.biz.service.impl.AlertFormValueServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
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.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -68,63 +69,65 @@ public class AlertFormRecordServiceImpl extends BaseService<AlertFormRecordDto,
}
/**
* 用户单位信息redis获取
**/
public ReginParams getReginParams() {
return JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
}
/**
* 保存警情修改记录
*
* @param map 包含新旧数据的map
* @return
*/
@Override
@Transactional
public ResponseModel saveAlertFormRecord(Map<String, AlertFormRecordDto> map) {
public ResponseModel saveAlertFormRecord(AlertFormRecordDto data) {
try {
AlertFormRecordDto oldData = map.get("oldData");
AlertFormRecordDto newData = map.get("newData");
List<AlertFormRecord> recordByCalledId = alertFormRecordMapper.getRecordByCalledId(newData.getAlertCalledId());
AlertFormRecord oldRecord = new AlertFormRecord();
//第一次修改,保存旧记录
if (recordByCalledId.isEmpty()) {
BeanUtils.copyProperties(oldData, oldRecord);
oldRecord.setEditTime(oldData.getTrappedTime());
alertFormRecordMapper.insert(oldRecord);
}
AlertFormRecord record = new AlertFormRecord();
BeanUtils.copyProperties(newData, record);
BeanUtils.copyProperties(data, record);
AgencyUserModel userModel = this.getReginParams().getUserModel();
record.setEditTime(new Date());
record.setRecUserRealName(userModel.getRealName());
record.setSourcesInfo(Objects.requireNonNull(SourcesInfoEnum.getEnum(Integer.valueOf(record.getSourcesInfo()))).getName());
alertFormRecordMapper.insert(record);
// 更新警情基本信息
Long alertCalled = record.getAlertCalledId();
if (!record.getName().equals(oldRecord.getName())){
LambdaUpdateWrapper<AlertCalled> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(AlertCalled::getSequenceNbr, alertCalled);
wrapper.set(AlertCalled::getEmergencyPerson, record.getName());
alertCalledServiceImpl.update(wrapper);
}
LambdaQueryWrapper<AlertFormValue> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, alertCalled);
// 更新警情动态表单数据
List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
HashMap<String, Object> listMap = new HashMap<>();
list.forEach(x -> listMap.put(x.getFieldCode(), x.getFieldValue()));
for (Field field : record.getClass().getDeclaredFields()) {
// 设置为可访问,以访问私有属性
field.setAccessible(true);
String fieldName = convertToUnderline(field.getName());
Object value = field.get(record);
//“是否有光照” 转 文字存储
if ("is_light".equals(fieldName)){
value = (value.equals(1) ? "是" : "否");
// 警情编辑时候更新警情动态表单数据
if (SourcesInfoEnum.Edit.getName().equals(record.getSourcesInfo())){
// 更新警情基本信息
if (!record.getName().equals(oldRecord.getName())){
LambdaUpdateWrapper<AlertCalled> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(AlertCalled::getSequenceNbr, alertCalled);
wrapper.set(AlertCalled::getEmergencyPerson, record.getName());
alertCalledServiceImpl.update(wrapper);
}
try {
//表tz_alert_form_value中的字典名称desc和表tz_alert_form_record中列名称description冲突,做特殊处理
if (listMap.containsKey(fieldName) || (listMap.containsKey("desc") && fieldName.equals("description"))) {
LambdaUpdateWrapper<AlertFormValue> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(AlertFormValue::getAlertCalledId, alertCalled);
wrapper.eq(AlertFormValue::getFieldCode, fieldName.equals("description") ? "desc" : fieldName);
wrapper.set(AlertFormValue::getFieldValue, value);
iAlertFormValueService.update(wrapper);
LambdaQueryWrapper<AlertFormValue> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, alertCalled);
List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
HashMap<String, Object> listMap = new HashMap<>();
list.forEach(x -> listMap.put(x.getFieldCode(), x.getFieldValue()));
for (Field field : record.getClass().getDeclaredFields()) {
// 设置为可访问,以访问私有属性
field.setAccessible(true);
String fieldName = convertToUnderline(field.getName());
Object value = field.get(record);
//“是否有光照” 转 文字存储
if ("is_light".equals(fieldName)){
value = (value.equals(1) ? "是" : "否");
}
try {
//表tz_alert_form_value中的字典名称desc和表tz_alert_form_record中列名称description冲突,做特殊处理
if (listMap.containsKey(fieldName) || (listMap.containsKey("desc") && fieldName.equals("description"))) {
LambdaUpdateWrapper<AlertFormValue> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(AlertFormValue::getAlertCalledId, alertCalled);
wrapper.eq(AlertFormValue::getFieldCode, fieldName.equals("description") ? "desc" : fieldName);
wrapper.set(AlertFormValue::getFieldValue, value);
iAlertFormValueService.update(wrapper);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
redisUtils.del(RedisKey.TZS_ALERTCALLED_ID + alertCalled);
......
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