Commit c2e56970 authored by hanbing's avatar hanbing

方案管理-运行计划,全局异常处理

parent 85fecf73
......@@ -29,4 +29,10 @@ public class SignalGlobalExceptionHandler {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.fail(e);
}
@ExceptionHandler(value = WeekException.class)
public JsonViewObject weekExceptionHandler(WeekException e) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.fail(e);
}
}
\ No newline at end of file
package net.wanji.web.common.exception;
/**
* 路段关系异常
*
* @author Kent HAN
* @date 2022/11/10 9:09
*/
public class WeekException extends RuntimeException {
public WeekException(String message) {
super(message);
}
public WeekException(String message, Exception e) {
super(message,e);
}
}
package net.wanji.web.controller.scheme;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.feign.pojo.result.JsonViewObject;
import net.wanji.web.dto.RunningPlanDTO;
import net.wanji.web.service.scheme.impl.RunningPlanServiceImpl;
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.ws.rs.core.MediaType;
/**
* 方案管理-运行计划
*
* @author Kent HAN
* @date 2022/12/20 10:14
*/
@Api(value = "RunningPlanController", description = "方案管理-运行计划")
@RequestMapping("/runningPlan")
@RestController
public class RunningPlanController {
private final RunningPlanServiceImpl runningPlanService;
public RunningPlanController(RunningPlanServiceImpl runningPlanService) {
this.runningPlanService = runningPlanService;
}
@ApiOperation(value = "保存运行计划", notes = "保存运行计划", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/saveRunningPlan",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
})
public JsonViewObject saveRunningPlan(@RequestBody RunningPlanDTO runningPlanDTO) {
runningPlanService.saveRunningPlan(runningPlanDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success();
}
//
// @ApiOperation(value = "渠化配置/灯组设置、车道配置列表", notes = "渠化配置/灯组设置、车道配置列表", response = JsonViewObject.class,
// produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
// @PostMapping(value = "/listLaneInfo",
// produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
// @ApiResponses({
// @ApiResponse(code = 200, message = "OK", response = SaveLaneInfoDTO.class),
// })
// public JsonViewObject listLaneInfo(@RequestBody CrossIdDTO crossIdDTO) {
// SaveLaneInfoDTO saveLaneInfoDTO = crossConfigService.listLaneInfo(crossIdDTO);
// JsonViewObject jsonViewObject = JsonViewObject.newInstance();
//
// return jsonViewObject.success(saveLaneInfoDTO);
// }
}
package net.wanji.web.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* 运行计划DTO
*
* @author Kent HAN
* @date 2023/1/28 16:11
*/
@NoArgsConstructor
@Data
public class RunningPlanDTO {
@ApiModelProperty(value = "路口ID", required = true)
private String crossId;
@ApiModelProperty(value = "日计划列表", required = true)
private List<DailyPlanListElement> dailyPlanList;
@ApiModelProperty(value = "运行计划列表", required = true)
private List<SchedulesPlanListElement> schedulesPlanList;
@NoArgsConstructor
@Data
public static class DailyPlanListElement {
/**
* planNo : P01
* name : 计划名1
* startTime : 07:00
* endTime : 09:00
* schemeName : 方案名1
*/
@ApiModelProperty(value = "计划编号", required = true)
private String planNo;
@ApiModelProperty(value = "日计划名", required = true)
private String name;
@ApiModelProperty(value = "开始时间", required = true)
private String startTime;
@ApiModelProperty(value = "结束时间", required = true)
private String endTime;
@ApiModelProperty(value = "方案名", required = true)
private String schemeName;
}
@NoArgsConstructor
@Data
public static class SchedulesPlanListElement {
/**
* scheduleNo : S01
* name : 运行计划名1
* week : [1,2,3,4,5]
* specialDate : null
* planName : 计划名1
*/
@ApiModelProperty(value = "运行计划编号", required = true)
private String scheduleNo;
@ApiModelProperty(value = "运行计划名", required = true)
private String name;
@ApiModelProperty(value = "星期:1周一,2周二,3周三,4周四,5周五,6周六,7周日", required = true)
private List<Integer> week;
@ApiModelProperty(value = "特殊日期,格式 2023-01-28", required = true)
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date specialDate;
@ApiModelProperty(value = "执行日计划名", required = true)
private String planName;
}
}
......@@ -27,7 +27,7 @@ public class CrossSchedulesPlanPO {
private Integer planId ;
/** 星期:1周一,2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期 */
@ApiModelProperty(name = "星期:1周一,2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期",notes = "")
private Integer week ;
private Integer week = 0 ;
/** 特殊日期 */
@ApiModelProperty(name = "特殊日期",notes = "")
private Date specialDate ;
......
package net.wanji.web.service.scheme;
import net.wanji.web.dto.RunningPlanDTO;
/**
* @author Kent HAN
* @date 2023/1/28 16:41
*/
public interface RunningPlanService {
void saveRunningPlan(RunningPlanDTO runningPlanDTO);
}
package net.wanji.web.service.scheme.impl;
import net.wanji.web.common.exception.WeekException;
import net.wanji.web.dto.RunningPlanDTO;
import net.wanji.web.service.scheme.RunningPlanService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author Kent HAN
* @date 2023/1/28 16:41
*/
@Service
public class RunningPlanServiceImpl implements RunningPlanService {
@Override
public void saveRunningPlan(RunningPlanDTO runningPlanDTO) {
// 验证特殊日期
List<RunningPlanDTO.SchedulesPlanListElement> schedulesPlanList = runningPlanDTO.getSchedulesPlanList();
for (RunningPlanDTO.SchedulesPlanListElement schedulesPlan : schedulesPlanList) {
List<Integer> week = schedulesPlan.getWeek();
Date specialDate = schedulesPlan.getSpecialDate();
if (week != null && week.size() > 0 && specialDate != null) {
throw new WeekException("不能同时有星期选择和日期选择");
}
}
// todo
// 保存计划数据
// 更新计划表获取计划ID
// 根据路口ID和方案名获取方案ID
// 更新时段表
// 保存调度数据
// 更新调度表获取调度ID
// 根据路口ID和计划名获取计划ID
// 更新调度计划关系表
}
}
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