Commit 875ad977 authored by hanbing's avatar hanbing

[add] 快速特勤,修改特勤详情

parent bddbe436
package net.wanji.web.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.web.vo.specialService.SpecialServiceDetailVO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/8 13:18
*/
@Data
@ApiModel(value = "UpdateSpecialServiceBO", description = "快速特勤-编辑特勤输入参数")
public class UpdateSpecialServiceBO {
@ApiModelProperty(value = "特勤ID")
Integer specialServiceId;
@ApiModelProperty(value = "开始路口ID")
String initCrossId;
@ApiModelProperty(value = "结束路口ID")
String finalCrossId;
@ApiModelProperty(value = "路口列表")
List<SpecialServiceDetailVO.CrossListElement> crossList;
}
......@@ -7,10 +7,7 @@ import io.swagger.annotations.ApiResponses;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.web.bo.AddSpecialServiceBO;
import net.wanji.web.bo.IsValidPointBO;
import net.wanji.web.bo.SpecialServiceIdBO;
import net.wanji.web.bo.SpecialServiceRouteBO;
import net.wanji.web.bo.*;
import net.wanji.web.service.SpecialServiceService;
import net.wanji.web.vo.specialService.RouteElementVO;
import net.wanji.web.vo.specialService.*;
......@@ -101,16 +98,34 @@ public class SpecialServiceController {
return JsonViewObject.newInstance().success(specialServiceDetailVO);
}
@AspectLog(description = "编辑特勤", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "编辑特勤", notes = "编辑特勤", response = JsonViewObject.class,
@AspectLog(description = "修改特勤详情", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "修改特勤详情", notes = "修改特勤详情", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/updateSpecialService",
@PostMapping(value = "/updateSpecialServiceDetail",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public JsonViewObject updateSpecialService(@RequestBody UpdateSpecialServiceInVO updateSpecialServiceInVO) {
specialServiceService.updateSpecialService(updateSpecialServiceInVO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
public JsonViewObject updateSpecialServiceDetail(@RequestBody UpdateSpecialServiceBO updateSpecialServiceBO) {
specialServiceService.updateSpecialServiceDetail(updateSpecialServiceBO);
return JsonViewObject.newInstance().success();
}
return jsonViewObject.success();
@AspectLog(description = "获取路口驶入方向列表", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "获取路口驶入方向列表", notes = "获取路口驶入方向列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/getInDirList",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public JsonViewObject getInDirList(@RequestBody CrossIdVO crossIdVO) {
List<String> inDirList = specialServiceService.getInDirList(crossIdVO);
return JsonViewObject.newInstance().success(inDirList);
}
@AspectLog(description = "获取路口驶出方向列表", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "获取路口驶出方向列表", notes = "获取路口驶出方向列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/getOutDirList",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public JsonViewObject getOutDirList(@RequestBody CrossIdVO crossIdVO) {
List<String> outDirList = specialServiceService.getOutDirList(crossIdVO);
return JsonViewObject.newInstance().success(outDirList);
}
@AspectLog(description = "更新路口", operationType = BaseEnum.OperationTypeEnum.UPDATE)
......
package net.wanji.web.mapper;
import net.wanji.web.po.SpecialServicePO;
import net.wanji.web.vo.specialService.UpdateSpecialServiceInVO;
import net.wanji.web.bo.UpdateSpecialServiceBO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -17,7 +17,7 @@ public interface SpecialServiceMapper {
List<SpecialServicePO> selectByAdCode(@Param("adCode") String adCode);
void updateSpecialService(UpdateSpecialServiceInVO updateSpecialServiceInVO);
void updateSpecialService(UpdateSpecialServiceBO updateSpecialServiceBO);
void deleteSpecialService(@Param("id") Integer id);
......@@ -34,5 +34,5 @@ public interface SpecialServiceMapper {
SpecialServicePO selectById(Integer specialServiceId);
void updateOne(Integer specialServiceId, SpecialServicePO specialServicePO);
void updateOne(SpecialServicePO specialServicePO);
}
package net.wanji.web.service;
import net.wanji.web.bo.AddSpecialServiceBO;
import net.wanji.web.bo.IsValidPointBO;
import net.wanji.web.bo.SpecialServiceIdBO;
import net.wanji.web.bo.SpecialServiceRouteBO;
import net.wanji.web.bo.*;
import net.wanji.web.vo.specialService.RouteElementVO;
import net.wanji.web.vo.specialService.*;
......@@ -19,7 +16,7 @@ public interface SpecialServiceService {
List<ListSpecialServicesVO> listSpecialServices();
void updateSpecialService(UpdateSpecialServiceInVO updateSpecialServiceInVO);
void updateSpecialService(UpdateSpecialServiceBO updateSpecialServiceBO);
void deleteSpecialService(Integer id);
......@@ -34,4 +31,10 @@ public interface SpecialServiceService {
void isValidPoint(IsValidPointBO isValidPointBO);
SpecialServiceDetailVO specialServiceDetail(SpecialServiceIdBO specialServiceIdBO);
void updateSpecialServiceDetail(UpdateSpecialServiceBO updateSpecialServiceBO);
List<String> getInDirList(CrossIdVO crossIdVO);
List<String> getOutDirList(CrossIdVO crossIdVO);
}
......@@ -2,6 +2,7 @@ package net.wanji.web.service.impl;
import cn.hutool.core.collection.CollectionUtil;
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.gts.GeometryUtil;
......@@ -13,18 +14,15 @@ import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.dao.mapper.RidInfoMapper;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.web.bo.AddSpecialServiceBO;
import net.wanji.web.bo.IsValidPointBO;
import net.wanji.web.bo.SpecialServiceIdBO;
import net.wanji.web.bo.SpecialServiceRouteBO;
import net.wanji.web.bo.*;
import net.wanji.web.common.enums.CrossDirEnum;
import net.wanji.web.mapper.*;
import net.wanji.web.po.CrossDirTurnPO;
import net.wanji.web.po.SpecialServiceCrossPO;
import net.wanji.web.po.SpecialServicePO;
import net.wanji.web.service.SpecialServiceService;
import net.wanji.web.vo.specialService.RouteElementVO;
import net.wanji.web.vo.specialService.*;
import net.wanji.web.vo.specialService.SpecialServiceDetailVO.CrossListElement;
import org.jetbrains.annotations.NotNull;
import org.locationtech.jts.geom.Geometry;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -163,12 +161,13 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
} else { // 传ID为修改
// 修改特勤表
SpecialServicePO specialServicePO = new SpecialServicePO();
specialServicePO.setId(specialServiceId);
specialServicePO.setName(addSpecialServiceBO.getName());
specialServicePO.setPlateNum(addSpecialServiceBO.getPlateNum());
specialServicePO.setStartLocation(addSpecialServiceBO.getStartLocation());
specialServicePO.setEndLocation(addSpecialServiceBO.getEndLocation());
specialServiceMapper.updateOne(specialServiceId, specialServicePO);
specialServiceMapper.updateOne(specialServicePO);
// 修改特勤路口关系表
......@@ -275,8 +274,8 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
}
@Override
public void updateSpecialService(UpdateSpecialServiceInVO updateSpecialServiceInVO) {
specialServiceMapper.updateSpecialService(updateSpecialServiceInVO);
public void updateSpecialService(UpdateSpecialServiceBO updateSpecialServiceBO) {
specialServiceMapper.updateSpecialService(updateSpecialServiceBO);
}
@Override
......@@ -527,6 +526,106 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
return specialServiceDetailVO;
}
@Override
@Transactional
public void updateSpecialServiceDetail(UpdateSpecialServiceBO updateSpecialServiceBO) {
Integer specialServiceId = updateSpecialServiceBO.getSpecialServiceId();
specialServiceCrossMapper.deleteCrossBySpecialServiceId(specialServiceId);
String initCrossId = updateSpecialServiceBO.getInitCrossId();
String finalCrossId = updateSpecialServiceBO.getFinalCrossId();
List<CrossListElement> crossList = updateSpecialServiceBO.getCrossList();
String currentCrossId = initCrossId;
Integer sort = 1;
while (!StrUtil.equals(finalCrossId, currentCrossId)) { // 未到最后一个路口
for (CrossListElement crossListElement : crossList) {
String crossId = crossListElement.getCrossId();
if (StrUtil.equals(currentCrossId, crossId) && !StrUtil.equals(currentCrossId, finalCrossId)) {
SpecialServiceCrossPO specialServiceCrossPO = new SpecialServiceCrossPO();
specialServiceCrossPO.setSpecialServiceId(specialServiceId);
specialServiceCrossPO.setCrossId(currentCrossId);
// 根据起点路口和使出方向确定路段
String routeEnd = crossListElement.getRouteEnd();
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("路线规划不正确或路网数据不连续");
}
String nextCrossId = ridInfoEntity.getEndCrossId();
if (StrUtil.equals(currentCrossId, initCrossId)) { // 是起点路口
specialServiceCrossPO.setInDir(0);
specialServiceCrossPO.setOutDir(outDir);
} else { // 中间路口
String routeStart = crossListElement.getRouteStart();
String inDirStr = routeStart.charAt(routeStart.length() - 1) + "";
Integer inDir = CrossDirEnum.getCodeByMsg(inDirStr);
specialServiceCrossPO.setInDir(inDir);
specialServiceCrossPO.setOutDir(outDir);
}
specialServiceCrossPO.setSort(sort);
specialServiceCrossPO.setStatus(0);
specialServiceCrossPO.setAutoUnlock(0);
specialServiceCrossMapper.insertOne(specialServiceCrossPO);
currentCrossId = nextCrossId;
sort++;
}
}
}
// 最后一个路口
for (CrossListElement crossListElement : crossList) {
String crossId = crossListElement.getCrossId();
if (StrUtil.equals(finalCrossId, crossId)) {
SpecialServiceCrossPO specialServiceCrossPO = new SpecialServiceCrossPO();
specialServiceCrossPO.setSpecialServiceId(specialServiceId);
specialServiceCrossPO.setCrossId(finalCrossId);
String routeStart = crossListElement.getRouteStart();
String inDirStr = routeStart.charAt(routeStart.length() - 1) + "";
Integer inDir = CrossDirEnum.getCodeByMsg(inDirStr);
specialServiceCrossPO.setInDir(inDir);
specialServiceCrossPO.setOutDir(0);
specialServiceCrossPO.setSort(sort);
specialServiceCrossPO.setStatus(0);
specialServiceCrossPO.setAutoUnlock(0);
specialServiceCrossMapper.insertOne(specialServiceCrossPO);
}
}
}
@Override
public List<String> getInDirList(CrossIdVO crossIdVO) {
List<String> res = new ArrayList<>();
String crossId = crossIdVO.getCrossId();
List<RidInfoEntity> ridList = ridInfoMapper.selectByEndCross(crossId);
for (RidInfoEntity ridInfoEntity : ridList) {
String name = ridInfoEntity.getName(); // 湘江中路:白沙路@劳动西路路段
String streetName = name.split(":")[0];
Integer inDir = ridInfoEntity.getInDir();
String msgByCode = CrossDirEnum.getMsgByCode(inDir);
res.add(streetName + msgByCode);
}
return res;
}
@Override
public List<String> getOutDirList(CrossIdVO crossIdVO) {
List<String> res = new ArrayList<>();
String crossId = crossIdVO.getCrossId();
List<RidInfoEntity> ridList = ridInfoMapper.selectByStartCross(crossId);
for (RidInfoEntity ridInfoEntity : ridList) {
String name = ridInfoEntity.getName(); // 湘江中路:白沙路@劳动西路路段
String streetName = name.split(":")[0];
Integer outDir = ridInfoEntity.getOutDir();
String msgByCode = CrossDirEnum.getMsgByCode(outDir);
res.add(streetName + msgByCode);
}
return res;
}
private List<SpecialServiceDetailVO.CrossListElement> buildCrossList(Integer specialServiceId) {
List<SpecialServiceDetailVO.CrossListElement> crossList = new ArrayList<>();
List<SpecialServiceCrossPO> specialServiceCrossList =
......
package net.wanji.web.vo.specialService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Kent HAN
* @date 2022/11/8 13:18
*/
@Data
@ApiModel(value = "UpdateSpecialServiceInVO", description = "快速特勤-编辑特勤输入参数")
public class UpdateSpecialServiceInVO {
@ApiModelProperty(value = "特勤ID")
Integer id;
@ApiModelProperty(value = "特勤名称")
String name;
}
......@@ -92,7 +92,7 @@
is_del = #{isDel},
</if>
</set>
where id = #{specialServiceId}
where id = #{id}
</update>
<select id="selectByAdCode" resultMap="BaseResultMap">
......
......@@ -31,4 +31,12 @@ public interface RidInfoMapper {
List<RidInfoEntity> selectUpCross(String startCrossId);
RidInfoEntity selectByStartEnd(String firstId, String secondId);
RidInfoEntity selectByStartOurDir(String crossId, Integer outDir);
RidInfoEntity selectByEndInDir2(String finalCrossId, Integer inDir);
List<RidInfoEntity> selectByEndCross(String crossId);
List<RidInfoEntity> selectByStartCross(String crossId);
}
......@@ -93,4 +93,28 @@
from t_base_rid_info
where start_cross_id = #{firstId} and end_cross_id = #{secondId}
</select>
<select id="selectByStartOurDir" resultType="net.wanji.databus.dao.entity.RidInfoEntity">
select <include refid="Base_Column_List"/>
from t_base_rid_info
where start_cross_id = #{crossId} and out_dir = #{outDir}
</select>
<select id="selectByEndInDir2" resultType="net.wanji.databus.dao.entity.RidInfoEntity">
select <include refid="Base_Column_List"/>
from t_base_rid_info
where end_cross_id = #{finalCrossId} and in_dir = #{inDir}
</select>
<select id="selectByEndCross" resultType="net.wanji.databus.dao.entity.RidInfoEntity">
select <include refid="Base_Column_List"/>
from t_base_rid_info
where end_cross_id = #{finalCrossId}
</select>
<select id="selectByStartCross" resultType="net.wanji.databus.dao.entity.RidInfoEntity">
select <include refid="Base_Column_List"/>
from t_base_rid_info
where start_cross_id = #{finalCrossId}
</select>
</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