Commit 1af9198e authored by 郭武斌's avatar 郭武斌

*)修改保存警情信息接口

parent 73083f2c
......@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -78,34 +79,14 @@ public class AlertCalledController extends BaseController {
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增警情接警记录", notes = "新增警情接警记录")
@Transactional
public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request, @RequestBody AlertCalledVo alertCalledVo) {
try {
// 警情基本信息
AlertCalled alertCalled = alertCalledVo.getAlertCalled();
// 判断是否归并警情
if (alertCalled.getFatherAlert() != null) {
// 警情归并,设置当前警情状态为结束。
alertCalled.setAlertStatus(true);
} else {
// 警情报送
// ****************************************************待确认开发
}
iAlertCalledService.save(alertCalled);
// 动态表单
List<AlertFormValue> alertFormValuelist = alertCalledVo.getAlertFormValue();
// 填充警情主键
alertFormValuelist.stream().forEach(alertFormValue -> {
alertFormValue.setAlertCalledId(alertCalled.getSequenceNbr());
alertFormValue.setAlertTypeCode(alertCalled.getAlertTypeCode());
});
// 保存动态表单数据
iAlertFormValueService.saveBatch(alertFormValuelist);
public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request,
@RequestBody AlertCalledVo alertCalledVo) throws Exception{
if (ValidationUtil.isEmpty(alertCalledVo)
|| ValidationUtil.isEmpty(alertCalledVo.getAlertCalled()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(alertCalledVo);
} catch (Exception e) {
throw new RuntimeException("系统异常");
}
return ResponseHelper.buildResponse(iAlertCalledService.createAlertCalled(alertCalledVo));
}
/**
......@@ -225,7 +206,7 @@ public class AlertCalledController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "初始化ES")
@RequestMapping(value = "/es/init", method = RequestMethod.PUT)
public ResponseModel<Boolean> initEs() {
public ResponseModel<Boolean> initEs() throws Exception {
return ResponseHelper.buildResponse(eSAlertCalledService.initEs());
}
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertCalledService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo;
/**
* 警情接警记录 服务实现类
......@@ -26,6 +29,54 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
RedisUtils redisUtils;
@Autowired
AlertCalledMapper alertCalledMapper;
@Autowired
private AlertFormValueServiceImpl iAlertFormValueService;
@Autowired
private ESAlertCalledService eSAlertCalledService;
/**
*
* <pre>
* 保存警情信息
* </pre>
*
* @param alertCalledVo
* @return
*/
public AlertCalledVo createAlertCalled(AlertCalledVo alertCalledVo) throws Exception
{
// 警情基本信息
AlertCalled alertCalled = alertCalledVo.getAlertCalled();
// 判断是否归并警情
if (alertCalled.getFatherAlert() != null) {
// 警情归并,设置当前警情状态为结束。
alertCalled.setAlertStatus(true);
} else {
// 警情报送
// ****************************************************待确认开发
}
this.save(alertCalled);
// 动态表单
List<AlertFormValue> alertFormValuelist = alertCalledVo.getAlertFormValue();
// 填充警情主键
alertFormValuelist.stream().forEach(alertFormValue -> {
alertFormValue.setAlertCalledId(alertCalled.getSequenceNbr());
alertFormValue.setAlertTypeCode(alertCalled.getAlertTypeCode());
});
// 保存动态表单数据
iAlertFormValueService.saveBatch(alertFormValuelist);
/**
* 同步保存ES
*/
eSAlertCalledService.saveAlertCalledToES(alertCalled);
return alertCalledVo;
}
/*
* 根据id 修改警情
* type:警情相关 操作类型 0警情续报 1非警情确认 2 警情结案
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
......@@ -52,10 +51,10 @@ public class ESAlertCalledService {
@PostConstruct
public void init()
public void init() throws Exception
{
//初始化ES,重建索引
// initEs();
initEs();
}
/**
......@@ -236,49 +235,7 @@ public class ESAlertCalledService {
// return page;
// }
/**
*
* <pre>
* 根据警情记录批量保存
* </pre>
*
* @param alertCalleds 警情信息列表
*/
public Boolean saveAlertCalledToES(List<AlertCalled> alertCalleds)
{
if (!ValidationUtil.isEmpty(alertCalleds))
{
List<ESAlertCalled> esAlertCalleds = new ArrayList<>();
for (AlertCalled alertCalled : alertCalleds)
{
ESAlertCalled esAlertCalled = new ESAlertCalled();
esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
esAlertCalled.setAlertType(alertCalled.getAlertType());
esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
esAlertCalled.setCallTime(alertCalled.getCallTime());
esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime());
esAlertCalled.setContactUser(alertCalled.getContactUser());
esAlertCalled.setContactPhone(alertCalled.getContactPhone());
esAlertCalled.setAddress(alertCalled.getAddress());
esAlertCalled.setAlertStage(alertCalled.getAlertStage());
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
if (alertCalled.getAlertStatus())
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
esAlertCalled.setCoordinateY(alertCalled.getCoordinateY());
esAlertCalleds.add(esAlertCalled);
}
this.saveAll(esAlertCalleds);
}
return true;
}
// /**
// * 将文档基本信息转为关键字符串
......@@ -389,7 +346,7 @@ public class ESAlertCalledService {
/**
* 重建索引
*/
public Boolean initEs() {
public Boolean initEs() throws Exception {
esAlertCalledRepository.deleteAll();
/**
* 同步历史48小时以内的警情处置记录
......@@ -405,8 +362,49 @@ public class ESAlertCalledService {
List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
if (!ValidationUtil.isEmpty(alertCalleds))
{
saveAlertCalledToES(alertCalleds);
for (AlertCalled alertCalled : alertCalleds)
{
saveAlertCalledToES(alertCalled);
}
}
return true;
}
/**
*
* <pre>
* 根据警情记录批量保存
* </pre>
*
* @param alertCalleds 警情信息列表
*/
public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception
{
ESAlertCalled esAlertCalled = new ESAlertCalled();
esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
esAlertCalled.setAlertType(alertCalled.getAlertType());
esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
esAlertCalled.setCallTime(alertCalled.getCallTime());
esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime());
esAlertCalled.setContactUser(alertCalled.getContactUser());
esAlertCalled.setContactPhone(alertCalled.getContactPhone());
esAlertCalled.setAddress(alertCalled.getAddress());
esAlertCalled.setAlertStage(alertCalled.getAlertStage());
esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
if (alertCalled.getAlertStatus())
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
}else
{
esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
}
esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
esAlertCalled.setCoordinateY(alertCalled.getCoordinateY());
esAlertCalledRepository.save(esAlertCalled);
return esAlertCalled;
}
}
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