Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
zhaoxianglong 10 months ago
parent
commit
acea6f2cb5
  1. 59
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  2. 4
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  3. 2
      zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml
  4. 2
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

59
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -1166,65 +1166,6 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessService.insertDcEventProcess(dcEventProcess);
//插入调度默认数据
ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>();
String stakeMark = dcEvent.getStakeMark();//传入桩号
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String, Object> map : mapList) {
if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())) {
continue;
}
Long sectionId = (Long) map.get("id");//机构的id
String stakeMarkNew = map.get("stakeMark").toString();//机构桩号
com.zc.business.utils.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", sectionId);
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(id);//查询事件是否已经有转的调度记录
if (!sortedHashMaps.isEmpty() && hashMap == null) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long sortId = (Long) map.get("id");//取出最近的机构id
if (sortId != null) {
DcDispatch dcDispatch = new DcDispatch();
DcDispatchResource dcDispatchResource = new DcDispatchResource();
dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId());
dcDispatch.setEventId(id);
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(dcEvent.getRemark());
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();//信息记录id
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(sortId);//人员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(sortId);//车辆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 i;
}

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

@ -612,6 +612,7 @@ public class DcWarningServiceImpl implements IDcWarningService
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult commandAndDispatch(DcWarning dcWarning) {
Map<String, Object> mapAll = new HashMap<>();
HashMap<String, Object> dcDispatch = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询是否存在调度记录
@ -671,6 +672,7 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//指挥调度,当调度信息为空的时候调用智能分配资源
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult intelligentSource(DcWarning dcWarning) {
String stakeMark = dcWarning.getStakeMark();
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
@ -747,7 +749,7 @@ public class DcWarningServiceImpl implements IDcWarningService
employees = Long.parseLong(map.get("employeesId").toString());//人员
}
Long vehicles=null;
if (map.get("vehiclesId").toString()!=null){
if (map.get("vehiclesId")!=null){
vehicles = Long.parseLong(map.get("vehiclesId").toString());//车辆
}
DcDispatch dcDispatch = new DcDispatch();

2
zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcEventProcessByEventId" parameterType="string" resultMap="DcEventProcessResult">
<include refid="selectDcEventProcessVo"/>
where event_id = #{eventId} and type = 'text'
where event_id = #{eventId}
</select>
</mapper>

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

@ -319,7 +319,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where parent_id!=0
</select>
<select id="selectOrganizationEmployees" resultType="java.util.HashMap">
select id, name,contact_number contactNumber from dc_employees where organization_id=#{organizationId}
select id, name,contact_number contactNumber from dc_employees where organization_id=#{organizationId} and employees_type=1
</select>
<select id="selectShifts" resultType="java.util.HashMap">
select shifts.scheduling,employees.name shiftsName,employees.contact_number shiftsNumber from dc_shifts as shifts

Loading…
Cancel
Save