|
|
@@ -92,8 +92,8 @@ public class ProductImageRecordServiceImpl extends BaseServiceImpl<ProductImageR
|
|
|
@Override
|
|
|
public ProductImageRecordVO submit(String productCode, EquipmentEntity equipmentEntity, ProductImageRecordEntity productImageRecord, BladeFile bladeFile, FactoryEntity factory) {
|
|
|
ProductEntity productEntity = null;
|
|
|
- //-1:未检出 0:OK 1:NG
|
|
|
- int isNg = -1;
|
|
|
+ //ai识别状态 -1无需识别 0未识别 1ng 2ok 3人工ok
|
|
|
+ int aiStatus = -1;
|
|
|
productImageRecord.setEquipmentId(equipmentEntity.getId());
|
|
|
productImageRecord.setEqSn(equipmentEntity.getEqSn());
|
|
|
if(productCode.length()<25){
|
|
|
@@ -109,9 +109,13 @@ public class ProductImageRecordServiceImpl extends BaseServiceImpl<ProductImageR
|
|
|
productEntity = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getQrCode,productCode).eq(ProductEntity::getFactoryId,equipmentEntity.getFactoryId()),false);
|
|
|
if(productEntity!=null && productEntity.getStatus()!=2){
|
|
|
productImageRecord.setStatus(2);
|
|
|
- productImageRecord.setMessage("产品"+(productEntity.getStatus()==1?"正在维修中,":(productEntity.getStatus()==-1?"NG待处理,":(productEntity.getStatus()==0?"已作废,":"已入库,")))+"无法下线");
|
|
|
+ productImageRecord.setMessage("产品"+(productEntity.getStatus()==1?"正在维修中,":(productEntity.getStatus()==0?"已作废,":"已入库,"))+"无法下线");
|
|
|
+ }else if(productEntity!=null && productEntity.getAiStatus()!=null && (productEntity.getAiStatus()==0 || productEntity.getAiStatus()==1) ){
|
|
|
+ productImageRecord.setStatus(2);
|
|
|
+ productImageRecord.setMessage("产品"+(productEntity.getAiStatus()==0 ?"AI未识别-待处理,":(productEntity.getAiStatus()==1?"NG待处理,":""))+"无法下线");
|
|
|
}else{
|
|
|
if(productModel.getIsAi()==1){
|
|
|
+ aiStatus = 0;
|
|
|
try {
|
|
|
// Map<String,Object> param = new HashMap<>();
|
|
|
// param.put("action","detect");
|
|
|
@@ -123,42 +127,43 @@ public class ProductImageRecordServiceImpl extends BaseServiceImpl<ProductImageR
|
|
|
param.put("path",bladeFile.getLink());
|
|
|
|
|
|
// String result = HttpUtil.postJson("http://127.0.0.1:3300/ws_init",param.toJSONString());
|
|
|
- String result = HttpUtil.postJson(aiUrl+"/ws_init",param.toJSONString());
|
|
|
+ String result = HttpUtil.postJson(aiUrl+"/ws_init",param.toJSONString());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
if(jsonObject.get("status")!=null && jsonObject.getInteger("status")==200){
|
|
|
- isNg = "OK".equals(jsonObject.get("result"))?0:1;
|
|
|
String filePath = jsonObject.getString("path");
|
|
|
File file = new File(filePath);
|
|
|
if(file.exists()){
|
|
|
+ aiStatus = "OK".equals(jsonObject.get("result"))?2:1;
|
|
|
String fileName= "upload/"+(factory==null?"000000":factory.getCode())+"/" + DateUtil.today() + "/"+productCode+"/" + StringUtil.randomUUID() + "." + FileUtil.getFileExtension(file.getName());
|
|
|
BladeFile aiFile = ossBuilder.template(equipmentEntity.getTenantId(),"minio").putFile(fileName, Files.newInputStream(Paths.get(filePath)));
|
|
|
productImageRecord.setProductAiImage(aiFile.getLink());
|
|
|
file.delete();
|
|
|
- }else{
|
|
|
+ }
|
|
|
+ else{
|
|
|
productImageRecord.setStatus(2);
|
|
|
- productImageRecord.setMessage("AI识别接口调用异常-文件不存在");
|
|
|
+ productImageRecord.setMessage("拍照成功,AI识别接口调用异常-文件不存在");
|
|
|
}
|
|
|
}else{
|
|
|
productImageRecord.setStatus(2);
|
|
|
- productImageRecord.setMessage("AI识别接口调用失败"+jsonObject.get("result"));
|
|
|
+ productImageRecord.setMessage("拍照成功,AI识别接口调用失败"+jsonObject.get("result"));
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
log.error("AI识别接口调用异常",e);
|
|
|
productImageRecord.setStatus(2);
|
|
|
- productImageRecord.setMessage("AI识别接口调用异常");
|
|
|
+ productImageRecord.setMessage("拍照成功,AI识别接口调用异常");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(productImageRecord.getStatus()==2){
|
|
|
+ if(productImageRecord.getStatus()==2 && aiStatus==-1){
|
|
|
this.save(productImageRecord);
|
|
|
ProductImageRecordVO productImageRecordVO = ProductImageRecordWrapper.build().entityVO(productImageRecord);
|
|
|
- productImageRecordVO.setIsNg(isNg);
|
|
|
+ productImageRecordVO.setAiStatus(aiStatus);
|
|
|
// productImageRecordVO.setProductEntity(productEntity);
|
|
|
return productImageRecordVO;
|
|
|
}
|
|
|
- if(isNg==1){
|
|
|
+ if(aiStatus==0 || aiStatus==1){
|
|
|
productImageRecord.setStatus(2);
|
|
|
}
|
|
|
|
|
|
@@ -173,27 +178,29 @@ public class ProductImageRecordServiceImpl extends BaseServiceImpl<ProductImageR
|
|
|
productEntity.setBackImg(productImageRecord.getProductImage());
|
|
|
productEntity.setBackAiImg(productImageRecord.getProductAiImage());
|
|
|
productEntity.setQrCode(productCode);
|
|
|
- productEntity.setStatus(isNg==1?-1:2);
|
|
|
+ productEntity.setStatus(2);
|
|
|
+ productEntity.setAiStatus(aiStatus);
|
|
|
productService.save(productEntity);
|
|
|
}else{
|
|
|
if(productEntity.getStatus()==2){
|
|
|
productEntity.setFrontImg(productImageRecord.getProductImage());
|
|
|
productEntity.setFrontAiImg(productImageRecord.getProductAiImage());
|
|
|
- productEntity.setStatus(isNg==1?-1:2);
|
|
|
+ productEntity.setStatus(2);
|
|
|
+ productEntity.setAiStatus(aiStatus);
|
|
|
productService.updateById(productEntity);
|
|
|
}
|
|
|
}
|
|
|
productImageRecord.setProductId(productEntity.getId());
|
|
|
- if(isNg==-1){
|
|
|
+ if(aiStatus==-1){
|
|
|
productImageRecord.setMessage("拍照成功");
|
|
|
- }else{
|
|
|
- productImageRecord.setMessage("拍照成功,产品识别"+(isNg==0?"OK":"NG"));
|
|
|
+ }else if(aiStatus==1 || aiStatus==2){
|
|
|
+ productImageRecord.setMessage("拍照成功,产品识别"+(aiStatus==2?"OK":"NG"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.save(productImageRecord);
|
|
|
ProductImageRecordVO productImageRecordVO = ProductImageRecordWrapper.build().entityVO(productImageRecord);
|
|
|
- productImageRecordVO.setIsNg(isNg);
|
|
|
+ productImageRecordVO.setAiStatus(aiStatus);
|
|
|
// productImageRecordVO.setProductEntity(productEntity);
|
|
|
return productImageRecordVO;
|
|
|
}
|