Browse Source

处置调度

develop
wangsixiang 6 months ago
parent
commit
109320d0a1
  1. 23
      zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
  2. 11
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  3. 6
      zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
  4. 215
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  5. 37
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

23
zc-business/src/main/java/com/zc/business/controller/DcWarningController.java

@ -160,7 +160,7 @@ public class DcWarningController extends BaseController
return dcWarningService.batchConvert(dcWarningBatchConvert); return dcWarningService.batchConvert(dcWarningBatchConvert);
} }
//指挥调度 //1,指挥调度,查看是否存在记录和资源信息,存在即返回
@PostMapping("/commandAndDispatch") @PostMapping("/commandAndDispatch")
public AjaxResult commandAndDispatch(@RequestBody DcWarning dcWarning){ public AjaxResult commandAndDispatch(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getStakeMark())||StringUtils.isBlank(dcWarning.getId())){ if (StringUtils.isBlank(dcWarning.getStakeMark())||StringUtils.isBlank(dcWarning.getId())){
@ -168,6 +168,22 @@ public class DcWarningController extends BaseController
} }
return (dcWarningService.commandAndDispatch(dcWarning)); return (dcWarningService.commandAndDispatch(dcWarning));
} }
//2,指挥调度,当调度信息为空的时候调用智能分配资源
@PostMapping("/intelligentSource")
public AjaxResult intelligentSource(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getStakeMark())){
return AjaxResult.error("参数错误");
}
return (dcWarningService.intelligentSource(dcWarning));
}
//3.指挥调度,新增调度记录信息
@PostMapping("/insertDispatch")
public AjaxResult insertDispatch(@RequestBody HashMap map){
if (map == null || !map.containsKey("eventId")||StringUtils.isBlank(map.get("eventId").toString())){
return AjaxResult.error("参数错误");
}
return (dcWarningService.insertDispatch(map));
}
//指挥调度记录修改 //指挥调度记录修改
@PostMapping("/updateDispatch") @PostMapping("/updateDispatch")
public AjaxResult insertDispatch(@RequestBody DcDispatch dcDispatch){ public AjaxResult insertDispatch(@RequestBody DcDispatch dcDispatch){
@ -176,12 +192,9 @@ public class DcWarningController extends BaseController
} }
return toAjax(dcWarningService.insertDispatch(dcDispatch)); return toAjax(dcWarningService.insertDispatch(dcDispatch));
} }
//指挥调度资源新增 //4.指挥调度资源新增(用户修改弹窗的提交)
@PostMapping("/updateSource") @PostMapping("/updateSource")
public AjaxResult insertDispatchSource(@RequestBody HashMap map){ public AjaxResult insertDispatchSource(@RequestBody HashMap map){
if (map==null||!map.containsKey("dispatchId")){
return AjaxResult.error("参数错误");
}
return toAjax(dcWarningService.insertDispatchSource(map)); return toAjax(dcWarningService.insertDispatchSource(map));
} }
//感知事件误报 //感知事件误报

11
zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java

@ -99,6 +99,7 @@ public interface DcWarningMapper
public Integer updateEndSection(@Param("dcWarningList") List<DcWarning> dcWarningList); public Integer updateEndSection(@Param("dcWarningList") List<DcWarning> dcWarningList);
//查询当天全部可以结束的事件 //查询当天全部可以结束的事件
public List<DcWarning> selectEndSection(); public List<DcWarning> selectEndSection();
//依据桩号返回驻点id //依据桩号返回驻点id
public Long selectSectionId(@Param("stakeMark")String stakeMark,@Param("direction")String direction); public Long selectSectionId(@Param("stakeMark")String stakeMark,@Param("direction")String direction);
//依据桩号获取最近距离的驻点 //依据桩号获取最近距离的驻点
@ -130,6 +131,8 @@ public interface DcWarningMapper
public HashMap<String,Object> selectOrganization(); public HashMap<String,Object> selectOrganization();
//选中的人员信息 //选中的人员信息
public List<HashMap<String,Object>> selectEmployeesChoice(@Param("dispatchId")Long dispatchId); public List<HashMap<String,Object>> selectEmployeesChoice(@Param("dispatchId")Long dispatchId);
//查询最近的交警人员和电话
public List<HashMap<String,Object>> selectTrafficPolice(@Param("organizationId")Long organizationId);
//选中的车辆信息 //选中的车辆信息
public List<HashMap<String,Object>> selectVehiclesChoice(@Param("dispatchId")Long dispatchId); public List<HashMap<String,Object>> selectVehiclesChoice(@Param("dispatchId")Long dispatchId);
public Integer deleteDispatchResource(@Param("dispatchId")Long dispatchId); public Integer deleteDispatchResource(@Param("dispatchId")Long dispatchId);
@ -137,4 +140,12 @@ public interface DcWarningMapper
DcDispatch selectDcDispatchById(@Param("id") Long id); DcDispatch selectDcDispatchById(@Param("id") Long id);
//误报解除 //误报解除
public Integer falseAlarmResolution(DcWarning dcWarning); public Integer falseAlarmResolution(DcWarning dcWarning);
//依据人员id查询人员名称
public String employeesName(Long id);
//依据车辆id查询车辆信息,前提车辆可用
public String vehiclesName(Long id);
//依据车辆id查询车辆信息,前提车辆可用
public String vehiclesType(Long id);
//依据机构id查询机构名称
public String organizationName(Long id);
} }

6
zc-business/src/main/java/com/zc/business/service/IDcWarningService.java

@ -91,8 +91,12 @@ public interface IDcWarningService
//定时结束部分事件 //定时结束部分事件
Integer updateEndSection(); Integer updateEndSection();
//指挥调度 //1.指挥调度
AjaxResult commandAndDispatch(DcWarning dcWarning); AjaxResult commandAndDispatch(DcWarning dcWarning);
//2.指挥调度,当调度信息为空的时候调用智能分配资源
AjaxResult intelligentSource(DcWarning dcWarning);
//3.指挥调度新增资源
AjaxResult insertDispatch(HashMap map);
//修改指挥调度资源记录 //修改指挥调度资源记录
public Integer insertDispatch(DcDispatch dcDispatch); public Integer insertDispatch(DcDispatch dcDispatch);
//新增指挥调度资源记录 //新增指挥调度资源记录

215
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.rmi.MarshalledObject; import java.rmi.MarshalledObject;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
@ -508,68 +509,10 @@ public class DcWarningServiceImpl implements IDcWarningService
dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间 dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间
dcEvent.setUserId(SecurityUtils.getUserId());//处置人员 dcEvent.setUserId(SecurityUtils.getUserId());//处置人员
dcEvent.setRoadId(1L);//高速公路(济菏高速) dcEvent.setRoadId(1L);//高速公路(济菏高速)
int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent); int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent);
if (insertDcEvent==0){ if (insertDcEvent==0){
return AjaxResult.error("操作失败"); return AjaxResult.error("操作失败");
} }
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
Long id = (Long) map.get("id");//机构的id
String stakeMarkNew = map.get("stakeMark").toString();//机构桩号
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map
map.put("id",id);
hashMaps.add(map);
}
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
HashMap<String, Object> hashMap = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询事件是否已经有转的调度记录
if (!sortedHashMaps.isEmpty()&&hashMap==null) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = (Long) map.get("id");//取出最近的机构id
if (id != null) {
DcDispatch dcDispatch = new DcDispatch();
DcDispatchResource dcDispatchResource = new DcDispatchResource();
dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId());
dcDispatch.setEventId(dcWarning.getId());
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(dcWarning.getRemark());
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();//信息记录id
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
if (employeesMap != null&&employeesMap.size()>0) {
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size());
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex);
Long employeesId = (Long) randomEmployee.get("id");//随机人员id
dcDispatchResource.setResourceId(employeesId);//资源id
dcDispatchResource.setDispatchType(1);//资源类型
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
dcWarningMapper.insertDispatchResource(dcDispatchResource);
}
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
if (vehiclesMap != null&&vehiclesMap.size()>0) {
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size());
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex);
Long vehiclesId = (Long) randomEmployee.get("id");//随机车辆id
dcDispatchResource.setResourceId(vehiclesId);//资源id
dcDispatchResource.setDispatchType(2);//资源类型
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
dcWarningMapper.insertDispatchResource(dcDispatchResource);//绑定车辆信息
}
}
}
return AjaxResult.success("操作成功"); return AjaxResult.success("操作成功");
} }
@ -670,10 +613,12 @@ public class DcWarningServiceImpl implements IDcWarningService
@Override @Override
public AjaxResult commandAndDispatch(DcWarning dcWarning) { public AjaxResult commandAndDispatch(DcWarning dcWarning) {
Map<String, Object> mapAll = new HashMap<>();
HashMap<String, Object> dcDispatch = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询是否存在调度记录
//逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息 //逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>(); ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
Map<String, Object> mapAll = new HashMap<>();
for (HashMap<String,Object> map:mapList){ for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){ if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue; continue;
@ -684,7 +629,7 @@ public class DcWarningServiceImpl implements IDcWarningService
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数 Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map map.put("difference",difference/1000.0);//米转公里加入到map
Long id = (Long) map.get("id");//机构的id,用户获取人员、值班、车辆等信息 Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、值班、车辆等信息
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map
map.put("employeesMap",employeesMap); map.put("employeesMap",employeesMap);
@ -692,20 +637,31 @@ public class DcWarningServiceImpl implements IDcWarningService
hashMaps.add(map); hashMaps.add(map);
} }
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList()); return (Double) map.get("difference"); })).collect(Collectors.toList());
mapAll.put("listData",sortedHashMaps); mapAll.put("listData",sortedHashMaps);
if (!sortedHashMaps.isEmpty()) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = Long.parseLong(map.get("id").toString());//取出最近的机构id
List<HashMap<String, Object>> trafficPolice = dcWarningMapper.selectTrafficPolice(id);//交警人员信息
mapAll.put("trafficPolice",trafficPolice);
}
if (dcDispatch==null){
mapAll.put("existence",0);
return AjaxResult.success(mapAll);
}
mapAll.put("existence",1);
HashMap<String, Object> map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id HashMap<String, Object> map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id
if (map!=null){ if (map!=null){
HashMap<Object, Object> hashMap = new HashMap<>(); HashMap<Object, Object> hashMap = new HashMap<>();
Long id = (Long) map.get("id");//调度记录id Long id =Long.parseLong(map.get("id").toString());//调度记录id
Object deptName =map.get("deptName");//部门名称 Object deptName =map.get("deptName");//部门名称
List<HashMap<String, Object>> shifts = dcWarningMapper.selectShiftsEmployees();//值班为空把全部的人员信息作为值班人员信息 //List<HashMap<String, Object>> shifts = dcWarningMapper.selectShiftsEmployees();//值班为空把全部的人员信息作为值班人员信息
List<HashMap<String, Object>> resource = dcWarningMapper.selectDispatchResource(id);//全部资源信息 List<HashMap<String, Object>> resource = dcWarningMapper.selectDispatchResource(id);//全部资源信息
List<HashMap<String, Object>> employeesChoice = dcWarningMapper.selectEmployeesChoice(id);//选中人员信息 List<HashMap<String, Object>> employeesChoice = dcWarningMapper.selectEmployeesChoice(id);//选中人员信息
List<HashMap<String, Object>> vehiclesChoice = dcWarningMapper.selectVehiclesChoice(id);//选中车辆信息 List<HashMap<String, Object>> vehiclesChoice = dcWarningMapper.selectVehiclesChoice(id);//选中车辆信息
hashMap.put("id",id);//调度记录id hashMap.put("id",id);//调度记录id
hashMap.put("deptName",deptName); hashMap.put("deptName",deptName);
hashMap.put("shifts",shifts); //hashMap.put("shifts",shifts);
hashMap.put("resource",resource); hashMap.put("resource",resource);
mapAll.put("resource",hashMap); mapAll.put("resource",hashMap);
mapAll.put("employeesChoice",employeesChoice); mapAll.put("employeesChoice",employeesChoice);
@ -713,6 +669,120 @@ public class DcWarningServiceImpl implements IDcWarningService
} }
return AjaxResult.success(mapAll); return AjaxResult.success(mapAll);
} }
//指挥调度,当调度信息为空的时候调用智能分配资源
@Override
public AjaxResult intelligentSource(DcWarning dcWarning) {
String stakeMark = dcWarning.getStakeMark();
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
Map<String, Object> mapAll = new HashMap<>();
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
HashMap<String, Object> mapValue = new HashMap<>();
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
String stakeMarkValue = map.get("stakeMark").toString();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkValue);//桩号本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
mapValue.put("difference",difference/1000.0);//米转公里加入到map
Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、车辆等信息
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map
String organizationName = dcWarningMapper.organizationName(id);
mapValue.put("employeesMap",employeesMap);
mapValue.put("vehiclesMap",vehiclesMap);
mapValue.put("organizationId",id);
mapValue.put("organizationName",organizationName);
hashMaps.add(mapValue);
}
mapAll.put("selectData",hashMaps);
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
if (!sortedHashMaps.isEmpty()) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long id = Long.parseLong(map.get("organizationId").toString());//取出最近的机构id
if (id != null) {
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
if (employeesMap != null&&employeesMap.size()>0) {
HashMap<String, Object> employeesHashMap = new HashMap<>();
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size());
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex);
Long employeesId = Long.parseLong(randomEmployee.get("id").toString());//随机人员id
String employeesName = dcWarningMapper.employeesName(employeesId);//随机人员姓名
employeesHashMap.put("employeesId",employeesId);
employeesHashMap.put("employeesName",employeesName);
mapAll.put("employees",employeesHashMap);
}
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
if (vehiclesMap != null&&vehiclesMap.size()>0) {
HashMap<String, Object> vehiclesHashMap = new HashMap<>();
// 生成一个随机索引,范围在0到列表长度减1之间
int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size());
HashMap<String, Object> randomEmployee = vehiclesMap.get(randomIndex);
Long vehiclesId =Long.parseLong(randomEmployee.get("id").toString());//随机车辆id
String vehiclesName = dcWarningMapper.vehiclesName(vehiclesId);//随机车辆
String vehiclesType = dcWarningMapper.vehiclesType(vehiclesId);//随机车辆
vehiclesHashMap.put("vehiclesId",vehiclesId);
vehiclesHashMap.put("vehiclesName",vehiclesName);
vehiclesHashMap.put("vehiclesType",vehiclesType);
mapAll.put("vehicles",vehiclesHashMap);
}
}
}
return AjaxResult.success(mapAll);
}
//3.指挥调度新增资源
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult insertDispatch(HashMap map) {
//事件id、事件备注、机构id、资源id
String eventId = map.get("eventId").toString();//事件id
String remark = Objects.toString(map.get("remark"), "");
Long employees=null;
if (map.get("employeesId")!=null){
employees = Long.parseLong(map.get("employeesId").toString());//人员
}
Long vehicles=null;
if (map.get("vehiclesId").toString()!=null){
vehicles = Long.parseLong(map.get("vehiclesId").toString());//车辆
}
DcDispatch dcDispatch = new DcDispatch();
DcDispatchResource dcDispatchResource = new DcDispatchResource();
dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId());
dcDispatch.setEventId(eventId);
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(remark);
Integer integer = dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
if (integer==0){
return AjaxResult.error();
}
Long dispatchId = dcDispatch.getId();//信息记录id
if (employees!=null) {
dcDispatchResource.setResourceId(employees);//资源id
dcDispatchResource.setDispatchType(1);//资源类型
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
Integer employeesSource = dcWarningMapper.insertDispatchResource(dcDispatchResource);
if (employeesSource==0){
return AjaxResult.error("人员调度异常");
}
}
if (vehicles!=null) {
// 生成一个随机索引,范围在0到列表长度减1之间
dcDispatchResource.setResourceId(vehicles);//资源id
dcDispatchResource.setDispatchType(2);//资源类型
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
Integer dispatchResource = dcWarningMapper.insertDispatchResource(dcDispatchResource);//绑定车辆信息
if (dispatchResource==0){
return AjaxResult.error("车辆调度异常");
}
}
return AjaxResult.success();
}
@Override @Override
public Integer insertDispatch(DcDispatch dcDispatch) { public Integer insertDispatch(DcDispatch dcDispatch) {
@ -725,12 +795,19 @@ public class DcWarningServiceImpl implements IDcWarningService
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Integer insertDispatchSource(HashMap map) { public Integer insertDispatchSource(HashMap map) {
String eventId = map.get("eventId").toString();//事件id
String remark = Objects.toString(map.get("remark"), "");
DcDispatch dcDispatch = new DcDispatch();
DcDispatchResource dcDispatchResource = new DcDispatchResource(); DcDispatchResource dcDispatchResource = new DcDispatchResource();
Integer pat = (Integer) map.get("dispatchId"); dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId());
long dispatchId = pat.longValue(); dcDispatch.setEventId(eventId);
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(remark);
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();
dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源 dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源
ArrayList<Map<String,Object>> employeesArray = (ArrayList<Map<String,Object>>) map.get("employees");//取出人员 ArrayList<Map<String,Object>> employeesArray = (ArrayList<Map<String,Object>>) map.get("employees");//取出人员
String context = ""; String context = "";
if (employeesArray!=null&&employeesArray.size()>0) { if (employeesArray!=null&&employeesArray.size()>0) {
context += "路管人员"; context += "路管人员";
@ -768,9 +845,9 @@ public class DcWarningServiceImpl implements IDcWarningService
context += "参与事件救援"; context += "参与事件救援";
} }
DcDispatch dcDispatch = dcWarningMapper.selectDcDispatchById(dispatchId); DcDispatch dcDispatchEventId = dcWarningMapper.selectDcDispatchById(dispatchId);
DcEventProcess dcEventProcess = new DcEventProcess(); DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcDispatch.getEventId()); dcEventProcess.setEventId(dcDispatchEventId.getEventId());
dcEventProcess.setSource(1); dcEventProcess.setSource(1);
dcEventProcess.setContext(context); dcEventProcess.setContext(context);
dcEventProcessService.insertDcEventProcess(dcEventProcess); dcEventProcessService.insertDcEventProcess(dcEventProcess);

37
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -255,6 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteDcWarningById" parameterType="Integer"> <delete id="deleteDcWarningById" parameterType="Integer">
delete from dc_warning where id = #{id} delete from dc_warning where id = #{id}
</delete> </delete>
@ -278,6 +279,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from dc_dispatch_resource where dispatch_id=#{dispatchId} delete from dc_dispatch_resource where dispatch_id=#{dispatchId}
</delete> </delete>
<select id="selectCount" resultType="int"> <select id="selectCount" resultType="int">
SELECT COUNT(*)AS count FROM dc_warning SELECT COUNT(*)AS count FROM dc_warning
</select> </select>
@ -317,7 +319,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where parent_id!=0 where parent_id!=0
</select> </select>
<select id="selectOrganizationEmployees" resultType="java.util.HashMap"> <select id="selectOrganizationEmployees" resultType="java.util.HashMap">
select id, name,contact_number contactNumber from dc_employees where organization_id=#{organizationId} and employees_type=2 select id, name,contact_number contactNumber from dc_employees where organization_id=#{organizationId}
</select> </select>
<select id="selectShifts" resultType="java.util.HashMap"> <select id="selectShifts" resultType="java.util.HashMap">
select shifts.scheduling,employees.name shiftsName,employees.contact_number shiftsNumber from dc_shifts as shifts select shifts.scheduling,employees.name shiftsName,employees.contact_number shiftsNumber from dc_shifts as shifts
@ -368,11 +370,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEmployeesDispatch" resultType="java.util.HashMap"> <select id="selectEmployeesDispatch" resultType="java.util.HashMap">
SELECT DISTINCT dc_employees.id, SELECT DISTINCT dc_employees.id,
dc_employees.name, dc_employees.name,
dc_employees.contact_number AS contactNumber, dc_employees.contact_number AS contactNumber
CASE
WHEN t.id IS NOT NULL THEN 1 -- 连接成立
ELSE 0 -- 连接不成立
END AS state
from dc_employees from dc_employees
LEFT JOIN( LEFT JOIN(
select employees.id id, employees.name, employees.contact_number contactNumber select employees.id id, employees.name, employees.contact_number contactNumber
@ -380,19 +378,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left JOIN dc_dispatch_resource as respurce on respurce.resource_id = employees.id left JOIN dc_dispatch_resource as respurce on respurce.resource_id = employees.id
LEFT JOIN dc_dispatch as path on path.id = respurce.dispatch_id LEFT JOIN dc_dispatch as path on path.id = respurce.dispatch_id
where employees.organization_id = #{organizationId} where employees.organization_id = #{organizationId}
and employees.employees_type = 2
and respurce.dispatch_type = 1 and respurce.dispatch_type = 1
and path.event_id = #{eventId}) as t on t.id = dc_employees.id and path.event_id = #{eventId}) as t on t.id = dc_employees.id
where organization_id = #{organizationId} where organization_id = #{organizationId} and dc_employees.employees_type=1
</select> </select>
<select id="selectVehiclesDispatch" resultType="java.util.HashMap"> <select id="selectVehiclesDispatch" resultType="java.util.HashMap">
select DISTINCT dc_vehicles.id, select DISTINCT dc_vehicles.id,
dc_vehicles.vehicle_type vehicleType, dc_vehicles.vehicle_type vehicleType,
dc_vehicles.vehicle_plate vehiclePlate, dc_vehicles.vehicle_plate vehiclePlate
CASE
WHEN t.id IS NOT NULL THEN 1 -- 连接成立
ELSE 0 -- 连接不成立
END AS state
from dc_vehicles from dc_vehicles
LEFT JOIN( LEFT JOIN(
select vehicles.id, vehicles.vehicle_type vehicleType, vehicles.vehicle_plate vehiclePlate select vehicles.id, vehicles.vehicle_type vehicleType, vehicles.vehicle_plate vehiclePlate
@ -400,11 +393,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN dc_dispatch_resource as resource on resource.resource_id = vehicles.id LEFT JOIN dc_dispatch_resource as resource on resource.resource_id = vehicles.id
LEFT JOIN dc_dispatch as path on path.id = resource.dispatch_id LEFT JOIN dc_dispatch as path on path.id = resource.dispatch_id
where vehicles.organization_id = #{organizationId} where vehicles.organization_id = #{organizationId}
and vehicles.vehicle_status = 1
and resource.dispatch_type = 2 and resource.dispatch_type = 2
and path.event_id = #{eventId}) as t on t.id = dc_vehicles.id and path.event_id = #{eventId}) as t on t.id = dc_vehicles.id
where vehicle_status = 1 where vehicle_status = 1
and organization_id = #{organizationId} and organization_id = #{organizationId} and dc_vehicles.vehicle_status = 1
</select> </select>
<select id="selectOrganization" resultType="java.util.HashMap"> <select id="selectOrganization" resultType="java.util.HashMap">
select id from dc_organization where parent_id=0; select id from dc_organization where parent_id=0;
@ -423,5 +415,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcDispatchById" resultType="com.zc.business.domain.DcDispatch"> <select id="selectDcDispatchById" resultType="com.zc.business.domain.DcDispatch">
select * from dc_dispatch where id = #{id} select * from dc_dispatch where id = #{id}
</select> </select>
<select id="employeesName" resultType="java.lang.String">
select name from dc_employees where id=#{id}
</select>
<select id="vehiclesName" resultType="java.lang.String">
select vehicle_plate from dc_vehicles where id=#{id}
</select>
<select id="organizationName" resultType="java.lang.String">
select organization_name from dc_organization where id=#{id}
</select>
<select id="vehiclesType" resultType="java.lang.String">
select vehicle_type from dc_vehicles where id=#{id}
</select>
<select id="selectTrafficPolice" resultType="java.util.HashMap">
select name,contact_number contactNumber from dc_employees where organization_id=#{organizationId} and employees_type=2
</select>
</mapper> </mapper>

Loading…
Cancel
Save