Commit 92556429 authored by duanruiming's avatar duanruiming

[add] 神思策略接口

parent e961c4c8
package net.wanji.opt.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.po.StrategyControlDataEntity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author duanruiming
* @date 2024/11/04 10:57
*/
public interface StrategyControlInfoMapper extends BaseMapper<StrategyControlDataEntity> {
int insertBatch(@Param("list") List<StrategyControlDataEntity> list);
}
package net.wanji.opt.po;
import lombok.Data;
import java.util.Date;
/**
* @author duanruiming
* @date 2024/11/04 10:53
*/
@Data
public class StrategyControlDataEntity {
/** value = 路口干线Id */
private String bizId;
/** value = 类型 0-路口 1-干线 */
private Integer bizType;
/** value = 策略类型 0-绿波带 1-失衡 2-溢出 3-空放 */
private Integer strategy;
/** value = 开始时间日期 */
private Date scheduleStart;
/** value = 结束时间日期 */
private Date scheduleEnd;
/** value = 日计划表 */
private String time;
/** value = 调控频率(秒),策略下发的频率(只针对失衡和绿波带有效) */
private Integer frequency;
/** value = 状态(1=开启,0=停止) */
private Integer status;
}
...@@ -28,7 +28,7 @@ public class StrategyControlDataVO { ...@@ -28,7 +28,7 @@ public class StrategyControlDataVO {
@ApiModelProperty(value = "日计划表") @ApiModelProperty(value = "日计划表")
private List<StrategyControlDataVO.TimeTable> time; private List<StrategyControlDataVO.TimeTable> time;
@ApiModelProperty(value = "调控频率(秒),策略下发的频率(只针对失衡和绿波带有效)") @ApiModelProperty(value = "调控频率(秒),策略下发的频率(只针对失衡和绿波带有效)")
private Integer freq; private Integer frequency;
@ApiModelProperty(value = "状态(1=开启,0=停止)") @ApiModelProperty(value = "状态(1=开启,0=停止)")
private Integer status; private Integer status;
@ApiModelProperty(value = "操作(insert=新增,update=更新,delete=删除)") @ApiModelProperty(value = "操作(insert=新增,update=更新,delete=删除)")
......
...@@ -7,13 +7,16 @@ import net.wanji.common.enums.DateStyle; ...@@ -7,13 +7,16 @@ import net.wanji.common.enums.DateStyle;
import net.wanji.common.framework.Constants; import net.wanji.common.framework.Constants;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.opt.dao.mapper.StrategyControlInfoMapper;
import net.wanji.opt.po.StrategyControlDataEntity;
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.springframework.beans.factory.annotation.Autowired; import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
/** /**
...@@ -24,34 +27,26 @@ import java.util.*; ...@@ -24,34 +27,26 @@ import java.util.*;
@Service @Service
public class StrategyControlServiceImpl implements StrategyControlService { public class StrategyControlServiceImpl implements StrategyControlService {
@Autowired @Resource
private PushStrategyControlService pushStrategyControlService; private PushStrategyControlService pushStrategyControlService;
@Resource
private StrategyControlInfoMapper strategyControlInfoMapper;
@Override @Override
public JsonViewObject strategyInfoOperation(StrategyControlVO strategyControlVO) throws Exception { public JsonViewObject strategyInfoOperation(StrategyControlVO strategyControlVO) throws Exception {
try { try {
StrategyControlReq req = convertReq(strategyControlVO);
// 存库 // 存库
// 调用推送 List<StrategyControlDataEntity> entities = new ArrayList<>();
//StrategyControlDataReq detailData = new StrategyControlDataReq(); List<StrategyControlDataVO> dataList = strategyControlVO.getDataList();
//detailData.setBiz_id("241940"); for (StrategyControlDataVO dataVO : dataList) {
//detailData.setBiz_type(0); StrategyControlDataEntity entity = new StrategyControlDataEntity();
//detailData.setStrategy(3); BeanUtils.copyProperties(entity, dataVO);
//Date date = new Date(); entity.setTime(JacksonUtils.getInstance().writeValueAsString(dataVO.getTime()));
//detailData.setSchedule_end(DateUtil.format(date, DateStyle.YYYY_MM_DD_HH_MM_SS.getValue())); }
//detailData.setSchedule_end(DateUtil.format(date, DateStyle.YYYY_MM_DD_HH_MM_SS.getValue())); strategyControlInfoMapper.insertBatch(entities);
//StrategyControlDataReq.Time_table timeTable = new StrategyControlDataReq.Time_table();
//timeTable.setWeek(1);
//timeTable.setTime_list(new String[]{"00:00-01:00", "01:00-02:00"});
//StrategyControlDataReq.Time_table timeTable1 = new StrategyControlDataReq.Time_table();
//timeTable1.setWeek(1);
//timeTable1.setTime_list(new String[]{"02:00-03:00", "03:00-04:00"});
//detailData.setTime(Arrays.asList(timeTable1, timeTable));
//detailData.setFreq(1000 * 60);
//detailData.setStrategy(1);
//detailData.setAction("insert");
StrategyControlReq req = convertReq(strategyControlVO);
// todo 测试数据 // todo 测试数据
//req.setData(Arrays.asList(detailData)); //req.setData(Arrays.asList(detailData));
Result result = pushStrategyControlService.push(req); Result result = pushStrategyControlService.push(req);
...@@ -93,7 +88,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -93,7 +88,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
timeTables.add(timeTable); timeTables.add(timeTable);
}); });
detailData.setTime(timeTables); detailData.setTime(timeTables);
detailData.setFreq(dataVO.getFreq()); detailData.setFreq(dataVO.getFrequency());
detailData.setStatus(dataVO.getStatus()); detailData.setStatus(dataVO.getStatus());
detailData.setAction(dataVO.getAction()); detailData.setAction(dataVO.getAction());
dataReqList.add(detailData); dataReqList.add(detailData);
......
<?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.StrategyControlInfoMapper">
<insert id="insertBatch" parameterType="net.wanji.opt.po.StrategyControlDataEntity">
INSERT INTO t_strategy_control_info (
bizId,
bizType,
strategy,
schedule_start,
schedule_end,
`time`,
frequency,
status,
create_time,
gmt_modified
) VALUES
<foreach collection="list" item="entity" separator=",">
#{entity.bizId},
#{entity.bizType},
#{entity.strategy},
#{entity.scheduleStart},
#{entity.scheduleEnd},
#{entity.time},
#{entity.frequency},
#{entity.status},
#{createTime, jdbcType=TIMESTAMP, default=CURRENT_TIMESTAMP},
#{gmtModified, jdbcType=TIMESTAMP, default=CURRENT_TIMESTAMP, update="CURRENT_TIMESTAMP"}
</foreach>
</insert>
</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