Commit e69d4323 authored by duanruiming's avatar duanruiming

[add] 策略历史优化查询

parent f4340281
package net.wanji.opt.controller.signalopt;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author duanruiming
* @date 2024/11/28 16:03
*/
@Api(value = "CrossIndexController", description = "路口指标控制器")
@RequestMapping("/crossIndex")
@RestController
public class GreenBeltController {
}
...@@ -30,7 +30,7 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -30,7 +30,7 @@ public class CrossIndexServiceImpl implements CrossIndexService {
@Override @Override
public Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO) { public Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO) {
List<CrossDirDataRealtimePO> crossDirDataRealtimePOS = crossDirDataRealtimeMapper.selectMaxBatchTime(crossIdBO.getCrossId()); List<CrossDirDataRealtimePO> crossDirDataRealtimePOS = crossDirDataRealtimeMapper.selectBycrossId(crossIdBO.getCrossId());
if (!CollectionUtils.isEmpty(crossDirDataRealtimePOS)) { if (!CollectionUtils.isEmpty(crossDirDataRealtimePOS)) {
Map<Integer, CrossDirDataRealtimePO> dirDataMap = new HashMap<>(crossDirDataRealtimePOS.size()); Map<Integer, CrossDirDataRealtimePO> dirDataMap = new HashMap<>(crossDirDataRealtimePOS.size());
for (CrossDirDataRealtimePO crossDirDataRealtimePO : crossDirDataRealtimePOS) { for (CrossDirDataRealtimePO crossDirDataRealtimePO : crossDirDataRealtimePOS) {
......
...@@ -22,7 +22,7 @@ import javax.ws.rs.core.MediaType; ...@@ -22,7 +22,7 @@ import javax.ws.rs.core.MediaType;
* @date 2024/11/03 12:42 * @date 2024/11/03 12:42
* @description 神思电子获取1.1策略计划基础信息 * @description 神思电子获取1.1策略计划基础信息
*/ */
@Api(value = "StrategyControlController", description = "策略控制") @Api(value = "strategyControl", description = "策略控制")
@RequestMapping("/strategyControl") @RequestMapping("/strategyControl")
@RestController @RestController
public class StrategyControlController { public class StrategyControlController {
...@@ -59,6 +59,18 @@ public class StrategyControlController { ...@@ -59,6 +59,18 @@ public class StrategyControlController {
@ApiOperation(value = "策略控制查询列表", notes = "策略控制查询列表", @ApiOperation(value = "策略控制查询列表", notes = "策略控制查询列表",
response = JsonViewObject.class, response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossStrategyHistList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyControlDataEntity.class),
})
public JsonViewObject crossStrategyHistList() throws Exception {
return strategyControlService.crossStrategyHistList();
}
@ApiOperation(value = "策略控制历史查询列表", notes = "策略控制历史查询列表",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossStrategyInfoList") @GetMapping(value = "/crossStrategyInfoList")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyControlDataEntity.class), @ApiResponse(code = 200, message = "OK", response = StrategyControlDataEntity.class),
......
...@@ -27,20 +27,6 @@ public class StrategyGreenBeltController { ...@@ -27,20 +27,6 @@ public class StrategyGreenBeltController {
@Resource @Resource
private StrategyGreenBeltServiceImpl strategyGreenBeltService; private StrategyGreenBeltServiceImpl strategyGreenBeltService;
@ApiOperation(value = "绿波时序图数据查询", notes = "绿波时序图数据查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBletData")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenBeltInfoVO.class),
})
public JsonViewObject greenBletData(String greenId) throws Exception {
//String key = Constants.GREEN_ID_OPT_KEY.concat(greenId);
//Object obj = redisUtils.get(key);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
//GreenBeltInfoVO greenBeltInfoVO = JacksonUtils.getInstance().readValue(String.valueOf(obj), GreenBeltInfoVO.class);
return jsonViewObject.success(null);
}
@ApiOperation(value = "绿波时序图图形查询", notes = "绿波时序图图形查询", response = JsonViewObject.class, @ApiOperation(value = "绿波时序图图形查询", notes = "绿波时序图图形查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltChart") @GetMapping(value = "/greenBeltChart")
......
...@@ -15,6 +15,7 @@ public interface StrategyControlService { ...@@ -15,6 +15,7 @@ public interface StrategyControlService {
JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception; JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception;
JsonViewObject crossStrategyInfoList(Integer type) throws Exception; JsonViewObject crossStrategyInfoList(Integer type) throws Exception;
JsonViewObject crossStrategyHistList() throws Exception;
JsonViewObject crossOptInfoList(Integer type) throws Exception; JsonViewObject crossOptInfoList(Integer type) throws Exception;
JsonViewObject strategyPlanDetail(String crossId) throws Exception; JsonViewObject strategyPlanDetail(String crossId) throws Exception;
......
...@@ -102,7 +102,6 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -102,7 +102,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private StrategyControlReq convertReq(StrategyControlVO vo) throws Exception { private StrategyControlReq convertReq(StrategyControlVO vo) throws Exception {
try { try {
ObjectMapper instance = JacksonUtils.getInstance();
List<StrategyControlDataVO> dataList = vo.getDataList(); List<StrategyControlDataVO> dataList = vo.getDataList();
StrategyControlReq req = new StrategyControlReq(); StrategyControlReq req = new StrategyControlReq();
if (!CollectionUtils.isEmpty(dataList)) { if (!CollectionUtils.isEmpty(dataList)) {
...@@ -158,10 +157,83 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -158,10 +157,83 @@ public class StrategyControlServiceImpl implements StrategyControlService {
return JsonViewObject.newInstance().success(pageInfo.getRecords()); return JsonViewObject.newInstance().success(pageInfo.getRecords());
} }
@Override
public JsonViewObject crossStrategyHistList() throws Exception {
List<StrategyControlDataEntity> resulsts = new ArrayList<>();
LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.isNotNull(StrategyControlDataEntity::getScheduleStart);
queryWrapper.orderByDesc(StrategyControlDataEntity::getScheduleEnd);
List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(entities)) {
for (StrategyControlDataEntity entity : entities) {
Integer type = entity.getBizType();
if (type == 0) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
entity.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
entity.setWkt(location);
}
if (type == 1) {
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId()));
entity.setCrossName(greenwaveInfoPO.getName());
entity.setWkt(greenwaveInfoPO.getWkt());
}
resulsts.add(entity);
}
}
return JsonViewObject.newInstance().success(resulsts);
}
@Override @Override
public JsonViewObject crossStrategyInfoList(Integer type) throws Exception { public JsonViewObject crossStrategyInfoList(Integer type) throws Exception {
try { try {
List<StrategyControlDataEntity> results = getCurrentStrateInfoList(type); List<StrategyControlDataEntity> results = new ArrayList<>();
List<StrategyControlDataEntity> entities = getCurrentStrateInfoList(type);
Map<String, StrategyControlDataEntity> map = entities.stream().collect(Collectors.toMap(StrategyControlDataEntity::getBizId, entity -> entity));
// 路口
if (Objects.equals(0, type)) {
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll();
if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) {
for (BaseCrossInfoPO baseCrossInfoPO : baseCrossInfoPOS) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
String crossId = baseCrossInfoPO.getId();
strategyControlDataEntity.setBizType(0);
strategyControlDataEntity.setBizId(baseCrossInfoPO.getId());
strategyControlDataEntity.setStrategy(null);
strategyControlDataEntity.setTime(null);
strategyControlDataEntity.setStatus(0);
strategyControlDataEntity.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
strategyControlDataEntity.setWkt(location);
if (map.containsKey(crossId)) {
strategyControlDataEntity = map.get(crossId);
}
results.add(strategyControlDataEntity);
}
}
} // 干线
if (Objects.equals(1, type)) {
List<GreenwaveInfoPO> greenwaveInfoPOS = greenwaveInfoMapper.selectAll();
if (!CollectionUtils.isEmpty(greenwaveInfoPOS)) {
for (GreenwaveInfoPO greenwaveInfoPO : greenwaveInfoPOS) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
Integer greenId = greenwaveInfoPO.getId();
strategyControlDataEntity.setBizType(1);
strategyControlDataEntity.setBizId(String.valueOf(greenId));
strategyControlDataEntity.setStrategy(null);
strategyControlDataEntity.setTime(null);
strategyControlDataEntity.setStatus(0);
strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName());
strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt());
if (map.containsKey(greenId)) {
strategyControlDataEntity = map.get(greenId);
}
results.add(strategyControlDataEntity);
}
}
}
return JsonViewObject.newInstance().success(results); return JsonViewObject.newInstance().success(results);
} catch (Exception e) { } catch (Exception e) {
log.error("策略控制查询列表:{}", e); log.error("策略控制查询列表:{}", e);
...@@ -173,6 +245,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -173,6 +245,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
ObjectMapper instance = JacksonUtils.getInstance(); ObjectMapper instance = JacksonUtils.getInstance();
LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyControlDataEntity::getBizType, type); queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
queryWrapper.ge(StrategyControlDataEntity::getScheduleStart, new Date());
queryWrapper.le(StrategyControlDataEntity::getScheduleEnd, new Date());
List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper); List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
List<StrategyControlDataEntity> results = new ArrayList<>(entities.size()); List<StrategyControlDataEntity> results = new ArrayList<>(entities.size());
Date current = new Date(); Date current = new Date();
...@@ -205,7 +279,10 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -205,7 +279,10 @@ public class StrategyControlServiceImpl implements StrategyControlService {
DateTime endHourDate = DateUtil.parse(entHour, "HH:mm"); DateTime endHourDate = DateUtil.parse(entHour, "HH:mm");
if (currentTime.before(startHourDate) || currentTime.after(endHourDate)) { if (currentTime.before(startHourDate) || currentTime.after(endHourDate)) {
result.setTime(hour); result.setTime(hour);
result.setStatus(1);
} }
// 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置
result.setStatus(0);
} }
} }
} }
...@@ -241,7 +318,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -241,7 +318,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt); BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt);
String strategyName = ""; String strategyName = "";
for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) { for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) {
if (strategy == strategyFactoryEntity.getScene()) { if (Objects.equals(strategy, strategyFactoryEntity.getScene())) {
strategyName = strategyFactoryEntity.getStrategyName(); strategyName = strategyFactoryEntity.getStrategyName();
} }
} }
......
...@@ -29,5 +29,4 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt ...@@ -29,5 +29,4 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt
CrossDirDataRealtimePO selectByCrossIdAndDirs(String crossId, List<Integer> dirCodeList); CrossDirDataRealtimePO selectByCrossIdAndDirs(String crossId, List<Integer> dirCodeList);
List<CrossDirDataRealtimePO> selectMaxBatchTime(String crossId);
} }
...@@ -97,11 +97,4 @@ ...@@ -97,11 +97,4 @@
and in_out_type = 1 and in_out_type = 1
</select> </select>
<select id="selectMaxBatchTime" resultType="net.wanji.databus.po.CrossDirDataRealtimePO">
select <include refid="Base_Column_List"/>
from t_cross_dir_data_realtime
where cross_id = #{crossId} and in_out_type = 1
and batch_time in (select max(batch_time) from t_cross_dir_data_realtime where cross_id = #{crossId})
</select>
</mapper> </mapper>
\ No newline at end of file
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