【字符串修改成枚举】

This commit is contained in:
weizhihong 2023-02-14 10:44:12 +08:00
parent 5bdad2aaa7
commit 47956c3a79

View File

@ -342,9 +342,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("XTY")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.XTY.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildXtyProjectDevices(accountVO);
@ -358,7 +357,7 @@ public class DeviceServiceImpl implements DeviceService {
List<ProjectDevice> list = new ArrayList<>();
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode("XTY");
plcGateway.setProjectCode(Project.XTY.name());
plcGateway.setCode("xty-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
@ -368,7 +367,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(plcGateway);
// 屏蔽门
ProjectDevice psd = new ProjectDevice();
psd.setProjectCode("XTY");
psd.setProjectCode(Project.XTY.name());
psd.setCode("xty-psd");
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
@ -384,9 +383,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("GZB")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.GZB.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildGzbProjectDevices(accountVO);
@ -400,9 +398,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("SDY")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.SDY.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildSdyProjectDevices(accountVO);
@ -416,9 +413,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("RICHOR_JOINT")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.RICHOR_JOINT.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildZjdProjectDevices(accountVO);
@ -432,9 +428,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("SR_SANDBOX")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.SR_SANDBOX.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildSrProjectDevices(accountVO, mapId);
@ -448,9 +443,8 @@ public class DeviceServiceImpl implements DeviceService {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo("RICHOR_HHCJ")
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andProjectCodeEqualTo(Project.RICHOR_HHCJ.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildHhcjProjectDevices(accountVO);
@ -465,8 +459,7 @@ public class DeviceServiceImpl implements DeviceService {
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo(Project.SAY.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildSayProjectDevices(accountVO);
@ -537,7 +530,7 @@ public class DeviceServiceImpl implements DeviceService {
List<ProjectDevice> list = new ArrayList<>();
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode("RICHOR_HHCJ");
plcGateway.setProjectCode(Project.RICHOR_HHCJ.name());
plcGateway.setCode("hhcj-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
@ -547,7 +540,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(plcGateway);
// IBP盘
ProjectDevice ibp = new ProjectDevice();
ibp.setProjectCode("RICHOR_HHCJ");
ibp.setProjectCode(Project.RICHOR_HHCJ.name());
ibp.setCode("hhcj-ibp");
ibp.setType(ProjectDeviceType.IBP.name());
ibp.setCreator(accountVO.getId());
@ -557,7 +550,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(ibp);
// PSD
ProjectDevice psd = new ProjectDevice();
psd.setProjectCode("RICHOR_HHCJ");
psd.setProjectCode(Project.RICHOR_HHCJ.name());
psd.setCode("hhcj-psd");
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
@ -574,7 +567,7 @@ public class DeviceServiceImpl implements DeviceService {
List<ProjectDevice> list = new ArrayList<>();
//UDP下位机
ProjectDevice udp = new ProjectDevice();
udp.setProjectCode("SR_SANDBOX");
udp.setProjectCode(Project.SR_SANDBOX.name());
udp.setCode("sr-udp");
udp.setType(ProjectDeviceType.UDP_LOW.name());
udp.setCreator(accountVO.getId());
@ -584,7 +577,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(udp);
//UDP客户端
ProjectDevice udpClient = new ProjectDevice();
udpClient.setProjectCode("SR_SANDBOX");
udpClient.setProjectCode(Project.SR_SANDBOX.name());
udpClient.setCode("sr-udp-client");
udpClient.setType(ProjectDeviceType.UDP_CLIENT.name());
udpClient.setCreator(accountVO.getId());
@ -599,7 +592,7 @@ public class DeviceServiceImpl implements DeviceService {
for (MapSignalNewVO mapSignalNewVO : graphDataNew.getSignalList()) {
if (StringUtils.hasText(mapSignalNewVO.getSrCode())) {
ProjectDevice signal = new ProjectDevice();
signal.setProjectCode("SR_SANDBOX");
signal.setProjectCode(Project.SR_SANDBOX.name());
signal.setCode("sr-signal-" + mapSignalNewVO.getCode());
signal.setType(ProjectDeviceType.SIGNAL.name());
signal.setCreator(accountVO.getId());
@ -613,7 +606,7 @@ public class DeviceServiceImpl implements DeviceService {
for (MapSwitchVO mapSwitchVO : graphDataNew.getSwitchList()) {
if (StringUtils.hasText(mapSwitchVO.getSrCode())) {
ProjectDevice aSwitch = new ProjectDevice();
aSwitch.setProjectCode("SR_SANDBOX");
aSwitch.setProjectCode(Project.SR_SANDBOX.name());
aSwitch.setCode("sr-switch-" + mapSwitchVO.getCode());
aSwitch.setType(ProjectDeviceType.SWITCH.name());
aSwitch.setCreator(accountVO.getId());
@ -627,7 +620,7 @@ public class DeviceServiceImpl implements DeviceService {
for (MapSectionNewVO mapSectionNewVO : graphDataNew.getSectionList()) {
if (StringUtils.hasText(mapSectionNewVO.getSrCode())) {
ProjectDevice section = new ProjectDevice();
section.setProjectCode("SR_SANDBOX");
section.setProjectCode(Project.SR_SANDBOX.name());
section.setCode("sr-section-" + mapSectionNewVO.getCode());
section.setType(ProjectDeviceType.SECTION.name());
section.setCreator(accountVO.getId());
@ -642,7 +635,7 @@ public class DeviceServiceImpl implements DeviceService {
List<MapTrainVO> trainList = graphDataNew.getTrainList();
for (MapTrainVO mapTrainVO : trainList) {
ProjectDevice train = new ProjectDevice();
train.setProjectCode("SR_SANDBOX");
train.setProjectCode(Project.SR_SANDBOX.name());
train.setCode("sr-train-" + mapTrainVO.getGroupNumber());
train.setType(ProjectDeviceType.TRAIN.name());
train.setCreator(accountVO.getId());
@ -714,7 +707,7 @@ public class DeviceServiceImpl implements DeviceService {
List<ProjectDevice> list = new ArrayList<>();
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode("RICHOR_JOINT");
plcGateway.setProjectCode(Project.RICHOR_JOINT.name());
plcGateway.setCode("zjd-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
@ -724,7 +717,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(plcGateway);
// 屏蔽门
ProjectDevice psd = new ProjectDevice();
psd.setProjectCode("RICHOR_JOINT");
psd.setProjectCode(Project.RICHOR_JOINT.name());
psd.setCode("zjd-psd");
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
@ -734,7 +727,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(psd);
// IBP盘
ProjectDevice ibp = new ProjectDevice();
ibp.setProjectCode("RICHOR_JOINT");
ibp.setProjectCode(Project.RICHOR_JOINT.name());
ibp.setCode("zjd-ibp");
ibp.setType(ProjectDeviceType.IBP.name());
ibp.setCreator(accountVO.getId());
@ -744,7 +737,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(ibp);
// PSL
ProjectDevice psl = new ProjectDevice();
psl.setProjectCode("RICHOR_JOINT");
psl.setProjectCode(Project.RICHOR_JOINT.name());
psl.setCode("zjd-psl");
psl.setType(ProjectDeviceType.PSL.name());
psl.setCreator(accountVO.getId());
@ -762,7 +755,7 @@ public class DeviceServiceImpl implements DeviceService {
// list.add(buildIm(Project.SDY, userVO.getId()));
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode("SDY");
plcGateway.setProjectCode(Project.SDY.name());
plcGateway.setCode("sdy-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
@ -772,7 +765,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(plcGateway);
// 屏蔽门
ProjectDevice psd = new ProjectDevice();
psd.setProjectCode("SDY");
psd.setProjectCode(Project.SDY.name());
psd.setCode("sdy-psd");
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
@ -782,7 +775,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(psd);
// PSL盘
ProjectDevice psl = new ProjectDevice();
psl.setProjectCode("SDY");
psl.setProjectCode(Project.SDY.name());
psl.setCode("sdy-psl");
psl.setType(ProjectDeviceType.PSL.name());
psl.setCreator(accountVO.getId());
@ -808,7 +801,7 @@ public class DeviceServiceImpl implements DeviceService {
List<ProjectDevice> list = new ArrayList<>();
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode("GZB");
plcGateway.setProjectCode(Project.GZB.name());
plcGateway.setCode("gzb-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
@ -818,7 +811,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(plcGateway);
// 道岔
ProjectDevice switchA = new ProjectDevice();
switchA.setProjectCode("GZB");
switchA.setProjectCode(Project.GZB.name());
switchA.setCode("gzb-switch");
switchA.setType(ProjectDeviceType.SWITCH.name());
switchA.setCreator(accountVO.getId());
@ -828,7 +821,7 @@ public class DeviceServiceImpl implements DeviceService {
list.add(switchA);
// 信号机
ProjectDevice signal = new ProjectDevice();
signal.setProjectCode("GZB");
signal.setProjectCode(Project.GZB.name());
signal.setCode("gzb-signal");
signal.setType(ProjectDeviceType.SIGNAL.name());
signal.setCreator(accountVO.getId());