Bladeren bron

加入设备方向

wuxw 6 jaren geleden
bovenliggende
commit
b0a8c9dfac

+ 1 - 0
Api/src/main/java/com/java110/api/listener/machine/SaveMachineListener.java

@@ -32,6 +32,7 @@ public class SaveMachineListener extends AbstractServiceApiListener {
         Assert.hasKeyAndValue(reqJson, "machineVersion", "必填,请填写设备版本号");
         Assert.hasKeyAndValue(reqJson, "machineName", "必填,请填写设备名称");
         Assert.hasKeyAndValue(reqJson, "machineTypeCd", "必填,请选择设备类型");
+        Assert.hasKeyAndValue(reqJson, "direction", "必填,请选择设备方向");
         Assert.hasKeyAndValue(reqJson, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(reqJson, "locationTypeCd", "必填,请选择位置类型");
         Assert.hasKeyAndValue(reqJson, "locationObjId", "必填,请填写位置对象ID");

+ 1 - 0
Api/src/main/java/com/java110/api/listener/machine/UpdateMachineListener.java

@@ -36,6 +36,7 @@ public class UpdateMachineListener extends AbstractServiceApiListener {
         Assert.hasKeyAndValue(reqJson, "machineVersion", "必填,请填写设备版本号");
         Assert.hasKeyAndValue(reqJson, "machineName", "必填,请填写设备名称");
         Assert.hasKeyAndValue(reqJson, "machineTypeCd", "必填,请选择设备类型");
+        Assert.hasKeyAndValue(reqJson, "direction", "必填,请选择设备方向");
         Assert.hasKeyAndValue(reqJson, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(reqJson, "locationTypeCd", "必填,请选择位置类型");
         Assert.hasKeyAndValue(reqJson, "locationObjId", "必填,请填写位置对象ID");

+ 88 - 0
Api/src/main/java/com/java110/api/listener/machineTranslate/MachineRoadGateOpenListener.java

@@ -0,0 +1,88 @@
+package com.java110.api.listener.machineTranslate;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.hardwareAdapation.IMachineInnerServiceSMO;
+import com.java110.dto.hardwareAdapation.MachineDto;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeMachineTranslateConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName MachineRoadGateOpenListener
+ * @Description 道闸开门侦听类
+ * @Author wuxw
+ * @Date 2020/1/25 21:50
+ * @Version 1.0
+ * add by wuxw 2020/1/25
+ **/
+@Java110Listener("machineRoadGateOpenListener")
+public class MachineRoadGateOpenListener extends BaseMachineListener {
+
+    @Autowired
+    private IMachineInnerServiceSMO machineInnerServiceSMOImpl;
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+
+        super.validateMachineHeader(event, reqJson);
+
+        Assert.hasKeyAndValue(reqJson, "carNum", "请求报文中未包含车牌号");
+
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        JSONObject outParam = null;
+        ResponseEntity<String> responseEntity = null;
+        Map<String, String> reqHeader = context.getRequestHeaders();
+        String communityId = reqHeader.get("communityId");
+        String machineCode = reqHeader.get("machinecode");
+        HttpHeaders headers = new HttpHeaders();
+        for (String key : reqHeader.keySet()) {
+            if (key.toLowerCase().equals("content-length")) {
+                continue;
+            }
+            headers.add(key, reqHeader.get(key));
+        }
+        //根据设备编码查询 设备信息
+        MachineDto machineDto = new MachineDto();
+        machineDto.setMachineCode(machineCode);
+        machineDto.setCommunityId(communityId);
+        List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
+        if (machineDtos == null || machineDtos.size() < 1) {
+            outParam.put("code", -1);
+            outParam.put("message", "该设备【" + machineCode + "】未在该小区【" + communityId + "】注册");
+            responseEntity = new ResponseEntity<>(outParam.toJSONString(), headers, HttpStatus.OK);
+            context.setResponseEntity(responseEntity);
+            return ;
+        }
+
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeMachineTranslateConstant.MACHINE_ROAD_GATE_OPEN;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+}

+ 1 - 0
WebService/src/main/java/com/java110/web/smo/machine/impl/AddMachineSMOImpl.java

@@ -34,6 +34,7 @@ public class AddMachineSMOImpl extends AbstractComponentSMO implements IAddMachi
         Assert.hasKeyAndValue(paramIn, "machineVersion", "必填,请填写设备版本号");
         Assert.hasKeyAndValue(paramIn, "machineName", "必填,请填写设备名称");
         Assert.hasKeyAndValue(paramIn, "machineTypeCd", "必填,请选择设备类型");
+        Assert.hasKeyAndValue(paramIn, "direction", "必填,请选择设备方向");
         Assert.hasKeyAndValue(paramIn, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(paramIn, "locationTypeCd", "必填,请选择位置类型");
         Assert.hasKeyAndValue(paramIn, "locationObjId", "必填,请填写位置对象ID");

+ 1 - 0
WebService/src/main/java/com/java110/web/smo/machine/impl/EditMachineSMOImpl.java

@@ -33,6 +33,7 @@ public class EditMachineSMOImpl extends AbstractComponentSMO implements IEditMac
         Assert.hasKeyAndValue(paramIn, "machineVersion", "必填,请填写设备版本号");
         Assert.hasKeyAndValue(paramIn, "machineName", "必填,请填写设备名称");
         Assert.hasKeyAndValue(paramIn, "machineTypeCd", "必填,请选择设备类型");
+        Assert.hasKeyAndValue(paramIn, "direction", "必填,请选择设备方向");
         Assert.hasKeyAndValue(paramIn, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(paramIn, "locationTypeCd", "必填,请选择位置类型");
         Assert.hasKeyAndValue(paramIn, "locationObjId", "必填,请填写位置对象ID");

+ 9 - 0
WebService/src/main/resources/components/machinePackage/add-machine/addMachine.html

@@ -39,6 +39,15 @@
                                         <option value="9996">车辆道闸</option>
                                     </select></div>
                             </div>
+                            <div class="form-group row">
+                                <label class="col-sm-2 col-form-label">设备方向</label>
+                                <div class="col-sm-10">
+                                    <select class="custom-select" v-model="addMachineInfo.direction">
+                                        <option selected disabled value="">必填,请选择设备方向</option>
+                                        <option value="3306">进入</option>
+                                        <option value="3307">出去</option>
+                                    </select></div>
+                            </div>
                             <div class="form-group row">
                                 <label class="col-sm-2 col-form-label">鉴权编码</label>
                                 <div class="col-sm-10">

+ 16 - 2
WebService/src/main/resources/components/machinePackage/add-machine/addMachine.js

@@ -23,7 +23,8 @@
                 roomId: '',
                 locationTypeCd: '',
                 locationObjId: '',
-                roomName: ''
+                roomName: '',
+                direction:''
             }
         },
         _initMethod: function () {
@@ -91,6 +92,19 @@
                                 errInfo: "设备类型格式错误"
                             },
                         ],
+                        'addMachineInfo.direction':
+                        [
+                            {
+                                limit: "required",
+                                param: "",
+                                errInfo: "设备方向不能为空"
+                            },
+                            {
+                                limit: "num",
+                                param: "",
+                                errInfo: "设备方向格式错误"
+                            },
+                        ],
                     'addMachineInfo.authCode':
                         [
                             {
@@ -201,7 +215,7 @@
                     authCode: '',
                     machineIp: '',
                     machineMac: '',
-
+                    direction:''
                 };
             },
             _initAddMachineData: function () {

+ 9 - 0
WebService/src/main/resources/components/machinePackage/edit-machine/editMachine.html

@@ -38,6 +38,15 @@
                                         <option value="9996">车辆道闸</option>
                                     </select></div>
                             </div>
+                            <div class="form-group row">
+                                <label class="col-sm-2 col-form-label">设备方向</label>
+                                <div class="col-sm-10">
+                                    <select class="custom-select" v-model="editMachineInfo.direction">
+                                        <option selected disabled value="">必填,请选择设备方向</option>
+                                        <option value="3306">进入</option>
+                                        <option value="3307">出去</option>
+                                    </select></div>
+                            </div>
                             <div class="form-group row">
                                 <label class="col-sm-2 col-form-label">鉴权编码</label>
                                 <div class="col-sm-10">

+ 16 - 1
WebService/src/main/resources/components/machinePackage/edit-machine/editMachine.js

@@ -21,6 +21,7 @@
                 locationObjId: '',
                 roomNum: '',
                 machineUrl: '',
+                direction:''
 
             }
         },
@@ -138,6 +139,19 @@
                                 errInfo: "设备类型格式错误"
                             },
                         ],
+                    'editMachineInfo.direction':
+                    [
+                        {
+                            limit: "required",
+                            param: "",
+                            errInfo: "设备方向不能为空"
+                        },
+                        {
+                            limit: "num",
+                            param: "",
+                            errInfo: "设备方向格式错误"
+                        },
+                    ],
                     'editMachineInfo.authCode':
                         [
                             {
@@ -253,7 +267,8 @@
                     locationTypeCd: '',
                     locationObjId: '',
                     roomNum: '',
-                    machineUrl: ''
+                    machineUrl: '',
+                     direction:''
 
                 }
             }

+ 3 - 0
WebService/src/main/resources/components/machinePackage/machine-manage/machineManage.html

@@ -20,6 +20,7 @@
                                 <option selected value="">请选择设备类型</option>
                                 <option value="992019111002270001">锐目门禁</option>
                                 <option value="9998">其他</option>
+                                <option value="9996">车辆道闸</option>
                             </select></div>
                         <div class="col-sm-3">
                             <div class="form-group">
@@ -75,6 +76,7 @@
                             <th class="text-center">设备名称</th>
                             <th class="text-center">设备类型</th>
                             <th class="text-center">设备位置</th>
+                            <th class="text-center">方向</th>
                             <th class="text-center">状态</th>
                             <th class="text-center">时间</th>
 <!--                            <th class="text-center">设备MAC</th>-->
@@ -90,6 +92,7 @@
                             <td class="text-center">{{machine.machineName}}</td>
                             <td class="text-center">{{machine.machineTypeCdName}}</td>
                             <td class="text-center">{{machine.locationObjName}}</td>
+                            <td class="text-center">{{machine.directionName}}</td>
                             <td class="text-center">{{machine.stateName}}</td>
                            <td class="text-center">{{machine.createTime}}</td>
                            <!--<td class="text-center">{{machine.machineMac}}</td>-->

+ 18 - 0
java110-bean/src/main/java/com/java110/dto/hardwareAdapation/MachineDto.java

@@ -39,6 +39,8 @@ public class MachineDto extends PageDto implements Serializable {
     private String roomId;
     private String roomNum;
     private String locationObjName;
+    private String direction;//设备方向
+    private String directionName;
 
 
 
@@ -255,4 +257,20 @@ public class MachineDto extends PageDto implements Serializable {
     public void setLocationObjIds(String[] locationObjIds) {
         this.locationObjIds = locationObjIds;
     }
+
+    public String getDirection() {
+        return direction;
+    }
+
+    public void setDirection(String direction) {
+        this.direction = direction;
+    }
+
+    public String getDirectionName() {
+        return directionName;
+    }
+
+    public void setDirectionName(String directionName) {
+        this.directionName = directionName;
+    }
 }

+ 19 - 0
java110-bean/src/main/java/com/java110/vo/api/machine/ApiMachineDataVo.java

@@ -27,6 +27,9 @@ public class ApiMachineDataVo implements Serializable {
     private String roomId;
     private String roomNum;
     private String locationObjName;
+    private String direction;
+    private String directionName;
+
 
     private String createTime;
 
@@ -197,4 +200,20 @@ public class ApiMachineDataVo implements Serializable {
     public void setCreateTime(String createTime) {
         this.createTime = createTime;
     }
+
+    public String getDirection() {
+        return direction;
+    }
+
+    public void setDirection(String direction) {
+        this.direction = direction;
+    }
+
+    public String getDirectionName() {
+        return directionName;
+    }
+
+    public void setDirectionName(String directionName) {
+        this.directionName = directionName;
+    }
 }

+ 35 - 15
java110-db/src/main/resources/mapper/hardwareAdapation/MachineServiceDaoImplMapper.xml

@@ -6,15 +6,15 @@
 
     <!-- 保存设备信息 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessMachineInfo" parameterType="Map">
-           insert into business_machine(
-machine_mac,machine_id,machine_code,auth_code,operate,machine_version,community_id,b_id,
-machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
-) values (
-#{machineMac},#{machineId},#{machineCode},#{authCode},#{operate},#{machineVersion},
-#{communityId},#{bId},#{machineName},#{machineTypeCd},#{machineIp},
-#{locationTypeCd},#{locationObjId},#{state}
-)
-       </insert>
+        insert into business_machine(
+        machine_mac,machine_id,machine_code,auth_code,operate,machine_version,community_id,b_id,
+        machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state,direction
+        ) values (
+        #{machineMac},#{machineId},#{machineCode},#{authCode},#{operate},#{machineVersion},
+        #{communityId},#{bId},#{machineName},#{machineTypeCd},#{machineIp},
+        #{locationTypeCd},#{locationObjId},#{state},#{direction}
+        )
+    </insert>
 
 
     <!-- 查询设备信息(Business) add by wuxw 2018-07-03 -->
@@ -23,7 +23,8 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         machineCode,t.auth_code,t.auth_code authCode,t.operate,t.machine_version,t.machine_version
         machineVersion,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.machine_name,t.machine_name
         machineName,t.machine_type_cd,t.machine_type_cd machineTypeCd,t.machine_ip,t.machine_ip machineIp,
-        t.location_type_cd,t.location_obj_id,t.state,t.location_type_cd,t.location_obj_id,t.location_type_cd locationTypeCd,t.location_obj_id locationObjId
+        t.location_type_cd,t.location_obj_id,t.state,t.location_type_cd,t.location_obj_id,t.location_type_cd
+        locationTypeCd,t.location_obj_id locationObjId,t.direction
         from business_machine t
         where 1 =1
         <if test="machineMac !=null and machineMac != ''">
@@ -69,6 +70,10 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         <if test="state !=null and state != ''">
             and t.state = #{state}
         </if>
+        <if test="direction !=null and direction != ''">
+            and t.direction = #{direction}
+        </if>
+
 
     </select>
 
@@ -78,11 +83,11 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         insert into machine(
         machine_mac,machine_id,machine_code,auth_code,machine_version,status_cd,
         community_id,b_id,machine_name,machine_type_cd,machine_ip,
-        location_type_cd,location_obj_id,state
+        location_type_cd,location_obj_id,state,direction
         ) select
         t.machine_mac,t.machine_id,t.machine_code,t.auth_code,t.machine_version,'0',t.community_id,t.b_id,
         t.machine_name,t.machine_type_cd,t.machine_ip,
-        t.location_type_cd,t.location_obj_id,t.state
+        t.location_type_cd,t.location_obj_id,t.state,t.direction
         from business_machine t where 1=1
         <if test="machineMac !=null and machineMac != ''">
             and t.machine_mac= #{machineMac}
@@ -125,6 +130,9 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         <if test="state !=null and state != ''">
             and t.state = #{state}
         </if>
+        <if test="direction !=null and direction != ''">
+            and t.direction = #{direction}
+        </if>
 
     </insert>
 
@@ -138,8 +146,8 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         machineTypeCd,t.machine_ip,t.machine_ip machineIp,td.name machineTypeCdName,
         t.state,t.location_type_cd locationTypeCd,t.location_obj_id locationObjId,
         t.location_type_cd,t.location_obj_id,
-        td1.name stateName,td2.name locationTypeName,t.create_time createTime
-        from machine t,t_dict td,t_dict td1,t_dict td2
+        td1.name stateName,td2.name locationTypeName,t.create_time createTime,t.direction,td3.name directionName
+        from machine t,t_dict td,t_dict td1,t_dict td2,t_dict td3
         where 1 =1
         and t.machine_type_cd=td.status_cd
         and td.table_name='machine'
@@ -150,6 +158,9 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         and t.location_type_cd = td2.status_cd
         and td2.table_name='machine'
         and td2.table_columns='location_type_cd'
+        and t.direction = td3.status_cd
+        and td3.table_name='machine'
+        and td3.table_columns='direction'
         <if test="machineMac !=null and machineMac != ''">
             and t.machine_mac= #{machineMac}
         </if>
@@ -198,6 +209,9 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         <if test="state !=null and state != ''">
             and t.state = #{state}
         </if>
+        <if test="direction !=null and direction != ''">
+            and t.direction = #{direction}
+        </if>
         order by t.create_time desc
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
@@ -245,6 +259,9 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         <if test="state !=null and state != ''">
             , t.state = #{state}
         </if>
+        <if test="direction !=null and direction != ''">
+            , t.direction = #{direction}
+        </if>
         where 1=1
         <if test="machineId !=null and machineId != ''">
             and t.machine_id= #{machineId}
@@ -258,7 +275,7 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
     <!-- 查询设备数量 add by wuxw 2018-07-03 -->
     <select id="queryMachinesCount" parameterType="Map" resultType="Map">
         select count(1) count
-        from machine t,t_dict td,t_dict td1,t_dict td2
+        from machine t,t_dict td,t_dict td1,t_dict td2,t_dict td3
         where 1 =1
         and t.machine_type_cd=td.status_cd
         and td.table_name='machine'
@@ -269,6 +286,9 @@ machine_name,machine_type_cd,machine_ip,location_type_cd,location_obj_id,state
         and t.location_type_cd = td2.status_cd
         and td2.table_name='machine'
         and td2.table_columns='location_type_cd'
+        and t.direction = td3.status_cd
+        and td3.table_name='machine'
+        and td3.table_columns='direction'
         <if test="machineMac !=null and machineMac != ''">
             and t.machine_mac= #{machineMac}
         </if>

+ 5 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeMachineTranslateConstant.java

@@ -52,5 +52,10 @@ public class ServiceCodeMachineTranslateConstant {
      */
     public static final String MACHINE_CMD_RESULT = "machineTranslate.machineCmdResult";
 
+    /**
+     * 道闸开门
+     */
+    public static final String MACHINE_ROAD_GATE_OPEN = "machineTranslate.machineRoadGateOpen";
+
 
 }