Browse Source

人员管理

yang 3 years ago
parent
commit
27c59f09ae

+ 2 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/controller/ClientController/ClientCarManageController.java

@@ -118,6 +118,8 @@ public class ClientCarManageController {
         return generalResponse ;
     }
 
+
+
         //白名单列表
     @RequestMapping("/ShowCarWhiteList")
     public GeneralResponse ShowCarWhiteList (HttpServletRequest request ,@RequestParam(name = "farmId") Integer farmId,

+ 196 - 31
huimv-farm-video/src/main/java/com/huimv/video/dhicc/controller/ClientController/ClientPersonManageController.java

@@ -11,40 +11,203 @@ import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
 import com.huimv.common.utils.StringUtilsWork;
 import com.huimv.video.dhicc.result.R;
 import com.huimv.video.dhicc.util.GetResponse;
+import com.huimv.video.dhicc.util.HttpClient;
 import net.sf.json.JSONObject;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.apache.commons.io.FileUtils;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
+
+
 
 //门禁是不一样的
+@CrossOrigin
 @RestController
 @RequestMapping("person")
 public class ClientPersonManageController {
-    /**
-     * 人员通行记录 ---测试通过  ---参数说明见大华官网 https://open-icc.dahuatech.com/#/
-     * 此处只做了代理
-     *pageNum              	是	Integer	当前页
-     * pageSize	            是	Integer	分页大小
-     * startSwingTime	    否	String	查询开始时间
-     * endSwingTime	        否	String	查询结束时间
-     * openType          	否	Integer	开门类型
-     * category	           否	String	卡片类型, null-全部, 0-IC卡, 1-有源RFID, 2-CPU卡
-     * personName          	否	String	人员名称
-     * personCode	        否	String	人员编号
-     * channelCode	       否	String	通道编码
-     * deptIds	           否	String	部门ID, 部门间”, “分隔
-     * cardNumber       	否	String	卡号
-     * enterOrExit       	否	String	事件类型, null-全部, 1-进门, 2出门, 3-进/出门
-     * openResult	        否	Integer	开门结果, null-全部, 1-成功, 0-失败
-     * @param params
-     * @return
-     * @throws ClientException
-     */
+
+    //添加图片
+    @RequestMapping("/addPersonPicture")
+    public R addPersonPicture(   @RequestParam(name = "file") MultipartFile multipartFile ) throws ClientException, IOException {
+
+        //文件上传前的名称
+        long s = System.currentTimeMillis();
+        String fileName = multipartFile.getOriginalFilename();
+        File file = new File(fileName);
+        OutputStream out = null;
+        try{
+            //获取文件流,以文件流的方式输出到新文件
+            out = new FileOutputStream(file);
+            byte[] ss = multipartFile.getBytes();
+            for(int i = 0; i < ss.length; i++){
+                out.write(ss[i]);
+            }
+        }catch(IOException e){
+            e.printStackTrace();
+        }finally {
+            if (out != null){
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        long e = System.currentTimeMillis();
+        System.out.println(e-s);
+        String URL  =  "/evo-apigw/evo-brm/1.0.0/person/upload/img";
+        IClient iClient = new DefaultClient();
+        GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
+        //generalRequest.header("Content-Type", "multipart/form-data");
+        HashMap<String, Object> formMap = new HashMap<>();
+       // formMap.put("enctype","multipart/form-data");
+        formMap.put("file", file);
+        generalRequest.form(formMap);
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+
+        // 操作完上的文件 需要删除在根目录下生成的文件
+        File f = new File(file.toURI());
+        if (f.delete()){
+            System.out.println("删除成功");
+        }else {
+            System.out.println("删除失败");
+        }
+        Object data = jsonObject.get("data");
+        JSONObject jsonObject1 = JSONObject.fromObject(data);
+        Object fileUrl = jsonObject1.get("fileUrl");
+        return  R.ok("请求成功").put("data", fileUrl.toString() );
+
+
+
+
+
+
+/*
+
+        Map map  = new HashMap();
+        HttpClient httpClient = new HttpClient(URL);
+        httpClient.setHttps(true);
+        Map<String ,String> header = new HashMap();
+        //header.put("Authorization","bearer 1:7bdc436b-e68c-4d78-aae0-fcf0bdf92f1e");
+        String content = httpClient.httpClientUploadFilePost(URL, file, header,map);
+*/
+
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+    //删除人员
+    @RequestMapping("/deletePercon")
+    public R deletePercon(@RequestBody Map<String, Object> params1) throws ClientException {
+        List<Integer > ids = (List<Integer>) params1.get("ids");
+        String URL = "/evo-apigw/evo-brm/1.2.0/person/delete";
+        Map map = new HashMap();
+        map.put("departmentId" ,1);
+        map.put("ids",ids);
+        IClient iClient = new DefaultClient();
+        GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
+        generalRequest.header("Content-Type", "application/json");
+        generalRequest.body(JSON.toJSONString(map));
+        System.out.println(JSON.toJSONString(map));
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+        return  R.ok("请求成功").put("data", jsonObject );
+    }
+
+
+    //人员管理--添加用户
+    @RequestMapping("/addPerson")
+    public R addPerson(@RequestBody Map<String, Object> params1   ) throws ClientException {
+        params1.put("paperType", 111);
+        params1.put("code", (int)((Math.random()*9+1)*10000));
+        params1.put("departmentId",(int) params1.get("departmentId"));
+        params1.put("name", (String)params1.get("name"));
+        params1.put("paperNumber","1101011990d3d"+(int)((Math.random()*9+1)*10000));
+        params1.put("phone",15171709858L+(int)((Math.random()*9+1)*10000));
+        params1.put("id",(int)((Math.random()*9+1)*10000));
+
+            String URL = "/evo-apigw/evo-brm/1.0.0/person/subsystem/add";
+            IClient iClient = new DefaultClient();
+            GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
+            generalRequest.header("Content-Type", "application/json");
+            generalRequest.body(JSON.toJSONString(params1));
+            System.out.println(JSON.toJSONString(params1));
+            GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+            JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+            return  R.ok("请求成功").put("data", jsonObject );
+    }
+
+
+    //人员管理--添加绑定用户的图片
+    @RequestMapping("/addPictureToPerson")
+    public GeneralResponse addPicture(@RequestBody Map<String, Object> params1 ) throws ClientException {
+
+        Map<String, Object> params  = new HashMap<>();
+
+        Map<String, Object> value1  = new HashMap<>();
+        value1.put("personId",(int)params1.get("personId"));
+        value1.put("type",3);
+        value1.put("index",1);
+        value1.put("path",(String)params1.get("path"));
+
+        List   mapList  = new ArrayList();
+        System.out.println(mapList);
+        mapList.add(value1);
+        params.put("personBiosignatures",mapList);
+        String URL = "/evo-apigw/evo-brm/1.0.0/person/subsystem/update-biosignature-face";
+        IClient iClient = new DefaultClient();
+        GeneralRequest generalRequest = new GeneralRequest(URL, Method.PUT);
+        generalRequest.header("Content-Type", " application/json");
+        generalRequest.body(JSON.toJSONString(params));
+        System.out.println(JSON.toJSONString(params));
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+        return generalResponse;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
     //刷脸失败记录
@@ -59,7 +222,7 @@ public class ClientPersonManageController {
         Calendar c = Calendar.getInstance();
         Date date = new Date();
         c.setTime(date);
-        c.set(Calendar.HOUR, 0);
+        c.set(Calendar.HOUR_OF_DAY, 0);
         c.set(Calendar.MINUTE, 0);
         c.set(Calendar.SECOND, 0);
         Date A = c.getTime();
@@ -73,7 +236,7 @@ public class ClientPersonManageController {
         }
         params1.put("containDomain","1");
         params1.put("openResult",0); //刷脸失败
-        String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?";
+        String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?systime=";
     IClient iClient = new DefaultClient();
     GeneralRequest generalRequest = new GeneralRequest(URL + Long.valueOf(String.valueOf((new Date()).getTime())), Method.POST);
         generalRequest.header("Content-Type", " application/json");
@@ -101,6 +264,10 @@ public class ClientPersonManageController {
             //返回为空数据
             return  null;
         }
+
+
+
+
         IClient iClient = new DefaultClient();
         GeneralRequest generalRequest = new GeneralRequest("/evo-apigw/evo-brm/1.2.0/person/page", Method.POST);
         generalRequest.header("Content-Type", " application/json");
@@ -155,8 +322,6 @@ public class ClientPersonManageController {
 
 
 
-
-
     @RequestMapping("/get_person_detail")
     public GeneralResponse getPersonDetail( @RequestBody Map<String, Object> params ) throws ClientException {
 

+ 0 - 1
huimv-farm-video/src/main/java/com/huimv/video/dhicc/controller/ClientController/GetPicture.java

@@ -38,7 +38,6 @@ public class GetPicture {
                                @RequestParam(name = "alarmPicture", required = false) String alarmPicture,
                                @RequestParam(name = "path", required = false) String  path
     ) throws IOException, ClientException {
-
         String url;
         IClient iClient = new DefaultClient();
         //如果 fileURL不为空  就认为是拿摄像头抓拍图片

+ 10 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/controller/ScreenController/ScreenIndexDataController.java

@@ -52,15 +52,25 @@ public class ScreenIndexDataController {
              String formatC = format.format(C);
 
              System.out.println(formatA+formatB);
+             //人员刷脸成功
              map.put("personPassSuccess",getResponse.SendMassageGetPagePerson( formatB , formatA ));
+             //人员刷脸失败
              map.put("personPassFail",getResponse.SendMassageGetPagePersonAlarm( formatB , formatA));
+             //车辆出数量统计
              map.put("carPassOut",getResponse.SendMassageCarOut( formatB , formatA));
+             //车辆进
              map.put("carPassIn",getResponse.SendMassageCarIn( formatB , formatA));
+             //死猪
              map.put("tadaySiZhu",getResponse.SendCountSiZhu( formatB , formatA));
+             //七日死猪事件
              map.put("SevenDaySiZhu",getResponse.SendCountSiZhu( formatC , formatA));
+             //今日洗消
              map.put("tadayXiXiao",getResponse.SendMassageXixiaoPerson(formatB , formatA));
+             //七日洗消事件
              map.put("SevenDayXIxiao",getResponse.SendMassageXixiaoPerson(formatC , formatA));
+             //大门七日记录数
              map.put("SevenDayGate",getResponse.SendMassageGateCount(formatC , formatA));
+             //大门今日记录数
              map.put("tadayGate",getResponse.SendMassageGateCount(formatB, formatA));
 
         return  R.ok("请求成功").put("data", map );

+ 48 - 10
huimv-farm-video/src/main/java/com/huimv/video/dhicc/util/GetResponse.java

@@ -8,10 +8,15 @@ import com.dahuatech.icc.oauth.http.IClient;
 import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
 import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
 
+import com.huimv.common.utils.StringUtilsWork;
 import com.huimv.video.dhicc.icc.CommonConstant;
 import com.huimv.video.dhicc.result.R;
 import net.sf.json.JSONObject;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -139,7 +144,6 @@ public class GetResponse {
 
 
 
-
     /**
      *  //查人员通过过去几个小时的接口---异常通过次数接口
      * @param begin   开始时间
@@ -175,6 +179,47 @@ public class GetResponse {
     }
 
 
+   public static void main(String[] args) throws ClientException {
+
+   Map<String, Object> params1 =new HashMap<>();
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar c = Calendar.getInstance();
+        Date date = new Date();
+        c.setTime(date);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        //调整天数
+        c.add(Calendar.DATE,-1);
+        Date A = c.getTime();
+        String formatA = format.format(A);
+        c.set(Calendar.HOUR, +24);
+        Date d = c.getTime();
+        String formatD = format.format(d);
+        System.out.println(formatA+formatD);
+
+        params1.put("pageNum",1);
+        params1.put("pageSize",20);
+            params1.put("startSwingTime",formatA);
+            params1.put("endSwingTime",formatD);
+
+        params1.put("containDomain","1");
+        params1.put("openResult",0); //刷脸失败
+        String URL = "http://36.26.62.70:80/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?systime=";
+        IClient iClient = new DefaultClient();
+        GeneralRequest generalRequest = new GeneralRequest(URL + Long.valueOf(String.valueOf((new Date()).getTime())), Method.POST);
+        generalRequest.header("Content-Type", " application/json");
+        generalRequest.body(JSON.toJSONString(params1));
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+        GetResponse getResponse = new GetResponse();
+
+        System.out.println(jsonObject.toString() +getResponse.SendMassageGetPagePersonAlarm((String) params1.get("startSwingTime"),(String) params1.get("endSwingTime")));
+    }
+
+
+
 
 
     /**
@@ -191,11 +236,7 @@ public class GetResponse {
         params.put("alarmType",303);
         params.put("dbType",0);
         params.put("deviceCategory",1);
-        String[]  nodeCodeList=  new String[3];
-        nodeCodeList[0]=     "1002871$1$0$0"    ;
-        nodeCodeList[1]=   "1002872$1$0$0"      ;
-        nodeCodeList[2]=    "1002873$1$0$0"     ;
-        params.put("nodeCodeList",nodeCodeList);
+        params.put("nodeCodeList",CommonConstant.XixiaoChannle);
         String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num";  //获取事件URL    post请求
         IClient iClient = new DefaultClient();
         String NewUrl = URL ;
@@ -232,9 +273,7 @@ public class GetResponse {
         params.put("alarmType",303);
         params.put("dbType",0);
         params.put("deviceCategory",1);
-        String[]  nodeCodeList=  new String[1];
-        nodeCodeList[0]="1003442$1$0$0";   //大门的通道
-        params.put("nodeCodeList",nodeCodeList);
+        params.put("nodeCodeList",CommonConstant.DoorChannle);
         String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num";  //获取事件URL    post请求
         IClient iClient = new DefaultClient();
         String NewUrl = URL ;
@@ -258,7 +297,6 @@ public class GetResponse {
 
 
 
-
     /**
      *  //查死猪 ---时间次数的接口-----
      * @param begin   开始时间

+ 41 - 14
huimv-farm-video/src/main/java/com/huimv/video/dhicc/util/HttpClient.java

@@ -295,7 +295,21 @@ public   class HttpClient {
 
 
 
-
+    private static CloseableHttpClient buildSSLCloseableHttpClient()
+            throws Exception {
+        SSLContext sslContext = new org.apache.http.conn.ssl.SSLContextBuilder().loadTrustMaterial(null,
+                new TrustStrategy() {
+                    // 信任所有
+                    public boolean isTrusted(X509Certificate[] chain,
+                                             String authType) throws CertificateException {
+                        return true;
+                    }
+                }).build();
+        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+                sslContext, new String[] { "TLSv1.2" }, null,
+                SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+        return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+    }
 
 
 
@@ -307,45 +321,58 @@ public   class HttpClient {
 
             HttpPost httpPost = new HttpPost(url);
             //请求头,women
-            if (MapUtils.isNotEmpty(header)) {
+          /*  if (MapUtils.isNotEmpty(header)) {
                 for (Map.Entry<String, String> entry : header.entrySet()) {
                     httpPost.addHeader(entry.getKey(), entry.getValue());
                 }
             }
+            */
+
+            httpPost.setHeader("Authorization","Bearer 1:0bf83146-2b0a-4dc9-9a61-044875561e75");
+            httpPost.setHeader("Connection","keep-alive");
+            httpPost.setHeader("Content-Type","multipart/form-data");
+           // httpPost.setHeader("Host","36.26.62.70");
+         // httpPost.setHeader("Content-Length",String.valueOf(file.getSize()));
+//            httpPost.setHeader("Accept","*/*");
+//            httpPost.setHeader("Accept-Encoding","gzip, deflate, br");
             MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-            System.out.println("jinlai");
             //设置文本字符编码为UTF-8
             //中间是格式
             //ContentType contentType= ContentType.create("application/x-www-form-urlencoded", Charset.forName("UTF-8"));
-            ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
             builder.setCharset(Charset.forName("utf-8"));
             builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
             builder.setCharset(StandardCharsets.UTF_8);
+
             // 文件流  应该写成可以复用的工具类
-            //builder.addBinaryBody("photo",file.getBytes());
+           // builder.addBinaryBody("file", file.getInputStream(), ContentType.MULTIPART_FORM_DATA, file.getName());
             builder.addBinaryBody(file.getName(), file.getInputStream(), ContentType.MULTIPART_FORM_DATA, file.getName());// 文件流
+           // builder.addBinaryBody("file", file.getInputStream(), ContentType.MULTIPART_FORM_DATA, file.getName());// 文件流
             System.out.println("获取文件成功");
             //暂时无法封装成工具
-             String group_id =parma1.get("group_id");
-             String name =parma1.get("name");
-             String idcard =parma1.get("idcard");
-            System.out.println("name="+parma1.get("name"));
-        builder.addTextBody("group_id", group_id);
-        builder.addTextBody("name",parma1.get("name"),contentType);
-        builder.addTextBody("idcard",idcard);
 
-            System.out.println(builder.toString());
+
             HttpEntity entity = builder.build();
+            System.out.println("获取文件成功1");
             httpPost.setEntity(entity);
             // 执行提交
-            HttpResponse response = httpClient.execute(httpPost);
+            System.out.println("获取文件成功2");
+
+            CloseableHttpClient buildSSLCloseableHttpClient = buildSSLCloseableHttpClient();
+            System.setProperty("jsse.enableSNIExtension", "false");
+
+            CloseableHttpResponse response = buildSSLCloseableHttpClient.execute(httpPost);
+            System.out.println("获取文件成功3");
+            System.out.println(response.toString());
+            System.out.println("获取文件成功4");
             HttpEntity responseEntity = response.getEntity();
+            System.out.println("fanhui"+responseEntity.getContent().toString());
             if (responseEntity != null) {
                 // 将响应内容转换为字符串
                 result = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
             }
 
         } catch (Exception e) {
+            System.out.println(e);
             System.out.println("baocuo");
         } finally {
             try {