From 7da40dfc8536c46b574024c23bcfb5f2504114d9 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 23 十月 2022 18:03:18 +0800
Subject: [PATCH] 优化代码
---
service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java b/service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java
index 8385731..059d64f 100644
--- a/service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java
+++ b/service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java
@@ -76,6 +76,14 @@
Assert.hasKeyAndValue(reqJson, "authCode", "蹇呭~锛岃濉啓閴存潈缂栫爜");
Assert.hasKeyAndValue(reqJson, "locationTypeCd", "蹇呭~锛岃閫夋嫨浣嶇疆绫诲瀷");
+ MachineDto machineDto = new MachineDto();
+ machineDto.setMachineCode(reqJson.getString("machineCode"));
+ int count = machineV1InnerServiceSMOImpl.queryMachinesCount(machineDto);
+
+ if (count > 0) {
+ throw new CmdException("璁惧宸插瓨鍦�");
+ }
+
//灞炴�ф牎楠�
Assert.judgeAttrValue(reqJson);
@@ -86,14 +94,14 @@
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
MachinePo machinePo = BeanConvertUtil.covertBean(reqJson, MachinePo.class);
- if(!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))){
+ if (!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))) {
CommunityLocationDto communityLocationDto = new CommunityLocationDto();
communityLocationDto.setCommunityId(reqJson.getString("communityId"));
communityLocationDto.setLocationId(reqJson.getString("locationTypeCd"));
List<CommunityLocationDto> locationDtos = communityLocationV1InnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
Assert.listOnlyOne(locationDtos, "浣嶇疆涓嶅瓨鍦�");
machinePo.setLocationObjId(locationDtos.get(0).getLocationObjId());
- }else{
+ } else {
machinePo.setLocationObjId("-1");
machinePo.setLocationTypeCd("-1");
}
@@ -107,12 +115,12 @@
throw new CmdException("淇濆瓨鏁版嵁澶辫触");
}
- dealMachineAttr(reqJson,machinePo);
+ dealMachineAttr(reqJson, machinePo);
cmdDataFlowContext.setResponseEntity(ResultVo.success());
}
- private void dealMachineAttr(JSONObject paramObj,MachinePo machinePo) {
+ private void dealMachineAttr(JSONObject paramObj, MachinePo machinePo) {
if (!paramObj.containsKey("attrs")) {
return;
--
Gitblit v1.8.0