Browse Source

优化充电桩厂家

Your Name 3 years ago
parent
commit
7deaa1f768

+ 32 - 16
java110-bean/src/main/java/com/java110/dto/chargeMachinePort/ChargeMachinePortDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.chargeMachinePort;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -14,12 +15,16 @@ import java.util.Date;
  **/
 public class ChargeMachinePortDto extends PageDto implements Serializable {
 
+    public static final String STATE_FREE = "FREE";//设备插座工作状态,FREE 空闲,WORKING 忙碌,BREAKDOWN 故障
+    public static final String STATE_WORKING = "WORKING";//设备插座工作状态,FREE 空闲,WORKING 忙碌,BREAKDOWN 故障
+    public static final String STATE_BREAKDOWN = "BREAKDOWN";//设备插座工作状态,FREE 空闲,WORKING 忙碌,BREAKDOWN 故障
+
     private String machineId;
-private String portName;
-private String state;
-private String portId;
-private String portCode;
-private String communityId;
+    private String portName;
+    private String state;
+    private String portId;
+    private String portCode;
+    private String communityId;
 
 
     private Date createTime;
@@ -30,37 +35,48 @@ private String communityId;
     public String getMachineId() {
         return machineId;
     }
-public void setMachineId(String machineId) {
+
+    public void setMachineId(String machineId) {
         this.machineId = machineId;
     }
-public String getPortName() {
+
+    public String getPortName() {
         return portName;
     }
-public void setPortName(String portName) {
+
+    public void setPortName(String portName) {
         this.portName = portName;
     }
-public String getState() {
+
+    public String getState() {
         return state;
     }
-public void setState(String state) {
+
+    public void setState(String state) {
         this.state = state;
     }
-public String getPortId() {
+
+    public String getPortId() {
         return portId;
     }
-public void setPortId(String portId) {
+
+    public void setPortId(String portId) {
         this.portId = portId;
     }
-public String getPortCode() {
+
+    public String getPortCode() {
         return portCode;
     }
-public void setPortCode(String portCode) {
+
+    public void setPortCode(String portCode) {
         this.portCode = portCode;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
 

+ 73 - 0
service-common/src/main/java/com/java110/common/cmd/chargeMachine/SaveChargeMachineCmd.java

@@ -15,6 +15,7 @@
  */
 package com.java110.common.cmd.chargeMachine;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
@@ -22,8 +23,14 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.chargeMachinePort.ChargeMachinePortDto;
+import com.java110.intf.common.IChargeMachinePortV1InnerServiceSMO;
+import com.java110.intf.common.IChargeMachineSpecV1InnerServiceSMO;
 import com.java110.intf.common.IChargeMachineV1InnerServiceSMO;
 import com.java110.po.chargeMachine.ChargeMachinePo;
+import com.java110.po.chargeMachinePort.ChargeMachinePortPo;
+import com.java110.po.chargeMachineSpec.ChargeMachineSpecPo;
+import com.java110.po.meterMachineSpec.MeterMachineSpecPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -53,6 +60,12 @@ public class SaveChargeMachineCmd extends Cmd {
     @Autowired
     private IChargeMachineV1InnerServiceSMO chargeMachineV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IChargeMachinePortV1InnerServiceSMO chargeMachinePortV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IChargeMachineSpecV1InnerServiceSMO chargeMachineSpecV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "machineName", "请求报文中未包含machineName");
@@ -61,6 +74,22 @@ public class SaveChargeMachineCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "durationPrice", "请求报文中未包含durationPrice");
         Assert.hasKeyAndValue(reqJson, "energyPrice", "请求报文中未包含energyPrice");
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "portCount", "请求报文中未包含portCount");
+
+
+        JSONArray specs = reqJson.getJSONArray("specs");
+        if (specs == null || specs.size() < 1) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONObject specObj = null;
+        for (int specIndex = 0; specIndex < specs.size(); specIndex++) {
+            specObj = specs.getJSONObject(specIndex);
+
+            Assert.hasKeyAndValue(specObj, "specValue", "未包含" + specObj.getString("specName"));
+        }
 
     }
 
@@ -77,6 +106,50 @@ public class SaveChargeMachineCmd extends Cmd {
             throw new CmdException("保存数据失败");
         }
 
+        int portCount = reqJson.getIntValue("portCount");
+        ChargeMachinePortPo chargeMachinePortPo = null;
+        for (int portIndex = 0; portIndex < portCount; portIndex++) {
+            chargeMachinePortPo = new ChargeMachinePortPo();
+            chargeMachinePortPo.setMachineId(chargeMachinePo.getMachineId());
+            chargeMachinePortPo.setPortId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+            chargeMachinePortPo.setPortCode((portIndex + 1) + "");
+            chargeMachinePortPo.setPortName((portIndex + 1) + "号插座");
+            chargeMachinePortPo.setCommunityId(chargeMachinePo.getCommunityId());
+            chargeMachinePortPo.setState(ChargeMachinePortDto.STATE_FREE);
+            chargeMachinePortV1InnerServiceSMOImpl.saveChargeMachinePort(chargeMachinePortPo);
+        }
+
+        if (!reqJson.containsKey("specs")) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONArray specs = reqJson.getJSONArray("specs");
+        if (specs == null || specs.size() < 1) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONObject specObj = null;
+        ChargeMachineSpecPo chargeMachineSpecPo = null;
+        for (int specIndex = 0; specIndex < specs.size(); specIndex++) {
+            specObj = specs.getJSONObject(specIndex);
+            chargeMachineSpecPo = new ChargeMachineSpecPo();
+            chargeMachineSpecPo.setMachineId(chargeMachinePo.getMachineId());
+            chargeMachineSpecPo.setSpecId(specObj.getString("specId"));
+            chargeMachineSpecPo.setSpecName(specObj.getString("specName"));
+            chargeMachineSpecPo.setSpecValue(specObj.getString("specValue"));
+            chargeMachineSpecPo.setCmsId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+            chargeMachineSpecPo.setCommunityId(chargeMachinePo.getCommunityId());
+            flag = chargeMachineSpecV1InnerServiceSMOImpl.saveChargeMachineSpec(chargeMachineSpecPo);
+
+            if (flag < 1) {
+                throw new CmdException("保存数据失败");
+            }
+        }
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 51 - 0
service-common/src/main/java/com/java110/common/cmd/chargeMachine/UpdateChargeMachineCmd.java

@@ -15,6 +15,7 @@
  */
 package com.java110.common.cmd.chargeMachine;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
@@ -22,8 +23,10 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.common.IChargeMachineSpecV1InnerServiceSMO;
 import com.java110.intf.common.IChargeMachineV1InnerServiceSMO;
 import com.java110.po.chargeMachine.ChargeMachinePo;
+import com.java110.po.chargeMachineSpec.ChargeMachineSpecPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -52,11 +55,28 @@ public class UpdateChargeMachineCmd extends Cmd {
     @Autowired
     private IChargeMachineV1InnerServiceSMO chargeMachineV1InnerServiceSMOImpl;
 
+
+    @Autowired
+    private IChargeMachineSpecV1InnerServiceSMO chargeMachineSpecV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "machineId", "machineId不能为空");
         Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
 
+        JSONArray specs = reqJson.getJSONArray("specs");
+        if (specs == null || specs.size() < 1) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONObject specObj = null;
+        for (int specIndex = 0; specIndex < specs.size(); specIndex++) {
+            specObj = specs.getJSONObject(specIndex);
+
+            Assert.hasKeyAndValue(specObj, "specValue", "未包含" + specObj.getString("specName"));
+        }
     }
 
     @Override
@@ -70,6 +90,37 @@ public class UpdateChargeMachineCmd extends Cmd {
             throw new CmdException("更新数据失败");
         }
 
+        if (!reqJson.containsKey("specs")) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONArray specs = reqJson.getJSONArray("specs");
+        if (specs == null || specs.size() < 1) {
+            cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+            return;
+        }
+
+        JSONObject specObj = null;
+        ChargeMachineSpecPo chargeMachineSpecPo = null;
+        for (int specIndex = 0; specIndex < specs.size(); specIndex++) {
+            specObj = specs.getJSONObject(specIndex);
+            chargeMachineSpecPo = new ChargeMachineSpecPo();
+            chargeMachineSpecPo.setMachineId(chargeMachinePo.getMachineId());
+            chargeMachineSpecPo.setSpecId(specObj.getString("specId"));
+            chargeMachineSpecPo.setSpecName(specObj.getString("specName"));
+            chargeMachineSpecPo.setSpecValue(specObj.getString("specValue"));
+            chargeMachineSpecPo.setCmsId(specObj.getString("cmsId"));
+            chargeMachineSpecPo.setCommunityId(chargeMachinePo.getCommunityId());
+            flag = chargeMachineSpecV1InnerServiceSMOImpl.updateChargeMachineSpec(chargeMachineSpecPo);
+
+            if (flag < 1) {
+                throw new CmdException("保存数据失败");
+            }
+        }
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }