|
@@ -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 {
|
|
|
|