|
@@ -2,25 +2,32 @@ package com.gzlh.device.camera.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.XmlUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.gzlh.bus.EventDataManager;
|
|
|
+import com.gzlh.config.SystemObject;
|
|
|
import com.gzlh.device.camera.factory.CameraFactory;
|
|
|
import com.gzlh.device.camera.properties.CameraPropertiesConfig;
|
|
|
+import com.gzlh.entity.ReqBO;
|
|
|
import com.gzlh.utils.FileUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.w3c.dom.Document;
|
|
|
+import org.w3c.dom.Element;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("/Camera")
|
|
|
+@RequestMapping("/camera")
|
|
|
public class CameraController {
|
|
|
@Value("${file.root-path}")
|
|
|
private String path;
|
|
@@ -40,7 +47,9 @@ public class CameraController {
|
|
|
// String xmlStr = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
|
|
|
|
|
|
Map<String, Object> StringObjectMap = new HashMap<>();
|
|
|
-
|
|
|
+ Document document = XmlUtil.parseXml(xmlStr);
|
|
|
+ Element rootElement = XmlUtil.getRootElement(document);
|
|
|
+ String i_e_type = rootElement.getAttribute("I_E_TYPE");
|
|
|
XmlUtil.xmlToMap(xmlStr, StringObjectMap);
|
|
|
|
|
|
Map<String, Object> ic = BeanUtil.beanToMap(StringObjectMap.get("IC"));
|
|
@@ -50,30 +59,70 @@ public class CameraController {
|
|
|
Map<String, Object> seal = BeanUtil.beanToMap(StringObjectMap.get("SEAL"));
|
|
|
|
|
|
|
|
|
- Map<String, String> cacheMap = new HashMap<>();
|
|
|
- cacheMap.put("carEcNo", (String) car.get("CAR_EC_NO"));
|
|
|
- cacheMap.put("contaIdF", !StringUtils.isEmpty((String) car.get("CONTA_ID_F"))?(String) car.get("CONTA_ID_F"):"");
|
|
|
- cacheMap.put("contaIdB", !StringUtils.isEmpty((String) car.get("CONTA_ID_B"))?(String) car.get("CONTA_ID_B"):"");
|
|
|
+ Map<String, String> boxNoMap = new HashMap<>();
|
|
|
+// cacheMap.put("carEcNo", (String) car.get("CAR_EC_NO"));
|
|
|
+ boxNoMap.put("boxNoF", !StringUtils.isEmpty((String) conta.get("CONTA_ID_F"))?(String) conta.get("CONTA_ID_F"):"");
|
|
|
+ boxNoMap.put("boxNoB", !StringUtils.isEmpty((String) conta.get("CONTA_ID_B"))?(String) conta.get("CONTA_ID_B"):"");
|
|
|
|
|
|
+ EventDataManager.cacheData("boxNoList",boxNoMap);
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
- String savePath=path+"/"+ calendar.get(Calendar.YEAR)+"-" + (calendar.get(Calendar.MONTH)+1);
|
|
|
|
|
|
- Map<String, String> picMap = new HashMap<>();
|
|
|
+
|
|
|
+ String savePath=path+"/"+SystemObject.applicationConfig.getChannelCode()+"/"+ calendar.get(Calendar.YEAR)+(calendar.get(Calendar.MONTH)+1)+calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+
|
|
|
+ List<String> fList = new ArrayList();
|
|
|
+ List<String> bList = new ArrayList();
|
|
|
for (Map.Entry<String, Object> entry : conta.entrySet()) {
|
|
|
if(entry.getKey().contains("PIC")&& !StringUtils.isEmpty((String) entry.getValue())){
|
|
|
String filePath = FileUtils.downLoad((String) entry.getValue(),savePath);
|
|
|
- String base64 = FileUtils.getBase64FromImg(filePath);
|
|
|
- picMap.put(entry.getKey(),base64);
|
|
|
+// String base64 = FileUtils.getBase64FromImg(filePath);
|
|
|
+ if (entry.getKey().contains("CONTA_F")){
|
|
|
+ fList.add(filePath);
|
|
|
+ }else if (entry.getKey().contains("CONTA_B")){
|
|
|
+ bList.add(filePath);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ EventDataManager.cacheData("boxFImgList",fList);
|
|
|
+ EventDataManager.cacheData("boxBImgList",bList);
|
|
|
|
|
|
- // TODO: 2023/11/10
|
|
|
- cameraFactory.handler(cameraPropertiesConfig.getBrand()).handlerAction("");
|
|
|
-
|
|
|
+// // TODO: 2023/11/10
|
|
|
+// cameraFactory.handler(cameraPropertiesConfig.getBrand()).handlerAction("");
|
|
|
|
|
|
+ request("",JSONUtil.toJsonStr(EventDataManager.getCacheData()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void request(String url,String json) {
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ url = "http://192.168.1.8:9191/open/submit";
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ System.out.println(startTime);
|
|
|
+
|
|
|
+ String body = json;
|
|
|
+// String method = Thread.currentThread().getStackTrace()[1].getMethodName();
|
|
|
+ try {
|
|
|
+// System.out.printf("%s/请求地址:%s,请求头:%s, 请求体:%s ", method,url, headers, body);
|
|
|
+
|
|
|
+ System.out.println();
|
|
|
+// log.info("【{}/{}】请求地址:{},请求头:{}, 请求体:{} ", OperateTypeEnum.OPERATE_TYPE_2.desc, logContent, url, headers, body);
|
|
|
+ HttpResponse res = HttpRequest.post(url)
|
|
|
+ .header("Content-Type", "application/json;character=utf-8;")
|
|
|
+ .body(body)
|
|
|
+ .execute();
|
|
|
+ String bodyResult = res.body();
|
|
|
+ System.out.printf("ReqStatus:%s,返回结果:{%s} ",res.getStatus(), bodyResult);
|
|
|
+
|
|
|
+// if(200 == res.getStatus()){
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|