Commit 535d9b8a authored by duanruiming's avatar duanruiming

[add] 路口指标方向指标

parent 27636fc2
package net.wanji.opt.controller.signalopt;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.service.CrossIndexService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.Date;
import java.util.Map;
/**
* @author duanruiming
* @date 2024/11/25 19:10
*/
@Api(value = "CrossIndexController", description = "路口指标控制器")
@RequestMapping("/crossIndex")
@RestController
public class CrossIndexController {
@Resource
private CrossIndexService crossIndexService;
@ApiOperation(value = "路口方向指标", notes = "路口方向指标", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossDirIndex",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
})
public JsonViewObject crossDirIndex(@RequestBody CrossIdBO crossIdBO) {
Map<Integer, CrossDirDataRealtimePO> result = crossIndexService.crossDirIndex(crossIdBO);
return JsonViewObject.newInstance().success(result);
}
public static void main(String[] args) {
Date date = new Date();
System.err.println(date);
}
}
...@@ -19,7 +19,7 @@ import java.util.Map; ...@@ -19,7 +19,7 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class GreenBeltKafkaDTO { public class GreenBeltKafkaDTO {
@JsonProperty("greenbelt_id") @JsonProperty("greenbelt_id")
private String greenbeltId; // 绿波带id private Integer greenbeltId; // 绿波带id
@JsonProperty("greenbelt_length") @JsonProperty("greenbelt_length")
private double greenbeltLength; // 绿波干线长度(m) private double greenbeltLength; // 绿波干线长度(m)
@JsonProperty("max_speed_forward") @JsonProperty("max_speed_forward")
......
package net.wanji.opt.service;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.po.CrossDirDataRealtimePO;
import java.util.Map;
/**
* @author duanruiming
* @date 2024/11/25 19:12
*/
public interface CrossIndexService {
Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO);
}
package net.wanji.opt.service.impl;
import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.opt.service.CrossIndexService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
* @date 2024/11/25 19:12
*/
@Service
@Slf4j
public class CrossIndexServiceImpl implements CrossIndexService {
@Resource
private CrossDirDataRealtimeMapper crossDirDataRealtimeMapper;
@Override
public Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO) {
List<CrossDirDataRealtimePO> crossDirDataRealtimePOS = crossDirDataRealtimeMapper.selectMaxBatchTime(crossIdBO.getCrossId());
if (!CollectionUtils.isEmpty(crossDirDataRealtimePOS)) {
Map<Integer, CrossDirDataRealtimePO> dirDataMap = new HashMap<>(crossDirDataRealtimePOS.size());
for (CrossDirDataRealtimePO crossDirDataRealtimePO : crossDirDataRealtimePOS) {
dirDataMap.put(crossDirDataRealtimePO.getDirType(), crossDirDataRealtimePO);
}
return dirDataMap;
}
return null;
}
}
...@@ -99,7 +99,7 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService { ...@@ -99,7 +99,7 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
entity.setGreenWidthTime(dirGreenDetail.getGreenWidthTime()); entity.setGreenWidthTime(dirGreenDetail.getGreenWidthTime());
entity.setCrossGreenDetail(JacksonUtils.getInstance().writeValueAsString(dirGreenDetail.getCrossGreenDetailList())); entity.setCrossGreenDetail(JacksonUtils.getInstance().writeValueAsString(dirGreenDetail.getCrossGreenDetailList()));
strategyGreenOptHistMapper.insert(entity); strategyGreenOptHistMapper.insert(entity);
String key = Constants.GREEN_ID_OPT_KEY.concat(infoVO.getGreenId()); String key = Constants.GREEN_ID_OPT_KEY.concat(String.valueOf(infoVO.getGreenId()));
} }
} }
} }
......
...@@ -43,4 +43,6 @@ public class StrategyControlDataEntity extends PageVO { ...@@ -43,4 +43,6 @@ public class StrategyControlDataEntity extends PageVO {
private Integer status; private Integer status;
@TableField(exist = false) @TableField(exist = false)
private String crossName; private String crossName;
@TableField(exist = false)
private String wkt;
} }
...@@ -23,8 +23,8 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper; ...@@ -23,8 +23,8 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper;
import net.wanji.opt.synthesis.pojo.*; import net.wanji.opt.synthesis.pojo.*;
import net.wanji.opt.synthesis.service.PushStrategyControlService; import net.wanji.opt.synthesis.service.PushStrategyControlService;
import net.wanji.opt.synthesis.service.StrategyControlService; import net.wanji.opt.synthesis.service.StrategyControlService;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -87,7 +87,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -87,7 +87,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDataVO> dataList = strategyControlVO.getDataList(); List<StrategyControlDataVO> dataList = strategyControlVO.getDataList();
for (StrategyControlDataVO dataVO : dataList) { for (StrategyControlDataVO dataVO : dataList) {
StrategyControlDataEntity entity = new StrategyControlDataEntity(); StrategyControlDataEntity entity = new StrategyControlDataEntity();
BeanUtils.copyProperties(entity, dataVO); BeanUtils.copyProperties(dataVO, entity);
entity.setTime(JacksonUtils.getInstance().writeValueAsString(dataVO.getTime())); entity.setTime(JacksonUtils.getInstance().writeValueAsString(dataVO.getTime()));
if (StringUtils.equals("insert", dataVO.getAction())) { if (StringUtils.equals("insert", dataVO.getAction())) {
entity.setId(null); entity.setId(null);
...@@ -178,7 +178,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -178,7 +178,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
Date current = new Date(); Date current = new Date();
for (StrategyControlDataEntity entity : entities) { for (StrategyControlDataEntity entity : entities) {
StrategyControlDataEntity result = new StrategyControlDataEntity(); StrategyControlDataEntity result = new StrategyControlDataEntity();
BeanUtils.copyProperties(result, entity); BeanUtils.copyProperties(entity, result);
Date start = entity.getScheduleStart(); Date start = entity.getScheduleStart();
Date end = entity.getScheduleEnd(); Date end = entity.getScheduleEnd();
if (current.before(start) || current.after(end)) { if (current.before(start) || current.after(end)) {
...@@ -214,10 +214,14 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -214,10 +214,14 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if (type == 0) { if (type == 0) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId()); BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
result.setCrossName(baseCrossInfoPO.getName()); result.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
result.setWkt(location);
} }
if (type == 1) { if (type == 1) {
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId())); GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId()));
result.setCrossName(greenwaveInfoPO.getName()); result.setCrossName(greenwaveInfoPO.getName());
result.setWkt(greenwaveInfoPO.getWkt());
} }
results.add(result); results.add(result);
} }
...@@ -234,7 +238,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -234,7 +238,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) { for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) {
Integer strategy = strategyControlDataEntity.getStrategy(); Integer strategy = strategyControlDataEntity.getStrategy();
StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt(); StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt();
BeanUtils.copyProperties(strategyControlDataExt, strategyControlDataEntity); BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt);
String strategyName = ""; String strategyName = "";
for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) { for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) {
if (strategy == strategyFactoryEntity.getScene()) { if (strategy == strategyFactoryEntity.getScene()) {
......
...@@ -64,7 +64,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -64,7 +64,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
private static void setBeltInfo(ObjectMapper mapper, List<StrategyGreenOptHistEntity> entities, GreenBeltInfoVO greenBeltInfoVO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) throws JsonProcessingException { private static void setBeltInfo(ObjectMapper mapper, List<StrategyGreenOptHistEntity> entities, GreenBeltInfoVO greenBeltInfoVO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) throws JsonProcessingException {
for (StrategyGreenOptHistEntity entity : entities) { for (StrategyGreenOptHistEntity entity : entities) {
greenBeltInfoVO.setGreenId(String.valueOf(entity.getGreenId())); greenBeltInfoVO.setGreenId(entity.getGreenId());
greenBeltInfoVO.setLength(entity.getLength()); greenBeltInfoVO.setLength(entity.getLength());
greenBeltInfoVO.setCycle(entity.getCycle()); greenBeltInfoVO.setCycle(entity.getCycle());
greenBeltInfoVO.setControlTime(entity.getControlTime()); greenBeltInfoVO.setControlTime(entity.getControlTime());
......
...@@ -19,7 +19,7 @@ import java.util.List; ...@@ -19,7 +19,7 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class GreenBeltInfoVO { public class GreenBeltInfoVO {
@ApiModelProperty("绿波id") @ApiModelProperty("绿波id")
private String greenId; private Integer greenId;
@ApiModelProperty("绿波带长度") @ApiModelProperty("绿波带长度")
private Double length; private Double length;
@ApiModelProperty("绿波带周期") @ApiModelProperty("绿波带周期")
......
...@@ -28,4 +28,6 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt ...@@ -28,4 +28,6 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt
CrossDirDataRealtimePO selectByInDir(String currentCrossId, Integer key); CrossDirDataRealtimePO selectByInDir(String currentCrossId, Integer key);
CrossDirDataRealtimePO selectByCrossIdAndDirs(String crossId, List<Integer> dirCodeList); CrossDirDataRealtimePO selectByCrossIdAndDirs(String crossId, List<Integer> dirCodeList);
List<CrossDirDataRealtimePO> selectMaxBatchTime(String crossId);
} }
...@@ -97,4 +97,11 @@ ...@@ -97,4 +97,11 @@
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