Your Name лет назад: 3
Родитель
Сommit
5b734454ba

+ 9 - 0
java110-bean/src/main/java/com/java110/dto/chargeMachinePort/ChargeMachinePortDto.java

@@ -22,6 +22,7 @@ public class ChargeMachinePortDto extends PageDto implements Serializable {
     private String machineId;
     private String portName;
     private String state;
+    private String stateName;
     private String portId;
     private String portCode;
     private String communityId;
@@ -96,4 +97,12 @@ public class ChargeMachinePortDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getStateName() {
+        return stateName;
+    }
+
+    public void setStateName(String stateName) {
+        this.stateName = stateName;
+    }
 }

+ 28 - 12
service-common/src/main/java/com/java110/common/cmd/chargeMachine/ListChargeMachinePortCmd.java

@@ -27,8 +27,10 @@ import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.java110.dto.chargeMachinePort.ChargeMachinePortDto;
+
 import java.util.List;
 import java.util.ArrayList;
+
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.HttpStatus;
 import org.slf4j.Logger;
@@ -48,7 +50,7 @@ import org.slf4j.LoggerFactory;
 @Java110Cmd(serviceCode = "chargeMachine.listChargeMachinePort")
 public class ListChargeMachinePortCmd extends Cmd {
 
-  private static Logger logger = LoggerFactory.getLogger(ListChargeMachinePortCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(ListChargeMachinePortCmd.class);
     @Autowired
     private IChargeMachinePortV1InnerServiceSMO chargeMachinePortV1InnerServiceSMOImpl;
 
@@ -62,22 +64,36 @@ public class ListChargeMachinePortCmd extends Cmd {
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-           ChargeMachinePortDto chargeMachinePortDto = BeanConvertUtil.covertBean(reqJson, ChargeMachinePortDto.class);
+        ChargeMachinePortDto chargeMachinePortDto = BeanConvertUtil.covertBean(reqJson, ChargeMachinePortDto.class);
+
+        int count = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePortsCount(chargeMachinePortDto);
+
+        List<ChargeMachinePortDto> chargeMachinePortDtos = null;
 
-           int count = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePortsCount(chargeMachinePortDto);
+        if (count > 0) {
+            chargeMachinePortDtos = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePorts(chargeMachinePortDto);
 
-           List<ChargeMachinePortDto> chargeMachinePortDtos = null;
+            //调用 第三方查询 插槽状态
+            queryPortState(chargeMachinePortDtos);
+        } else {
+            chargeMachinePortDtos = new ArrayList<>();
+        }
 
-           if (count > 0) {
-               chargeMachinePortDtos = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePorts(chargeMachinePortDto);
-           } else {
-               chargeMachinePortDtos = new ArrayList<>();
-           }
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, chargeMachinePortDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        cmdDataFlowContext.setResponseEntity(responseEntity);
+    }
 
-           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, chargeMachinePortDtos);
+    private void queryPortState(List<ChargeMachinePortDto> chargeMachinePortDtos) {
+        if (chargeMachinePortDtos == null || chargeMachinePortDtos.size() < 1) {
+            return;
 
-           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        }
 
-           cmdDataFlowContext.setResponseEntity(responseEntity);
+        for (ChargeMachinePortDto chargeMachinePortDto : chargeMachinePortDtos) {
+            chargeMachinePortDto.setStateName("空闲");
+        }
     }
 }

+ 10 - 0
service-common/src/main/java/com/java110/common/cmd/chargeMachine/SaveChargeMachinePortCmd.java

@@ -22,6 +22,7 @@ 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.po.chargeMachinePort.ChargeMachinePortPo;
 import com.java110.utils.exception.CmdException;
@@ -60,6 +61,15 @@ public class SaveChargeMachinePortCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "state", "请求报文中未包含state");
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
 
+
+        ChargeMachinePortDto chargeMachinePortDto = new ChargeMachinePortDto();
+        chargeMachinePortDto.setMachineId(reqJson.getString("machineId"));
+        chargeMachinePortDto.setPortCode(reqJson.getString("portCode"));
+        chargeMachinePortDto.setCommunityId(reqJson.getString("communityId"));
+        int flag = chargeMachinePortV1InnerServiceSMOImpl.queryChargeMachinePortsCount(chargeMachinePortDto);
+        if (flag > 0) {
+            throw new CmdException("插座已经存在");
+        }
     }
 
     @Override

+ 0 - 74
service-common/src/main/java/com/java110/common/cmd/chargeMachine/UpdateChargeMachinePortCmd.java

@@ -1,74 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.common.cmd.chargeMachine;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.core.annotation.Java110Cmd;
-import com.java110.core.annotation.Java110Transactional;
-import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.Cmd;
-import com.java110.core.event.cmd.CmdEvent;
-import com.java110.intf.common.IChargeMachinePortV1InnerServiceSMO;
-import com.java110.po.chargeMachinePort.ChargeMachinePortPo;
-import com.java110.utils.exception.CmdException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * 类表述:更新
- * 服务编码:chargeMachinePort.updateChargeMachinePort
- * 请求路劲:/app/chargeMachinePort.UpdateChargeMachinePort
- * add by 吴学文 at 2023-03-02 01:17:43 mail: 928255095@qq.com
- * open source address: https://gitee.com/wuxw7/MicroCommunity
- * 官网:http://www.homecommunity.cn
- * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
- * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
- */
-@Java110Cmd(serviceCode = "chargeMachine.updateChargeMachinePort")
-public class UpdateChargeMachinePortCmd extends Cmd {
-
-    private static Logger logger = LoggerFactory.getLogger(UpdateChargeMachinePortCmd.class);
-
-
-    @Autowired
-    private IChargeMachinePortV1InnerServiceSMO chargeMachinePortV1InnerServiceSMOImpl;
-
-    @Override
-    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "portId", "portId不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
-
-    }
-
-    @Override
-    @Java110Transactional
-    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
-        ChargeMachinePortPo chargeMachinePortPo = BeanConvertUtil.covertBean(reqJson, ChargeMachinePortPo.class);
-        int flag = chargeMachinePortV1InnerServiceSMOImpl.updateChargeMachinePort(chargeMachinePortPo);
-
-        if (flag < 1) {
-            throw new CmdException("更新数据失败");
-        }
-
-        cmdDataFlowContext.setResponseEntity(ResultVo.success());
-    }
-}