闸机代码
parent
4919a6f1bb
commit
a25574ef1f
|
@ -3,14 +3,17 @@ package com.zcloud.controller.gatemachine;
|
||||||
import com.zcloud.controller.base.BaseController;
|
import com.zcloud.controller.base.BaseController;
|
||||||
import com.zcloud.entity.Page;
|
import com.zcloud.entity.Page;
|
||||||
import com.zcloud.entity.PageData;
|
import com.zcloud.entity.PageData;
|
||||||
|
import com.zcloud.service.doorDevice.DoorDeviceService;
|
||||||
import com.zcloud.service.gatemachine.GateMachineService;
|
import com.zcloud.service.gatemachine.GateMachineService;
|
||||||
import com.zcloud.util.Jurisdiction;
|
import com.zcloud.util.Jurisdiction;
|
||||||
import com.zcloud.util.ReturnMap;
|
import com.zcloud.util.ReturnMap;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 说明:TODO
|
* 说明:TODO
|
||||||
|
@ -23,8 +26,17 @@ public class GateMachineController extends BaseController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private GateMachineService gateMachineService;
|
private GateMachineService gateMachineService;
|
||||||
|
@Autowired
|
||||||
|
private DoorDeviceService doorDeviceService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/getDoorDevice")
|
||||||
|
public ReturnMap getDoorDevice() throws Exception {
|
||||||
|
PageData pageData = this.getPageData();
|
||||||
|
List<PageData> dataList = doorDeviceService.listAll(pageData);
|
||||||
|
ReturnMap returnMap = new ReturnMap();
|
||||||
|
returnMap.put("dataList", dataList);
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/page")
|
@RequestMapping(value = "/page")
|
||||||
public ReturnMap page(Page page) {
|
public ReturnMap page(Page page) {
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.zcloud.mapper.datasource.doorDevice;
|
||||||
|
|
||||||
|
import com.zcloud.entity.Page;
|
||||||
|
import com.zcloud.entity.PageData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 说明:数据库管理Mapper
|
||||||
|
* 作者:luoxiaobao
|
||||||
|
* 官网:www.qdkjchina.com
|
||||||
|
*/
|
||||||
|
public interface DoorDeviceMapper {
|
||||||
|
|
||||||
|
/**新增
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void save(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**删除
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void delete(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**修改
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void edit(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**列表
|
||||||
|
* @param page
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<PageData> listAll(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**根据indexCode查询数据
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
* */
|
||||||
|
public PageData findByIndexCode(PageData pd)throws Exception;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.zcloud.service.doorDevice;
|
||||||
|
|
||||||
|
import com.zcloud.entity.Page;
|
||||||
|
import com.zcloud.entity.PageData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 说明:闸机
|
||||||
|
*/
|
||||||
|
public interface DoorDeviceService {
|
||||||
|
|
||||||
|
/**新增
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void save(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**删除
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void delete(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**修改
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void edit(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
/**列表
|
||||||
|
* @param page
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<PageData> listAll(PageData pd)throws Exception;
|
||||||
|
|
||||||
|
public PageData findByIndexCode(PageData pageData)throws Exception;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.zcloud.service.doorDevice.impl;
|
||||||
|
|
||||||
|
import com.zcloud.entity.Page;
|
||||||
|
import com.zcloud.entity.PageData;
|
||||||
|
import com.zcloud.mapper.datasource.docking.DockingRelationMapper;
|
||||||
|
import com.zcloud.mapper.datasource.doorDevice.DoorDeviceMapper;
|
||||||
|
import com.zcloud.service.doorDevice.DoorDeviceService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 说明:闸机信息
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional //开启事物
|
||||||
|
public class DoorDeviceServiceImpl implements DoorDeviceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DoorDeviceMapper doorDeviceMapper;
|
||||||
|
|
||||||
|
/**新增
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void save(PageData pd)throws Exception{
|
||||||
|
doorDeviceMapper.save(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**删除
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void delete(PageData pd)throws Exception{
|
||||||
|
doorDeviceMapper.delete(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**修改
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void edit(PageData pd)throws Exception{
|
||||||
|
doorDeviceMapper.edit(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**列表
|
||||||
|
* @param pd
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<PageData> listAll(PageData pd)throws Exception{
|
||||||
|
return doorDeviceMapper.listAll(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData findByIndexCode(PageData pageData)throws Exception{
|
||||||
|
return doorDeviceMapper.findByIndexCode(pageData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.zcloud.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.zcloud.entity.PageData;
|
||||||
|
import com.zcloud.service.doorDevice.DoorDeviceService;
|
||||||
|
import com.zcloud.util.hk.HKUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门禁闸机数据获取
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class DoorDeviceScheduled {
|
||||||
|
@Autowired
|
||||||
|
private DoorDeviceService doorDeviceService;
|
||||||
|
// @Scheduled(cron ="0 30 0 * * ?")//每天12点30
|
||||||
|
@Scheduled(cron ="*/20 * * * * ?")//测试
|
||||||
|
public void scheduled(){
|
||||||
|
PageData pageData = new PageData();
|
||||||
|
Map<String, Object> carDoorInfo = HKUtil.getCarDoorList(pageData);
|
||||||
|
Object data = carDoorInfo.get("data");
|
||||||
|
List<PageData> dataList = JSONArray.parseArray(data.toString(), PageData.class);
|
||||||
|
String parkIndexCodes = "";
|
||||||
|
System.out.println(dataList);
|
||||||
|
for (PageData pd : dataList) {
|
||||||
|
parkIndexCodes = parkIndexCodes + pd.getString("parkIndexCode")+",";
|
||||||
|
}
|
||||||
|
Map<String, Object> carDoorDevice = HKUtil.getCarDoorInfo(parkIndexCodes);
|
||||||
|
System.out.println(carDoorDevice);
|
||||||
|
Map<String, Object> root = HKUtil.getRoot();
|
||||||
|
System.out.println(root);
|
||||||
|
|
||||||
|
// PageData pageData = new PageData();
|
||||||
|
// Boolean hasNext = true;
|
||||||
|
// List<PageData> doorList = new ArrayList<>();
|
||||||
|
// int pageNo = 1;
|
||||||
|
// int pageSize = 100;
|
||||||
|
// while (hasNext) {
|
||||||
|
// pageData.put("pageNo",pageNo);
|
||||||
|
// pageData.put("pageSize",pageSize);
|
||||||
|
// Map<String, Object> gateMachineInfo = HKUtil.getGateMachineInfo(pageData);
|
||||||
|
// JSONObject data = (JSONObject) gateMachineInfo.get("data");
|
||||||
|
// Object list = data.get("list");
|
||||||
|
// List<PageData> dataList = JSONArray.parseArray(list.toString(), PageData.class);
|
||||||
|
// doorList.addAll(dataList);
|
||||||
|
// if (dataList.size()<100){
|
||||||
|
// hasNext = false;
|
||||||
|
// }else {
|
||||||
|
// pageNo++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (PageData doordevice : doorList) {
|
||||||
|
// try {
|
||||||
|
// PageData byIndexCode = doorDeviceService.findByIndexCode(doordevice);
|
||||||
|
// if (!Tools.isEmpty(byIndexCode)) {
|
||||||
|
// doorDeviceService.edit(doordevice);
|
||||||
|
// }else {
|
||||||
|
// String uuid = get32UUID();
|
||||||
|
// doordevice.put("DOORDEVICE_ID",uuid);
|
||||||
|
// doorDeviceService.save(doordevice);
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**得到32位的uuid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String get32UUID(){
|
||||||
|
return UuidUtil.get32UUID();
|
||||||
|
}
|
||||||
|
}
|
|
@ -172,11 +172,6 @@ public class HKUtil {
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param currDay before 设备编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Map<String,Object> getCarOnSiteCount(String pageNo,String pageSize,String startTime, String endTime ) {
|
public static Map<String,Object> getCarOnSiteCount(String pageNo,String pageSize,String startTime, String endTime ) {
|
||||||
JSONObject jsonBody = new JSONObject();
|
JSONObject jsonBody = new JSONObject();
|
||||||
if (pageNo != null)
|
if (pageNo != null)
|
||||||
|
@ -191,11 +186,6 @@ public class HKUtil {
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取监控点预览取流URL
|
|
||||||
* @param id 设备编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Map<String,Object> getDoorComeAndOutInfo(){
|
public static Map<String,Object> getDoorComeAndOutInfo(){
|
||||||
JSONObject jsonBody = new JSONObject();
|
JSONObject jsonBody = new JSONObject();
|
||||||
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v1/entrance/entranceList");
|
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v1/entrance/entranceList");
|
||||||
|
@ -243,4 +233,47 @@ public class HKUtil {
|
||||||
Map<String,Object> returnMap=publicHkInterface(jsonBody,"/api/resource/v2/acsDevice/search");
|
Map<String,Object> returnMap=publicHkInterface(jsonBody,"/api/resource/v2/acsDevice/search");
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 闸机信息获取
|
||||||
|
/**
|
||||||
|
* API名称:
|
||||||
|
* 闸机信息获取v2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> getGateMachineInfo(PageData pd){
|
||||||
|
JSONObject jsonBody = new JSONObject();
|
||||||
|
jsonBody.put("pageNo", pd.get("pageNo"));
|
||||||
|
jsonBody.put("pageSize", pd.get("pageSize"));
|
||||||
|
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v2/door/search");
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API名称:
|
||||||
|
* 闸机信息获取v2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> getCarDoorList(PageData pd){
|
||||||
|
JSONObject jsonBody = new JSONObject();
|
||||||
|
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v1/park/parkList");
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API名称:
|
||||||
|
* 闸机信息获取v2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> getCarDoorInfo(String parkIndexCodes){
|
||||||
|
JSONObject jsonBody = new JSONObject();
|
||||||
|
jsonBody.put("parkIndexCodes",parkIndexCodes);
|
||||||
|
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v1/entrance/entranceList");
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String,Object> getRoot(){
|
||||||
|
JSONObject jsonBody = new JSONObject();
|
||||||
|
Map<String,Object> returnMap = publicHkInterface(jsonBody,"/api/resource/v1/regions/root");
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.zcloud.mapper.datasource.doorDevice.DoorDeviceMapper">
|
||||||
|
|
||||||
|
<!--表名 -->
|
||||||
|
<sql id="tableName">
|
||||||
|
mk_door_device
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 字段 -->
|
||||||
|
<sql id="Field">
|
||||||
|
DOORDEVICE_ID,
|
||||||
|
channelNo,
|
||||||
|
channelType,
|
||||||
|
controlOneId,
|
||||||
|
controlTwoId,
|
||||||
|
createTime,
|
||||||
|
description,
|
||||||
|
disOrder,
|
||||||
|
doorNo,
|
||||||
|
doorSerial,
|
||||||
|
indexCode,
|
||||||
|
isCascade,
|
||||||
|
name,
|
||||||
|
parentIndexCode,
|
||||||
|
readerInId,
|
||||||
|
readerOutId,
|
||||||
|
regionIndexCode,
|
||||||
|
regionName,
|
||||||
|
regionPath,
|
||||||
|
regionPathName,
|
||||||
|
resourceType,
|
||||||
|
sort,
|
||||||
|
treatyType,
|
||||||
|
updateTime
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 字段值 -->
|
||||||
|
<sql id="FieldValue">
|
||||||
|
#{DOORDEVICE_ID},
|
||||||
|
#{channelNo},
|
||||||
|
#{channelType},
|
||||||
|
#{controlOneId},
|
||||||
|
#{controlTwoId},
|
||||||
|
#{createTime},
|
||||||
|
#{description},
|
||||||
|
#{disOrder},
|
||||||
|
#{doorNo},
|
||||||
|
#{doorSerial},
|
||||||
|
#{indexCode},
|
||||||
|
#{isCascade},
|
||||||
|
#{name},
|
||||||
|
#{parentIndexCode},
|
||||||
|
#{readerInId},
|
||||||
|
#{readerOutId},
|
||||||
|
#{regionIndexCode},
|
||||||
|
#{regionName},
|
||||||
|
#{regionPath},
|
||||||
|
#{regionPathName},
|
||||||
|
#{resourceType},
|
||||||
|
#{sort},
|
||||||
|
#{treatyType},
|
||||||
|
#{updateTime}
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 新增-->
|
||||||
|
<insert id="save" parameterType="pd">
|
||||||
|
insert into
|
||||||
|
<include refid="tableName"></include>
|
||||||
|
(
|
||||||
|
<include refid="Field"></include>
|
||||||
|
) values (
|
||||||
|
<include refid="FieldValue"></include>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 删除-->
|
||||||
|
<delete id="delete" parameterType="pd">
|
||||||
|
delete from
|
||||||
|
<include refid="tableName"></include>
|
||||||
|
where
|
||||||
|
DOORDEVICE_ID = #{DOORDEVICE_ID}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!-- 修改 -->
|
||||||
|
<update id="edit" parameterType="pd">
|
||||||
|
update
|
||||||
|
<include refid="tableName"></include>
|
||||||
|
set
|
||||||
|
channelNo = #{channelNo},
|
||||||
|
channelType = #{channelType},
|
||||||
|
controlOneId = #{controlOneId},
|
||||||
|
controlTwoId = #{controlTwoId},
|
||||||
|
createTime = #{createTime},
|
||||||
|
description = #{description},
|
||||||
|
disOrder = #{disOrder},
|
||||||
|
doorNo = #{doorNo},
|
||||||
|
doorSerial = #{doorSerial},
|
||||||
|
indexCode = #{indexCode},
|
||||||
|
isCascade = #{isCascade},
|
||||||
|
name = #{name},
|
||||||
|
parentIndexCode = #{parentIndexCode},
|
||||||
|
readerInId = #{readerInId},
|
||||||
|
readerOutId = #{readerOutId},
|
||||||
|
regionIndexCode = #{regionIndexCode},
|
||||||
|
regionName = #{regionName},
|
||||||
|
regionPath = #{regionPath},
|
||||||
|
regionPathName = #{regionPathName},
|
||||||
|
resourceType = #{resourceType},
|
||||||
|
sort = #{sort},
|
||||||
|
treatyType = #{treatyType},
|
||||||
|
updateTime = #{updateTime}
|
||||||
|
where
|
||||||
|
indexCode = #{indexCode}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<select id="datalistPage" parameterType="page" resultType="pd">
|
||||||
|
select
|
||||||
|
<include refid="Field"></include>
|
||||||
|
from
|
||||||
|
<include refid="tableName"></include>
|
||||||
|
where 1=1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 列表(全部) -->
|
||||||
|
<select id="listAll" parameterType="pd" resultType="pd">
|
||||||
|
SELECT
|
||||||
|
indexCode,
|
||||||
|
name
|
||||||
|
FROM
|
||||||
|
mk_door_device
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
EQUIPMENTID as indexCode,
|
||||||
|
GATE_MACHINE_NAME as name
|
||||||
|
FROM
|
||||||
|
mk_gate_machine
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 列表(全部) -->
|
||||||
|
<select id="findByIndexCode" parameterType="pd" resultType="pd">
|
||||||
|
select
|
||||||
|
<include refid="Field"></include>
|
||||||
|
from
|
||||||
|
<include refid="tableName"></include> f
|
||||||
|
where
|
||||||
|
f.indexCode = #{indexCode}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue