Commit 36fc4f68 authored by duanruiming's avatar duanruiming

[add] 绿波子区指标

parent ee9a9ccb
package net.wanji.opt.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.wanji.common.utils.tool.StringUtils;
/**
* @author duanruiming
* @date 2024/12/03 19:14
*/
@Getter
@AllArgsConstructor
public enum GreenBeltDirEnum {
E2W("e2w", "东向西"),
W2E("w2e", "西向东"),
N2S("n2s", "北向南"),
S2N("s2n", "南向北");
private String code;
private String desc;
public static String getDesc(String code) {
for (GreenBeltDirEnum dirEnum : GreenBeltDirEnum.values()) {
if (StringUtils.equalsIgnoreCase(code, dirEnum.getCode())) {
return dirEnum.getDesc();
}
}
return "";
}
}
...@@ -5,14 +5,18 @@ import io.swagger.annotations.ApiOperation; ...@@ -5,14 +5,18 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO; import net.wanji.opt.synthesis.pojo.GreenBeltAreaIndexVO;
import net.wanji.opt.synthesis.service.impl.StrategyGreenBeltServiceImpl; import net.wanji.opt.synthesis.service.impl.StrategyGreenBeltServiceImpl;
import net.wanji.opt.vo.*; import net.wanji.opt.vo.GreenBeltChartVO;
import org.springframework.web.bind.annotation.*; import net.wanji.opt.vo.GreenBeltInfoVO;
import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO;
import net.wanji.opt.vo.HotspotCrossVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -58,7 +62,7 @@ public class StrategyGreenBeltController { ...@@ -58,7 +62,7 @@ public class StrategyGreenBeltController {
@ApiResponse(code = 200, message = "OK", response = HotspotCrossVO.class), @ApiResponse(code = 200, message = "OK", response = HotspotCrossVO.class),
}) })
public JsonViewObject greenBeltAreaIndex(Integer greenId) throws Exception { public JsonViewObject greenBeltAreaIndex(Integer greenId) throws Exception {
GreenwaveRealtimePO result = strategyGreenBeltService.greenBeltAreaIndex(greenId); GreenBeltAreaIndexVO result = strategyGreenBeltService.greenBeltAreaIndex(greenId);
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
......
package net.wanji.opt.synthesis.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2024/12/03 18:59
*/
@Data
@ApiModel("绿波干线子区返回参数")
public class GreenBeltAreaIndexVO {
@ApiModelProperty("子区状态")
private Integer status;
@ApiModelProperty("优化策略")
private String strategyName;
@ApiModelProperty("绿波方向详情")
private List<DirDetail> dirDetail;
@Data
public static class DirDetail {
@ApiModelProperty("绿波名称")
private String dirName;
@ApiModelProperty("行程时间")
private Integer travelTime;
@ApiModelProperty("停车次数")
private Double StopTimes;
}
}
package net.wanji.opt.synthesis.service; package net.wanji.opt.synthesis.service;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO; import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import net.wanji.opt.synthesis.pojo.GreenBeltAreaIndexVO;
import net.wanji.opt.vo.GreenBeltChartVO; import net.wanji.opt.vo.GreenBeltChartVO;
import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO; import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO;
...@@ -15,5 +16,5 @@ public interface StrategyGreenBeltService { ...@@ -15,5 +16,5 @@ public interface StrategyGreenBeltService {
GreenBeltChartVO selectChart(Integer greenId, Date queryDate); GreenBeltChartVO selectChart(Integer greenId, Date queryDate);
List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId); List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId);
GreenwaveRealtimePO greenBeltAreaIndex(Integer greenId); GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId);
} }
...@@ -12,8 +12,10 @@ import net.wanji.databus.dao.entity.GreenwaveHistPO; ...@@ -12,8 +12,10 @@ import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO; import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import net.wanji.databus.dao.mapper.GreenwaveHistMapper; import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveRealtimeMapper; import net.wanji.databus.dao.mapper.GreenwaveRealtimeMapper;
import net.wanji.opt.common.enums.GreenBeltDirEnum;
import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper; import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.synthesis.pojo.GreenBeltAreaIndexVO;
import net.wanji.opt.synthesis.service.StrategyGreenBeltService; import net.wanji.opt.synthesis.service.StrategyGreenBeltService;
import net.wanji.opt.vo.GreenBeltChartVO; import net.wanji.opt.vo.GreenBeltChartVO;
import net.wanji.opt.vo.GreenBeltInfoVO; import net.wanji.opt.vo.GreenBeltInfoVO;
...@@ -41,9 +43,29 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -41,9 +43,29 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
GreenwaveRealtimeMapper greenwaveRealtimeMapper; GreenwaveRealtimeMapper greenwaveRealtimeMapper;
@Override @Override
public GreenwaveRealtimePO greenBeltAreaIndex(Integer greenId) { public GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId) {
GreenwaveRealtimePO greenwaveRealtimePO = greenwaveRealtimeMapper.selectById(greenId); LambdaQueryWrapper<GreenwaveRealtimePO> queryWrapper = new LambdaQueryWrapper<>();
return greenwaveRealtimePO; queryWrapper.eq(GreenwaveRealtimePO::getGreenId, greenId);
List<GreenwaveRealtimePO> realtimePOS = greenwaveRealtimeMapper.selectList(queryWrapper);
GreenBeltAreaIndexVO greenBeltAreaIndexVO = new GreenBeltAreaIndexVO();
Integer status = 1;
if (!CollectionUtils.isEmpty(realtimePOS)) {
List<GreenBeltAreaIndexVO.DirDetail> dirDetails = new ArrayList<>();
for (GreenwaveRealtimePO realtimePO : realtimePOS) {
GreenBeltAreaIndexVO.DirDetail dirDetail = new GreenBeltAreaIndexVO.DirDetail();
String roadDirection = realtimePO.getRoadDirection();
dirDetail.setDirName(GreenBeltDirEnum.getDesc(roadDirection));
dirDetail.setTravelTime(realtimePO.getTrvalTime());
dirDetail.setStopTimes(realtimePO.getStopTimes());
status = status >= realtimePO.getStatus() ? status : realtimePO.getStatus();
dirDetails.add(dirDetail);
}
greenBeltAreaIndexVO.setDirDetail(dirDetails);
greenBeltAreaIndexVO.setStatus(status);
greenBeltAreaIndexVO.setStrategyName("绿波带");
}
return greenBeltAreaIndexVO;
} }
@Override @Override
......
...@@ -2,6 +2,7 @@ package net.wanji.databus.dao.entity; ...@@ -2,6 +2,7 @@ package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
...@@ -12,6 +13,7 @@ import java.util.Date; ...@@ -12,6 +13,7 @@ import java.util.Date;
@Data @Data
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@TableName("t_greenwave_realtime")
public class GreenwaveRealtimePO { public class GreenwaveRealtimePO {
/** 绿波ID */ /** 绿波ID */
@ApiModelProperty(name = "id",notes = "") @ApiModelProperty(name = "id",notes = "")
......
package net.wanji.databus.dao.mapper; package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import feign.Param; import feign.Param;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO; import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -12,9 +13,8 @@ import java.util.List; ...@@ -12,9 +13,8 @@ import java.util.List;
* @date 2022/10/31 11:03 * @date 2022/10/31 11:03
*/ */
@Repository @Repository
public interface GreenwaveRealtimeMapper { public interface GreenwaveRealtimeMapper extends BaseMapper<GreenwaveRealtimePO> {
GreenwaveRealtimePO selectById(Integer id); GreenwaveRealtimePO selectById(Integer id);
int insertBatch(@Param("list") List<GreenwaveRealtimePO> list); int insertBatch(@Param("list") List<GreenwaveRealtimePO> list);
int deleteOne(@Param("greenId") Integer greenId); int deleteOne(@Param("greenId") Integer greenId);
......
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