Commit 82fafd8c authored by duanruiming's avatar duanruiming

[update] 优化1

parent 1ded3369
......@@ -4,10 +4,10 @@ import lombok.extern.slf4j.Slf4j;
import net.wanji.com.mapper.TCrossInfoMapper;
import net.wanji.com.pojo.po.CrossInfoPO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
......@@ -19,10 +19,11 @@ import java.util.Map;
*/
@Slf4j
@Component
@SuppressWarnings("unchecked")
public class CrossInfoCache implements CommandLineRunner {
@Autowired
private TCrossInfoMapper crossInfoMapper;
@Resource
private TCrossInfoMapper tCrossInfoMapper;
private static final Map<String, CrossInfoPO> crossInfoMap = new HashMap<>();
......@@ -46,7 +47,7 @@ public class CrossInfoCache implements CommandLineRunner {
}
private void init() {
List<CrossInfoPO> crossInfoPOS = crossInfoMapper.selectAll();
List<CrossInfoPO> crossInfoPOS = tCrossInfoMapper.selectAll();
for (CrossInfoPO crossInfoPO : crossInfoPOS) {
String key = StringUtils.join("/", crossInfoPO.getIp(), ":", crossInfoPO.getPort());
crossInfoMap.put(key, crossInfoPO);
......
......@@ -21,7 +21,7 @@ public class Swagger2 {
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("net.wanji.utc.controller"))
.apis(RequestHandlerSelectors.basePackage("net.wanji.com.controller"))
.paths(PathSelectors.any())
.build();
}
......
......@@ -5,11 +5,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.cache.SignalCommandInterfaceCache;
import net.wanji.com.common.constants.Constants;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.com.service.CommonService;
import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
......@@ -22,25 +18,13 @@ import org.springframework.web.bind.annotation.*;
* @author duanruiming
* @date 2023/05/08 10:45
*/
@Slf4j
@Api(value = "信号指令服务", tags = "信号指令服务")
@RequestMapping("/controlCommand")
@RestController
@RequiredArgsConstructor
@RequestMapping("/controlCommand")
@Api(value = "信号指令服务")
public class ControlCommandController {
private final SignalCommandInterfaceCache signalCommandInterfaceCache;
private final CommonService commonService;
/**
* 通过厂商编码和类类型,获取缓存中实现类
*
* @param manufacturerId
* @return
*/
private ControlCommandService getService(String manufacturerId) {
return (ControlCommandService) (signalCommandInterfaceCache.getService(manufacturerId.concat(SignalInterfaceTypeEnum.CONTROL.getCode())));
}
private final ControlCommandService controlCommandService;
/**
* 信号机方案下发
......@@ -52,8 +36,7 @@ public class ControlCommandController {
@ApiOperation(value = "信号机方案下发-基础方案下发", notes = "信号机方案下发-基础方案下发")
@PostMapping("/schemeSend")
public JsonViewObject schemeSend(@RequestBody @Validated SchemeSendVO schemeSendVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(schemeSendVO.getCrossCode());
return getService(manufacturerId).schemeSend(schemeSendVO);
return controlCommandService.schemeSend(schemeSendVO);
}
/**
......@@ -66,8 +49,7 @@ public class ControlCommandController {
@ApiOperation(value = "计划下发-计划信息、时段信息", notes = "计划下发-计划信息、时段信息")
@PostMapping("/planSend")
public JsonViewObject planSend(@RequestBody @Validated PlanSendVO planSendVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(planSendVO.getCrossCode());
return getService(manufacturerId).planSend(planSendVO);
return controlCommandService.planSend(planSendVO);
}
/**
......@@ -81,8 +63,7 @@ public class ControlCommandController {
@ApiOperation(value = "时间表下发-时间表信息", notes = "时间表下发-时间表信息")
@PostMapping("/scheduleSend")
public JsonViewObject scheduleSend(@RequestBody @Validated ScheduleSendVO scheduleSendVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(scheduleSendVO.getCrossCode());
return getService(manufacturerId).scheduleSend(scheduleSendVO);
return controlCommandService.scheduleSend(scheduleSendVO);
}
/**
......@@ -95,8 +76,7 @@ public class ControlCommandController {
@ApiOperation(value = "相位配时下发-(下发相位参数)", notes = "相位配时下发-(下发相位参数)")
@PostMapping("/phaseTimingSend")
public JsonViewObject phaseTimingSend(@RequestBody @Validated PhaseTimingSendVO phaseTimingSendVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(phaseTimingSendVO.getCrossCode());
return getService(manufacturerId).phaseTimingSend(phaseTimingSendVO);
return controlCommandService.phaseTimingSend(phaseTimingSendVO);
}
/**
......@@ -110,8 +90,7 @@ public class ControlCommandController {
@ApiOperation(value = "全红控制-路口全红控制/恢复", notes = "全红控制-路口全红控制/恢复")
@PostMapping("/allRedControl")
public JsonViewObject allRedControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(commandVO.getCrossCode());
return getService(manufacturerId).setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.ALL_RED_CONTROL);
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.ALL_RED_CONTROL);
}
/**
......@@ -125,8 +104,7 @@ public class ControlCommandController {
@ApiOperation(value = "黄闪控制-路口黄闪控制/恢复", notes = "黄闪控制-路口黄闪控制/恢复")
@PostMapping("/yellowLightControl")
public JsonViewObject yellowLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(commandVO.getCrossCode());
return getService(manufacturerId).setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.YELLOW_LIGHT_CONTROL);
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.YELLOW_LIGHT_CONTROL);
}
/**
......@@ -140,8 +118,7 @@ public class ControlCommandController {
@ApiOperation(value = "关灯控制-路口关灯控制/开灯", notes = "关灯控制-路口关灯控制/开灯")
@PostMapping("/closeLightControl")
public JsonViewObject closeLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(commandVO.getCrossCode());
return getService(manufacturerId).setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.CLOSE_LIGHT_CONTROL);
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.CLOSE_LIGHT_CONTROL);
}
/**
......@@ -163,8 +140,7 @@ public class ControlCommandController {
public JsonViewObject stepControl(@RequestParam String crossCode,
@RequestParam Integer command,
@RequestParam int stepNum) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(crossCode);
return getService(manufacturerId).stepControl(crossCode, command, stepNum);
return controlCommandService.stepControl(crossCode, command, stepNum);
}
/**
......@@ -177,8 +153,7 @@ public class ControlCommandController {
@ApiOperation(value = "恢复时间表-恢复路口时间表执行", notes = "恢复时间表-恢复路口时间表执行")
@PostMapping("/recoverSchedule")
public JsonViewObject recoverSchedule(@RequestParam String crossCode) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(crossCode);
return getService(manufacturerId).recoverSchedule(crossCode);
return controlCommandService.recoverSchedule(crossCode);
}
/**
......@@ -192,8 +167,7 @@ public class ControlCommandController {
@ApiOperation(value = "锁定控制-相位锁定/解锁", notes = "锁定控制-相位锁定/解锁")
@PostMapping("/lockControl")
public JsonViewObject lockControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
String manufacturerId = commonService.getManufacturerCodeByCrossId(commandVO.getCrossCode());
return getService(manufacturerId).lockControl(commandVO);
return controlCommandService.lockControl(commandVO);
}
/**
......@@ -203,14 +177,7 @@ public class ControlCommandController {
@ApiOperation(value = "相位差下发", notes = "相位差下发")
@PostMapping("/phaseDiffSend")
public JsonViewObject phaseDiffSend(String crossCode) {
String manufacturerId = commonService.getManufacturerCodeByCrossId(crossCode);
return getService(manufacturerId).phaseDiffSend();
return controlCommandService.phaseDiffSend();
}
/* @AspectLog(description = "删除信号机配置参数", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "删除信号机配置参数", notes = "删除信号机配置参数")
@PostMapping("/delBaseConfig")
public JsonViewObject delBaseConfig(@RequestBody @Validated DelBaseConfigVO delBaseConfigVO) throws Exception {
return signalTypeServiceImplCache.getService(manufacturerId).delBaseConfig(delBaseConfigVO);
}*/
}
......@@ -10,8 +10,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import net.wanji.com.cache.SignalCommandInterfaceCache;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.com.pojo.po.SignalStatusLogPO;
import net.wanji.com.pojo.vo.LightsStatusVO;
import net.wanji.com.service.controller.SignalStatusService;
......@@ -30,17 +28,12 @@ import java.util.List;
*
* @date 2022/11/15 9:38
*/
@Api(value = "运行状态、告警、灯态信息接口", description = "运行状态、告警、灯态信息接口")
@Api(value = "运行状态、告警、灯态信息接口", tags = "运行状态、告警、灯态信息接口")
@RequestMapping("/signalStatus")
@RestController
@RequiredArgsConstructor
public class SignalStatusController {
private final SignalStatusService signalStatusService;
private final SignalCommandInterfaceCache signalCommandInterfaceCache;
private SignalStatusService getService(String manufacturerId) {
return (SignalStatusService) (signalCommandInterfaceCache.getService(manufacturerId.concat(SignalInterfaceTypeEnum.STATUS.getCode())));
}
@AspectLog(description = "运行状态、告警数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/runningStatusAlarm", produces = MediaType.APPLICATION_JSON)
......@@ -52,7 +45,6 @@ public class SignalStatusController {
public JsonViewObject runningStatusAlarm() {
List<SignalStatusLogPO> signalStatusLogPOList = signalStatusService.runningStatusAlarm();
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(signalStatusLogPOList);
}
......@@ -67,8 +59,6 @@ public class SignalStatusController {
public JsonViewObject lightStatus() {
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus();
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(lightsStatusVOList);
}
}
......@@ -5,8 +5,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import net.wanji.com.cache.SignalCommandInterfaceCache;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.com.pojo.dto.CrossInfoDTO;
import net.wanji.com.pojo.dto.CrossSchedulesDTO;
import net.wanji.com.pojo.dto.PlanSectionDTO;
......@@ -34,18 +32,13 @@ import java.util.Objects;
*
* @date 2022/11/15 9:38
*/
@Api(value = "静态信息接口", description = "静态信息接口")
@Api(value = "静态信息接口", tags = "静态信息接口")
@RequestMapping("/staticInfo")
@RestController
@RequiredArgsConstructor
public class StaticInfoController {
private final StaticInfoService staticInfoService;
private final SignalCommandInterfaceCache signalCommandInterfaceCache;
private StaticInfoService getService(String manufacturerId) {
return (StaticInfoService) (signalCommandInterfaceCache.getService(manufacturerId.concat(SignalInterfaceTypeEnum.STATIC.getCode())));
}
@AspectLog(description = "信号路口基础信息", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossInfo",
......
package net.wanji.com.mapper;
import net.wanji.com.pojo.po.ManufacturerInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -10,7 +9,6 @@ import java.util.List;
* @author Kent HAN
* @date 2022/11/15 16:48
*/
@Mapper
public interface ManufacturerInfoMapper {
ManufacturerInfoPO selectByCode(@Param("code") String code);
......
package net.wanji.com.mapper;
import net.wanji.com.pojo.po.CrossInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -10,7 +9,6 @@ import java.util.List;
* @author duanruiming
* @date 2023/05/09 9:10
*/
@Mapper
public interface TCrossInfoMapper {
CrossInfoPO selectByPrimaryKey(@Param("key") String key);
......
package net.wanji.com.service.controller.dt.impl;
package net.wanji.com.service.controller.impl;
import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.common.enums.BaseEnum;
......
package net.wanji.com.service.controller.dt.impl;
package net.wanji.com.service.controller.impl;
import net.wanji.com.pojo.po.SignalStatusLogPO;
import net.wanji.com.pojo.vo.LightsStatusVO;
......
package net.wanji.com.service.controller.dt.impl;
package net.wanji.com.service.controller.impl;
import net.wanji.com.pojo.dto.CrossInfoDTO;
import net.wanji.com.pojo.dto.CrossSchedulesDTO;
......
package net.wanji.com.service.protocol.dt.impl;
package net.wanji.com.service.protocol.impl;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.service.protocol.ProtocolConversionService;
......
......@@ -13,8 +13,8 @@
</resultMap>
<insert id="insertOne">
insert into t_manufacturer_info(code,name,nick_name,address,maintenance_unit)
values (#{code},#{name},#{nickName},#{address},#{maintenanceUnit})
insert into t_manufacturer_info(code, name, nick_name, address, maintenance_unit)
values (#{code}, #{name}, #{nickName}, #{address}, #{maintenanceUnit})
</insert>
<update id="updateOne">
......@@ -48,21 +48,39 @@
</delete>
<select id="selectByCode" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
select id,
code,
name,
nick_name,
address,
maintenance_unit,
gmt_create,
gmt_modified
from t_manufacturer_info
where code = #{code}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
select id,
code,
name,
nick_name,
address,
maintenance_unit,
gmt_create,
gmt_modified
from t_manufacturer_info
where id = #{manufacturerId}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
select id,
code,
name,
nick_name,
address,
maintenance_unit,
gmt_create,
gmt_modified
from t_manufacturer_info
</select>
......@@ -78,12 +96,14 @@
</select>
<select id="selectIdByNick" resultType="java.lang.Integer">
select id from t_manufacturer_info
select id
from t_manufacturer_info
where nick_name = #{manufacturerNick}
</select>
<select id="selectNickById" resultType="java.lang.String">
select nick_name from t_manufacturer_info
select nick_name
from t_manufacturer_info
where id = #{manufacturerId}
</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