소스 검색

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

# Conflicts:
#	common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java
#	common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java
yanliming 5 년 전
부모
커밋
e68bd8501b

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/CompanyDeviceRelationDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.smart.modules.base.dao;
 
 import java.util.List;
+
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.smart.modules.base.entity.CompanyDeviceRelation;
 import java.util.Map;
@@ -15,4 +17,6 @@ public interface CompanyDeviceRelationDAO {
 	int delete(String id);
 	List<CompanyDeviceRelation> list();
 	List<CompanyDeviceRelation> search(Map<String,Object> searchParams,List<Sort> sortList);
+    List<DeviceInfo> findDeviceByCompanyId(String companyId);
+	int deleteByCompanyId(String companyId);
 }

+ 61 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/PersonDeviceFilterLogDTO.java

@@ -0,0 +1,61 @@
+package com.jpsoft.smart.modules.base.dto;
+
+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.util.Date;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-15 13:30
+ */
+@Data
+@ApiModel(value = "base_person_device_filter_log的实体类")
+public class PersonDeviceFilterLogDTO {
+    @ApiModelProperty(value = "ID")
+    private Long id;
+    @ApiModelProperty(value = "设备序列号")
+    private String deviceNo;
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+    @ApiModelProperty(value = "人员id")
+    private Integer personId;
+    @ApiModelProperty(value = "人员名称")
+    private String personName;
+    @ApiModelProperty(value = "记录温度")
+    private BigDecimal temperature;
+    @ApiModelProperty(value = "匹配状态")
+    private Integer matchStatus;
+    @ApiModelProperty(value = "匹配信息")
+    private String  matchMsg;
+    @ApiModelProperty(value = "匹配人脸 ID")
+    private Integer  matchFaceId;
+    @ApiModelProperty(value = "图片地址")
+    private String faceImage;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
+    @ApiModelProperty(value = "记录时间")
+    private Date recordTime;
+    @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;
+    @ApiModelProperty(value = "时间段")
+    private String timeZones;
+    @ApiModelProperty(value = "温度是否正常")
+    private Boolean fever;
+}

+ 3 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/CompanyDeviceRelationService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 import com.jpsoft.smart.modules.base.entity.CompanyDeviceRelation;
 import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.common.dto.Sort;
 
 public interface CompanyDeviceRelationService {
@@ -14,4 +15,6 @@ public interface CompanyDeviceRelationService {
 	int delete(String id);
 	List<CompanyDeviceRelation> list();
 	Page<CompanyDeviceRelation> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	List<DeviceInfo> findDeviceByCompanyId(String companyId);
+	int deleteByCompanyId(String companyId);
 }

+ 12 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/CompanyDeviceRelationServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
+
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.smart.modules.base.dao.CompanyDeviceRelationDAO;
@@ -67,4 +69,14 @@ public class CompanyDeviceRelationServiceImpl implements CompanyDeviceRelationSe
         
         return page;
 	}
+
+	@Override
+	public List<DeviceInfo> findDeviceByCompanyId(String companyId) {
+		return companyDeviceRelationDAO.findDeviceByCompanyId(companyId);
+	}
+
+	@Override
+	public int deleteByCompanyId(String companyId) {
+		return companyDeviceRelationDAO.deleteByCompanyId(companyId);
+	}
 }

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

@@ -41,6 +41,11 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     @Resource(name="personDeviceFilterLogDAO")
     private PersonDeviceFilterLogDAO personDeviceFilterLogDAO;
 
+    @Override
+    public PersonDeviceFilterLog get(Long id) {
+        // TODO Auto-generated method stub
+        return personDeviceFilterLogDAO.get(id);
+    }
 
     @Override
     public void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {

+ 7 - 0
common/src/main/resources/mapper/base/CompanyDeviceRelation.xml

@@ -38,6 +38,9 @@
     <delete id="delete" parameterType="string">
         delete from base_company_device_relation where id_=#{id,jdbcType=VARCHAR}
     </delete>
+    <delete id="deleteByCompanyId" parameterType="string">
+        delete from base_company_device_relation where company_id=#{0}
+    </delete>
     <update id="update" parameterType="com.jpsoft.smart.modules.base.entity.CompanyDeviceRelation">
         update base_company_device_relation
         <set>
@@ -89,4 +92,8 @@
             ${sort.name} ${sort.order}
         </foreach>
     </select>
+    <select id="findDeviceByCompanyId" resultMap="com.jpsoft.smart.modules.base.dao.DeviceInfoDAO.DeviceInfoMap">
+        select b.* from base_company_device_relation a,base_device_info b
+        where a.device_id=b.id_ and a.company_id=#{0} order by b.create_time asc
+    </select>
 </mapper>

+ 32 - 22
common/src/main/resources/mapper/base/DeviceInfo.xml

@@ -36,25 +36,25 @@
 	    (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}
-,#{header,jdbcType=VARCHAR}
-,#{deviceNo,jdbcType=VARCHAR}
-,#{aliasName,jdbcType=VARCHAR}
-,#{address,jdbcType=VARCHAR}
-,#{isOnline,jdbcType= NUMERIC }
-,#{companyId,jdbcType=VARCHAR}
-,#{unlockPassword,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}
+			#{id,jdbcType=VARCHAR}
+			,#{header,jdbcType=VARCHAR}
+			,#{deviceNo,jdbcType=VARCHAR}
+			,#{aliasName,jdbcType=VARCHAR}
+			,#{address,jdbcType=VARCHAR}
+			,#{isOnline,jdbcType= NUMERIC }
+			,#{companyId,jdbcType=VARCHAR}
+			,#{unlockPassword,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>
@@ -178,8 +178,18 @@ id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,
 			select * from base_device_info where device_no = #{0} and del_flag=false
 	</select>
 	<select id="findByCompanyId" parameterType="string" resultMap="DeviceInfoMap">
-			select * from base_device_info where company_id = #{0} and del_flag=false
+		<![CDATA[
+			select * from base_device_info a where
+			(
+				a.company_id = #{0}
+				or
+				a.id_ in(
+					select b.device_id from base_company_device_relation b
+					where b.device_id=a.id_ and b.company_id=#{0}
+				)
+			)
+			and del_flag=0
+			order by create_time asc
+		]]>
 	</select>
-
-
 </mapper>

+ 4 - 0
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -36,6 +36,10 @@
         <result property="timeZones" column="time_zones" />
     </resultMap>
 
+    <select id="get" parameterType="Long" resultMap="PersonDeviceFilterLogMap">
+        select * from base_person_device_filter_log where id_=#{0}
+    </select>
+
     <insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog">
         <!--
         <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">

+ 62 - 3
web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -2,17 +2,17 @@ package com.jpsoft.smart.modules.base.controller;
 
 import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.base.dto.CompanyInfoDTO;
-import com.jpsoft.smart.modules.base.entity.CompanyPosition;
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.entity.*;
+import com.jpsoft.smart.modules.base.service.CompanyDeviceRelationService;
 import com.jpsoft.smart.modules.base.service.CompanyPositionService;
 import com.jpsoft.smart.modules.base.service.PersonInfoService;
 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.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.service.CompanyInfoService;
 import com.jpsoft.smart.modules.sys.entity.User;
 import com.jpsoft.smart.modules.sys.service.UserService;
+import com.rabbitmq.client.AMQP;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -21,6 +21,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -47,6 +49,9 @@ public class CompanyInfoController {
     @Autowired
     private PersonInfoService personInfoService;
 
+    @Autowired
+    private CompanyDeviceRelationService companyDeviceRelationService;
+
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
     public MessageResult<CompanyInfoDTO> create(){
@@ -369,4 +374,58 @@ public class CompanyInfoController {
 
         return msgResult;
     }
+
+    @GetMapping("queryBindDeviceList")
+    public MessageResult<List> queryBindDeviceList(String companyId){
+        MessageResult<List> messageResult = new MessageResult<>();
+
+        try {
+            List<DeviceInfo> deviceList = companyDeviceRelationService.findDeviceByCompanyId(companyId);
+
+            messageResult.setData(deviceList);
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @PostMapping("bindDevice")
+    public MessageResult<String> bindDevice(String companyId,String deviceIds,@ModelAttribute String subject){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            String[] arr = deviceIds.split(",");
+
+            companyDeviceRelationService.deleteByCompanyId(companyId);
+
+            for (String deviceId : arr) {
+                CompanyDeviceRelation cdr = new CompanyDeviceRelation();
+                cdr.setId(UUID.randomUUID().toString());
+                cdr.setCompanyId(companyId);
+                cdr.setDeviceId(deviceId);
+
+                cdr.setCreateBy(subject);
+                cdr.setCreateTime(new Date());
+
+                companyDeviceRelationService.insert(cdr);
+            }
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+
+            logger.error(ex.getMessage(),ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
 }

+ 69 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceFilterLogController.java

@@ -1,12 +1,81 @@
 package com.jpsoft.smart.modules.mobile.controller;
 
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.dto.PersonDeviceFilterLogDTO;
+import com.jpsoft.smart.modules.base.entity.CompanyPosition;
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.service.DeviceInfoService;
+import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
+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.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @RestController
 @RequestMapping("/mobile/PersonDeviceFilterLog")
 public class PersonDeviceFilterLogController {
     private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private PersonDeviceFilterLogService personDeviceFilterLogService;
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+    @Autowired
+    private PersonInfoService personInfoService;
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<PersonDeviceFilterLogDTO> edit(@PathVariable("id") Long id){
+        MessageResult<PersonDeviceFilterLogDTO> msgResult = new MessageResult<>();
+
+        try {
+            PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogService.get(id);
+            PersonDeviceFilterLogDTO personDeviceFilterLogDTO = new PersonDeviceFilterLogDTO();
+
+            if (personDeviceFilterLog != null) {
+                PojoUtils.map(personDeviceFilterLog, personDeviceFilterLogDTO);
+
+                DeviceInfo deviceInfo = deviceInfoService.get(personDeviceFilterLog.getDeviceNo());
+                PersonInfo personInfo = personInfoService.get(Long.valueOf(personDeviceFilterLog.getPersonId()));
+
+                personDeviceFilterLogDTO.setDeviceName(deviceInfo.getAliasName());
+                personDeviceFilterLogDTO.setPersonName(personInfo.getName());
+                if(personDeviceFilterLog.getTemperature().compareTo(new BigDecimal("37")) == 1 || personDeviceFilterLog.getTemperature().compareTo(new BigDecimal("37")) == 0){
+                    personDeviceFilterLogDTO.setFever(true);
+                }else {
+                    personDeviceFilterLogDTO.setFever(false);
+                }
+
+                msgResult.setResult(true);
+                msgResult.setData(personDeviceFilterLogDTO);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }