Преглед изворни кода

优化 HC小区管理系统加入 道闸控制台工鞥

java110 пре 4 година
родитељ
комит
7a27efc7ee

+ 3 - 0
java110-interface/src/main/java/com/java110/intf/job/IDataBusInnerServiceSMO.java

@@ -86,4 +86,7 @@ public interface IDataBusInnerServiceSMO {
 
     @RequestMapping(value = "/getQRcode", method = RequestMethod.POST)
     ResultVo getQRcode(@RequestBody JSONObject reqJson);
+
+    @RequestMapping(value = "/customCarInOut", method = RequestMethod.POST)
+    ResultVo customCarInOut(@RequestBody JSONObject reqJson);
 }

+ 1 - 0
service-common/src/main/java/com/java110/common/api/MachineApi.java

@@ -63,6 +63,7 @@ public class MachineApi {
         return machineOpenDoorBMOImpl.openDoor(reqJson);
     }
 
+
     /**
      * 设备二维码
      *

+ 7 - 0
service-common/src/main/java/com/java110/common/bmo/machine/IMachineOpenDoorBMO.java

@@ -50,4 +50,11 @@ public interface IMachineOpenDoorBMO {
      * @return
      */
     ResponseEntity<String> getQRcode(JSONObject reqJson);
+
+    /**
+     * 手工进出场
+     * @param reqJson
+     * @return
+     */
+    ResponseEntity<String> customCarInOut(JSONObject reqJson);
 }

+ 6 - 0
service-common/src/main/java/com/java110/common/bmo/machine/impl/MachineOpenDoorBMOImpl.java

@@ -139,4 +139,10 @@ public class MachineOpenDoorBMOImpl implements IMachineOpenDoorBMO {
         ResultVo resultVo = dataBusInnerServiceSMOImpl.getQRcode(reqJson);
         return ResultVo.createResponseEntity(resultVo.getCode(), resultVo.getMsg(), resultVo.getData());
     }
+
+    @Override
+    public ResponseEntity<String> customCarInOut(JSONObject reqJson) {
+        ResultVo resultVo = dataBusInnerServiceSMOImpl.customCarInOut(reqJson);
+        return ResultVo.createResponseEntity(resultVo);
+    }
 }

+ 66 - 0
service-common/src/main/java/com/java110/common/cmd/machine/CustomCarInOutCmd.java

@@ -0,0 +1,66 @@
+/*
+ * 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.machine;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.bmo.machine.IMachineOpenDoorBMO;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 类表述:保存
+ * 服务编码:machine.customCarInOutCmd
+ * 请求路劲:/app/machine.customCarInOutCmd
+ * add by 吴学文 at 2021-09-18 13:35:13 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 = "machine.customCarInOutCmd")
+public class CustomCarInOutCmd extends AbstractServiceCmdListener {
+
+    private static Logger logger = LoggerFactory.getLogger(CustomCarInOutCmd.class);
+
+    public static final String CODE_PREFIX_ID = "10";
+
+    @Autowired
+    private IMachineOpenDoorBMO machineOpenDoorBMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
+        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
+        Assert.hasKeyAndValue(reqJson, "machineId", "请求报文中未包含设备信息");
+        Assert.hasKeyAndValue(reqJson, "carNum", "请求报文中未包含车牌号");
+        Assert.hasKeyAndValue(reqJson, "type", "请求报文中未包含类型");
+
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+
+        ResponseEntity<String> responseEntity = machineOpenDoorBMOImpl.customCarInOut(reqJson);
+        cmdDataFlowContext.setResponseEntity(responseEntity);
+    }
+}

+ 5 - 0
service-job/src/main/java/com/java110/job/adapt/DatabusAdaptImpl.java

@@ -56,6 +56,11 @@ public abstract class DatabusAdaptImpl implements IDatabusAdapt {
         return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
     }
 
+    @Override
+    public ResultVo customCarInOut(JSONObject reqJson) {
+        return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
+    }
+
     @Override
     public ResultVo getQRcode(JSONObject reqJson) {
         return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);

+ 1 - 0
service-job/src/main/java/com/java110/job/adapt/IDatabusAdapt.java

@@ -70,4 +70,5 @@ public interface IDatabusAdapt {
      */
     void customExchange(CustomBusinessDatabusDto customBusinessDatabusDto);
 
+    ResultVo customCarInOut(JSONObject reqJson);
 }

+ 3 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/IotConstant.java

@@ -78,6 +78,9 @@ public class IotConstant {
     //开门接口
     public static final String OPEN_DOOR = "/extApi/machine/openDoor";
 
+    //手动进出场
+    public static final String CUSTOM_CAR_INOUT = "/extApi/machine/customCarInOut";
+
     //获取二维码
     public static final String GET_QRCODE = "/extApi/machine/getQRcode";
     //重启接口

+ 34 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/OpenDoorAdapt.java

@@ -138,4 +138,38 @@ public class OpenDoorAdapt extends DatabusAdaptImpl {
         }
     }
 
+    /**
+     * 开门实现方法
+     *
+     * @param paramIn 业务信息
+     * @return
+     */
+    @Override
+    public ResultVo customCarInOut(JSONObject paramIn) {
+
+        MachineDto machineDto = new MachineDto();
+        machineDto.setMachineId(paramIn.getString("machineId"));
+        machineDto.setCommunityId(paramIn.getString("communityId"));
+        List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
+
+        Assert.listOnlyOne(machineDtos, "设备不存在");
+
+        JSONObject postParameters = new JSONObject();
+        postParameters.put("taskId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        postParameters.put("extMachineId", paramIn.getString("machineId"));
+        postParameters.put("carNum", paramIn.getString("carNum"));
+        postParameters.put("type", paramIn.getString("type"));
+        postParameters.put("amount", paramIn.getString("amount"));
+        postParameters.put("payCharge", paramIn.getString("payCharge"));
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders(outRestTemplate));
+        ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.getUrl(IotConstant.CUSTOM_CAR_INOUT), HttpMethod.POST, httpEntity, String.class);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return new ResultVo(ResultVo.CODE_ERROR, responseEntity.getBody());
+        }
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+
+        return new ResultVo(paramOut.getInteger("code"), paramOut.getString("msg"));
+
+    }
+
 }

+ 6 - 0
service-job/src/main/java/com/java110/job/smo/impl/DataBusInnerServiceSMOImpl.java

@@ -63,6 +63,12 @@ public class DataBusInnerServiceSMOImpl extends BaseServiceSMO implements IDataB
         return databusAdaptImpl.getQRcode(reqJson);
     }
 
+    @Override
+    public ResultVo customCarInOut(@RequestBody JSONObject reqJson) {
+        IDatabusAdapt databusAdaptImpl = ApplicationContextFactory.getBean(DEFAULT_OPEN_DOOR_PROTOCOL, IDatabusAdapt.class);
+        return databusAdaptImpl.customCarInOut(reqJson);
+    }
+
     @Override
     public ResultVo restartMachine(@RequestBody JSONObject reqJson) {
         IDatabusAdapt databusAdaptImpl = ApplicationContextFactory.getBean(DEFAULT_START_MACHINE_PROTOCOL, IDatabusAdapt.class);