Explorar el Código

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

# Conflicts:
#	web/src/main/resources/application-dev.yml
zhengqiang hace 5 años
padre
commit
be6dc8aefc

+ 11 - 1
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -60,7 +60,7 @@
 			on a.person_id = c.id_
 		]]>
         <where>
-            and a.del_flag = false and b.del_flag=false and c.del_flag=false
+            and a.del_flag = false and b.del_flag=false
             <if test="searchParams.companyId != null">
                 and c.company_id = #{searchParams.companyId}
             </if>
@@ -86,6 +86,16 @@
                   and a.record_time <= #{searchParams.endTime}
                 ]]>
             </if>
+            <if test="searchParams.minTemperature != null">
+                <![CDATA[
+                  and a.temperature_ >= #{searchParams.minTemperature}
+                ]]>
+            </if>
+            <if test="searchParams.maxTemperature != null">
+                <![CDATA[
+                  and a.temperature_ <= #{searchParams.maxTemperature}
+                ]]>
+            </if>
         </where>
         <foreach item="sort" collection="sortList"  open="order by" separator=",">
             ${sort.name} ${sort.order}

+ 28 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -7,6 +7,7 @@ import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.service.DeviceInfoService;
+import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.sys.service.DataDictionaryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -34,6 +35,9 @@ public class DeviceInfoController {
     @Autowired
     private DataDictionaryService dataDictionaryService;
 
+    @Autowired
+    private ILapiService lapiService;
+
     @ApiOperation(value="添加设备")
     @PostMapping("add")
     public MessageResult<DeviceInfo> add(@RequestBody DeviceInfo deviceInfo,@RequestAttribute String subject){
@@ -245,4 +249,28 @@ public class DeviceInfoController {
 
         return msgResult;
     }
+
+
+    @ApiOperation(value="根据IP地址和端口号查找设备")
+    @PostMapping("getByIpAddressAndPort")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ipAddress",value = "IP地址", paramType = "query"),
+            @ApiImplicitParam(name = "port",value = "端口号", paramType = "query")
+    })
+    public MessageResult<DeviceInfo> getByIpAddressAndPort( String ipAddress,String port,@RequestAttribute String subject) {
+        MessageResult<DeviceInfo> msgResult = new MessageResult<>();
+        try {
+            DeviceInfo device = lapiService.findByIpAddressAndPort(ipAddress, port);
+
+            msgResult.setResult(true);
+            msgResult.setData(device);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+        return msgResult;
+    }
 }

+ 210 - 6
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java

@@ -3,19 +3,30 @@ package com.jpsoft.smart.modules.base.controller;
 
 import com.github.pagehelper.Page;
 import com.github.pagehelper.util.StringUtil;
+import com.jpsoft.smart.config.OSSConfig;
 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.OSSUtil;
 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.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -25,9 +36,13 @@ import java.util.Map;
 @RequestMapping("/personDeviceLog")
 @Api(description = "日志台账")
 public class PersonDeviceLogController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
     private PersonDeviceLogService personDeviceLogService;
 
+    @Autowired
+    private OSSConfig ossConfig;
+
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     @ApiImplicitParams({
@@ -35,14 +50,14 @@ public class PersonDeviceLogController {
             @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")
+            @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query"),
+            @ApiImplicitParam(name = "temperatureRanges",value = "温度范围", paramType = "query")
 
     })
     public MessageResult<Map> pageList(
             String companyId,
             String deviceNo,String aliasName,String personName,
-            String matchStatus,String timeRanges,
+            String timeRanges,String temperatureRanges,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -69,9 +84,7 @@ public class PersonDeviceLogController {
         if(StringUtil.isNotEmpty(personName)){
             searchParams.put("personName","%"+personName+"%");
         }
-        if(StringUtil.isNotEmpty(matchStatus)){
-            searchParams.put("matchStatus",matchStatus);
-        }
+
 
         if(StringUtil.isNotEmpty(timeRanges)){
             String[] timeRangeArray = timeRanges.split(",");
@@ -89,6 +102,28 @@ public class PersonDeviceLogController {
             searchParams.put("endTime",endTime);
         }
 
+        if(StringUtil.isNotEmpty(temperatureRanges)){
+            String[] temperatureRangeArray = temperatureRanges.split(",");
+
+            String minTemperature = "";
+            String maxTemperature = "";
+
+            if(temperatureRangeArray.length == 1){
+                minTemperature = temperatureRangeArray[0];
+            }
+            if(temperatureRangeArray.length == 2){
+                minTemperature = temperatureRangeArray[0];
+                maxTemperature = temperatureRangeArray[1];
+            }
+
+            if(StringUtil.isNotEmpty(minTemperature)){
+                searchParams.put("minTemperature",minTemperature);
+            }
+            if(StringUtil.isNotEmpty(maxTemperature)){
+                searchParams.put("maxTemperature",maxTemperature);
+            }
+        }
+
         Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
         msgResult.setResult(true);
@@ -96,4 +131,173 @@ public class PersonDeviceLogController {
 
         return msgResult;
     }
+
+
+    @ApiOperation(value="导出日志台账")
+    @PostMapping("exportXls")
+    @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 = "timeRanges",value = "时间范围", paramType = "query"),
+            @ApiImplicitParam(name = "temperatureRanges",value = "温度范围", paramType = "query")
+    })
+    public MessageResult<String> exportXls(
+                                String companyId,
+                                String deviceNo,String aliasName,String personName,
+                                String timeRanges,String temperatureRanges,
+                                @RequestAttribute String subject) {
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            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("设备编号");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("设备别称");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("拍照图片");
+
+
+            //表内容
+            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(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);
+            }
+
+            if(StringUtil.isNotEmpty(temperatureRanges)){
+                String[] temperatureRangeArray = temperatureRanges.split(",");
+
+                String minTemperature = "";
+                String maxTemperature = "";
+                if(temperatureRangeArray.length==1){
+                    minTemperature = temperatureRangeArray[0];
+                }
+                else if(temperatureRangeArray.length==2){
+                    minTemperature = temperatureRangeArray[0];
+                    maxTemperature = temperatureRangeArray[1];
+                }
+
+                searchParams.put("minTemperature",minTemperature);
+                searchParams.put("maxTemperature",maxTemperature);
+            }
+
+            Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams,1,10000,false,sortList);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            for(int i=0; i<page.size(); i++){
+
+                PersonDeviceLog personDeviceLog = page.get(i);
+
+                HSSFRow rowContent = sheet.createRow(i+1);
+
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i+1);
+
+                String recordTime ="";
+                if(personDeviceLog.getRecordTime()!=null){
+                    recordTime = sdf.format(personDeviceLog.getRecordTime());
+                }
+
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(recordTime);
+
+                String name = "";
+                if(personDeviceLog.getPerson()!=null){
+                    name = personDeviceLog.getPerson().getName();
+                }
+                else{
+                    name = "匿名用户";
+                }
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(name);
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                cellContent4.setCellValue(personDeviceLog.getTemperature().toString());
+                HSSFCell cellContent5 = rowContent.createCell(4);
+                cellContent5.setCellValue(personDeviceLog.getDeviceNo());
+                HSSFCell cellContent6 = rowContent.createCell(5);
+                cellContent6.setCellValue(personDeviceLog.getDevice().getAliasName());
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                cellContent7.setCellValue(personDeviceLog.getFaceImage());
+
+                sheet.autoSizeColumn(i);
+            }
+
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+
+            //todo 返回导入失败报表下载链接
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
+
+            //将exal输出到哪个文件夹中
+//            ByteArrayOutputStream out = new ByteArrayOutputStream();
+//            workbook.write(out);
+//            workbook.close();
+//
+//            String fileName = new String("导出数据".getBytes("UTF-8"), "iso-8859-1");
+//            response.setContentType("application/x-msdownload");
+//            response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".xls");
+//            response.getOutputStream().write(out.toByteArray());
+//            response.getOutputStream().flush();
+
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 65 - 26
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -10,6 +10,8 @@ import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.lapi.service.ILapiService;
+import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.sys.entity.User;
 import com.jpsoft.smart.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
@@ -40,6 +42,8 @@ import java.util.*;
 public class PersonInfoController {
     private Logger logger = LoggerFactory.getLogger(getClass());
 
+    @Autowired
+    private ILapiService lapiService;
     @Autowired
     private OSSConfig ossConfig;
     @Autowired
@@ -707,14 +711,14 @@ public class PersonInfoController {
             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("访客开关");
+//            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<>();
@@ -753,33 +757,33 @@ public class PersonInfoController {
             for(int i=0; i<page.size(); i++){
                 PersonInfo personInfo = page.get(i);
 
-                HSSFRow rowContent = sheet.createRow(0);
+                HSSFRow rowContent = sheet.createRow(i + 1);
                 HSSFCell cellContent1 = rowContent.createCell(0);
                 cellContent1.setCellValue(i+1);
                 HSSFCell cellContent2 = rowContent.createCell(1);
-                cellContent2.setCellValue(personInfo.getName());
+                if(personInfo.getName() != null) cellContent2.setCellValue(personInfo.getName());
                 HSSFCell cellContent3 = rowContent.createCell(2);
-                cellContent3.setCellValue(personInfo.getIdCard());
+                if(personInfo.getIdCard() != null) cellContent3.setCellValue(personInfo.getIdCard());
                 HSSFCell cellContent4 = rowContent.createCell(3);
-                cellContent4.setCellValue(personInfo.getPhone());
+                if(personInfo.getPhone() != null) cellContent4.setCellValue(personInfo.getPhone());
                 HSSFCell cellContent5 = rowContent.createCell(4);
-                cellContent5.setCellValue(personInfo.getPosition1());
+                if(personInfo.getPosition1() != null) cellContent5.setCellValue(personInfo.getPosition1());
                 HSSFCell cellContent6 = rowContent.createCell(5);
-                cellContent6.setCellValue(personInfo.getPosition2());
+                if(personInfo.getPosition2() != null) cellContent6.setCellValue(personInfo.getPosition2());
                 HSSFCell cellContent7 = rowContent.createCell(6);
-                cellContent7.setCellValue(personInfo.getPosition3());
+                if(personInfo.getPosition3() != null) cellContent7.setCellValue(personInfo.getPosition3());
                 HSSFCell cellContent8 = rowContent.createCell(7);
-                cellContent8.setCellValue(personInfo.getPosition4());
+                if(personInfo.getPosition4() != null) 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());
+                if(personInfo.getPosition5() != null) cellContent9.setCellValue(personInfo.getPosition5());
+//                HSSFCell cellContent10 = rowContent.createCell(9);
+//                if(personInfo.getFaceEnabled() != null && personInfo.getFaceEnabled() == true) cellContent10.setCellValue("开"); else cellContent10.setCellValue("关");
+//                HSSFCell cellContent11 = rowContent.createCell(10);
+//                if(personInfo.getCardEnabled() != null && personInfo.getCardEnabled() == true) cellContent11.setCellValue("开"); else cellContent11.setCellValue("关");
+//                HSSFCell cellContent12 = rowContent.createCell(11);
+//                if(personInfo.getAppEnabled() != null && personInfo.getAppEnabled() == true) cellContent12.setCellValue("开"); else cellContent12.setCellValue("关");
+//                HSSFCell cellContent13 = rowContent.createCell(12);
+//                if(personInfo.getGuestEnabled() != null && personInfo.getGuestEnabled() == true) cellContent13.setCellValue("开"); else cellContent13.setCellValue("关");
             }
 
             //todo 将wb保存到oss
@@ -792,8 +796,9 @@ public class PersonInfoController {
             String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
 
             //todo 返回导入失败报表下载链接
-            msgResult.setData(downloadUrl);
 
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
             //将exal输出到哪个文件夹中
 //            ByteArrayOutputStream out = new ByteArrayOutputStream();
 //            workbook.write(out);
@@ -822,7 +827,41 @@ public class PersonInfoController {
 
         try {
             for(String id : ids){
+                PersonInfo personInfo = personInfoService.get(Long.valueOf(id));
+
+                if (personInfo==null){
+                    throw new Exception("人员信息不存在!");
+                }
+
+                //todo 同步终端
+                boolean success = true;
+                StringBuilder sb = new StringBuilder();
+                List<LapiMsgResult> msgResultList = lapiService.addPerson(Long.valueOf(id));
+                for(int i=0;i<msgResultList.size();i++) {
+                    LapiMsgResult lapiMsgResult = msgResultList.get(i);
+
+                    if (lapiMsgResult.isSuccess()){
+                        sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "绑定人脸信息成功!");
+                    }
+                    else{
+                        sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "绑定人脸信息失败!" + lapiMsgResult.getMsg());
+                    }
 
+                    if (i!=msgResultList.size()-1){
+                        sb.append(",");
+                    }
+                    else{
+                        sb.append("。");
+                    }
+
+                    success &= lapiMsgResult.isSuccess();
+                }
+
+                personInfo.setFaceBound(success);
+                personInfo.setUpdateTime(new Date());
+                personInfoService.update(personInfo);
+
+                msgResult.setResult(true);
             }
         }
         catch(Exception ex){