Selaa lähdekoodia

Merge remote-tracking branch 'origin/V1' into V1

tomatozq 5 vuotta sitten
vanhempi
commit
27bb6948cc
42 muutettua tiedostoa jossa 1434 lisäystä ja 214 poistoa
  1. 3 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/DeviceInfoDAO.java
  2. 6 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java
  3. 8 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceRelationDAO.java
  4. 34 0
      common/src/main/java/com/jpsoft/smart/modules/base/entity/DeviceInfo.java
  5. 16 0
      common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceLog.java
  6. 1 1
      common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceRelation.java
  7. 123 126
      common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonInfo.java
  8. 1 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/DeviceInfoService.java
  9. 7 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java
  10. 5 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceRelationService.java
  11. 21 7
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/DeviceInfoServiceImpl.java
  12. 19 2
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java
  13. 29 6
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceRelationServiceImpl.java
  14. 36 4
      common/src/main/java/com/jpsoft/smart/modules/common/utils/LApiUtil.java
  15. 37 0
      common/src/main/java/com/jpsoft/smart/modules/common/utils/OSSUtil.java
  16. 11 0
      common/src/main/java/com/jpsoft/smart/modules/constant/LApiConstant.java
  17. 22 0
      common/src/main/java/com/jpsoft/smart/modules/lapi/service/ILapiService.java
  18. 146 5
      common/src/main/java/com/jpsoft/smart/modules/lapi/service/impl/LapiServiceImpl.java
  19. 34 0
      common/src/main/java/com/jpsoft/smart/modules/lapi/vo/AddPersonVo.java
  20. 15 0
      common/src/main/java/com/jpsoft/smart/modules/lapi/vo/IdentificationVo.java
  21. 18 0
      common/src/main/java/com/jpsoft/smart/modules/lapi/vo/ImageVo.java
  22. 19 0
      common/src/main/java/com/jpsoft/smart/modules/lapi/vo/LapiMsgResult.java
  23. 5 1
      common/src/main/java/com/jpsoft/smart/modules/sys/dao/DataDictionaryDAO.java
  24. 3 1
      common/src/main/java/com/jpsoft/smart/modules/sys/service/DataDictionaryService.java
  25. 30 15
      common/src/main/java/com/jpsoft/smart/modules/sys/service/impl/DataDictionaryServiceImpl.java
  26. 33 6
      common/src/main/resources/mapper/base/DeviceInfo.xml
  27. 42 0
      common/src/main/resources/mapper/base/PersonDeviceLog.xml
  28. 31 7
      common/src/main/resources/mapper/base/PersonDeviceRelation.xml
  29. 7 2
      common/src/main/resources/mapper/base/PersonInfo.xml
  30. 16 0
      common/src/main/resources/mapper/sys/DataDictionary.xml
  31. 19 0
      lapi/src/main/java/com/jpsoft/smart/lapi/handler/HeartReportHandler.java
  32. 1 0
      lapi/src/main/java/com/jpsoft/smart/lapi/handler/ParseRequestHandler.java
  33. 7 4
      lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java
  34. 16 0
      web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java
  35. 15 1
      web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java
  36. 99 0
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java
  37. 201 6
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java
  38. 141 11
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java
  39. 61 0
      web/src/main/java/com/jpsoft/smart/modules/common/controller/fileUploadController.java
  40. 38 9
      web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java
  41. 25 0
      web/src/main/java/com/jpsoft/smart/modules/sys/controller/DataDictionaryController.java
  42. 33 0
      web/src/test/java/com/jpsoft/smart/LApiTest.java

+ 3 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/DeviceInfoDAO.java

@@ -12,7 +12,10 @@ public interface DeviceInfoDAO {
 	int update(DeviceInfo entity);
 	int exist(String id);
 	DeviceInfo get(String id);
+	DeviceInfo getByDeviceNo(String deviceNo);
 	int delete(String id);
 	List<DeviceInfo> list();
 	List<DeviceInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+	DeviceInfo findByDeviceNo(String deviceNo);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java

@@ -1,8 +1,12 @@
 package com.jpsoft.smart.modules.base.dao;
 
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.common.dto.Sort;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author 墨鱼_mo
  * @date 2020-3-15 14:22
@@ -12,4 +16,6 @@ public interface PersonDeviceLogDAO {
 
 
     void insert(PersonDeviceLog personDeviceLog);
+
+    List<PersonDeviceLog> search(Map<String, Object> searchParams, List<Sort> sortList);
 }

+ 8 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceRelationDAO.java

@@ -1,4 +1,5 @@
 package com.jpsoft.smart.modules.base.dao;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import org.springframework.stereotype.Repository;
@@ -14,5 +15,12 @@ public interface PersonDeviceRelationDAO {
 	PersonDeviceRelation get(String id);
 	int delete(String id);
 	List<PersonDeviceRelation> list();
+	List<PersonDeviceRelation> findByPersonId(Long personId);
+    List<PersonDeviceRelation> findByDeviceId(String deviceId);
+    PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId);
 	List<PersonDeviceRelation> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+//    List<PersonDeviceRelation>  findByPersonId(@Param("personId")Long personId);
+
+
 }

+ 34 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/DeviceInfo.java

@@ -60,6 +60,13 @@ public class DeviceInfo {
 	 *运行状态(是否在线)
 	 */
 	private String isOnlineN;
+
+    /**
+     *公司ID
+     */
+    @ApiModelProperty(value = "公司ID")
+    private String companyId;
+
 	/**
 	 *开锁密码
 	 */
@@ -91,6 +98,14 @@ public class DeviceInfo {
 	 */
 	@ApiModelProperty(value = "类型")
 	private String typeN;
+	/**
+	 *是否开启自动更新
+	 */
+	@ApiModelProperty(value = "是否开启自动更新")
+	private Boolean isAutoUpdate;
+
+	@ApiModelProperty(value = "是否开启自动更新")
+	private String isAutoUpdateN;
 	/**
 	 *是否删除
 	 */
@@ -121,6 +136,13 @@ public class DeviceInfo {
 	    @ApiModelProperty(value = "更新时间")
 	private Date updateTime;
 
+
+	@ApiModelProperty(value = "是否绑定人员(只做查询作用,不写入数据库)")
+	private Boolean isBindPerson;
+
+	@ApiModelProperty(value = "默认人脸库id")
+	private String defaultFaceLibraryId;
+
 	public String getIsOnlineN() {
 		if(isOnline!=null) {
 			if (isOnline) {
@@ -132,4 +154,16 @@ public class DeviceInfo {
 		return isOnlineN;
 	}
 
+	public String getIsAutoUpdateN() {
+		if(isAutoUpdate!=null) {
+			if (isAutoUpdate) {
+				isAutoUpdateN = "是";
+			} else {
+				isAutoUpdateN = "否";
+			}
+		}
+		return isAutoUpdateN;
+	}
+
+
 }

+ 16 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceLog.java

@@ -1,8 +1,10 @@
 package com.jpsoft.smart.modules.base.entity;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -28,6 +30,9 @@ public class PersonDeviceLog {
     @ApiModelProperty(value = "设备序列号")
     private String deviceNo;
 
+    @ApiModelProperty(value = "设备信息")
+    private DeviceInfo device;
+
 
     /**
      * 人员id
@@ -35,6 +40,9 @@ public class PersonDeviceLog {
     @ApiModelProperty(value = "人员id")
     private Integer personId;
 
+    @ApiModelProperty(value = "人员信息")
+    private PersonInfo person;
+
     /**
      * 记录温度
      */
@@ -70,6 +78,9 @@ public class PersonDeviceLog {
     /**
      * 记录时间
      */
+
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
     @ApiModelProperty(value = "记录时间")
     private Date recordTime;
 
@@ -88,6 +99,8 @@ public class PersonDeviceLog {
     /**
      * 创建时间
      */
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
 
@@ -100,6 +113,9 @@ public class PersonDeviceLog {
     /**
      * 更新时间
      */
+
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "更新时间")
     private Date updateTime;
 

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceRelation.java

@@ -33,7 +33,7 @@ public class PersonDeviceRelation {
 	 *人员ID
 	 */
         @ApiModelProperty(value = "人员ID")
-	private String personId;
+	private Long personId;
 
 	@ApiModelProperty(value = "人员信息")
 	private PersonInfo personInfo;

+ 123 - 126
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonInfo.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
+
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -11,136 +12,132 @@ import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
 /**
-  描述:base_person_info的实体类
+ * 描述:base_person_info的实体类
  */
 @Data
 @ApiModel(value = "base_person_info的实体类")
 public class PersonInfo {
-	/**
-	 *编号
-	 */
-	@ApiModelProperty(value = "编号")
-	private Long id;
-	/**
-	 *企业编号
-	 */
-        @ApiModelProperty(value = "企业编号")
-	private String companyId;
-	/**
-	 *企业名称
-	 */
-	@ApiModelProperty(value = "企业名称")
-	private String companyName;
-	/**
-	 *姓名
-	 */
-        @ApiModelProperty(value = "姓名")
-	private String name;
-	/**
-	 *手机号
-	 */
-	@ApiModelProperty(value = "手机号")
-	private String phone;
-	/**
-	 *身份证号
-	 */
-	@ApiModelProperty(value = "身份证号")
-	private String idCard;
-	/**
-	 *微信openId
-	 */
-	@ApiModelProperty(value = "微信openId")
-	private String openId;
-	/**
-	 *人脸
-	 */
-        @ApiModelProperty(value = "人脸")
-	private Boolean faceEnabled;
-	/**
-	 *刷卡
-	 */
-        @ApiModelProperty(value = "刷卡")
-	private Boolean cardEnabled;
-	/**
-	 *手机
-	 */
-        @ApiModelProperty(value = "手机")
-	private Boolean appEnabled;
-	/**
-	 *密码
-	 */
-        @ApiModelProperty(value = "密码")
-	private Boolean passwordEnabled;
-	/**
-	 *访客
-	 */
-        @ApiModelProperty(value = "访客")
-	private Boolean guestEnabled;
-	/**
-	 *位置1
-	 */
-        @ApiModelProperty(value = "位置1")
-	private String position1;
-	/**
-	 *位置2
-	 */
-        @ApiModelProperty(value = "位置2")
-	private String position2;
-	/**
-	 *位置3
-	 */
-        @ApiModelProperty(value = "位置3")
-	private String position3;
-	/**
-	 *位置4
-	 */
-        @ApiModelProperty(value = "位置4")
-	private String position4;
-	/**
-	 *位置5
-	 */
-        @ApiModelProperty(value = "位置5")
-	private String position5;
-	/**
-	 *是否删除
-	 */
-        @ApiModelProperty(value = "是否删除")
-	private Boolean delFlag;
-	/**
-	 *创建人
-	 */
-        @ApiModelProperty(value = "创建人")
-	private String createBy;
-	/**
-	 *创建时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "创建时间")
-	private Date createTime;
-	/**
-	 *更新人
-	 */
-        @ApiModelProperty(value = "更新人")
-	private String updateBy;
-	/**
-	 *更新时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "更新时间")
-	private Date updateTime;
-	/**
-	 *设置企业名称
-	 */
-	public String getCompanyName() {
-		return companyName;
-	}
+    /**
+     * 编号
+     */
+    @ApiModelProperty(value = "编号")
+    private Long id;
+    /**
+     * 企业编号
+     */
+    @ApiModelProperty(value = "企业编号")
+    private String companyId;
+    /**
+     * 企业名称
+     */
+    @ApiModelProperty(value = "企业名称")
+    private String companyName;
+    /**
+     * 姓名
+     */
+    @ApiModelProperty(value = "姓名")
+    private String name;
+    /**
+     * 手机号
+     */
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+    /**
+     * 身份证号
+     */
+    @ApiModelProperty(value = "身份证号")
+    private String idCard;
+    /**
+     * 微信openId
+     */
+    @ApiModelProperty(value = "微信openId")
+    private String openId;
+    /**
+     * 人脸
+     */
+    @ApiModelProperty(value = "人脸")
+    private Boolean faceEnabled;
+
+    @ApiModelProperty(value = "是否已将人脸信息传给终端")
+    private Boolean faceBound;
+
+    /**
+     * 刷卡
+     */
+    @ApiModelProperty(value = "刷卡")
+    private Boolean cardEnabled;
+    /**
+     * 手机
+     */
+    @ApiModelProperty(value = "手机")
+    private Boolean appEnabled;
+    /**
+     * 密码
+     */
+    @ApiModelProperty(value = "密码")
+    private Boolean passwordEnabled;
+    /**
+     * 访客
+     */
+    @ApiModelProperty(value = "访客")
+    private Boolean guestEnabled;
+    /**
+     * 位置1
+     */
+    @ApiModelProperty(value = "位置1")
+    private String position1;
+    /**
+     * 位置2
+     */
+    @ApiModelProperty(value = "位置2")
+    private String position2;
+    /**
+     * 位置3
+     */
+    @ApiModelProperty(value = "位置3")
+    private String position3;
+    /**
+     * 位置4
+     */
+    @ApiModelProperty(value = "位置4")
+    private String position4;
+    /**
+     * 位置5
+     */
+    @ApiModelProperty(value = "位置5")
+    private String position5;
+    /**
+     * 是否删除
+     */
+    @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**
+     * 更新时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
 
-	public void setCompanyName(String companyName) {
-		this.companyName = companyName;
-	}
+    @ApiModelProperty(value = "人脸相片地址")
+    private String faceImageUrl;
 
-	@ApiModelProperty(value = "人脸相片地址")
-	private String faceImageUrl;
 }

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/DeviceInfoService.java

@@ -14,4 +14,5 @@ public interface DeviceInfoService {
 	int delete(String id);
 	List<DeviceInfo> list();
 	Page<DeviceInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
+	void updateByDeviceNo(String deviceNo, String ip);
 }

+ 7 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -1,10 +1,15 @@
 package com.jpsoft.smart.modules.base.service;
 
 import cn.hutool.json.JSONObject;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.github.pagehelper.Page;
 
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author 墨鱼_mo
@@ -21,4 +26,6 @@ public interface PersonDeviceLogService {
      * @param matchPersonInfo
      */
     void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) ;
+
+    Page<PersonDeviceLog> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceRelationService.java

@@ -13,5 +13,10 @@ public interface PersonDeviceRelationService {
 	int update(PersonDeviceRelation model);
 	int delete(String id);
 	List<PersonDeviceRelation> list();
+	List<PersonDeviceRelation> findByPersonId(Long personId);
+	List<PersonDeviceRelation> findByDeviceId(String deviceId);
+	PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId);
 	Page<PersonDeviceRelation> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
+
+	//List<PersonDeviceRelation> findByPersonId(Long id);
 }

+ 21 - 7
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/DeviceInfoServiceImpl.java

@@ -2,8 +2,9 @@ package com.jpsoft.smart.modules.base.service.impl;
 
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import javax.annotation.Resource;
+
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.smart.modules.base.dao.DeviceInfoDAO;
@@ -13,6 +14,7 @@ import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.github.pagehelper.PageHelper;
 
+@Slf4j
 @Transactional
 @Component(value="deviceInfoService")
 public class DeviceInfoServiceImpl implements DeviceInfoService {
@@ -29,14 +31,14 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
 	public int insert(DeviceInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return deviceInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(DeviceInfo model) {
 		// TODO Auto-generated method stub
-		return deviceInfoDAO.update(model);		
+		return deviceInfoDAO.update(model);
 	}
 
 	@Override
@@ -49,22 +51,34 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = deviceInfoDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<DeviceInfo> list() {
 		// TODO Auto-generated method stub
 		return deviceInfoDAO.list();
 	}
-		
+
 	@Override
 	public Page<DeviceInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<DeviceInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             deviceInfoDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public void updateByDeviceNo(String deviceNo, String ip) {
+		DeviceInfo deviceInfo= deviceInfoDAO.findByDeviceNo(deviceNo);
+		String oldIp = deviceInfo.getIpAddress();
+		if (deviceInfo.getIsAutoUpdate() && !deviceInfo.getIpAddress().equals(ip)){
+			deviceInfo.setIpAddress(ip);
+			deviceInfoDAO.update(deviceInfo);
+			log.warn(deviceNo+"的ip由原来的:"+oldIp+"自动更新为:"+ip);
+		}
+
+	}
 }

+ 19 - 2
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -1,14 +1,17 @@
 package com.jpsoft.smart.modules.base.service.impl;
 
 import cn.hutool.json.JSONObject;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
 import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.modules.base.dao.AlarmInfoDAO;
 import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.BASE64DecodedMultipartFile;
 import com.jpsoft.smart.modules.common.utils.Base64;
-import com.jpsoft.smart.modules.common.utils.IApiUtil;
+import com.jpsoft.smart.modules.common.utils.LApiUtil;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +27,8 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 /**
@@ -93,7 +98,7 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))){
             System.out.println();
             personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
-            personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
+            personDeviceLog.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
             personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
         }else {
             personDeviceLog.setMatchStatus(0);
@@ -106,4 +111,16 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         personDeviceLog.setFaceImage(retFileUrl);
         personDeviceLogDAO.insert(personDeviceLog);
     }
+
+    @Override
+    public Page<PersonDeviceLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            personDeviceLogDAO.search(searchParams,sortList);
+        });
+
+        return page;
+    }
+
+
+
 }

+ 29 - 6
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceRelationServiceImpl.java

@@ -29,14 +29,14 @@ public class PersonDeviceRelationServiceImpl implements PersonDeviceRelationServ
 	public int insert(PersonDeviceRelation model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return personDeviceRelationDAO.insert(model);
 	}
 
 	@Override
 	public int update(PersonDeviceRelation model) {
 		// TODO Auto-generated method stub
-		return personDeviceRelationDAO.update(model);		
+		return personDeviceRelationDAO.update(model);
 	}
 
 	@Override
@@ -49,22 +49,45 @@ public class PersonDeviceRelationServiceImpl implements PersonDeviceRelationServ
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = personDeviceRelationDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<PersonDeviceRelation> list() {
 		// TODO Auto-generated method stub
 		return personDeviceRelationDAO.list();
 	}
-		
+
+	@Override
+	public List<PersonDeviceRelation> findByPersonId(Long personId){
+		return personDeviceRelationDAO.findByPersonId(personId);
+	}
+
+	@Override
+	public List<PersonDeviceRelation> findByDeviceId(String deviceId){
+		return personDeviceRelationDAO.findByDeviceId(deviceId);
+	}
+
+	@Override
+	public PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId){
+		return personDeviceRelationDAO.findByDeviceIdAndPersonId(deviceId,personId);
+	}
+
+
+
 	@Override
 	public Page<PersonDeviceRelation> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<PersonDeviceRelation> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             personDeviceRelationDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+//	@Override
+//	public List<PersonDeviceRelation> findByPersonId(Long id) {
+//
+//		return personDeviceRelationDAO.findByPersonId(id);
+//	}
 }

+ 36 - 4
common/src/main/java/com/jpsoft/smart/modules/common/utils/IApiUtil.java → common/src/main/java/com/jpsoft/smart/modules/common/utils/LApiUtil.java

@@ -1,10 +1,13 @@
 package com.jpsoft.smart.modules.common.utils;
 
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.Date;
 import java.util.HashMap;
 
 /**
@@ -12,17 +15,18 @@ import java.util.HashMap;
  * @date 2020-3-14 16:43
  */
 @Component
-public class IApiUtil {
+public class LApiUtil {
 
 
-   /* public JSONObject PostRequest(String url){
+    public static JSONObject PostRequest(String url,HashMap map){
 
-        String body = HttpRequest.post(url).header("referer",referer).form(map).execute().body();
+
+        String body = HttpRequest.post(url).body(new JSONObject(map).toJSONString()).execute().body();
         JSONObject jsonbody = JSONObject.parseObject(body);
         return jsonbody;
 
 
-    }*/
+    }
 
     public static JSONObject GetRequest(String url) throws Exception{
 
@@ -33,6 +37,8 @@ public class IApiUtil {
 
     }
 
+
+
     public static JSONObject getResponse(JSONObject dataJson) throws Exception{
 
         if (dataJson.getInteger("ResponseCode") == 1){
@@ -77,6 +83,7 @@ public class IApiUtil {
         if (dataJson.getInteger("StatusCode") == 14){
             throw new Exception("重复订阅");
         }
+
         return dataJson.getJSONObject("Data");
     }
 
@@ -101,6 +108,31 @@ public class IApiUtil {
         return matchMsg;
     }
 
+    public static Integer imageSize(String imageBase64Str){
+
+        //1.找到等号,把等号也去掉(=用来填充base64字符串长度用)
+        Integer equalIndex= imageBase64Str.indexOf("=");
+        if(imageBase64Str.indexOf("=")>0) {
+            imageBase64Str=imageBase64Str.substring(0, equalIndex);
+        }
+        //2.原来的字符流大小,单位为字节
+        Integer strLength=imageBase64Str.length();
+     //   System.out.println("imageBase64Str Length = "+strLength);
+        //3.计算后得到的文件流大小,单位为字节
+        Integer size=strLength-(strLength/8)*2;
+        return size;
+    }
+
+
+
+    public static void main(String[] args) {
+        Date date = new Date(1584321770000L);
+    //    Date date = new
+     //   Date date = new Date();
+      // long time = date.getTime();
+        System.out.println(date);
+    }
+
 
 
 }

+ 37 - 0
common/src/main/java/com/jpsoft/smart/modules/common/utils/OSSUtil.java

@@ -1,5 +1,6 @@
 package com.jpsoft.smart.modules.common.utils;
 
+import cn.hutool.core.codec.Base64Encoder;
 import cn.hutool.core.date.DateTime;
 import com.aliyun.oss.HttpMethod;
 import com.aliyun.oss.OSS;
@@ -92,6 +93,42 @@ public class OSSUtil {
 
         return result;
     }
+    public static String  downloadToBase64(String fileUrl){
+            ByteArrayOutputStream data = new ByteArrayOutputStream();;
+        try {
+       //     FileOutputStream output = new FileOutputStream();
+       //     OutputStream outputStream =null;
+
+
+
+            URL url = new URL(encodeFileName(fileUrl));
+        //    URLConnection conn = url.openConnection();
+        //    InputStream input = conn.getInputStream();
+
+            byte[] buffs = new byte[1024 * 10];
+            //创建连接
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            conn.setRequestMethod("GET");
+            conn.setConnectTimeout(5000);
+            InputStream input = conn.getInputStream();
+            //将内容读到内存中
+            int len = -1;
+            while ((len =input.read(buffs))!=-1){
+                data.write(buffs,0,len);
+            }
+            input.close();
+
+
+
+        } catch (Exception e) {
+
+            log.error(e.getMessage(),e);
+        }
+
+
+        return Base64Encoder.encode(data.toByteArray());
+    }
+
 
     public static void batchDownload(List<Map<String,Object>> fileList, OutputStream output){
         try{

+ 11 - 0
common/src/main/java/com/jpsoft/smart/modules/constant/LApiConstant.java

@@ -16,4 +16,15 @@ public class LApiConstant {
      */
     public static final String KEEPALIVE = "/LAPI/V1.0/System/KeepAlive";
 
+
+    /**
+     * 上传人脸接口url
+     */
+    public static final String ADDPERSON = "/LAPI/V1.0/PeopleLibraries/";
+
+    /**
+     * 获取人脸库url
+     */
+    public static final String GETFACEDB = "/LAPI/V1.0/PeopleLibraries/BasicInfo";
+
 }

+ 22 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/service/ILapiService.java

@@ -1,6 +1,10 @@
 package com.jpsoft.smart.modules.lapi.service;
 
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
+
+import java.util.List;
 
 /**
  * @author 墨鱼_mo
@@ -23,4 +27,22 @@ public interface ILapiService {
      * @return
      */
      Boolean keepAlive(String id) throws Exception;
+
+
+    /**
+     * 平台上传设备人脸信息
+     * @param id
+     * @return
+     * @throws Exception
+     */
+     List<LapiMsgResult> addPerson(Long id) throws Exception;
+
+    /**
+     * 根据公司名称获取人脸库
+     * @param companyName
+     * @return
+     */
+     String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception;
+
+     
 }

+ 146 - 5
common/src/main/java/com/jpsoft/smart/modules/lapi/service/impl/LapiServiceImpl.java

@@ -1,20 +1,35 @@
 package com.jpsoft.smart.modules.lapi.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceRelation;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
 import com.jpsoft.smart.modules.base.service.DeviceInfoService;
-import com.jpsoft.smart.modules.common.utils.IApiUtil;
+import com.jpsoft.smart.modules.base.service.PersonDeviceRelationService;
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.common.utils.LApiUtil;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.constant.LApiConstant;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
+import com.jpsoft.smart.modules.lapi.vo.AddPersonVo;
+import com.jpsoft.smart.modules.lapi.vo.IdentificationVo;
+import com.jpsoft.smart.modules.lapi.vo.ImageVo;
+import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.UUID;
+import java.util.*;
 
 /**
  * @author 墨鱼_mo
  * @date 2020-3-15 9:37
  */
+@Slf4j
 @Service
 public class LapiServiceImpl implements ILapiService {
 
@@ -22,11 +37,20 @@ public class LapiServiceImpl implements ILapiService {
     @Autowired
     private DeviceInfoService deviceInfoService;
 
+    @Autowired
+    private PersonInfoService personInfoService;
+
+    @Autowired
+    private PersonDeviceRelationService personDeviceRelationService;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
     @Override
     public DeviceInfo findByIpAddressAndPort(String ipAddress, String port) throws Exception {
-        JSONObject jsonObject = IApiUtil.GetRequest(ipAddress + ":" + port + LApiConstant.DEVICEBASICINFO);
+        JSONObject jsonObject = LApiUtil.GetRequest(ipAddress + ":" + port + LApiConstant.DEVICEBASICINFO);
         JSONObject dataJson = jsonObject.getJSONObject("Response");
-        JSONObject response = IApiUtil.getResponse(dataJson);
+        JSONObject response = LApiUtil.getResponse(dataJson);
         DeviceInfo deviceInfo = new DeviceInfo();
         deviceInfo.setId(UUID.randomUUID().toString());
         deviceInfo.setIpAddress(ipAddress);
@@ -43,8 +67,125 @@ public class LapiServiceImpl implements ILapiService {
         if (deviceInfo == null){
             throw new Exception("设备未绑定");
         }
-        JSONObject jsonObject = IApiUtil.GetRequest(deviceInfo.getIpAddress()+":" + deviceInfo.getPort()+LApiConstant.KEEPALIVE);
+        JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress()+":" + deviceInfo.getPort()+LApiConstant.KEEPALIVE);
         JSONObject dataJson = jsonObject.getJSONObject("Response");
         return true;
     }
+
+    @Override
+    public List<LapiMsgResult> addPerson(Long id) throws Exception {
+
+        PersonInfo personInfo = personInfoService.get(id);
+        if (personInfo == null){
+            throw new Exception("人员不存在");
+        }
+        List<PersonDeviceRelation> listRelation = personDeviceRelationService.findByPersonId(id);
+        if (listRelation.size()<=0){
+            throw new Exception("人员未绑定设备");
+        }
+        CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+        List<DeviceInfo> deviceList = new ArrayList<>();
+        for (PersonDeviceRelation personDeviceRelation:listRelation){
+            DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
+            if (deviceInfo!=null){
+                deviceList.add(deviceInfo);
+            }
+        }
+        if (deviceList.size()<=0){
+            throw new Exception("人员与设备绑定错误");
+        }
+        List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
+        for (DeviceInfo deviceInfo : deviceList){
+            HashMap<String,Object> map = new HashMap<>();
+            map.put("Num",1L);
+            HashMap<String,Object> map1 = new HashMap<>();
+            map1.put("PersonID",personInfo.getId());
+            map1.put("LastChange",new Date().getTime());
+            map1.put("PersonCode",personInfo.getId().toString());
+            map1.put("PersonName",personInfo.getName());
+            map1.put("Remarks",companyInfo.getName());
+
+            //TimeTemplateNum 首字符必须大写
+            map1.put("TimeTemplateNum",0L);
+
+            map1.put("IdentificationNum",1L);
+            HashMap<String,Object> map2 = new HashMap<>();
+            List listMap2 = new ArrayList();
+            listMap2.add(map2);
+            map2.put("Type",0L);
+            map2.put("Number",personInfo.getIdCard());
+            map1.put("IdentificationList",listMap2);
+            map1.put("ImageNum",1L);
+
+            HashMap<String,Object> map3 = new HashMap<>();
+            map3.put("FaceID",personInfo.getId());
+            map3.put("Name",personInfo.getId()+".jpg");
+            map3.put("Size",OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()).length());
+            map3.put("Data",OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()));
+            List listMap3 = new ArrayList();
+            listMap3.add(map3);
+            map1.put("ImageList",listMap3);
+            List listMap1 = new ArrayList();
+            listMap1.add(map1);
+            map.put("PersonInfoList",listMap1);
+
+
+            try{
+                //获取人员人脸库id
+                String faceDbId = getFaceDbId(deviceInfo,companyInfo.getName());
+                JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress()+":"+deviceInfo.getPort()+LApiConstant.ADDPERSON+faceDbId+"/People",map);
+                JSONObject dataJson = jsonObject.getJSONObject("Response");
+                JSONObject response = LApiUtil.getResponse(dataJson);
+                if (dataJson.getInteger("ResponseCode") ==0 && dataJson.getInteger("StatusCode") == 0){
+                    LapiMsgResult lapiMsgResult = new LapiMsgResult();
+                    lapiMsgResult.setPersonName(personInfo.getName());
+                    lapiMsgResult.setSuccess(true);
+                    lapiMsgResult.setAliasName(deviceInfo.getAliasName());
+                    lapiMsgResults.add(lapiMsgResult);
+                }
+
+            }catch (Exception e){
+
+                log.error(e.getMessage());
+                LapiMsgResult lapiMsgResult = new LapiMsgResult();
+                lapiMsgResult.setPersonName(personInfo.getName());
+                lapiMsgResult.setSuccess(false);
+                lapiMsgResult.setMsg(e.getMessage());
+                lapiMsgResult.setAliasName(deviceInfo.getAliasName());
+                lapiMsgResults.add(lapiMsgResult);
+
+            }
+
+        }
+
+
+        return lapiMsgResults;
+    }
+
+    @Override
+    public String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception{
+        if (StringUtils.isBlank(companyName)){
+            throw new Exception("公司名称为空");
+        }
+        String faceDbId = "";
+        JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress()+":" + deviceInfo.getPort()+LApiConstant.GETFACEDB);
+        JSONObject dataJson = jsonObject.getJSONObject("Response");
+        JSONObject response = LApiUtil.getResponse(dataJson);
+        List listData = response.getJSONArray("LibList");
+        if (listData.size()<=0){
+            throw new Exception("设备没有配置人脸库");
+        }
+        for (int i =0;i<listData.size();i++){
+            JSONObject jsonObject1 = (JSONObject) JSONArray.toJSON(listData.get(i));
+            String name = jsonObject1.getString("Name");
+            if (StringUtils.isNotBlank(name) && companyName.equals(name)){
+                faceDbId = jsonObject1.getString("ID");
+            }
+        }
+        //人员所属的公司库不存在,保存到默认库
+        if (StringUtils.isBlank(faceDbId)){
+            faceDbId = deviceInfo.getDefaultFaceLibraryId();
+        }
+        return faceDbId;
+    }
 }

+ 34 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/vo/AddPersonVo.java

@@ -0,0 +1,34 @@
+package com.jpsoft.smart.modules.lapi.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-16 10:38
+ */
+@Data
+public class AddPersonVo {
+
+    private Long PersonID;
+
+    private Long LastChange;
+
+    private String  PersonCode;
+
+    private String PersonName;
+
+    private String Remarks;
+
+    private Long TimeTemplateNum;
+
+    private Long IdentificationNum;
+
+    private List<IdentificationVo> IdentificationList;
+
+    private Long ImageNum;
+
+    private List<ImageVo> ImageList;
+
+}

+ 15 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/vo/IdentificationVo.java

@@ -0,0 +1,15 @@
+package com.jpsoft.smart.modules.lapi.vo;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-16 10:44
+ */
+@Data
+public class IdentificationVo {
+
+    private Long Type;
+
+    private String Number;
+}

+ 18 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/vo/ImageVo.java

@@ -0,0 +1,18 @@
+package com.jpsoft.smart.modules.lapi.vo;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-16 10:46
+ */
+@Data
+public class ImageVo {
+    private Long FaceID;
+
+    private String Name;
+
+    private Long Size;
+
+    private String Data;
+}

+ 19 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/vo/LapiMsgResult.java

@@ -0,0 +1,19 @@
+package com.jpsoft.smart.modules.lapi.vo;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-16 15:23
+ */
+@Data
+public class LapiMsgResult {
+
+    private String personName;
+
+    private String aliasName;
+
+    private String msg;
+
+    private boolean success;
+}

+ 5 - 1
common/src/main/java/com/jpsoft/smart/modules/sys/dao/DataDictionaryDAO.java

@@ -18,7 +18,11 @@ public interface DataDictionaryDAO {
 	String getName(String id);
 	String getValue(String id);
 	List<DataDictionary> list();
-	List<Map<String, Object>> queryChildren(String parentId);
 	String findParentId(String parentId,String value);
+	List<Map<String, Object>> queryChildren(String parentId);
 	List<DataDictionary> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+	List<DataDictionary> findByCatalogName(String catalogName);
+
+	String findNameByCatalogNameAndValue(String catalogName,String value);
 }

+ 3 - 1
common/src/main/java/com/jpsoft/smart/modules/sys/service/DataDictionaryService.java

@@ -1,8 +1,8 @@
 package com.jpsoft.smart.modules.sys.service;
 
 import com.github.pagehelper.Page;
-import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.sys.entity.DataDictionary;
+import com.jpsoft.smart.modules.common.dto.Sort;
 
 import java.util.List;
 import java.util.Map;
@@ -19,4 +19,6 @@ public interface DataDictionaryService {
 	String findParentId(String parentId,String value);
 	List<Map<String, Object>> queryChildren(String parentId);
 	Page<DataDictionary> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
+	List<DataDictionary> findByCatalogName(String catalogName);
+	String findNameByCatalogNameAndValue(String catalogName,String value);
 }

+ 30 - 15
common/src/main/java/com/jpsoft/smart/modules/sys/service/impl/DataDictionaryServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -29,14 +30,14 @@ public class DataDictionaryServiceImpl implements DataDictionaryService {
 	public int insert(DataDictionary model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return dataDictionaryDAO.insert(model);
 	}
 
 	@Override
 	public int update(DataDictionary model) {
 		// TODO Auto-generated method stub
-		return dataDictionaryDAO.update(model);		
+		return dataDictionaryDAO.update(model);
 	}
 
 	@Override
@@ -49,7 +50,7 @@ public class DataDictionaryServiceImpl implements DataDictionaryService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = dataDictionaryDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
 
@@ -61,29 +62,43 @@ public class DataDictionaryServiceImpl implements DataDictionaryService {
 	public String getValue(String id){
 		return dataDictionaryDAO.getValue(id);
 	}
-	
-	@Override
-	public List<DataDictionary> list() {
-		// TODO Auto-generated method stub
-		return dataDictionaryDAO.list();
-	}
 
 	@Override
 	public String findParentId(String parentId,String value){
 		return dataDictionaryDAO.findParentId(parentId,value);
 	}
 
+	@Override
+	public List<DataDictionary> list() {
+		// TODO Auto-generated method stub
+		return dataDictionaryDAO.list();
+	}
+
 	@Override
 	public List<Map<String, Object>> queryChildren(String parentId){
 		return dataDictionaryDAO.queryChildren(parentId);
 	}
-		
+
 	@Override
 	public Page<DataDictionary> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<DataDictionary> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
-            dataDictionaryDAO.search(searchParams,sortList);
-        });
-        
-        return page;
+		Page<DataDictionary> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
+			dataDictionaryDAO.search(searchParams,sortList);
+		});
+
+		return page;
+	}
+
+	@Override
+	public List<DataDictionary> findByCatalogName(String catalogName) {
+		return dataDictionaryDAO.findByCatalogName(catalogName);
+	}
+
+	@Override
+	public String findNameByCatalogNameAndValue(String catalogName,String value) {
+//		Map<String,Object> map = new HashMap<>();
+//		map.put("catalogName",catalogName);
+//		map.put("value",value);
+
+		return dataDictionaryDAO.findNameByCatalogNameAndValue(catalogName,value);
 	}
 }

+ 33 - 6
common/src/main/resources/mapper/base/DeviceInfo.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.smart.modules.base.dao.DeviceInfoDAO">
@@ -10,16 +10,19 @@
 			<result property="aliasName" column="alias_name" />
 			<result property="address" column="address_" />
 			<result property="isOnline" column="is_online" />
+			<result property="companyId" column="company_id" />
 			<result property="unlockPassword" column="unlock_password" />
 			<result property="codeAddress" column="code_address" />
 			<result property="ipAddress" column="ip_address" />
 			<result property="port" column="port_" />
 			<result property="type" column="type_" />
+			<result property="isAutoUpdate" column="is_auto_update" />
 			<result property="delFlag" column="del_flag" />
 			<result property="createBy" column="create_by" />
 			<result property="createTime" column="create_time" />
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
+		    <result property="defaultFaceLibraryId" column="default_face_library_id" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.DeviceInfo">
 	<!--
@@ -29,7 +32,7 @@
 	-->
 	<![CDATA[
 		insert into base_device_info
-	    (id_,header_,device_no,alias_name,address_,is_online,unlock_password,code_address,ip_address,port_,type_,del_flag,create_by,create_time,update_by,update_time)
+	    (id_,header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -39,15 +42,18 @@
 ,#{address,jdbcType=VARCHAR}
 ,#{isOnline,jdbcType= NUMERIC }
 ,#{unlockPassword,jdbcType=VARCHAR}
+,#{companyId,jdbcType=VARCHAR}
 ,#{codeAddress,jdbcType=VARCHAR}
 ,#{ipAddress,jdbcType=VARCHAR}
 ,#{port,jdbcType=VARCHAR}
 ,#{type,jdbcType=VARCHAR}
+,#{isAutoUpdate,jdbcType=NUMERIC}
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{createBy,jdbcType=VARCHAR}
 ,#{createTime,jdbcType= TIMESTAMP }
 ,#{updateBy,jdbcType=VARCHAR}
 ,#{updateTime,jdbcType= TIMESTAMP }
+,#{defaultFaceLibraryId,jdbcType=VARCHAR}
 		)
 	]]>
 	</insert>
@@ -72,6 +78,9 @@
 				<if test="isOnline!=null">
 		is_online=#{isOnline,jdbcType= NUMERIC },
 		</if>
+			<if test="companyId!=null">
+				company_id=#{companyId,jdbcType=VARCHAR},
+			</if>
 				<if test="unlockPassword!=null">
 		unlock_password=#{unlockPassword,jdbcType=VARCHAR},
 		</if>
@@ -87,6 +96,9 @@
 				<if test="type!=null">
 		type_=#{type,jdbcType=VARCHAR},
 		</if>
+			<if test="isAutoUpdate!=null">
+				is_auto_update=#{isAutoUpdate,jdbcType= NUMERIC },
+			</if>
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
 		</if>
@@ -102,24 +114,32 @@
 				<if test="updateTime!=null">
 		update_time=#{updateTime,jdbcType= TIMESTAMP },
 		</if>
+			<if test="defaultFaceLibraryId!=null">
+				default_face_library_id=#{defaultFaceLibraryId,jdbcType= VARCHAR },
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="DeviceInfoMap">
-		select 
-id_, header_,device_no,alias_name,address_,is_online,unlock_password,code_address,ip_address,port_,type_,del_flag,create_by,create_time,update_by,update_time		from base_device_info where id_=#{0}
+		select
+id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id		from base_device_info where id_=#{0}
+	</select>
+	<select id="getByDeviceNo" parameterType="string" resultMap="DeviceInfoMap">
+		select
+id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id		from base_device_info where device_no=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
-		select count(*) from base_device_info where id_=#{0}
+		select count(*) from base_device_info where id_=#{0} and  del_flag=false
 	</select>
 	<select id="list" resultMap="DeviceInfoMap">
-		select * from base_device_info
+		select * from base_device_info where del_flag=false
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="DeviceInfoMap">
 		<![CDATA[
 			select * from base_device_info
 		]]>
 		<where>
+			and del_flag=false
 			<if test="searchParams.aliasName != null">
 				and alias_name like #{searchParams.aliasName}
 			</if>
@@ -129,9 +149,16 @@ id_, header_,device_no,alias_name,address_,is_online,unlock_password,code_addres
 			<if test="searchParams.address != null">
 				and address_ like #{searchParams.address}
 			</if>
+			<if test="searchParams.companyId != null">
+				and company_id = #{searchParams.companyId}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="findByDeviceNo" parameterType="string" resultMap="DeviceInfoMap">
+			select * from base_device_info where device_no = #{0}
+	</select>
+
 </mapper>

+ 42 - 0
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -18,6 +18,10 @@
         <result property="matchFaceId" column="match_face_id" />
         <result property="faceImage" column="face_image" />
         <result property="recordTime" column="record_time" />
+        <association property="device" column="device_no"
+                     select="com.jpsoft.smart.modules.base.dao.DeviceInfoDAO.getByDeviceNo"></association>
+        <association property="person" column="person_id"
+                     select="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.get"></association>
     </resultMap>
     <insert id="insert" parameterType="PersonDeviceLog">
         <!--
@@ -47,5 +51,43 @@
 		)
 	]]>
     </insert>
+    <select id="search" parameterType="hashmap" resultMap="PersonDeviceLogMap">
+        <![CDATA[
+			select * from base_person_device_log a left join base_device_info b
+			on  a.device_no = b.device_no left join base_person_info c
+			on a.person_id = c.id_
+		]]>
+        <where>
+            and a.del_flag = false and b.del_flag=false and c.del_flag=false
+            <if test="searchParams.companyId != null">
+                and c.company_id = #{searchParams.companyId}
+            </if>
+            <if test="searchParams.deviceNo != null">
+                and a.device_no like #{searchParams.deviceNo}
+            </if>
+            <if test="searchParams.aliasName != null">
+                and b.alias_name like #{searchParams.aliasName}
+            </if>
+            <if test="searchParams.personName != null">
+                and c.name_ like #{searchParams.personName}
+            </if>
+            <if test="searchParams.matchStatus != null">
+                and a.match_status = #{searchParams.matchStatus}
+            </if>
+            <if test="searchParams.beginTime != null">
+                <![CDATA[
+                  and a.record_time >= #{searchParams.beginTime}
+                ]]>
+            </if>
+            <if test="searchParams.endTime != null">
+                <![CDATA[
+                  and a.record_time <= #{searchParams.endTime}
+                ]]>
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList"  open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
 
 </mapper>

+ 31 - 7
common/src/main/resources/mapper/base/PersonDeviceRelation.xml

@@ -1,9 +1,21 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.smart.modules.base.dao.PersonDeviceRelationDAO">
-	<resultMap id="PersonDeviceRelationMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceRelation">
+    <sql id="Base_Column_List">
+	id_,
+	device_id,
+	person_id,
+	del_flag,
+	create_by,
+	create_time,
+	update_by,
+	update_time,
+	device_id,
+	person_id
+</sql>
+    <resultMap id="PersonDeviceRelationMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceRelation">
 		<id property="id" column="id_" />
 			<result property="deviceId" column="device_id" />
 			<result property="personId" column="person_id" />
@@ -30,7 +42,7 @@
 		(
 #{id,jdbcType=VARCHAR}
 ,#{deviceId,jdbcType=VARCHAR}
-,#{personId,jdbcType=VARCHAR}
+,#{personId,jdbcType=BIGINT}
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{createBy,jdbcType=VARCHAR}
 ,#{createTime,jdbcType= TIMESTAMP }
@@ -49,7 +61,7 @@
 		device_id=#{deviceId,jdbcType=VARCHAR},
 		</if>
 				<if test="personId!=null">
-		person_id=#{personId,jdbcType=VARCHAR},
+		person_id=#{personId,jdbcType=BIGINT},
 		</if>
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
@@ -70,14 +82,23 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="PersonDeviceRelationMap">
-		select 
+		select
 id_,device_id,person_id,del_flag,create_by,create_time,update_by,update_time		from base_person_device_relation where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
-		select count(*) from base_person_device_relation where id_=#{0}
+		select count(*) from base_person_device_relation where id_=#{0} and del_flag=false
 	</select>
 	<select id="list" resultMap="PersonDeviceRelationMap">
-		select * from base_person_device_relation
+		select * from base_person_device_relation where del_flag=false
+	</select>
+	<select id="findByPersonId" parameterType="long" resultMap="PersonDeviceRelationMap">
+		select * from base_person_device_relation where person_id=#{personId} and del_flag=false
+	</select>
+	<select id="findByDeviceId" parameterType="string" resultMap="PersonDeviceRelationMap">
+		select * from base_person_device_relation where device_id=#{deviceId} and del_flag=false
+	</select>
+	<select id="findByDeviceIdAndPersonId"  resultMap="PersonDeviceRelationMap">
+		select * from base_person_device_relation where device_id=#{deviceId} and person_id=#{personId} and del_flag=false
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="PersonDeviceRelationMap">
 		<![CDATA[
@@ -96,4 +117,7 @@ id_,device_id,person_id,del_flag,create_by,create_time,update_by,update_time		fr
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+
+
 </mapper>

+ 7 - 2
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -12,6 +12,7 @@
         <result property="idCard" column="id_card"/>
         <result property="openId" column="open_id"/>
         <result property="faceEnabled" column="face_enabled"/>
+        <result property="faceBound" column="face_bound"/>
         <result property="cardEnabled" column="card_enabled"/>
         <result property="appEnabled" column="app_enabled"/>
         <result property="passwordEnabled" column="password_enabled"/>
@@ -36,7 +37,7 @@
         -->
         <![CDATA[
 		insert into base_person_info
-	    (company_id,name_,phone_,id_card,open_id,face_enabled,card_enabled,
+	    (company_id,name_,phone_,id_card,open_id,face_enabled,face_bound,card_enabled,
 	    app_enabled,password_enabled,guest_enabled,position1_,position2_,
 	    position3_,position4_,position5_,face_image_url,del_flag,create_by,create_time,update_by,update_time)
 		values
@@ -47,6 +48,7 @@
             ,#{idCard,jdbcType=VARCHAR}
             ,#{openId,jdbcType= VARCHAR }
             ,#{faceEnabled,jdbcType= NUMERIC }
+            ,#{faceBound,jdbcType= NUMERIC }
             ,#{cardEnabled,jdbcType= NUMERIC }
             ,#{appEnabled,jdbcType= NUMERIC }
             ,#{passwordEnabled,jdbcType= NUMERIC }
@@ -56,7 +58,7 @@
             ,#{position3,jdbcType=VARCHAR}
             ,#{position4,jdbcType=VARCHAR}
             ,#{position5,jdbcType=VARCHAR}
-            ,#{face_image_url,jdbcType=VARCHAR}
+            ,#{faceImageUrl,jdbcType=VARCHAR}
             ,#{delFlag,jdbcType= NUMERIC }
             ,#{createBy,jdbcType=VARCHAR}
             ,#{createTime,jdbcType= TIMESTAMP }
@@ -89,6 +91,9 @@
             <if test="faceEnabled!=null">
                 face_enabled=#{faceEnabled,jdbcType= NUMERIC },
             </if>
+            <if test="faceBound!=null">
+                face_bound=#{faceBound,jdbcType= NUMERIC },
+            </if>
             <if test="cardEnabled!=null">
                 card_enabled=#{cardEnabled,jdbcType= NUMERIC },
             </if>

+ 16 - 0
common/src/main/resources/mapper/sys/DataDictionary.xml

@@ -158,4 +158,20 @@
         from sys_data_dictionary a
         where a.id_=#{0} and a.del_flag = 0
     </select>
+    <select id="findByCatalogName" resultMap="DataDictionaryMap">
+        select a.*
+        from sys_data_dictionary a,sys_data_dictionary b
+        where a.parent_id =b.id_ and b.name_=#{0}
+        and a.del_flag = 0
+        order by a.sort_no asc
+    </select>
+    <select id="findNameByCatalogNameAndValue" parameterType="map" resultType="string">
+        select a.name_
+        from sys_data_dictionary a,sys_data_dictionary b
+        where a.parent_id =b.id_ and b.name_=#{catalogName}
+        and a.del_flag = 0
+        and a.value_=#{value}
+        order by a.sort_no asc
+        limit 1
+    </select>
 </mapper>

+ 19 - 0
lapi/src/main/java/com/jpsoft/smart/lapi/handler/HeartReportHandler.java

@@ -2,11 +2,14 @@ package com.jpsoft.smart.lapi.handler;
 
 import cn.hutool.json.JSONObject;
 import com.jpsoft.smart.lapi.dto.HeartReportInfo;
+import com.jpsoft.smart.modules.base.service.DeviceInfoService;
+import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import io.netty.handler.codec.http.FullHttpRequest;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.text.SimpleDateFormat;
@@ -16,8 +19,24 @@ import java.util.Date;
 @Component
 @ChannelHandler.Sharable
 public class HeartReportHandler extends SimpleChannelInboundHandler<HeartReportInfo> {
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+
     @Override
     protected void channelRead0(ChannelHandlerContext channelHandlerContext, HeartReportInfo heartReportInfo) throws Exception {
+
+        log.warn(String.valueOf(channelHandlerContext.channel().remoteAddress()));
         log.warn(heartReportInfo.toString());
+        String ipAndPort = String.valueOf(channelHandlerContext.channel().remoteAddress());
+        String deviceNo = heartReportInfo.getDeviceCode();
+        String ip = ipAndPort.substring(ipAndPort.indexOf("/")+1,ipAndPort.indexOf(":"));
+        log.warn(deviceNo);
+        log.warn("ip =="+ip);
+
+        deviceInfoService.updateByDeviceNo(deviceNo,ip);
+
+
+
+
     }
 }

+ 1 - 0
lapi/src/main/java/com/jpsoft/smart/lapi/handler/ParseRequestHandler.java

@@ -30,6 +30,7 @@ public class ParseRequestHandler extends SimpleChannelInboundHandler<FullHttpReq
         byteBuf.resetReaderIndex();
 
         log.warn(request.uri());
+     //   log.warn(String.valueOf(ctx.channel().remoteAddress()));
 
         String json = new String(buffer,"UTF-8");
 

+ 7 - 4
lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java

@@ -37,11 +37,16 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         JSONObject faceJson = new JSONObject(jsonObject.getStr("FaceInfoList").substring(1,jsonObject.getStr("FaceInfoList").length()-1));
       //  log.warn(faceJson.getStr("FaceImage"));
 
-        long timestamp = faceJson.getLong("Timestamp");
+     //   String  timestampStr = faceJson.getStr("Timestamp");
+        Long timestamp = faceJson.getLong("Timestamp");
+        if (timestamp.toString().length()<13){
+             double timestampDouble = timestamp *  Math.pow(10, 13 - timestamp.toString().length());
+             timestamp =new Double(timestampDouble).longValue() ;
+        }
 
+        log.warn(String.valueOf(timestamp));
         Date date = new Date(timestamp);
 
-     //   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
 
 
@@ -55,8 +60,6 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         //人员抓拍信息
         JSONObject faceImageJson = faceJson.getJSONObject("FaceImage");
 
-        //log.warn("jsonObject========"+jsonObject);
-      //  log.warn("LibMatInfoList:----"+ jsonObject.getStr("LibMatInfoList"));
         //匹配状态信息
         JSONObject libMatInfoListJson = new JSONObject();
         if (StringUtils.isNotBlank(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1))){

+ 16 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -105,6 +105,22 @@ public class CompanyInfoController {
 
             if (companyInfo != null) {
                 PojoUtils.map(companyInfo, companyInfoDTO);
+
+                CompanyPosition companyPosition = new CompanyPosition();
+                Map<String,Object> searchParams1 = new HashMap<>();
+                searchParams1.put("companyId",companyInfo.getId());
+                List<Sort> sortList1 = new ArrayList<>();
+                sortList1.add(new Sort("id_","asc"));
+                Page<CompanyPosition> page1 = companyPositionService.pageSearch(searchParams1,1,1,false,sortList1);
+                if(page1.size() > 0) {
+                    companyPosition = page1.get(0);
+                    companyInfoDTO.setPosition1Name(companyPosition.getPosition1Name());
+                    companyInfoDTO.setPosition2Name(companyPosition.getPosition2Name());
+                    companyInfoDTO.setPosition3Name(companyPosition.getPosition3Name());
+                    companyInfoDTO.setPosition4Name(companyPosition.getPosition4Name());
+                    companyInfoDTO.setPosition5Name(companyPosition.getPosition5Name());
+                }
+
                 msgResult.setResult(true);
                 msgResult.setData(companyInfoDTO);
             } else {

+ 15 - 1
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -1,6 +1,7 @@
 package com.jpsoft.smart.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.AlarmInfo;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
@@ -22,7 +23,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 @RestController
-@RequestMapping("/deviceInfo")
+@RequestMapping("/base/deviceInfo")
 @Api(description = "设备信息")
 public class DeviceInfoController {
     private Logger logger = LoggerFactory.getLogger(getClass());
@@ -64,6 +65,19 @@ public class DeviceInfoController {
         return msgResult;
     }
 
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<DeviceInfo> create(){
+        MessageResult<DeviceInfo> msgResult = new MessageResult<>();
+
+        DeviceInfo deviceInfo = new DeviceInfo();
+
+        msgResult.setData(deviceInfo);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
     @ApiOperation(value="获取设备信息")
     @GetMapping("edit/{id}")
     public MessageResult<DeviceInfo> edit(@PathVariable("id") String id){

+ 99 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java

@@ -0,0 +1,99 @@
+package com.jpsoft.smart.modules.base.controller;
+
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.util.StringUtil;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/personDeviceLog")
+@Api(description = "日志台账")
+public class PersonDeviceLogController {
+    @Autowired
+    private PersonDeviceLogService personDeviceLogService;
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "companyId",value = "企业ID", paramType = "query"),
+            @ApiImplicitParam(name = "deviceNo",value = "设备编号", paramType = "query"),
+            @ApiImplicitParam(name = "aliasName",value = "设备别名", paramType = "query"),
+            @ApiImplicitParam(name = "personName",value = "人员姓名", paramType = "query"),
+            @ApiImplicitParam(name = "matchStatus",value = "开门类型", paramType = "query"),
+            @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query")
+
+    })
+    public MessageResult<Map> pageList(
+            String companyId,
+            String deviceNo,String aliasName,String personName,
+            String matchStatus,String timeRanges,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.record_time","desc"));
+
+        if(StringUtil.isNotEmpty(companyId)){
+            searchParams.put("companyId",companyId);
+        }
+        if(StringUtil.isNotEmpty(deviceNo)){
+            searchParams.put("deviceNo","%"+deviceNo+"%");
+        }
+        if(StringUtil.isNotEmpty(aliasName)){
+            searchParams.put("aliasName","%"+aliasName+"%");
+        }
+        if(StringUtil.isNotEmpty(personName)){
+            searchParams.put("personName","%"+personName+"%");
+        }
+        if(StringUtil.isNotEmpty(matchStatus)){
+            searchParams.put("matchStatus",matchStatus);
+        }
+
+        if(StringUtil.isNotEmpty(timeRanges)){
+            String[] timeRangeArray = timeRanges.split(",");
+            String beginTime = "";
+            String endTime = "";
+            if(timeRangeArray.length==1){
+                beginTime = timeRangeArray[0];
+            }
+            else if(timeRangeArray.length==2){
+                beginTime = timeRangeArray[0];
+                endTime = timeRangeArray[1];
+            }
+
+            searchParams.put("beginTime",beginTime);
+            searchParams.put("endTime",endTime);
+        }
+
+        Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}

+ 201 - 6
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -1,11 +1,17 @@
 package com.jpsoft.smart.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.github.pagehelper.util.StringUtil;
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.service.DeviceInfoService;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.sys.entity.User;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceRelation;
 import com.jpsoft.smart.modules.base.service.PersonDeviceRelationService;
+import com.jpsoft.smart.modules.sys.service.DataDictionaryService;
+import com.jpsoft.smart.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -29,6 +35,15 @@ public class PersonDeviceRelationController {
     @Autowired
     private PersonDeviceRelationService personDeviceRelationService;
 
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+
     
     @ApiOperation(value="添加设备和人员绑定")
     @PostMapping("add")
@@ -36,12 +51,19 @@ public class PersonDeviceRelationController {
         MessageResult<PersonDeviceRelation> msgResult = new MessageResult<>();
 
         try {
-            personDeviceRelation.setId(UUID.randomUUID().toString());
-            personDeviceRelation.setDelFlag(false);
-            personDeviceRelation.setCreateBy(subject);
-            personDeviceRelation.setCreateTime(new Date());
-            
-            int affectCount = personDeviceRelationService.insert(personDeviceRelation);
+            int affectCount = 0;
+
+            PersonDeviceRelation item = personDeviceRelationService.findByDeviceIdAndPersonId(personDeviceRelation.getDeviceId(),personDeviceRelation.getPersonId());
+
+            if(item == null) {
+
+                personDeviceRelation.setId(UUID.randomUUID().toString());
+                personDeviceRelation.setDelFlag(false);
+                personDeviceRelation.setCreateBy(subject);
+                personDeviceRelation.setCreateTime(new Date());
+
+                affectCount = personDeviceRelationService.insert(personDeviceRelation);
+            }
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
@@ -61,6 +83,57 @@ public class PersonDeviceRelationController {
         return msgResult;
     }
 
+
+    @ApiOperation(value="人员与设备批量绑定")
+    @PostMapping("batchBindDevice")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId",value = "人员ID", required = true,paramType = "query"),
+            @ApiImplicitParam(name = "devices",value = "设备ID(多个设备)", required = true, paramType = "query")
+    })
+    public MessageResult<Integer> batchBindDevice(Long personId,String devices,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+        int affectCount = 0;
+
+        try {
+            if(StringUtil.isNotEmpty(devices)){
+               String[] deviceArray = devices.split(",");
+
+               for (String deviceId:deviceArray) {
+
+                   PersonDeviceRelation item = personDeviceRelationService.findByDeviceIdAndPersonId(deviceId,personId);
+
+                   if(item == null) {
+                       item = new PersonDeviceRelation();
+                       item.setId(UUID.randomUUID().toString());
+                       item.setDeviceId(deviceId);
+                       item.setPersonId(personId);
+                       item.setDelFlag(false);
+                       item.setCreateBy(subject);
+                       item.setCreateTime(new Date());
+
+                       affectCount += personDeviceRelationService.insert(item);
+                   }
+               }
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="获取人员和设备绑定信息")
     @GetMapping("edit/{id}")
     public MessageResult<PersonDeviceRelation> edit(@PathVariable("id") String id){
@@ -220,4 +293,126 @@ public class PersonDeviceRelationController {
 
         return msgResult;
     }
+
+
+    @ApiOperation(value="根据人员ID查询设备列表")
+    @RequestMapping(value = "listByPersonId",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId",value = "人员ID",paramType = "query")
+    })
+    public MessageResult<List<PersonDeviceRelation>> listByPersonId(Long personId){
+
+        MessageResult<List<PersonDeviceRelation>> msgResult = new MessageResult<>();
+
+        List<PersonDeviceRelation> personDeviceRelationList = personDeviceRelationService.findByPersonId(personId);
+
+        msgResult.setResult(true);
+        msgResult.setData(personDeviceRelationList);
+
+        return msgResult;
+    }
+
+
+
+    @ApiOperation(value="根据设备ID查询人员列表")
+    @RequestMapping(value = "listByDeviceId",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "deviceId",value = "设备ID",paramType = "query")
+    })
+    public MessageResult<List<PersonDeviceRelation>> listByDeviceId(String deviceId){
+
+        MessageResult<List<PersonDeviceRelation>> msgResult = new MessageResult<>();
+
+        List<PersonDeviceRelation> personDeviceRelationList = personDeviceRelationService.findByDeviceId(deviceId);
+
+        msgResult.setResult(true);
+        msgResult.setData(personDeviceRelationList);
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="人员解绑所有设备")
+    @RequestMapping(value = "unbindDevice",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId",value = "人员ID",paramType = "query")
+    })
+    public MessageResult<Integer> unbindDevice(Long personId,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try{
+            List<PersonDeviceRelation> personDeviceRelationList = personDeviceRelationService.findByPersonId(personId);
+
+            int affectCount = 0;
+
+            for (PersonDeviceRelation personDeviceRelation: personDeviceRelationList){
+                personDeviceRelation.setDelFlag(true);
+                personDeviceRelation.setUpdateBy(subject);
+                personDeviceRelation.setUpdateTime(new Date());
+                affectCount += personDeviceRelationService.update(personDeviceRelation);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="人员查询是否绑定设备")
+    @RequestMapping(value = "isUnbindDeviceList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId",value = "人员ID",required = true ,paramType = "query")
+    })
+    public MessageResult<Map> isUnbindDeviceList(
+            Long personId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,@RequestAttribute String subject){
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        User user = userService.get(subject);
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        searchParams.put("companyId",user.getCompanyId());
+
+        Page<DeviceInfo> page = deviceInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        for (DeviceInfo deviceInfo:page) {
+            PersonDeviceRelation item = personDeviceRelationService.findByDeviceIdAndPersonId(deviceInfo.getId(),personId);
+            if(item == null){
+                deviceInfo.setIsBindPerson(false);
+            }
+            else{
+                deviceInfo.setIsBindPerson(true);
+            }
+            String typeN = dataDictionaryService.findParentId("ddf2ecbe-84a6-4f0d-a84f-2fc6917f5856",deviceInfo.getType());
+            deviceInfo.setTypeN(typeN);
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+
+    }
+
+
+
+
 }

+ 141 - 11
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -284,6 +284,7 @@ public class PersonInfoController {
             @ApiImplicitParam(name = "name",value = "姓名", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "companyId",value = "企业id", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
@@ -294,6 +295,7 @@ public class PersonInfoController {
             @RequestParam(value="name",defaultValue="") String name,
             @RequestParam(value="idCard",defaultValue="") String idCard,
             @RequestParam(value="phone",defaultValue="") String phone,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
             @RequestParam(value="position1",defaultValue="") String position1,
             @RequestParam(value="position2",defaultValue="") String position2,
             @RequestParam(value="position3",defaultValue="") String position3,
@@ -317,10 +319,13 @@ public class PersonInfoController {
             searchParams.put("name","%" + name + "%");
         }
         if (StringUtils.isNotEmpty(idCard)) {
-            searchParams.put("name","%" + idCard + "%");
+            searchParams.put("idCard","%" + idCard + "%");
         }
         if (StringUtils.isNotEmpty(phone)) {
-            searchParams.put("name","%" + phone + "%");
+            searchParams.put("phone","%" + phone + "%");
+        }
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId",companyId);
         }
         if (StringUtils.isNotEmpty(position1)) {
             searchParams.put("position1",position1);
@@ -656,21 +661,126 @@ public class PersonInfoController {
 
     @ApiOperation(value="导出人员")
     @PostMapping("exportXls")
-    public MessageResult<String> exportXls(HttpServletRequest request, HttpServletResponse response){
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name",value = "姓名", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "companyId",value = "企业id", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position4",value = "四级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position5",value = "五级位置", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<String> exportXls(@RequestParam(value="name",defaultValue="") String name,
+                                           @RequestParam(value="idCard",defaultValue="") String idCard,
+                                           @RequestParam(value="phone",defaultValue="") String phone,
+                                           @RequestParam(value="companyId",defaultValue="") String companyId,
+                                           @RequestParam(value="position1",defaultValue="") String position1,
+                                           @RequestParam(value="position2",defaultValue="") String position2,
+                                           @RequestParam(value="position3",defaultValue="") String position3,
+                                           @RequestParam(value="position4",defaultValue="") String position4,
+                                           @RequestParam(value="position5",defaultValue="") String position5,
+                                           @RequestAttribute String subject){
         MessageResult<String> msgResult = new MessageResult<>();
 
         try {
-            //创建hssfWorkbook
             HSSFWorkbook workbook = new HSSFWorkbook();
-
-            //创建工作簿
             HSSFSheet sheet = workbook.createSheet();
+            //表头
+            HSSFRow rowTitle = sheet.createRow(0);
+            HSSFCell cellTitle1 = rowTitle.createCell(0);
+            cellTitle1.setCellValue("序号");
+            HSSFCell cellTitle2 = rowTitle.createCell(1);
+            cellTitle2.setCellValue("姓名");
+            HSSFCell cellTitle3 = rowTitle.createCell(2);
+            cellTitle3.setCellValue("身份证");
+            HSSFCell cellTitle4 = rowTitle.createCell(3);
+            cellTitle4.setCellValue("手机号");
+            HSSFCell cellTitle5 = rowTitle.createCell(4);
+            cellTitle5.setCellValue("位置1");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("位置2");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("位置3");
+            HSSFCell cellTitle8 = rowTitle.createCell(7);
+            cellTitle8.setCellValue("位置4");
+            HSSFCell cellTitle9 = rowTitle.createCell(8);
+            cellTitle9.setCellValue("位置5");
+            HSSFCell cellTitle10 = rowTitle.createCell(9);
+            cellTitle10.setCellValue("人脸开关");
+            HSSFCell cellTitle11 = rowTitle.createCell(10);
+            cellTitle11.setCellValue("刷卡开关");
+            HSSFCell cellTitle12 = rowTitle.createCell(11);
+            cellTitle12.setCellValue("手机开关");
+            HSSFCell cellTitle13 = rowTitle.createCell(12);
+            cellTitle13.setCellValue("访客开关");
+
+            //表内容
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.id_","asc"));
+            Map<String,Object> searchParams = new HashMap<>();
+            if (StringUtils.isNotEmpty(name)) {
+                searchParams.put("name","%" + name + "%");
+            }
+            if (StringUtils.isNotEmpty(idCard)) {
+                searchParams.put("idCard","%" + idCard + "%");
+            }
+            if (StringUtils.isNotEmpty(phone)) {
+                searchParams.put("phone","%" + phone + "%");
+            }
+            if (StringUtils.isNotEmpty(companyId)) {
+                searchParams.put("companyId",companyId);
+            }
+            if (StringUtils.isNotEmpty(position1)) {
+                searchParams.put("position1",position1);
+            }
+            if (StringUtils.isNotEmpty(position2)) {
+                searchParams.put("position2",position2);
+            }
+            if (StringUtils.isNotEmpty(position3)) {
+                searchParams.put("position3",position3);
+            }
+            if (StringUtils.isNotEmpty(position4)) {
+                searchParams.put("position4",position4);
+            }
+            if (StringUtils.isNotEmpty(position5)) {
+                searchParams.put("position5",position5);
+            }
 
-            //创建标题
-            HSSFRow row = sheet.createRow(0);
-            HSSFCell cell = row.createCell(0);
-            cell.setCellValue("商品信息汇总");
-
+            Page<PersonInfo> page = personInfoService.pageSearch(searchParams,1,10000,false,sortList);
+
+            for(int i=0; i<page.size(); i++){
+                PersonInfo personInfo = page.get(i);
+
+                HSSFRow rowContent = sheet.createRow(0);
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i+1);
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(personInfo.getName());
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(personInfo.getIdCard());
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                cellContent4.setCellValue(personInfo.getPhone());
+                HSSFCell cellContent5 = rowContent.createCell(4);
+                cellContent5.setCellValue(personInfo.getPosition1());
+                HSSFCell cellContent6 = rowContent.createCell(5);
+                cellContent6.setCellValue(personInfo.getPosition2());
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                cellContent7.setCellValue(personInfo.getPosition3());
+                HSSFCell cellContent8 = rowContent.createCell(7);
+                cellContent8.setCellValue(personInfo.getPosition4());
+                HSSFCell cellContent9 = rowContent.createCell(8);
+                cellContent9.setCellValue(personInfo.getPosition5());
+                HSSFCell cellContent10 = rowContent.createCell(9);
+                cellContent10.setCellValue(personInfo.getFaceEnabled());
+                HSSFCell cellContent11 = rowContent.createCell(10);
+                cellContent11.setCellValue(personInfo.getCardEnabled());
+                HSSFCell cellContent12 = rowContent.createCell(11);
+                cellContent12.setCellValue(personInfo.getAppEnabled());
+                HSSFCell cellContent13 = rowContent.createCell(12);
+                cellContent13.setCellValue(personInfo.getGuestEnabled());
+            }
 
             //todo 将wb保存到oss
             ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -704,4 +814,24 @@ public class PersonInfoController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="数据同步")
+    @PostMapping("dataSync")
+    public MessageResult<String> dataSync(@RequestBody List<String> ids){
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            for(String id : ids){
+
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 61 - 0
web/src/main/java/com/jpsoft/smart/modules/common/controller/fileUploadController.java

@@ -0,0 +1,61 @@
+package com.jpsoft.smart.modules.common.controller;
+
+import com.jpsoft.smart.config.OSSConfig;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.utils.DES3;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.security.Keys;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpSession;
+import java.security.Key;
+import java.util.Base64;
+import java.util.Date;
+
+@RestController
+public class fileUploadController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private OSSConfig ossConfig;
+
+    @PostMapping("uploadPicture")
+    @ApiOperation(value="人员照片上传")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="subFolder",value = "路径",required = true,paramType = "form"),
+            @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
+    })
+    public MessageResult<String> uploadPicture(String subFolder, MultipartFile photoFile){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            String retFileUrl = OSSUtil.upload(ossConfig,"/" + subFolder,photoFile.getOriginalFilename(),photoFile.getInputStream());
+
+            messageResult.setResult(true);
+            messageResult.setData(retFileUrl);
+            messageResult.setCode(200);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+        }
+
+        return messageResult;
+    }
+}

+ 38 - 9
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -7,6 +7,8 @@ import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.common.utils.SMSUtil;
+import com.jpsoft.smart.modules.lapi.service.ILapiService;
+import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
@@ -23,10 +25,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 @RestController
@@ -40,6 +39,9 @@ public class PersonInfoApiController {
     @Autowired
     private PersonInfoService personInfoService;
 
+    @Autowired
+    private ILapiService lapiService;
+
     @Autowired
     private ValueOperations<String, Object> valueOperations;
 
@@ -56,7 +58,7 @@ public class PersonInfoApiController {
             PersonInfo personInfo = personInfoService.findByNameAndPhone(name, phone);
 
             if (personInfo==null){
-                throw new Exception("当前用户信息未登记,请先联系单位管理员!");
+                throw new Exception("您的信息暂未登记,请先联系管理人员!");
             }
 
             if (personInfo.getFaceEnabled()==null || !personInfo.getFaceEnabled()){
@@ -266,18 +268,45 @@ public class PersonInfoApiController {
                 throw new Exception("人员信息不存在!");
             }
 
+            //todo 同步终端
+            List<LapiMsgResult> msgResultList = lapiService.addPerson(personId);
+
+            StringBuilder sb = new StringBuilder();
+
+            boolean success = true;
+
+            for(int i=0;i<msgResultList.size();i++) {
+                LapiMsgResult lapiMsgResult = msgResultList.get(i);
+
+                if (lapiMsgResult.isSuccess()){
+                    sb.append(lapiMsgResult.getAliasName() + "绑定人脸信息成功!");
+                }
+                else{
+                    sb.append(lapiMsgResult.getAliasName() + "绑定人脸信息失败!" + lapiMsgResult.getMsg());
+                }
+
+                if (i!=msgResultList.size()-1){
+                    sb.append(",");
+                }
+                else{
+                    sb.append("。");
+                }
+
+                success &= lapiMsgResult.isSuccess();
+            }
+
             personInfo.setOpenId(openId);
             personInfo.setFaceImageUrl(faceImageUrl);
+            personInfo.setFaceBound(success);
 
             personInfo.setUpdateTime(new Date());
 
             personInfoService.update(personInfo);
 
-            //todo 同步终端
-
-
             messageResult.setData(personInfo);
-            messageResult.setResult(true);
+            messageResult.setResult(success);
+            messageResult.setMessage(sb.toString());
+
             messageResult.setCode(200);
         } catch (Exception e) {
             logger.error(e.getMessage(),e);

+ 25 - 0
web/src/main/java/com/jpsoft/smart/modules/sys/controller/DataDictionaryController.java

@@ -7,6 +7,8 @@ import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.sys.entity.DataDictionary;
 import com.jpsoft.smart.modules.sys.service.DataDictionaryService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -281,4 +283,27 @@ public class DataDictionaryController {
         msgResult.setData(dataDictionaryList);
         return msgResult;
     }
+
+    @PostMapping("findByCatalogName")
+    @ApiOperation(value = "根据目录名称查询数据列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "catalogName",value = "数据目录名称", required = true, paramType = "form",dataType = "String"),
+    })
+    public MessageResult<List> findByCatalogName(String catalogName){
+        MessageResult<List> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            List<DataDictionary> list = dataDictionaryService.findByCatalogName(catalogName);
+            messageResult.setData(list);
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
 }

+ 33 - 0
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -1,12 +1,16 @@
 package com.jpsoft.smart;
 
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
+import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.List;
+
 /**
  * @author 墨鱼_mo
  * @date 2020-3-15 9:58
@@ -30,4 +34,33 @@ public class LApiTest {
 
     }
 
+    @Test
+    public void testAddPerson(){
+        try {
+
+            List<LapiMsgResult> result = lapiService.addPerson(1111L);
+            System.out.println(result);
+        } catch (Exception e) {
+            e.printStackTrace();
+            String message = e.getMessage();
+        }
+
+    }
+
+    @Test
+    public void testGetFaceDB(){
+        try {
+
+            DeviceInfo deviceInfo = new DeviceInfo();
+            deviceInfo.setIpAddress("192.168.11.13");
+            deviceInfo.setPort("80");
+            lapiService.getFaceDbId(deviceInfo,"荆鹏软件");
+            System.out.println();
+        } catch (Exception e) {
+            e.printStackTrace();
+            String message = e.getMessage();
+        }
+
+    }
+
 }