Commit 8c88dd31 authored by duanruiming's avatar duanruiming

[update] 状态检测优化

parent 9cb9fa61
......@@ -23,7 +23,7 @@ import java.util.*;
* @author Kent HAN
* @date 2022/10/26 13:31
*/
@Api(value = "SituationDetectionController", description = "态势监测")
@Api(value = "SituationDetectionController", description = "状态检测")
@RequestMapping("/situationDetection")
@RestController
public class SituationDetectionController extends BaseController {
......@@ -163,15 +163,8 @@ public class SituationDetectionController extends BaseController {
public JsonViewObject crossDeviceStatusInfo() {
List<CrossDeviceStatusInfoOutVO> list = situationDetectionService.crossDeviceStatusInfo();
for (CrossDeviceStatusInfoOutVO item : list) {
int fualType = item.getFaultType();
int status = item.getStatus();
if (status == 1 && fualType == 0) {
status = 1;
}
if (status == 1 && fualType != 0) {
status = 3;
}
item.setStatus(status);
item.setStatus(status + 1);
}
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(list);
......@@ -235,21 +228,7 @@ public class SituationDetectionController extends BaseController {
@ApiOperation(value = "设备厂商", notes = "设备厂商")
@GetMapping("/signalManufacturerInfoCount")
public JsonViewObject signalManufacturerInfoCount() throws Exception {
// List<SignalManufacturerCountInfoVO> result = situationDetectionService.signalManufacturerInfoCount();
// todo 测试数据
List<SignalManufacturerCountInfoVO> result = new ArrayList<>();
List<String> strings = Arrays.asList("大华", "东土", "海信", "海康");
List<Integer> count1 = Arrays.asList(10, 25, 19, 29);
List<Integer> count2 = Arrays.asList(1, 2, 3, 3);
List<Integer> count3 = Arrays.asList(1, 2, 3, 2);
for (int i = 0; i < 4; i++) {
SignalManufacturerCountInfoVO signalManufacturerCountInfoVO = new SignalManufacturerCountInfoVO();
signalManufacturerCountInfoVO.setName(strings.get(i));
signalManufacturerCountInfoVO.setOnlineCount(count1.get(i));
signalManufacturerCountInfoVO.setOfflineCount(count2.get(i));
signalManufacturerCountInfoVO.setFaultCount(count3.get(i));
result.add(signalManufacturerCountInfoVO);
}
List<SignalManufacturerCountInfoVO> result = situationDetectionService.signalManufacturerInfoCount();
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(result);
}
......
......@@ -33,4 +33,6 @@ public interface CrossLightsMapper {
void update(CrossLightsPO crossLightsPO);
void insertOne(CrossLightsPO crossLightsPO);
List<CrossLightsPO> listCrossLightsPO(@Param("entity") CrossLightsPO entity);
}
......@@ -27,4 +27,6 @@ public interface CrossPhaseLightsMapper {
Integer selectIdByThreeIds(Integer lightsId, Integer phaseId, String crossId);
void insertOne(CrossPhaseLightsPO crossPhaseLightsPO);
List<CrossPhaseLightsPO> listCrossPhaseLightsPO(@Param("entity") CrossPhaseLightsPO entity);
}
......@@ -46,4 +46,6 @@ public interface CrossPhaseMapper {
void update(CrossPhasePO crossPhasePO);
void insertBatch(List<CrossPhasePO> crossPhaseList);
List<CrossPhasePO> listCrossPhasePO(@Param("entity") CrossPhasePO entity);
}
......@@ -65,6 +65,58 @@ public class PlanSendServiceImpl implements PlanSendService {
this.crossSectionMapper = crossSectionMapper;
}
public JsonViewObject PhaseLaneSend(String crossId, String schemeId) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
PhaseTimingSendVO phaseTimingSendVO = new PhaseTimingSendVO();
phaseTimingSendVO.setCrossCode(crossId);
List<PhaseTimingSendVO.Phase> phaseList = new ArrayList<>();
CrossPhasePO crossPhasePO = new CrossPhasePO();
crossPhasePO.setCrossId(crossId);
List<CrossPhasePO> crossPhasePOS = crossPhaseMapper.listCrossPhasePO(crossPhasePO);
CrossPhaseLightsPO crossPhaseLightsPO = new CrossPhaseLightsPO();
crossPhaseLightsPO.setCrossId(crossId);
List<CrossPhaseLightsPO> crossPhaseLightsPOS = crossPhaseLightsMapper.listCrossPhaseLightsPO(crossPhaseLightsPO);
CrossLightsPO crossLightsPO = new CrossLightsPO();
crossLightsPO.setCrossId(crossId);
List<CrossLightsPO> crossLightsPOS = crossLightsMapper.listCrossLightsPO(crossLightsPO);
for (CrossPhasePO phasePO : crossPhasePOS) {
PhaseTimingSendVO.Phase phase = new PhaseTimingSendVO.Phase();
phase.setPhaseNo(Integer.valueOf(phasePO.getPhaseNo()));
phase.setDesc(phasePO.getName());
phase.setYellow(phasePO.getYellowTime());
phase.setAllred(phasePO.getRedTime());
phase.setGreenFlash(String.valueOf(phasePO.getGreenFlashTime()));
phase.setRedFlash(String.valueOf(phasePO.getRedFlashTime()));
phase.setMaxGreen(String.valueOf(phasePO.getMaxGreenTime()));
phase.setMinGreen(String.valueOf(phasePO.getMinGreenTime()));
Integer id = phasePO.getId();
List<PhaseTimingSendVO.Phase.Lane> lanes = new ArrayList<>();
for (CrossPhaseLightsPO phaseLightsPO : crossPhaseLightsPOS) {
if (Objects.equals(id, phaseLightsPO.getPhaseId())) {
Integer lightsId = phaseLightsPO.getLightsId();
for (CrossLightsPO lightsPO : crossLightsPOS) {
if (Objects.equals(lightsId, lightsPO.getId())) {
PhaseTimingSendVO.Phase.Lane lane = new PhaseTimingSendVO.Phase.Lane();
lane.setLaneNo(Integer.valueOf(lightsPO.getLightsNo()));
lane.setDirection(lightsPO.getDir());
lane.setTurn(lightsPO.getTurn());
lanes.add(lane);
}
}
}
}
phase.setLanes(lanes);
phaseList.add(phase);
}
phaseTimingSendVO.setPhaseList(phaseList);
JsonViewObject phaseTimingSendResult = utcFeignClients.phaseTimingSend(phaseTimingSendVO);
if (Objects.isNull(phaseTimingSendResult) || phaseTimingSendResult.getCode() != 200) {
return jsonViewObject.fail("信号机方案下发-相位参数下发UTC服务调用异常");
}
return jsonViewObject.success(phaseTimingSendResult);
}
@Override
@Transactional
public JsonViewObject scheduleSend(ScheduleIdDTO scheduleIdDTO) {
......@@ -86,6 +138,8 @@ public class PlanSendServiceImpl implements PlanSendService {
if (Objects.isNull(planSendResult) || planSendResult.getCode() != 200) {
return jsonViewObject.fail("信号机方案下发-日计划下发UTC服务调用异常");
}
// 下发相位
// 更新时间表状态为已执行
crossSchedulesMapper.resetStatus(crossId);
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import net.wanji.common.enums.EventAlarmEnum;
import net.wanji.common.enums.EventAlarmSourceEnum;
......@@ -22,6 +21,8 @@ import net.wanji.web.common.enums.CrossAlarmEnum;
import net.wanji.web.common.enums.DeviceStatusEnum;
import net.wanji.web.common.enums.DeviceTypeEnum;
import net.wanji.web.common.util.StringUtils;
import net.wanji.web.common.util.date.DateStyle;
import net.wanji.web.common.util.date.DateUtils;
import net.wanji.web.dto.CrossIdNameDTO;
import net.wanji.web.entity.TBaseAreaCross;
import net.wanji.web.entity.TBaseAreaInfo;
......@@ -581,7 +582,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
SignalFaultInfoVO signalFaultInfoVO = new SignalFaultInfoVO();
signalFaultInfoVO.setDealStatus("1"); // 默认未处理
BeanUtils.copyProperties(tDeviceStatus, signalFaultInfoVO);
signalFaultInfoVO.setStartTime(tDeviceStatus.getGmtCreate().toString().substring(11, 19));
signalFaultInfoVO.setStartTime(DateUtils.dateToString(tDeviceStatus.getGmtCreate(), DateStyle.YYYY_MM_DD_HH_MM_SS));
if (!CollectionUtils.isEmpty(crossInfoOutVoList)) {
for (CrossInfoOutVo crossInfoOutVo : crossInfoOutVoList) {
if (StringUtils.equals(crossInfoOutVo.getId(), tDeviceStatus.getCode())) {
......@@ -596,11 +597,13 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
});
List<SignalFaultInfoVO> result = null;
if (StringUtils.isNotEmpty(dealStatus)) {
result = signalFaultInfoVOS.stream().filter(signalFaultInfoVO -> StringUtils.equals(dealStatus, signalFaultInfoVO.getDealStatus())).collect(Collectors.toList());
result = signalFaultInfoVOS.stream()
.filter(signalFaultInfoVO -> StringUtils.equals(dealStatus, signalFaultInfoVO.getDealStatus())).collect(Collectors.toList());
} else {
result = signalFaultInfoVOS;
}
result = result.stream().sorted(Comparator.comparing(SignalFaultInfoVO::getStartTime).reversed()).collect(Collectors.toList());
result = result.stream().sorted(Comparator.comparing(SignalFaultInfoVO::getDealStatus).reversed()
.thenComparing(SignalFaultInfoVO::getGmtCreate).reversed()).collect(Collectors.toList());
return result;
}
......@@ -622,6 +625,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
/**
* 在线并且无故障为已处理
*
* @param tDeviceStatusInfo
* @return
*/
......@@ -664,7 +668,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
String location = tBaseCrossInfo.getLocation().replace("POINT", "").replace("(", "").replace(")", "").replace(" ", ",");
signalOperationModeVO.setLocation(location);
signalOperationModeVO.setCrossName(tBaseCrossInfo.getName());
signalOperationModeVO.setOperationTime(signalOperationModeVO.getStartTime().toString().substring(11, 19));
signalOperationModeVO.setOperationTime(DateUtils.dateToString(signalOperationModeVO.getStartTime(),DateStyle.YYYY_MM_DD_HH_MM_SS));
}
}
}
......@@ -717,25 +721,26 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
List<ManufacturerInfoOutVO> manufacturerInfoOutVOList = getManufacturerInfoOutVOList(new ManufacturerVO());
List<CrossInfoOutVo> crossInfoOutVoList = getCrossInfoOutVoList(new CrossInfoPageVO());
// key:crossId value:nickName
// key:nickName value:List<crossId>
Map<String, List<String>> nickNameCrossIdMap = getCrossIdNickNameMap(manufacturerInfoOutVOList, crossInfoOutVoList);
List<TDeviceStatusInfo> tDeviceStatusInfos = allDeviceStatusMapper.selectByEntity(new TDeviceStatusInfo());
SignalManufacturerCountInfoVO signalManufacturerCountInfoVO = new SignalManufacturerCountInfoVO();
for (Map.Entry<String, List<String>> entry : nickNameCrossIdMap.entrySet()) {
SignalManufacturerCountInfoVO signalManufacturerCountInfoVO = new SignalManufacturerCountInfoVO();
String nickName = entry.getKey();
List<String> value = entry.getValue();
List<String> crossIdList = entry.getValue();
int onlineCount = 0;
int offlineCount = 0;
int faultCount = 0;
signalManufacturerCountInfoVO.setName(nickName);
for (TDeviceStatusInfo tDeviceStatusInfo : tDeviceStatusInfos) {
String crossId = tDeviceStatusInfo.getCode();
if (crossIdList.contains(crossId)) {
int status = tDeviceStatusInfo.getStatus();
if (value.contains(crossId)) {
if (status == 0) {
offlineCount++;
}
if (status == 1) {
offlineCount++;
onlineCount++;
}
if (status == 2) {
faultCount++;
......@@ -745,7 +750,6 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
signalManufacturerCountInfoVO.setOnlineCount(onlineCount);
signalManufacturerCountInfoVO.setOfflineCount(offlineCount);
signalManufacturerCountInfoVO.setFaultCount(faultCount);
signalManufacturerCountInfoVO.setName(nickName);
resultList.add(signalManufacturerCountInfoVO);
}
......@@ -761,7 +765,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
List<String> crossIdList = new ArrayList<>();
for (CrossInfoOutVo crossInfoOutVo : crossInfoOutVoList) {
crossId = crossInfoOutVo.getId();
Integer manufacturerId = crossInfoOutVo.getManufacturerId();
Integer manufacturerId = Integer.valueOf(crossInfoOutVo.getManufacturerId());
if (Objects.equals(id, manufacturerId)) {
crossIdList.add(crossId);
}
......@@ -805,8 +809,13 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("远程调用UTC服务信号机厂商信息失败!");
}
PageInfo<ManufacturerInfoOutVO> content = (PageInfo<ManufacturerInfoOutVO>) jsonViewObject.getContent();
List<ManufacturerInfoOutVO> list = content.getList();
List<ManufacturerInfoOutVO> list = new ArrayList<>();
Map map = (Map) jsonViewObject.getContent();
List<Map<String, Object>> content = (List<Map<String, Object>>) map.get("list");
for (Map<String, Object> entry : content) {
ManufacturerInfoOutVO manufacturerInfoOutVO = BeanMapUtils.mapToBean(entry, ManufacturerInfoOutVO.class);
list.add(manufacturerInfoOutVO);
}
return list;
}
}
......
......@@ -60,7 +60,11 @@ public class SignalStatusTask {
TDeviceStatusInfo tDeviceStatusInfo = tDeviceStatusMapper.selectOne(lambdaQueryWrapper);
if (isExucuteUpdate(currentSignalStatus, currentFaultType, tDeviceStatusInfo)) {
tDeviceStatusInfo.setStatus(currentSignalStatus);
if (!Objects.equals(0, currentFaultType)) {
tDeviceStatusInfo.setStatus(2);
} else {
tDeviceStatusInfo.setStatus(currentFaultType);
}
tDeviceStatusInfo.setFaultType(currentFaultType);
tDeviceStatusInfo.setGmtCreate(new Date()); // 实时数据,创建和修改时间一致
tDeviceStatusMapper.updateById(tDeviceStatusInfo);
......
......@@ -14,6 +14,21 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id, lights_no,type, dir, sort, cross_id, gmt_create, gmt_modified
</sql>
<select id="listCrossLightsPO" parameterType="net.wanji.web.po.scheme.CrossLightsPO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from t_base_cross_lights
<where>
<if test="entity.crossId != null and entity.crossId != ''">
cross_id = #{entity.crossId}
</if>
</where>
</select>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no,type,dir,sort,cross_id)
values
......@@ -23,8 +38,8 @@
</insert>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no,type,dir,sort,cross_id)
values (#{lightsNo},#{type},#{dir},#{sort},#{crossId})
insert into t_base_cross_lights(lights_no, type, dir, sort, cross_id)
values (#{lightsNo}, #{type}, #{dir}, #{sort}, #{crossId})
</insert>
<update id="update">
......@@ -44,34 +59,61 @@
</update>
<delete id="deleteByCrossId">
delete from t_base_cross_lights
delete
from t_base_cross_lights
where cross_id = #{crossId}
</delete>
<select id="selectByCrossIdAndLedNum" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId} and lights_no = #{ledNum}
where cross_id = #{crossId}
and lights_no = #{ledNum}
</select>
<select id="selectByCrossId" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
</select>
<select id="selectByCrossIdAndDir" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId} and dir = #{dir}
where cross_id = #{crossId}
and dir = #{dir}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where id = #{id}
</select>
......
......@@ -12,6 +12,24 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id, lights_id, phase_id, cross_id, gmt_create, gmt_modified
</sql>
<select id="listCrossPhaseLightsPO" resultMap="BaseResultMap" parameterType="net.wanji.web.po.scheme.CrossPhaseLightsPO">
select
<include refid="Base_Column_List"></include>
from t_base_cross_phase_lights
<where>
<if test="entity.crossId != null and entity.crossId != ''">
cross_id = #{entity.crossId}
</if>
<if test="entity.phaseId != null and entity.phaseId != ''">
phase_id = #{entity.phaseId}
</if>
</where>
</select>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_phase_lights(lights_id,phase_id,cross_id)
values
......
......@@ -26,6 +26,21 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id,phase_no,name,sort,cross_id,plan_id,ring_no,group_no,phase_type,control_mode,phase_time,green_time,green_flash_time,yellow_flash_time,red_flash_time,ped_flash_time,yellow_time,red_time,min_green_time,max_green_time
</sql>
<select id="listCrossPhasePO" resultMap="BaseResultMap" parameterType="net.wanji.web.po.scheme.CrossPhasePO">
select
<include refid="Base_Column_List"></include>
from t_base_cross_phase
<where>
<if test="entity.crossId != null and entity.crossId !=''">
cross_id = #{entity.crossId}
</if>
</where>
</select>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_phase(phase_no,name,sort,cross_id,plan_id,ring_no,group_no,phase_type,control_mode,phase_time,green_time,green_flash_time,yellow_flash_time,red_flash_time,ped_flash_time,yellow_time,red_time,min_green_time,max_green_time)
values (#{phaseNo},#{name},#{sort},#{crossId},#{planId},#{ringNo},#{groupNo},#{phaseType},#{controlMode},#{phaseTime},#{greenTime},#{greenFlashTime},#{yellowFlashTime},#{redFlashTime},#{pedFlashTime},#{yellowTime},#{redTime},#{minGreenTime},#{maxGreenTime})
......
......@@ -60,6 +60,7 @@ public class CrossInfoServiceImpl implements CrossInfoService {
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerIdInPage);
String nickName = manufacturerInfoPO.getNickName();
crossInfoListVO.setManufacturerNick(nickName);
crossInfoListVO.setManufacturerId(manufacturerIdInPage);
crossInfoListOutVOPageInfo.getList().add(crossInfoListVO);
}
......
......@@ -25,6 +25,8 @@ public class CrossInfoListVO {
/** 信号机厂商 */
@ApiModelProperty(value = "信号机厂商",notes = "")
private String manufacturerNick ;
@ApiModelProperty(value = "信号机厂商编码",notes = "")
private Integer manufacturerId ;
/** 信号机IP */
@ApiModelProperty(value = "信号机IP",notes = "")
private String ip ;
......
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