Commit bebe09eb authored by kongfm's avatar kongfm

优化代码

parent c4a52869
......@@ -213,4 +213,10 @@ public class AlertCalled extends BaseEntity {
@ApiModelProperty(value = "接警时间str")
private String callTimeStr;
/**
* 响应级别
*/
@ApiModelProperty(value = "响应级别")
private String responseLevel;
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -21,9 +20,6 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledRequestDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertFormValueServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.DispatchPaperServiceImpl;
......@@ -54,7 +50,6 @@ import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
......@@ -120,9 +115,6 @@ public class AlertCalledController extends BaseController {
@RequestParam(value = "size") int size) throws Exception {
Page<ESAlertCalledDto> esAlertCalledDtoPage = eSAlertCalledService.queryByKeys(alertCalledVo, current, size);
esAlertCalledDtoPage.getRecords().stream().forEach(e->{
getResponseLevel(e.getSequenceNbr(),null,e);
});
return ResponseHelper.buildResponse(esAlertCalledDtoPage);
}
......@@ -263,9 +255,8 @@ public class AlertCalledController extends BaseController {
}
page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
IPage<AlertCalledDto> calledVoIPage = AlertBeanDtoVoUtils.alertCalledIPageDto(page);
calledVoIPage.getRecords().stream().forEach(e->e.setAlertAddress(e.getCity()+e.getDistrict()));
calledVoIPage.getRecords().stream().forEach(e->{
getResponseLevel(e.getSequenceNbr(), e,null);
e.setAlertAddress(e.getCity()+e.getDistrict());
});
return ResponseHelper.buildResponse(calledVoIPage);
}
......@@ -325,28 +316,6 @@ public class AlertCalledController extends BaseController {
return queryWrapper;
}
void getResponseLevel(Long alertId, AlertCalledDto alertCalledDto, ESAlertCalledDto esAlertCalledDto) {
LambdaQueryWrapper<DispatchPaper> dispatchPaperQueryWrapper = new LambdaQueryWrapper<>();
dispatchPaperQueryWrapper.eq(DispatchPaper::getAlertId,alertId);
DispatchPaper dispatchPaper = dispatchPaperServiceImpl.getOne(dispatchPaperQueryWrapper);
if(null != dispatchPaper) {
LambdaQueryWrapper<AlertFormValue> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertFormValue::getAlertCalledId, dispatchPaper.getSequenceNbr()).eq(AlertFormValue::getAlertTypeCode, DispatchPaperEnums.getEnumById(dispatchPaper.getAlertCode()).getDynamicCode());
// 派遣单动态表单数据
List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
// map 存取数据
Map<String,String> dynamicParms = new HashMap<String,String>();
list.stream().forEach(paperFormValue -> {
dynamicParms.put(paperFormValue.getFieldCode(),paperFormValue.getFieldValue());
});
String responseLevel = dynamicParms.get("response_level");
if(null != alertCalledDto) {
alertCalledDto.setResponseLevel(responseLevel);
} else {
esAlertCalledDto.setResponseLevel(responseLevel);
}
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -2,12 +2,14 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.DispatchPaperFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.DispatchTaskDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.RescueProcessDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchTask;
......@@ -230,6 +232,11 @@ public class DispatchTaskServiceImpl extends BaseService<DispatchTaskDto,Dispatc
} else if(alertFormValue.getFieldCode().equals("response_level")) {
alertFormValue.setFieldValue(DispatchPaperEnums.levelOneUnit.getValue());
alertFormValue.setFieldValueCode(DispatchPaperEnums.levelOneUnit.getId());
// 响应级别反馈给警情
LambdaUpdateWrapper<AlertCalled> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AlertCalled::getSequenceNbr,dispatchTask.getAlertId());
updateWrapper.set(AlertCalled::getResponseLevel,DispatchPaperEnums.levelOneUnit.getValue());
alertCalledServiceImpl.update(updateWrapper);
} else if(alertFormValue.getFieldCode().equals("save_credit_code")) {
alertFormValue.setFieldValue(socialCreditCode);
}
......@@ -247,6 +254,11 @@ public class DispatchTaskServiceImpl extends BaseService<DispatchTaskDto,Dispatc
} else if(alertFormValue.getFieldCode().equals("response_level")) {
alertFormValue.setFieldValue(DispatchPaperEnums.levelTwoUnit.getValue());
alertFormValue.setFieldValueCode(DispatchPaperEnums.levelTwoUnit.getId());
// 响应级别反馈给警情
LambdaUpdateWrapper<AlertCalled> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AlertCalled::getSequenceNbr,dispatchTask.getAlertId());
updateWrapper.set(AlertCalled::getResponseLevel,DispatchPaperEnums.levelTwoUnit.getValue());
alertCalledServiceImpl.update(updateWrapper);
}
});
break;
......
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
......@@ -8,6 +9,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.DispatchPaperFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.DispatchTaskDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.RescueProcessDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchTask;
......@@ -148,11 +150,16 @@ public class RescueProcessServiceImpl extends BaseService<RescueProcessDto,Rescu
// 修改动态字段
dynamicFormAlert.stream().forEach(alertFormValue -> {
if (alertFormValue.getFieldCode().equals("dispatch_status")) {
alertFormValue.setFieldValue("已派遣");
alertFormValue.setFieldValueCode("hasDispatched");
alertFormValue.setFieldValue(DispatchPaperEnums.hasDispatched.getValue());
alertFormValue.setFieldValueCode(DispatchPaperEnums.hasDispatched.getId());
} else if (alertFormValue.getFieldCode().equals("response_level")) {
alertFormValue.setFieldValue("三级响应");
alertFormValue.setFieldValueCode("levelThreeUnit");
alertFormValue.setFieldValue(DispatchPaperEnums.levelThreeUnit.getValue());
alertFormValue.setFieldValueCode(DispatchPaperEnums.levelThreeUnit.getId());
// 响应级别反馈给警情
LambdaUpdateWrapper<AlertCalled> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AlertCalled::getSequenceNbr,dispatchTask.getAlertId());
updateWrapper.set(AlertCalled::getResponseLevel,DispatchPaperEnums.levelThreeUnit.getValue());
iAlertCalledService.update(updateWrapper);
}
});
}
......
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