【字符串修改成枚举】

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