Commit df21f27c authored by hanbing's avatar hanbing

[update] 快速特勤,编辑特勤路线规划错误返回状态码1001

parent 463c33b6
package net.wanji.web.common.exception;
import net.wanji.common.framework.exceptionhandler.GlobalExceptionHandler;
import net.wanji.common.framework.rest.JsonViewObject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
......@@ -11,7 +12,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
* @date 2023/1/5 13:18
*/
@RestControllerAdvice
public class SignalGlobalExceptionHandler {
public class SignalGlobalExceptionHandler extends GlobalExceptionHandler {
@ExceptionHandler(value = LightLaneConflictException.class)
public JsonViewObject lightLaneExceptionHandler(LightLaneConflictException e) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
......
......@@ -47,7 +47,7 @@ public interface SpecialServiceCrossMapper {
Integer selectSpecialServiceIdByCrossId(String crossId);
void updateGroupName(String crossId, String groupName, Integer specialServiceId);
void updateGroupName(String crossId, String groupName, Integer specialServiceId, Integer groupSort);
void deleteGroup(Integer specialServiceId, String groupName);
......
......@@ -12,20 +12,17 @@ import java.util.Date;
*/
@Data
public class SpecialServiceCrossPO {
/** 主键 */
@Id
@ApiModelProperty(name = "主键",notes = "")
private Integer id ;
/** 特勤ID */
@ApiModelProperty(name = "特勤ID",notes = "")
private Integer specialServiceId ;
@ApiModelProperty(name = "分组名称",notes = "")
private String groupName = "未分组路口";
/** 路口编号 */
@ApiModelProperty(name = "分组序号",notes = "")
private Integer groupSort = 0;
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId ;
/** 进口方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北 */
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private Integer inDir ;
@ApiModelProperty(name = "驶出方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
......@@ -36,10 +33,8 @@ public class SpecialServiceCrossPO {
private Integer status ;
@ApiModelProperty(name = "自动解锁:1是;0否",notes = "")
private Integer autoUnlock ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
......@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.wanji.common.framework.exception.RidException;
import net.wanji.common.gts.GeometryUtil;
import net.wanji.common.gts.GeomsConvertUtil;
import net.wanji.common.gts.service.GtsService;
......@@ -511,13 +512,13 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
// 根据起点路口和使出方向确定路段
String routeEnd = crossListElement.getRouteEnd();
if (null == routeEnd) {
throw new RuntimeException("路线规划不正确或路网数据不连续");
throw new RidException("路线规划不正确或路网数据不连续");
}
String outDirStr = routeEnd.charAt(routeEnd.length() - 1) + "";
Integer outDir = CrossDirEnum.getCodeByMsg(outDirStr);
RidInfoEntity ridInfoEntity = ridInfoMapper.selectByStartOurDir(currentCrossId, outDir);
if (ObjectUtil.isEmpty(ridInfoEntity)) {
throw new RuntimeException("路线规划不正确或路网数据不连续");
throw new RidException("路线规划不正确或路网数据不连续");
}
String nextCrossId = ridInfoEntity.getEndCrossId();
......@@ -527,7 +528,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
} else { // 中间路口
String routeStart = crossListElement.getRouteStart();
if (null == routeStart) {
throw new RuntimeException("路线规划不正确或路网数据不连续");
throw new RidException("路线规划不正确或路网数据不连续");
}
String inDirStr = routeStart.charAt(routeStart.length() - 1) + "";
Integer inDir = CrossDirEnum.getCodeByMsg(inDirStr);
......@@ -553,7 +554,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
String routeStart = crossListElement.getRouteStart();
if (null == routeStart) {
throw new RuntimeException("路线规划不正确或路网数据不连续");
throw new RidException("路线规划不正确或路网数据不连续");
}
String inDirStr = routeStart.charAt(routeStart.length() - 1) + "";
Integer inDir = CrossDirEnum.getCodeByMsg(inDirStr);
......@@ -570,7 +571,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
List<SpecialServiceCrossPO> crossPOList =
specialServiceCrossMapper.selectBySpecialServiceId(specialServiceId);
if (crossPOList.size() != crossList.size()) {
throw new RuntimeException("路口关系不正确或路网数据不连续");
throw new RidException("路线规划不正确或路网数据不连续");
}
}
......@@ -689,14 +690,14 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
Integer specialServiceId = groupListVO.getSpecialServiceId();
for (GroupListVO.GroupListElement groupListElement : groupList) {
for (int i = 0; i < groupList.size(); i++) {
GroupListVO.GroupListElement groupListElement = groupList.get(i);
String groupName = groupListElement.getGroupName();
if (!"未分组路口".equals(groupName)){
List<CrossListElement> crossList = groupListElement.getCrossList();
for (CrossListElement crossListElement : crossList) {
String crossId = crossListElement.getCrossId();
specialServiceCrossMapper.updateGroupName(crossId, groupName, specialServiceId);
}
Integer groupSort = i + 1;
List<CrossListElement> crossList = groupListElement.getCrossList();
for (CrossListElement crossListElement : crossList) {
String crossId = crossListElement.getCrossId();
specialServiceCrossMapper.updateGroupName(crossId, groupName, specialServiceId, groupSort);
}
}
}
......@@ -745,16 +746,18 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
List<SpecialServiceCrossPO> specialServiceCrossList =
specialServiceCrossMapper.selectBySpecialServiceId(specialServiceId);
Map<String, List<SpecialServiceCrossPO>> map = specialServiceCrossList.stream()
.collect(Collectors.groupingBy(SpecialServiceCrossPO::getGroupName));
LinkedHashMap<Integer, List<SpecialServiceCrossPO>> map = specialServiceCrossList.stream()
.collect(Collectors.groupingBy(
SpecialServiceCrossPO::getGroupSort, LinkedHashMap::new, Collectors.toList()));
for (String groupName : map.keySet()) {
for (Map.Entry<Integer, List<SpecialServiceCrossPO>> entry : map.entrySet()) {
SpecialServiceCrossPO specialServiceCrossPO = entry.getValue().get(0);
String groupName = specialServiceCrossPO.getGroupName();
Integer groupSort = specialServiceCrossPO.getGroupSort();
GroupListVO.GroupListElement groupListElement = new GroupListVO.GroupListElement();
groupListElement.setGroupName(groupName);
List<SpecialServiceCrossPO> groupCrossList = map.get(groupName);
List<SpecialServiceCrossPO> groupCrossList = map.get(groupSort);
Collections.sort(groupCrossList, Comparator.comparing(SpecialServiceCrossPO::getSort));
StringBuilder wktBuilder = new StringBuilder();
List<SpecialServiceDetailVO.CrossListElement> crossList = new ArrayList<>();
......@@ -763,10 +766,8 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
groupListElement.setWkt(wktBuilder.toString());
groupListElement.setCrossList(crossList);
groupList.add(groupListElement);
}
return groupList;
}
......
......@@ -7,6 +7,7 @@
<result property="id" column="id" />
<result property="specialServiceId" column="special_service_id" />
<result property="groupName" column="group_name" />
<result property="groupSort" column="group_sort" />
<result property="crossId" column="cross_id" />
<result property="inDir" column="in_dir" />
<result property="outDir" column="out_dir" />
......@@ -18,7 +19,7 @@
</resultMap>
<sql id="Base_Column_List">
id,special_service_id,group_name,cross_id,in_dir,out_dir,sort,status,auto_unlock,gmt_create,gmt_modified
id,special_service_id,group_name,group_sort,cross_id,in_dir,out_dir,sort,status,auto_unlock,gmt_create,gmt_modified
</sql>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
......@@ -58,7 +59,7 @@
<update id="updateGroupName">
update t_special_service_cross
set group_name = #{groupName}
set group_name = #{groupName}, group_sort = #{groupSort}
where cross_id = #{crossId} and special_service_id = #{specialServiceId}
</update>
......
......@@ -335,6 +335,8 @@ public final class Constants {
public static final String MESSAGE_GET_PARAM_ERROR = "GET请求参数错误,注:暂不支持对象嵌套及数组";
public static final String MESSAGE_LOGIN_SUCCESS = "登录成功";
public static final String DELETE_ERROR_MSG = "表单【%s】已被流程【%s】使用";
public static final String RID_ERROR = "1001"; // 路线规划失败错误码
}
/**
......
package net.wanji.common.framework.exception;
/**
* 路段关系异常
*
* @author Kent HAN
* @date 2022/11/10 9:09
*/
public class RidException extends RuntimeException {
public RidException(String message) {
super(message);
}
public RidException(String message, Exception e) {
super(message,e);
}
}
package net.wanji.common.framework.exceptionhandler;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants;
import net.wanji.common.framework.exception.FeignServiceException;
import net.wanji.common.framework.exception.RidException;
import net.wanji.common.framework.rest.JsonViewObject;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.converter.HttpMessageNotReadableException;
......@@ -18,6 +20,19 @@ import java.io.IOException;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
/**
* 路线规划异常
*/
@ExceptionHandler(value = RidException.class)
public JsonViewObject ridExceptionHandler(RidException e) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
jsonViewObject.setContent("");
jsonViewObject.setMessage(e.getMessage());
jsonViewObject.setStatus(Constants.JsonView.STATUS_FAIL);
String ridError = Constants.JsonView.RID_ERROR;
jsonViewObject.setCode(Integer.parseInt(ridError));
return jsonViewObject;
}
/**
* 数据库字段值重复异常
*/
......
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