|
|
@@ -3,12 +3,10 @@ package com.zd.alg.forward.serivce;
|
|
|
import cn.hutool.core.text.CharSequenceUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.alg.forward.config.AlgorithmYml;
|
|
|
-import com.zd.alg.forward.domain.AnalysisData;
|
|
|
-import com.zd.alg.forward.domain.DataPostAnalysisRespDto;
|
|
|
-import com.zd.alg.forward.domain.ImgPostResponse;
|
|
|
-import com.zd.alg.forward.domain.VideoRequestData;
|
|
|
+import com.zd.alg.forward.domain.*;
|
|
|
import com.zd.alg.forward.serivce.mqtt.CommonSend;
|
|
|
import com.zd.alg.forward.utils.Base64DecodedMultipartFile;
|
|
|
import com.zd.alg.forward.utils.FileUploadUtils;
|
|
|
@@ -99,10 +97,10 @@ public class CheckService {
|
|
|
int alarmNum = 0;
|
|
|
//========= 请求超时验证部分开始 ===========
|
|
|
//600 则代表退出验证流程 需要重新刷卡
|
|
|
-// R<Long> fail = getObjectR(id);
|
|
|
-// if (fail.getCode() != 200) {
|
|
|
-// return fail;
|
|
|
-// }
|
|
|
+ R<Long> fail = getObjectR(id);
|
|
|
+ if (fail.getCode() != 200) {
|
|
|
+ return fail;
|
|
|
+ }
|
|
|
//根据实验室id查询检查项
|
|
|
R<Map<Object, Object>> subject = laboratoryService.getCheckInfo(subId);
|
|
|
if (subject.getCode() != 200) {
|
|
|
@@ -132,20 +130,22 @@ public class CheckService {
|
|
|
MultiValueMap<String, Object> params = getStringObjectMultiValueMap(checkValid, String.valueOf(id));
|
|
|
HttpEntity<MultiValueMap<String, Object>> files = getHttpEntityMap(toFile, params);
|
|
|
logger.info("===============4=================");
|
|
|
- ImgPostResponse<DataPostAnalysisRespDto> send = HttpUtils.send(restTemplateLocal, files, algorithmYml);
|
|
|
+ ImgPostResponse<AnalysisReturnData> send = HttpUtils.sendV5(restTemplateLocal, files, algorithmYml);
|
|
|
if (send == null || send.getStatus_code() != 1000) {
|
|
|
assert send != null;
|
|
|
- logger.error(send.getMessage());
|
|
|
+ logger.error("==================4.1==================="+send.getStatus_code()+"==========="+send.getMessage());
|
|
|
return R.fail("算法服务错误,请重试!");
|
|
|
}
|
|
|
logger.info("===============5=================");
|
|
|
- R algorithm = saveAlgorithm(send, checkValid);
|
|
|
+ R algorithm = saveAlgorithmV5(send, checkValid);
|
|
|
if (algorithm.getCode() != 200) {
|
|
|
+ logger.error("==============="+algorithm.getCode()+"=================");
|
|
|
return algorithm;
|
|
|
}
|
|
|
- DataPostAnalysisRespDto data = send.getData();
|
|
|
-
|
|
|
- Map<String, Object> result = (Map<String, Object>) data.getAnalysisDatas().get(0).getResult();
|
|
|
+ logger.info("===============6=================");
|
|
|
+ AnalysisReturnData data = send.getData();
|
|
|
+ Map<String, Object> result = (Map<String, Object>) data.getResult();
|
|
|
+ logger.info("=========================7==============="+result.toString());
|
|
|
Map<String, Object> algorithmData = (Map<String, Object>) result.get("algorithm_data");
|
|
|
Map<String, Object> modelResult = (Map<String, Object>) result.get("model_data");
|
|
|
List<Map<String, Object>> objects = (List<Map<String, Object>>) modelResult.get("objects");
|
|
|
@@ -176,7 +176,7 @@ public class CheckService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- logger.error(e.getMessage());
|
|
|
+ logger.error("e.getMessage:"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return R.fail();
|
|
|
@@ -272,8 +272,8 @@ public class CheckService {
|
|
|
* @param codes
|
|
|
* @return
|
|
|
*/
|
|
|
- public R checkInAll(Long[] ids, MultipartFile file[], String codes) {
|
|
|
- Map result = new HashMap();
|
|
|
+ public R<Map<Object, String>> checkInAll(Long[] ids, MultipartFile file[], String codes) {
|
|
|
+ Map<Object, String> result = new HashMap<>();
|
|
|
String[] codesArrs = codes.split(",");
|
|
|
for (int i = 0; i < codesArrs.length; i++) {
|
|
|
R r = checkAndCommit(codesArrs[i], file[i], ids[i]);
|
|
|
@@ -285,7 +285,7 @@ public class CheckService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Algorithm Covert(Map data) {
|
|
|
+ public Algorithm Covert(Map<String, Object> data) {
|
|
|
Algorithm algorithm = new Algorithm();
|
|
|
algorithm.setAlgorithmType(data.get("type").toString());
|
|
|
algorithm.setAlgorithmResult(data.get("src_img").toString());
|
|
|
@@ -297,6 +297,19 @@ public class CheckService {
|
|
|
return algorithm;
|
|
|
}
|
|
|
|
|
|
+ public Algorithm CovertV5(Map<String, Object> data) {
|
|
|
+ Algorithm algorithm = new Algorithm();
|
|
|
+ algorithm.setAlgorithmType(data.get("type").toString());
|
|
|
+ algorithm.setAlgorithmResult(data.get("src_img").toString());
|
|
|
+ algorithm.setSubId(Long.valueOf(data.get("aid").toString()));
|
|
|
+ algorithm.setSignId(Long.valueOf(data.get("cid").toString()));
|
|
|
+ algorithm.setAlgorithmName(data.get("algorithmName").toString());
|
|
|
+ algorithm.setIsAlarm(Integer.parseInt(data.get("isAlarm").toString()));
|
|
|
+ algorithm.setStatus(0);
|
|
|
+ return algorithm;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param algorithmResult
|
|
|
* @param type
|
|
|
@@ -398,7 +411,7 @@ public class CheckService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
//如果没有通过则次数加一
|
|
|
- Map<String, Boolean> map = new HashMap(1);
|
|
|
+ Map<String, Boolean> map = new HashMap<>(1);
|
|
|
//键为前缀+签到id +下划线+验证类型
|
|
|
String key = BaseConstants.SINGIN_CHECK_JUMP_KEY + id + "_" + code;
|
|
|
Long increment = redisTemplate.opsForValue().increment(key);
|
|
|
@@ -547,4 +560,38 @@ public class CheckService {
|
|
|
logger.error("接口数据返回异常");
|
|
|
throw new ServiceException("接口数据返回异常");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 存储数据
|
|
|
+ * @param send
|
|
|
+ * @param checkValid
|
|
|
+ */
|
|
|
+ private R saveAlgorithmV5(ImgPostResponse<AnalysisReturnData> send,AlgorithmYml.CheckValid checkValid){
|
|
|
+ String picture = send.getData().getRet_image();
|
|
|
+ String header = "data:image/jpeg;base64,"+picture;
|
|
|
+ MultipartFile multipartFile = Base64DecodedMultipartFile.base64ToMultipart(header);
|
|
|
+ R<SysFile> sysFileR = remoteFileService.upload(multipartFile);
|
|
|
+ String imageUrl = sysFileR.getData().getUrl();
|
|
|
+ logger.info("==================================imageUrl:"+imageUrl);
|
|
|
+ AnalysisReturnData data = send.getData();
|
|
|
+ Map<String, Object> map =new HashMap<>();
|
|
|
+ Map<String, Object> result =(Map<String, Object>)data.getResult();
|
|
|
+ Map<String, Object> algorithmData = (Map<String, Object>) result.get("algorithm_data");
|
|
|
+ Map<String, Object> modelResult = (Map<String, Object>) result.get("model_data");
|
|
|
+ List<Map<String, Object>> objects = (List<Map<String, Object>>) modelResult.get("objects");
|
|
|
+ if(algorithmData.getOrDefault("is_alert", "").toString().equals("false") && objects.size()>0){
|
|
|
+ map.put("isAlarm", 0);
|
|
|
+ }else{
|
|
|
+ map.put("isAlarm", 1);
|
|
|
+ }
|
|
|
+ map.put("isAlarm", 1);
|
|
|
+ map.put("aid", data.getAid());
|
|
|
+ map.put("cid", data.getCid());
|
|
|
+ map.put("src_img", imageUrl);
|
|
|
+ map.put("type", "image");
|
|
|
+ map.put("algorithmName", checkValid.getAlgorithmName());
|
|
|
+ logger.info("=======================map.tostring()"+map.toString());
|
|
|
+ return laboratoryService.saveAlgorithmData(CovertV5(map));
|
|
|
+ }
|
|
|
}
|