Commit a981bb1b authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 00bf0bfb 489e3f6f
...@@ -36,6 +36,26 @@ public class GreenWaveCrossRidController { ...@@ -36,6 +36,26 @@ public class GreenWaveCrossRidController {
@ApiOperation(httpMethod="GET",value="干线拥堵信息", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"),
@ApiImplicitParam(name = "dayType", value = "高峰类型 1早高峰 2晚高峰 3全天", required = true, dataType = "String",defaultValue = "1"),
})
@GetMapping(value = "/getGreenWeekDataList")
public JsonViewObject getGreenWeekDataList(@RequestParam(value = "ids", required = false, defaultValue = "2") String ids,
@RequestParam(value = "type", required = false, defaultValue = "2") String type
) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
JSONObject object = greenWaveCrossRidService.getGreenInfoList(ids);
jsonViewObject.success(object);
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(httpMethod="GET",value="干线基础信息", notes="") @ApiOperation(httpMethod="GET",value="干线基础信息", notes="")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"), @ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"),
......
package net.wanji.opt.controllerv2.report;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.controllerv2.judgeanalysis.design.response.areaproblem.AreaCrossProblemAnalysisResult;
import net.wanji.opt.controllerv2.report.design.GreenReportOverviewAnalysisResult;
import net.wanji.opt.controllerv2.report.design.GreenReportSamePeriodCompareResult;
import net.wanji.opt.servicev2.report.GreenWaveCrossRidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 干线概况 接口API
* </p>
* @version 1.0
* @author
* @Date 2025-03-18
*/
@RestController
@Slf4j
@RequestMapping("/green-wave-overview")
@Api(value="GreenWaveCrossRidController", description="干线分析报告接口", tags = "干线分析报告")
public class GreenWaveOverviewController {
@Autowired
private GreenWaveCrossRidService greenWaveCrossRidService;
@ApiOperation(httpMethod="GET",value="干线概况-总体情况说明", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔【为空时查询所有干线】", required = true, dataType = "String",defaultValue = "1,2"),
@ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String",defaultValue = "2025"),
@ApiImplicitParam(name = "week", value = "一年的第几周", required = true, dataType = "String",defaultValue = "20"),
})
@GetMapping(value = "/getOverallSituation")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenReportOverviewAnalysisResult.class),
})
public JsonViewObject getGreenInfoList(Integer year,Integer week, String ids) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(httpMethod="GET",value="干线概况-工作日同期对比", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"),
@ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String",defaultValue = "2025"),
@ApiImplicitParam(name = "week", value = "一年的第几周", required = true, dataType = "String",defaultValue = "20"),
})
@GetMapping(value = "/getSamePeriodCompare")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenReportSamePeriodCompareResult.class),
})
public JsonViewObject getSamePeriodCompare(Integer year,Integer week, String ids) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
}
...@@ -79,7 +79,7 @@ class GreenReportOverview { ...@@ -79,7 +79,7 @@ class GreenReportOverview {
@ApiModelProperty(value = "最长时间拥堵时段分布",example = "周一7:30~8:15") @ApiModelProperty(value = "最长时间拥堵时段分布",example = "周一7:30~8:15")
private String maxCongestTimeDistribute; private String maxCongestTimeDistribute;
@ApiModelProperty(value = "本周拥堵时段集中分布情况",example = "周一7:30~8:15") @ApiModelProperty(value = "本周拥堵时段集中分布情况",example = "周一7:30~8:15,周五17:30~18:15")
private String weekCongestTimeDistribute; private String weekCongestTimeDistribute;
} }
......
package net.wanji.opt.controllerv2.report.design;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.opt.controllerv2.judgeanalysis.design.response.ParentResult;
import java.util.ArrayList;
import java.util.List;
@Data
public class GreenReportSamePeriodCompareResult extends ParentResult {
private List<GreenReportSamePeriodCompareDataResponse> content;
public List<GreenReportSamePeriodCompareDataResponse> getContent() {
return content;
}
public GreenReportSamePeriodCompareResult setContent(List<GreenReportSamePeriodCompareDataResponse> content) {
this.content = content;
return this;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
}
@Data
class GreenReportSamePeriodCompareDataResponse {
@ApiModelProperty(value = "路口ID", example = "")
private String greenId;
@ApiModelProperty(value = "干线名称", example = "")
private String greenName;
@ApiModelProperty(value = "早高峰流量情况", example = "减少")
private String amPeakSituation;
@ApiModelProperty(value = "晚高峰流量情况", example = "减少")
private String pmPeakSituation;
@ApiModelProperty(value = "行程时间同比情况", example = "增加20s")
private String amTravelTimeSituation;
@ApiModelProperty(value = "行程时间同比情况", example = "减少20s")
private String pmTravelTimeSituation;
private List<GreenReportSamePeriodData> dataList = new ArrayList<>();
}
@Data
class GreenReportSamePeriodData {
@ApiModelProperty(value = "峰期类型 早高峰、晚高峰、全天", example = "早高峰")
private String peakName;
@ApiModelProperty(value = "通行量(辆)", example = "736278")
private Integer peakFlow;
@ApiModelProperty(value = "通行量同比", example = "-1.5%")
private Double peakFlowRatio;
@ApiModelProperty(value = "拥堵指数", example = "3.5")
private Double congestIndex;
@ApiModelProperty(value = "拥堵指数同比", example = "3.5%")
private Double congestIndexRatio;
@ApiModelProperty(value = "平均车速km/h", example = "30.5")
private Double avgSpeed;
@ApiModelProperty(value = "平均车速同比", example = "-1.5%")
private Double avgSpeedRatio;
@ApiModelProperty(value = "行程时间(分钟)", example = "6.5")
private Double travelTime;
@ApiModelProperty(value = "行程时间同比", example = "-1.5%")
private Double travelTimeRatio;
}
package net.wanji.opt.controllerv2.strategy; package net.wanji.opt.controllerv2.strategy;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle; import net.wanji.common.framework.i18n.I18nResourceBundle;
...@@ -12,6 +13,7 @@ import io.swagger.annotations.Api; ...@@ -12,6 +13,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.wanji.opt.entity.strategy.dto.StrategyPriorityGroup;
import net.wanji.opt.servicev2.strategy.StrategyPriorityService; import net.wanji.opt.servicev2.strategy.StrategyPriorityService;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -33,7 +35,7 @@ import java.util.Map; ...@@ -33,7 +35,7 @@ import java.util.Map;
* @author fengyi * @author fengyi
* @since 2025-03-28 * @since 2025-03-28
*/ */
@Api(tags = "策略优先级日计划详情表") @Api(tags = "策略管理")
@RestController @RestController
@RequestMapping("/strategy-priority") @RequestMapping("/strategy-priority")
@Slf4j @Slf4j
...@@ -147,4 +149,38 @@ public class StrategyPriorityController { ...@@ -147,4 +149,38 @@ public class StrategyPriorityController {
} }
return jsonView; return jsonView;
} }
@ApiOperation(value = "策略管理-策略优先级批量保存", notes = "批量保存", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,hidden = false)
@ApiImplicitParams({
@ApiImplicitParam(name = "dataList", value = "优先级配置数据", required = false, dataType = "String"),
})
@PostMapping("/savePriority")
public JsonViewObject savePriority(@RequestBody List<StrategyPriorityGroup>dataList){
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
strategyPriorityService.savePriority(dataList);
jsonView.success();
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
log.error("{} StrategyPriorityController-savePriority", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@ApiOperation(value = "策略管理-策略优先级数据回显", notes = "数据回显", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,hidden = false)
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口id", required = true, dataType = "String")
})
@GetMapping("/getPriorityConfig")
public JsonViewObject getPriorityData(@RequestParam(required = true) String crossId){
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
List<StrategyFactoryEntity>list=strategyPriorityService.getPriorityData(crossId);
jsonView.success(list);
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
log.error("{} StrategyPriorityController-getPriorityData", this.getClass().getSimpleName(), e);
}
return jsonView;
}
} }
\ No newline at end of file
package net.wanji.opt.controllerv2.syslog; package net.wanji.opt.controllerv2.syslog;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
...@@ -35,18 +36,19 @@ public class sysLogController { ...@@ -35,18 +36,19 @@ public class sysLogController {
@ApiImplicitParam(name = "crossId", value = "路口id", required = true, dataType = "String", paramType = "query"), @ApiImplicitParam(name = "crossId", value = "路口id", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "startTime", value = "日期 格式:yyyy-MM-dd h:i:s", required = true, dataType = "String", paramType = "query"), @ApiImplicitParam(name = "startTime", value = "日期 格式:yyyy-MM-dd h:i:s", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "endTime", value = "日期 格式:yyyy-MM-dd h:i:s", required = true, dataType = "String", paramType = "query"), @ApiImplicitParam(name = "endTime", value = "日期 格式:yyyy-MM-dd h:i:s", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "pageNum", value = "分页页码", required = true, dataType = "Integer", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "分页数据条数", required = true, dataType = "Integer", paramType = "query"),
}) })
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = String.class), @ApiResponse(code = 200, message = "OK", response = String.class),
}) })
public JsonViewObject getOptimizeLog(String crossId,String startTime,String endTime) { public JsonViewObject getOptimizeLog(String crossId,String startTime,String endTime,Integer pageNum,Integer pageSize) {
List<SysOptimizeLog> list = Collections.emptyList();
try { try {
list = sysLogServer.findSysOptimizeLog(crossId,startTime,endTime); JSONObject list = sysLogServer.findSysOptimizeLog(crossId,startTime,endTime,pageNum,pageSize);
return JsonViewObject.newInstance().success(list);
} catch (Exception e) { } catch (Exception e) {
log.error("系统日志-优化日志-查询失败:{}", e); log.error("系统日志-优化日志-查询失败:{}", e);
JsonViewObject.newInstance().success(list); return JsonViewObject.newInstance().success("");
} }
return JsonViewObject.newInstance().success(list);
} }
} }
package net.wanji.opt.dao.mapper.judgeanalysis;
import net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AnalysisGreenCongestionPeriodMapper {
List<AnalysisGreenCongestionPeriod> selectGreenDataHist(@Param("date") String date);
void insertGreenCongestionPeriodData(Map<String, Object> map);
}
package net.wanji.opt.dao.mapper.report; package net.wanji.opt.dao.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.opt.entity.report.ConfigPeakHours; import net.wanji.opt.entity.report.ConfigPeakHours;
import net.wanji.opt.entity.report.GreenWaveWeekData; import net.wanji.opt.entity.report.GreenWaveWeekData;
import net.wanji.opt.servicev2.report.GreenWaveWeekDataService; import net.wanji.opt.servicev2.report.GreenWaveWeekDataService;
...@@ -22,5 +23,7 @@ public interface GreenWaveWeekDataMapper extends BaseMapper<GreenWaveWeekData> { ...@@ -22,5 +23,7 @@ public interface GreenWaveWeekDataMapper extends BaseMapper<GreenWaveWeekData> {
Integer getFlowByTime(@Param("greenId") Integer greenId,@Param("dir") Integer dir,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("startTime") String startTime,@Param("endTime") String endTime); Integer getFlowByTime(@Param("greenId") Integer greenId,@Param("dir") Integer dir,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("startTime") String startTime,@Param("endTime") String endTime);
void insertOrUpdateBatch(@Param("list") List<GreenWaveWeekData> greenWaveWeekDataList); void insertOrUpdateBatch(@Param("list") List<GreenWaveWeekData> greenWaveWeekDataList);
List<GreenwaveHistPO> selectAllByTime(@Param("greenId") Integer greenId,@Param("roadDirection") String roadDirection,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("startTime") String startTime,@Param("endTime") String endTime);
// MyBatis-Plus 提供了基本的 CRUD 方法,这里无需额外定义 // MyBatis-Plus 提供了基本的 CRUD 方法,这里无需额外定义
} }
\ No newline at end of file
package net.wanji.opt.dao.mapper.strategy; package net.wanji.opt.dao.mapper.strategy;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.wanji.opt.entity.strategy.StrategyPriorityConfig;
import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo; import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -55,5 +56,19 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily ...@@ -55,5 +56,19 @@ public interface StrategyPriorityMapper extends BaseMapper<StrategyPriorityDaily
List<StrategyFactoryEntity> getSceneList(); List<StrategyFactoryEntity> getSceneList();
List<StrategyFactoryEntity> getCompanyList(); List<StrategyFactoryEntity> getCompanyList();
void savePriorityInsert(List<StrategyPriorityConfig> saveList);
List<StrategyPriorityConfig> selectPriorityTable(String crossId);
void deletePriorityConfig(String crossId);
List<String> getstrategyNo(String crossId);
List<StrategyFactoryEntity> getPriorityConfigData(@Param("strategyNo") List<String> strategyNo,@Param("crossId") String crossId);
} }
package net.wanji.opt.entity.judgeanalysis;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "AnalysisGreenCongestionPeriod", description = "")
public class AnalysisGreenCongestionPeriod {
@ApiModelProperty(value = "干线ID")
private String greenId;
@ApiModelProperty(value = "道路方向")
private String roadDirection;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "状态")
private String status;
}
...@@ -29,7 +29,10 @@ public class GreenWaveWeekData { ...@@ -29,7 +29,10 @@ public class GreenWaveWeekData {
private Integer congestCount; // 拥堵次数 private Integer congestCount; // 拥堵次数
@ApiModelProperty(value = "拥堵总时长,单位秒") @ApiModelProperty(value = "拥堵总时长,单位秒")
private Double congestDuration; // 拥堵总时长,单位秒 private Double congestDuration;
@ApiModelProperty(value = "最大拥堵持续时长,单位秒")
private Double maxCongestDuration;
@ApiModelProperty(value = "总流量") @ApiModelProperty(value = "总流量")
private Integer flow; // 总流量 private Integer flow; // 总流量
...@@ -40,11 +43,17 @@ public class GreenWaveWeekData { ...@@ -40,11 +43,17 @@ public class GreenWaveWeekData {
@ApiModelProperty(value = "平均速度") @ApiModelProperty(value = "平均速度")
private Double speed; // 平均速度 private Double speed; // 平均速度
@ApiModelProperty(value = "高峰类型 1早高峰 2晚高峰 3全天")
private String peakType;
@ApiModelProperty(value = "类型:1工作日 2节假日") @ApiModelProperty(value = "类型:1工作日 2节假日")
private String peakType; // 类型:1工作日 2节假日 private String dayType;
@ApiModelProperty(value = "高峰类型 1早高峰 2晚高峰 3全天") @ApiModelProperty(value = "最大拥堵时段")
private String dayType; // 高峰类型 1早高峰 2晚高峰 3全天 private String maxCongestionPeriod;
@ApiModelProperty(value = "第二大拥堵时段")
private String secondCongestionPeriod;
@ApiModelProperty(value = "数据统计范围的开始时间") @ApiModelProperty(value = "数据统计范围的开始时间")
private String startTime; // 数据统计范围的开始时间 private String startTime; // 数据统计范围的开始时间
......
package net.wanji.opt.entity.strategy.dto;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.wanji.opt.entity.strategy.StrategyPriorityConfig;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper=false)
@NoArgsConstructor
@AllArgsConstructor
public class StrategyPriorityGroup {
//分组ID
private Integer labelCode;
//分组名称
private String label;
//路口Id
private String crossId;
//优先级的配置信息
private List<StrategyPriorityConfig> data;
}
package net.wanji.opt.servicev2.judgeanalysis;
import java.text.ParseException;
public interface AnalysisGreenCongestionPeriodService {
public void selectCountByCongestionPeriod() throws ParseException;
}
package net.wanji.opt.servicev2.strategy; package net.wanji.opt.servicev2.strategy;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo; import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import net.wanji.opt.entity.strategy.dto.StrategyPriorityGroup;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import java.util.List; import java.util.List;
...@@ -61,4 +63,9 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI ...@@ -61,4 +63,9 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI
List<StrategyFactoryEntity> getSceneList(); List<StrategyFactoryEntity> getSceneList();
List<StrategyFactoryEntity> getCompanyList(); List<StrategyFactoryEntity> getCompanyList();
void savePriority(List<StrategyPriorityGroup> dataList);
List<StrategyFactoryEntity> getPriorityData(String crossId);
} }
package net.wanji.opt.servicev2.strategy.impl; package net.wanji.opt.servicev2.strategy.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.opt.dao.mapper.strategy.StrategyPriorityMapper; import net.wanji.opt.dao.mapper.strategy.StrategyPriorityMapper;
import net.wanji.opt.entity.strategy.StrategyPriorityConfig;
import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo; import net.wanji.opt.entity.strategy.StrategyPriorityDailyInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.opt.entity.strategy.dto.StrategyPriorityGroup;
import net.wanji.opt.servicev2.strategy.StrategyPriorityService; import net.wanji.opt.servicev2.strategy.StrategyPriorityService;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -19,6 +29,7 @@ import java.util.List; ...@@ -19,6 +29,7 @@ import java.util.List;
* @since 2025-03-28 * @since 2025-03-28
*/ */
@Service @Service
@Slf4j
public class StrategyPriorityServiceImpl extends ServiceImpl<StrategyPriorityMapper, StrategyPriorityDailyInfo> implements StrategyPriorityService { public class StrategyPriorityServiceImpl extends ServiceImpl<StrategyPriorityMapper, StrategyPriorityDailyInfo> implements StrategyPriorityService {
@Resource @Resource
...@@ -122,4 +133,61 @@ import java.util.List; ...@@ -122,4 +133,61 @@ import java.util.List;
List<StrategyFactoryEntity> strategyList=strategyPriorityMapper.getCompanyList(); List<StrategyFactoryEntity> strategyList=strategyPriorityMapper.getCompanyList();
return strategyList; return strategyList;
} }
@Override
@Transactional
public void savePriority(List<StrategyPriorityGroup> dataList) {
try {
List<StrategyPriorityConfig> saveList = new ArrayList<>();
for (StrategyPriorityGroup group : dataList) {
String label = group.getLabel();
Integer labelCode = group.getLabelCode();
//路口id
String crossId = group.getCrossId();
//先判断表里有没有数据,有的话删除t_strategy_priority_config
List<StrategyPriorityConfig> priorityConfig = strategyPriorityMapper.selectPriorityTable(crossId);
if (priorityConfig.size() > 0) {
strategyPriorityMapper.deletePriorityConfig(crossId);
}
if (CollectionUtils.isNotEmpty(group.getData())) {
for (StrategyPriorityConfig item : group.getData()) {
StrategyPriorityConfig strategyPriorityConfig = new StrategyPriorityConfig();
strategyPriorityConfig.setCrossId(crossId);
//分组id
strategyPriorityConfig.setGroupId(labelCode);
//分组名称
strategyPriorityConfig.setGroupName(label);
//策略编号
strategyPriorityConfig.setStrategyNo(item.getStrategyNo());
//优先级
strategyPriorityConfig.setPriority(item.getPriority());
saveList.add(strategyPriorityConfig);
}
}
}
strategyPriorityMapper.savePriorityInsert(saveList);
} catch (Exception e) {
log.error("{} savePriority", this.getClass().getSimpleName(), e);
throw e;
}
}
@Override
@Transactional
public List<StrategyFactoryEntity> getPriorityData(String crossId) {
try {
//先获取策略编号
List<String> strategyNo = strategyPriorityMapper.getstrategyNo(crossId);
List<StrategyFactoryEntity> priorityList = strategyPriorityMapper.getPriorityConfigData(strategyNo,crossId);
return priorityList;
}catch (Exception e){
log.error("{} getPriorityData", this.getClass().getSimpleName(), e);
throw e;
}
}
} }
package net.wanji.opt.servicev2.syslog; package net.wanji.opt.servicev2.syslog;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import net.wanji.opt.entity.syslog.SysOptimizeLog; import net.wanji.opt.entity.syslog.SysOptimizeLog;
import java.util.List; import java.util.List;
...@@ -14,5 +15,5 @@ import java.util.List; ...@@ -14,5 +15,5 @@ import java.util.List;
*/ */
public interface SysLogServer extends IService<SysOptimizeLog> { public interface SysLogServer extends IService<SysOptimizeLog> {
List<SysOptimizeLog> findSysOptimizeLog(String crossId,String startTime,String endTime); JSONObject findSysOptimizeLog(String crossId, String startTime, String endTime, Integer pageNum, Integer pageSize);
} }
package net.wanji.opt.servicev2.syslog.impl; package net.wanji.opt.servicev2.syslog.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDayMapper; import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDayMapper;
import net.wanji.opt.dao.mapper.syslog.SysLogMapper; import net.wanji.opt.dao.mapper.syslog.SysLogMapper;
import net.wanji.opt.entity.comprehensivequery.CrossLaneDataHistPoExtendName;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.entity.syslog.SysOptimizeLog; import net.wanji.opt.entity.syslog.SysOptimizeLog;
import net.wanji.opt.servicev2.syslog.SysLogServer; import net.wanji.opt.servicev2.syslog.SysLogServer;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -25,8 +30,17 @@ public class SysLogServerImpl extends ServiceImpl<SysLogMapper, SysOptimizeLog> ...@@ -25,8 +30,17 @@ public class SysLogServerImpl extends ServiceImpl<SysLogMapper, SysOptimizeLog>
private SysLogMapper sysLogMapper; private SysLogMapper sysLogMapper;
@Override @Override
public List<SysOptimizeLog> findSysOptimizeLog(String crossId,String startTime,String endTime) { public JSONObject findSysOptimizeLog(String crossId,String startTime,String endTime,Integer pageNum,Integer pageSize) {
List<SysOptimizeLog> list = sysLogMapper.findSysOptimizeLog(crossId,startTime,endTime);
return sysLogMapper.findSysOptimizeLog(crossId,startTime,endTime); List<SysOptimizeLog> collect = new ArrayList<>();
if(CollectionUtils.isNotEmpty(list)){
collect = list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
}
JSONObject result = new JSONObject();
result.put("fullDataList",list);
result.put("pageList",collect);
result.put("totalPage",Math.ceil((double) list.size() / pageSize));
result.put("totalSize",list.size());
return result;
} }
} }
...@@ -46,4 +46,21 @@ public class StrategyFactoryEntity { ...@@ -46,4 +46,21 @@ public class StrategyFactoryEntity {
@ApiModelProperty("优化类型") @ApiModelProperty("优化类型")
@TableField("opt_type") @TableField("opt_type")
private Integer optType; private Integer optType;
/*非数据库字段*/
/**
* 优先级
*/
private Integer priority;
/**
* 路口ID
*/
private String crossId;
/**
* 分组名称
*/
private String label;
/**
* 分组ID
*/
private Integer labelCode;
} }
package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisGreenCongestionPeriodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.ParseException;
@Component
@Configurable
@EnableScheduling
@Slf4j
@Profile("docker")
public class AnalysisGreenCongestionPeriodWeekTask {
@Autowired
private AnalysisGreenCongestionPeriodService analysisGreenCongestionPeriodService;
@Scheduled(cron = "0 0 2 ? * 1")
public void task() throws ParseException {
analysisGreenCongestionPeriodService.selectCountByCongestionPeriod();
}
}
...@@ -21,7 +21,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner { ...@@ -21,7 +21,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now()); log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新 // 周总体拥堵概况更新
try { try {
greenWaveWeekDataService.insertGreenWaveWeekData(); // greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){ }catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e); log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
} }
...@@ -34,7 +34,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner { ...@@ -34,7 +34,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
@Scheduled(cron = "0 30 0 ? * MON") @Scheduled(cron = "0 30 0 ? * MON")
public void executeWeeklyTask() { public void executeWeeklyTask() {
//周总体拥堵概况更新 //周总体拥堵概况更新
log.info("定时任务--周总体拥堵概况更新--执行结束时间:" + LocalDateTime.now()); log.info("定时任务--周总体拥堵概况更新--执行开始时间:" + LocalDateTime.now());
try { try {
greenWaveWeekDataService.insertGreenWaveWeekData(); greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){ }catch (Exception e){
......
<?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.judgeanalysis.AnalysisGreenCongestionPeriodMapper">
<!-- 通用查询映射结果 -->
<resultMap id="AnalysisGreenCongestionPeriodMap" type="net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod">
<result column="green_id" property="greenId"/>
<result column="road_direction" property="roadDirection"/>
<result column="start_time" property="startTime"/>
<result column="status" property="status"/>
</resultMap>
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a
where a.start_time between DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59')
and a.green_id is not null
order by a.green_id,a.road_direction,a.start_time
</select>
<insert id="insertGreenCongestionPeriodData" parameterType="map">
insert into t_analysis_green_wave_congest_time_span (green_id,road_direction,week_day,congest_start_time,congest_end_time,congest_index,status,travel_time,speed,peak_type,year_week,week_start_time,week_end_time,insert_time)
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') as congest_start_time,DATE_FORMAT(DATE_ADD(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
#{peakType} as peak_type,#{weekNumber} as year_week,DATE_FORMAT(#{weekStartTime},'%Y-%m-%d') as week_start_time,DATE_FORMAT(#{weekEndTime},'%Y-%m-%d') as week_end_time,now()
FROM t_greenwave_hist a
where a.start_time between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
and a.green_id = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
</mapper>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<insert id="insertOrUpdateBatch"> <insert id="insertOrUpdateBatch">
INSERT INTO t_analysis_green_wave_week_data ( INSERT INTO t_analysis_green_wave_week_data (
green_id, road_direction, congest_index, max_congest_index, congest_count, green_id, road_direction, congest_index, max_congest_index, congest_count,
congest_duration, flow, travel_time, speed, peak_type, day_type, congest_duration, max_congest_duration, flow, travel_time, speed, peak_type, max_congestion_period, second_congestion_period, day_type,
start_time, end_time, year_week, insert_time start_time, end_time, year_week, insert_time
) )
VALUES VALUES
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
#{item.maxCongestIndex}, #{item.maxCongestIndex},
#{item.congestCount}, #{item.congestCount},
#{item.congestDuration}, #{item.congestDuration},
#{item.maxCongestDuration},
#{item.flow}, #{item.flow},
#{item.travelTime}, #{item.travelTime},
#{item.speed}, #{item.speed},
#{item.peakType}, #{item.peakType},
#{item.maxCongestionPeriod},
#{item.secondCongestionPeriod},
#{item.dayType}, #{item.dayType},
#{item.startTime}, #{item.startTime},
#{item.endTime}, #{item.endTime},
...@@ -34,9 +37,12 @@ ...@@ -34,9 +37,12 @@
max_congest_index = VALUES(max_congest_index), max_congest_index = VALUES(max_congest_index),
congest_count = VALUES(congest_count), congest_count = VALUES(congest_count),
congest_duration = VALUES(congest_duration), congest_duration = VALUES(congest_duration),
max_congest_duration = VALUES(max_congest_duration),
flow = VALUES(flow), flow = VALUES(flow),
travel_time = VALUES(travel_time), travel_time = VALUES(travel_time),
speed = VALUES(speed), speed = VALUES(speed),
max_congestion_period = VALUES(max_congestion_period),
second_congestion_period = VALUES(second_congestion_period),
start_time = VALUES(start_time), start_time = VALUES(start_time),
end_time = VALUES(end_time), end_time = VALUES(end_time),
insert_time = VALUES(insert_time); insert_time = VALUES(insert_time);
...@@ -48,25 +54,33 @@ ...@@ -48,25 +54,33 @@
select * from t_config_peak_hours; select * from t_config_peak_hours;
</select> </select>
<select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData"> <select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3) congest_count,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} and #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction
</select> </select>
<select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData"> <select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3) congest_count,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} and #{endDate} GROUP BY green_id,road_direction from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} GROUP BY green_id,road_direction
</select> </select>
<select id="getFlow" resultType="java.lang.Integer"> <select id="getFlow" resultType="java.lang.Integer">
SELECT COALESCE(flow, 0) from SELECT COALESCE(flow, 0) from
(select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data (select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data
left join left join
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} and #{endDate} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id (SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} AND #{endDate} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
</select> </select>
<select id="getFlowByTime" resultType="java.lang.Integer"> <select id="getFlowByTime" resultType="java.lang.Integer">
SELECT COALESCE(flow, 0) from SELECT COALESCE(flow, 0) from
(select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data (select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data
left join left join
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} and #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id (SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
</select>
<select id="selectAllByTime" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select * from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate}
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and TIME( start_time ) BETWEEN #{startTime} AND #{endTime}
</if>
and green_id = #{greenId}
and status >= 3 and road_direction = #{roadDirection} order by start_time
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -148,4 +148,62 @@ ...@@ -148,4 +148,62 @@
FROM FROM
t_strategy_factory_info t_strategy_factory_info
</select> </select>
<insert id="savePriorityInsert" parameterType="java.util.List">
INSERT INTO
t_strategy_priority_config (cross_id,group_id,group_name,priority,strategy_no)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.crossId},#{item.groupId},#{item.groupName},#{item.priority},#{item.strategyNo})
</foreach>
</insert>
<select id="selectPriorityTable" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyPriorityConfig">
select
id,group_id,cross_id
FROM
t_strategy_priority_config
WHERE
1=1
<if test="crossId!=null and crossId!=''">
and cross_id = #{crossId}
</if>
</select>
<delete id="deletePriorityConfig" parameterType="map">
DELETE
FROM t_strategy_priority_config
WHERE cross_id =#{crossId}
</delete>
<select id="getPriorityConfigData" parameterType="map" resultType="net.wanji.opt.synthesis.pojo.StrategyFactoryEntity">
SELECT
t2.method,t2.strategy_name,t2.strategy_no,
t2.mark,t2.company,t1.priority as priority,
t1.group_id as labelCode ,t1.group_name as label,t1.cross_id as crossId
FROM
t_strategy_priority_config t1
LEFT JOIN t_strategy_factory_info t2 on t1.strategy_no=t2.strategy_no
WHERE
1=1
AND t1.strategy_no IN
<foreach item="item" collection="strategyNo" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
</if>
</select>
<select id="getstrategyNo" resultType="java.lang.String">
SELECT
strategy_no
FROM
t_strategy_priority_config
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
</select>
</mapper> </mapper>
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