后台修改

新疆科信智慧盘点
LAPTOP-S9HJSOEB\昊天 3 weeks ago
parent 34b7fa20b0
commit d4705723e4

@ -21,6 +21,7 @@ public class AlgorithmPojo {
private Calculate calculate;
private String path;
private String model;
private String resultImage;
public static AlgorithmPojo buildAlgorithmPojo(Street street, KsecDataInfo dataInfo) {
AlgorithmPojo algorithmPojo = new AlgorithmPojo();

@ -449,6 +449,7 @@ public class PlcService {
if (configProperties.getActionCheckPic()){
code = "E1" + "-" + plcCmdInfo.getEndStr(1, plcCmdInfo.getFromAround());
algorithmService.getGoodResult(path);
gyrateCameraByCode(cameraId, code);
@ -787,7 +788,7 @@ public class PlcService {
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(street, dataInfo,path);
AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(path);
String paths = path;
//货物使用球机扫码

@ -216,6 +216,7 @@ public class StreetService extends ServiceImpl<StreetMapper, Street> {
}
}
public void RFIDConfig(StreetVO streetVO,Integer streetId){
Map<String,Object> map = new HashMap<>();
map.put("street_id",streetId);

@ -238,4 +238,52 @@ public class AlgorithmService {
return algorithmPojo;
}
/**
* 算法预测服务地址(yolo)
*/
private static final String PREDICT_URL = "http://127.0.0.1:8001/predict";
/**
* 调用算法服务对指定图片进行预测
*
* @param path 图片绝对路径
* @return 算法结果,result为1表示合格(success=true),0表示不合格
*/
public AlgorithmPojo getGoodResult(String path) {
AlgorithmPojo algorithmPojo = new AlgorithmPojo();
algorithmPojo.setPath(path);
String realPath = configProperties.getSavePath().getMediaPath() + path;
if (!configProperties.getVisualSense().getAble()) {
algorithmPojo.setResult(1);
algorithmPojo.setGoodsNumberResult(algorithmPojo.getGoodsNumber());
algorithmPojo.setGoodsTypeResult(algorithmPojo.getGoodsType());
return algorithmPojo;
}
try {
ResponseEntity<String> response = restTemplate.getForEntity(PREDICT_URL + "?path={path}", String.class, realPath);
String body = response.getBody();
log.info("算法服务返回结果:{}", body);
JSONObject result = JSONObject.parseObject(body);
if (result == null) {
log.error("算法服务返回结果为空,path={}", path);
algorithmPojo.setResult(0);
return algorithmPojo;
}
//success 为算法给出的判定结果:true 合格(1),false 不合格(0)
algorithmPojo.setResult(Boolean.TRUE.equals(result.getBoolean("success")) ? 1 : 0);
algorithmPojo.setGoodsNumberResult(result.getIntValue("count"));
algorithmPojo.setResultImage(result.getString("result_image"));
log.info("算法服务结果:path={}, result={}, count={}, resultImage={}",
result.getString("path"), algorithmPojo.getResult(),
algorithmPojo.getGoodsNumberResult(), algorithmPojo.getResultImage());
} catch (RestClientException e) {
log.error("未连接上算法平台" + e);
algorithmPojo.setResult(0);
} catch (Exception e) {
log.error("算法平台报错" + e);
algorithmPojo.setResult(0);
}
return algorithmPojo;
}
}

Loading…
Cancel
Save