Commit 88e44e38 authored by duanruiming's avatar duanruiming

[add] 绿波时序图功能提交

parent 3a3921e0
...@@ -52,4 +52,9 @@ public class Constants { ...@@ -52,4 +52,9 @@ public class Constants {
*/ */
public static final Integer CANCEL_STEP_CONTROL = 11; public static final Integer CANCEL_STEP_CONTROL = 11;
/**
* 绿波优化查询缓存key
*/
public static final String GREEN_ID_OPT_KEY = "green_opt_";
} }
\ No newline at end of file
...@@ -47,4 +47,32 @@ public class RedisUtils { ...@@ -47,4 +47,32 @@ public class RedisUtils {
} }
return null; return null;
} }
/**
* @description: 判断是否存在Key
* @param key redis的Key
* @return boolean true:有 false:无
*/
public boolean hasKey(String key) {
return redis7Template.hasKey(key);
}
/**
* @description: 添加字符串
* @param key redis的Key
* @param value 添加redis的value
*/
public void set(String key, String value) {
redis7Template.opsForValue().set(key, value);
}
/**
* @description: 获取对象
* @param key redis的Key
* @return Object 返回对象
*/
public Object get(String key) {
return redis7Template.opsForValue().get(key);
}
} }
package net.wanji.opt.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
/**
* @author duanruiming
* @date 2024/11/19 18:02
* @description 神思推送绿波时序图信息
*/
public interface StrategyGreenOptHistMapper extends BaseMapper<StrategyGreenOptHistEntity> {
}
package net.wanji.opt.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* @author duanruiming
* @date 2024/11/19 17:48
*/
@Data
@TableName("t_strategy_green_opt_hist")
public class StrategyGreenOptHistEntity {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("green_id")
private String greenId;
@TableField("length")
private Double length;
@TableField("cycle")
private Integer cycle;
@TableField("control_time")
private String controlTime;
@TableField("control_duration")
private Integer controlDuration;
@TableField("control_method")
private Integer controlMethod;
@TableField("type")
private Integer type;
@TableField("dynamic")
private Integer dynamic;
@TableField("dir_type")
private Integer dirType;
@TableField("dir")
private String dir;
@TableField("max_speed")
private Double maxSpeed;
@TableField("min_speed")
private Double minSpeed;
@TableField("green_width_time")
private Double greenWidthTime;
@TableField("cross_green_detail")
private String crossGreenDetail;
@TableField("create_time")
private Date createTime;
@TableField("modify_time")
private Date modifyTime;
}
package net.wanji.opt.service;
import net.wanji.opt.vo.GreenBeltInfoVO;
/**
* @author duanruiming
* @date 2024/11/19 18:07
*/
public interface GreenBeltInfoService {
/**
* 数据转换
* @param message
* @return
* @throws Exception
*/
GreenBeltInfoVO convertData(String message) throws Exception;
/**
* 存储
* @param infoVO
* @throws Exception
*/
void save(GreenBeltInfoVO infoVO) throws Exception;
}
package net.wanji.opt.synthesis.controller;
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.common.utils.tool.JacksonUtils;
import net.wanji.opt.common.Constants;
import net.wanji.opt.common.RedisUtils;
import net.wanji.opt.service.GreenBeltInfoService;
import net.wanji.opt.synthesis.pojo.StrategyControlVO;
import net.wanji.opt.vo.GreenBeltInfoVO;
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;
/**
* @author duanruiming
* @date 2024/11/19 20:10
* @description 神思推送绿波时序图
*/
@Api(value = "StrategyGreenBeltController", description = "策略绿波带")
@RequestMapping("/strategyBelt")
@RestController
public class StrategyGreenBeltController {
@Resource
private RedisUtils redisUtils;
@Resource
private GreenBeltInfoService greenBeltInfoService;
@ApiOperation(value = "绿波时序图查询", notes = "绿波时序图查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyInfoOperation",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenBeltInfoVO.class),
})
public JsonViewObject strategyInfoOperation(@RequestBody String greenId) throws Exception {
// todo 测试
GreenBeltInfoVO greenBeltInfoVO1 = greenBeltInfoService.convertData(null);
greenBeltInfoService.save(greenBeltInfoVO1);
String key = Constants.GREEN_ID_OPT_KEY.concat(greenId);
redisUtils.set(key, JacksonUtils.getInstance().writeValueAsString(greenBeltInfoVO1));
Object obj = redisUtils.get(key);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
GreenBeltInfoVO greenBeltInfoVO = JacksonUtils.getInstance().readValue(String.valueOf(obj), GreenBeltInfoVO.class);
return jsonViewObject.success(greenBeltInfoVO);
}
}
...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel; ...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -47,7 +46,7 @@ public class GreenBeltInfoVO { ...@@ -47,7 +46,7 @@ public class GreenBeltInfoVO {
@ApiModelProperty("最小速度") @ApiModelProperty("最小速度")
private Double minSpeed; private Double minSpeed;
@ApiModelProperty("绿波带宽") @ApiModelProperty("绿波带宽")
private Double greenWithTime; private Double greenWidthTime;
@ApiModelProperty("绿波路口详情") @ApiModelProperty("绿波路口详情")
private List<CrossGreenDetail> crossGreenDetailList; private List<CrossGreenDetail> crossGreenDetailList;
} }
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper">
</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