Commit 23d6ea4b authored by duanruiming's avatar duanruiming

[update] UTC服务添加参数校验逻辑

parent 9aac9c66
......@@ -138,27 +138,28 @@ public class ControlCommandController {
@AspectLog(description = "步进控制-步进控制/恢复", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "步进控制-步进控制/恢复", notes = "步进控制-步进控制/恢复")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossCode", value = "13位路口编号", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "command", value = "1 开始步进 0 取消步进", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "stepNum", value = "0 顺序步进 n 跳过n个相位", paramType = "query", required = true, dataType = "int"),
})
@PostMapping("/stepControl")
public JsonViewObject stepControl(@RequestParam String code,
public JsonViewObject stepControl(@RequestParam String crossCode,
@RequestParam Integer command,
@RequestParam int stepNum) throws Exception {
return controlCommandStrategyService.stepControlStrategy(code, command, stepNum);
return controlCommandStrategyService.stepControlStrategy(crossCode, command, stepNum);
}
/**
* 恢复时间表
*
* @param code 信号id
* @param crossCode
* @return
*/
@AspectLog(description = "恢复时间表-恢复路口时间表执行", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "恢复时间表-恢复路口时间表执行", notes = "恢复时间表-恢复路口时间表执行")
@PostMapping("/recoverSchedule")
public JsonViewObject recoverSchedule(@RequestParam String code) throws Exception {
return controlCommandStrategyService.recoverScheduleStrategy(code);
public JsonViewObject recoverSchedule(@RequestParam String crossCode) throws Exception {
return controlCommandStrategyService.recoverScheduleStrategy(crossCode);
}
/**
......
......@@ -15,6 +15,7 @@ import net.wanji.utc.po.ManufacturerApiInfoPO;
import net.wanji.utc.service.systemadmin.ManufacturerApiInfoService;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -55,7 +56,7 @@ public class ManufacturerApiController {
@AspectLog(description = "接口添加或修改", operationType = BaseEnum.OperationTypeEnum.QUERY)
@ApiOperation(value = "接口添加或修改", notes = "接口添加或修改", consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/insertOrUpdate", consumes = MediaType.APPLICATION_JSON)
public JsonViewObject insertOrUpdate(@RequestBody ManufacturerApiInfoInsertOrUpdateDTO inVO) {
public JsonViewObject insertOrUpdate(@RequestBody @Validated ManufacturerApiInfoInsertOrUpdateDTO inVO) {
manufacturerApiInfoService.insertOrUpdate(inVO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
......
......@@ -14,6 +14,7 @@ import net.wanji.utc.dto.systemadmin.ManufacturerListDTO;
import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.systemadmin.ManufacturerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -62,7 +63,7 @@ public class ManufacturerController {
@AspectLog(description = "厂商添加或修改", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "厂商添加或修改", notes = "厂商添加或修改", consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/insertOrUpdate", consumes = MediaType.APPLICATION_JSON)
public JsonViewObject insertOrUpdate(@RequestBody ManufacturerInsertOrUpdateDTO inVO) {
public JsonViewObject insertOrUpdate(@RequestBody @Validated ManufacturerInsertOrUpdateDTO inVO) {
manufacturerService.insertOrUpdate(inVO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
......
......@@ -17,6 +17,7 @@ import net.wanji.utc.service.staticinfo.StaticInfoService;
import net.wanji.utc.vo.PlanSectionVO;
import net.wanji.utc.vo.SchemePhaseLightsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -46,7 +47,7 @@ public class StaticInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossInfoPO.class)
})
public JsonViewObject crossInfo(@RequestBody CrossInfoDTO crossInfoDTO) throws Exception {
public JsonViewObject crossInfo(@RequestBody @Validated CrossInfoDTO crossInfoDTO) throws Exception {
List<CrossInfoPO> crossInfoPOList = staticInfoService.crossBasicInfo(crossInfoDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
......@@ -62,7 +63,7 @@ public class StaticInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = SchemePhaseLightsVO.class)
})
public JsonViewObject schemePhaseLights(@RequestBody SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
public JsonViewObject schemePhaseLights(@RequestBody @Validated SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
// 更新数据库
staticInfoService.schemePhaseLights(schemePhaseLightsDTO);
// 构造返回值
......@@ -80,7 +81,7 @@ public class StaticInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = PlanSectionVO.class)
})
public JsonViewObject planSection(@RequestBody PlanSectionDTO planSectionDTO) throws Exception {
public JsonViewObject planSection(@RequestBody @Validated PlanSectionDTO planSectionDTO) throws Exception {
// 更新数据库
staticInfoService.planSection(planSectionDTO);
// 构造返回值
......@@ -107,7 +108,7 @@ public class StaticInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
public JsonViewObject crossSchedules(@RequestBody CrossSchedulesDTO crossSchedulesDTO) throws Exception {
public JsonViewObject crossSchedules(@RequestBody @Validated CrossSchedulesDTO crossSchedulesDTO) throws Exception {
// 更新数据库
staticInfoService.crossSchedules(crossSchedulesDTO);
// 构造返回值
......
......@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/15 9:57
......@@ -12,5 +15,7 @@ import lombok.Data;
@ApiModel(value = "CrossInfoDTO", description = "查询信号路口基础信息输入参数")
public class CrossInfoDTO {
@ApiModelProperty(value = "厂商代码 HK")
@NotBlank
@Pattern(regexp = "^[A-Z]*$", message = "厂商代码只能包含大写英文字母")
String manufacturerCode;
}
......@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
......@@ -14,8 +17,11 @@ import java.util.List;
@ApiModel(value = "CrossSchedulesDTO", description = "查询时间表数据输入参数")
public class CrossSchedulesDTO {
@ApiModelProperty(value = "厂商代码 HK")
@NotBlank
@Pattern(regexp = "^[A-Z]*$", message = "厂商代码只能包含大写英文字母")
String manufacturerCode;
@ApiModelProperty(value = "路口列表")
@NotEmpty
List<String> crossIdList;
}
......@@ -4,6 +4,10 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/15 9:57
......@@ -12,8 +16,11 @@ import lombok.Data;
@ApiModel(value = "PlanSectionDTO", description = "查询计划数据-计划信息、时段信息输入参数")
public class PlanSectionDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossId;
@ApiModelProperty(value = "计划号,-1代表所有")
@NotNull(message = "最小为-1,查所有")
@Min(value = -1, message = "最小为-1,查所有")
private Integer planNo;
}
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/16 13:23
......@@ -12,5 +14,6 @@ import lombok.Data;
@ApiModel(value = "SchemePhaseLightsDTO", description = "查询方案数据-方案信息、相位信息、灯组信息输入参数")
public class SchemePhaseLightsDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossId;
}
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author Kent HAN
* @date 2022/11/24 15:20
......@@ -16,20 +18,26 @@ public class ManufacturerApiInfoInsertOrUpdateDTO {
private Integer id ;
/** 接口代码 */
@ApiModelProperty(required = true, value = "接口代码",notes = "")
@NotBlank
private String code ;
/** 接口名称 */
@ApiModelProperty(required = true, value = "接口名称",notes = "")
@NotBlank
private String name ;
/** 接口类型 */
@ApiModelProperty(required = true, value = "接口类型",notes = "")
@NotBlank
private String apiType ;
/** 请求方式:GET、POST */
@ApiModelProperty(required = true, value = "请求方式:GET、POST",notes = "")
@NotBlank
private String method ;
/** 接口地址 */
@ApiModelProperty(required = true, value = "接口地址",notes = "")
@NotBlank
private String address ;
/** 接口厂商 */
@ApiModelProperty(required = true, value = "接口厂商",notes = "")
@NotBlank
private String manufacturerNick;
}
......@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/24 9:42
......@@ -17,17 +20,23 @@ public class ManufacturerInsertOrUpdateDTO {
private Integer id ;
/** 厂商代码 */
@ApiModelProperty(required = true, value = "厂商代码",notes = "")
@NotBlank
@Pattern(regexp = "^[A-Z]*$", message = "厂商代码只能包含大写英文字母")
private String code ;
/** 厂商名称 */
@ApiModelProperty(required = true, value = "厂商名称",notes = "")
@NotBlank
private String name ;
/** 厂商简称 */
@ApiModelProperty(required = true, value = "厂商简称",notes = "")
@NotBlank
private String nickName ;
/** 平台地址 */
@ApiModelProperty(required = true, value = "平台地址",notes = "")
@NotBlank
private String address ;
/** 维护单位 */
@ApiModelProperty(required = true, value = "维护单位",notes = "")
@NotBlank
private String maintenanceUnit ;
}
......@@ -131,10 +131,12 @@ public class StaticInfoServiceImpl implements StaticInfoService {
if (!CollectionUtils.isEmpty(crossIdList)) {
String crossId = crossIdList.get(0);
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.nonNull(crossInfoPO)) {
String signalIc = crossInfoPO.getCode();
wanjiCommonStaticInfoService.schedules(crossId, signalIc);
}
}
}
}
......
......@@ -4,10 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.*;
import java.util.List;
/**
......@@ -22,6 +19,7 @@ public class ControlCommandVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "1是;0否")
......@@ -30,10 +28,10 @@ public class ControlCommandVO {
@Min(value = 0, message = "控制类型:1是;0否")
private Integer command;
@ApiModelProperty(value = "持续时间")
@ApiModelProperty(value = "持续时间", notes = "持续时间, 可为空,默认999")
private Integer duration;
@ApiModelProperty(value = "锁定相位列表")
@ApiModelProperty(value = "锁定相位列表", notes = "锁定相位列表, 可为空")
private List<Integer> phaseList;
}
......@@ -7,6 +7,7 @@ import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
......@@ -22,6 +23,7 @@ public class PhaseTimingSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "需要下发的相位列表", notes = "需要下发的相位列表")
......
......@@ -7,6 +7,7 @@ import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
......@@ -22,6 +23,7 @@ public class PlanSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "计划列表", notes = "计划列表")
@NotEmpty(message = "计划列表不可为空")
......
......@@ -7,6 +7,7 @@ import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
......@@ -22,6 +23,7 @@ public class ScheduleSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "时间表", notes = "时间表")
@NotEmpty(message = "时间表不可为空")
......
......@@ -22,6 +22,7 @@ public class SchemeSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@javax.validation.constraints.Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "方案列表", notes = "方案列表")
......
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