flag修改值

泸州-视觉+扫码-昆船
LAPTOP-S9HJSOEB\昊天 4 months ago
parent 3d0cb82a65
commit b005566bc0

@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
import com.zhehekeji.common.util.ValidatorUtil;
import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.entity.CheckLog;
import com.zhehekeji.web.entity.ReadOCR;
import com.zhehekeji.web.entity.SensorGun;
import com.zhehekeji.web.entity.StockLog;
import com.zhehekeji.web.pojo.stock.CheckLogSearch;
@ -47,16 +48,16 @@ public class CheckLogController {
if(checkLogSearch.getSide()==2) {
leftRight=leftRight+2;
}
String trayCode = "";
ReadOCR trayCode = new ReadOCR();
SensorGun sensorGun = sensorService.getSensorByPlc(checkLogSearch.getStreetId(),leftRight);
if (sensorGun == null) {
trayCode = "扫码枪未配置";
trayCode.setCode("扫码枪未配置");
} else {
if (leftRight > 2) {
trayCode = CognexSocket.readOCR(sensorGun.getIp(), sensorGun.getPort());
}
}
return Result.success(trayCode);
return Result.success(trayCode.getCode());
}
}

@ -3,6 +3,7 @@ package com.zhehekeji.web.controller;
import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.entity.KuKou;
import com.zhehekeji.web.entity.ReadOCR;
import com.zhehekeji.web.entity.Street;
import com.zhehekeji.web.pojo.IndustrialCameraVO;
import com.zhehekeji.web.pojo.stock.CheckLogSearch;
@ -174,9 +175,10 @@ public class IndustrialCameraController {
String pa = "";
try {
Thread.sleep(400);
ReadOCR readOCR = new ReadOCR();
code = SickSocket.readOCR(configProperties.getCameraConfig().getSickIp(), configProperties.getCameraConfig().getSickPort());
readOCR = SickSocket.readOCR(configProperties.getCameraConfig().getSickIp(), configProperties.getCameraConfig().getSickPort());
code = readOCR.getCode();
//2d识别
for (String path : listResult.getData()) {
re = FeatureMatchingExample.matchTemplate(

@ -0,0 +1,11 @@
package com.zhehekeji.web.entity;
import lombok.Data;
@Data
public class ReadOCR {
String code;
Integer status;
}

@ -372,73 +372,20 @@ public class PlcService {
@Resource
RestTemplate restTemplate;
String scan(PlcCmdInfo plcCmdInfo,Street street,String wmsTrayCode){
ReadOCR scan(PlcCmdInfo plcCmdInfo,Street street,String wmsTrayCode){
Boolean trayCheck = Boolean.FALSE;
String trayCode = "";
ReadOCR trayCode = new ReadOCR();
log.info("扫码类型:" + configProperties.getScanCodeMode().getTray());
//使用sick扫码枪
int leftRight = plcCmdInfo.getLeftRight1();
if(plcCmdInfo.getSeparation1()==2) {
leftRight=leftRight+2;
}
// if(plcCmdInfo.getSeparation1()==1) {
//
// }else {
//
// Integer cameraId=street.getCamera1Id();;
// String code = "E1-DEEP-";
// String path = "";
//
// //使用同侧的camera
// if(plcCmdInfo.getLeftRight1() ==1){
//
// code = code+"L";
// }else {
//
// code = code+"R";
// }
// path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
// gyrateCameraByCode(cameraId,code);
// try {
// Thread.sleep(5000L);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// path = cameraCapture(cameraId,false,0L,path);
//
//
// trayCode = reentrantLockExample.identify( configProperties.getSavePath().getMediaPath() + path,configProperties.getIntelliBink().getIp(),configProperties.getIntelliBink().getPort());
// if(trayCode != null && !"".equals(trayCode)){
// if ("".equals(plcCmdInfo.getWmsCode())) {
// //托盘码为空,无货物
// //只要扫码枪未识别出条码,即认为盘点正确
// if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
// trayCode = "无货物";
// trayCheck = Boolean.TRUE;
// } else {
// trayCode = "扫码枪识别异常";
// trayCheck = Boolean.FALSE;
// log.warn("sick ocr error:{}", trayCode);
// }
// } else {
// if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
// trayCode = "扫码枪识别异常";
// trayCheck = Boolean.FALSE;
// log.warn("sick ocr error:{}", trayCode);
// } else {
// //扫到与货码相同
// if(trayCode.equals(plcCmdInfo.getWmsCode())){
// trayCheck = Boolean.TRUE;
// }
// }
// }
// }
// }
//托盘使用sick扫码枪
SensorGun sensorGun = sensorService.getSensorByPlc(street.getId(), leftRight);
if (sensorGun == null) {
trayCode = "扫码枪未配置";
trayCode.setCode("扫码枪未配置");
trayCode.setStatus(2);
trayCheck = Boolean.FALSE;
log.error("no sensor gun config in database ,street id:{},direction:{}", street.getId(), plcCmdInfo.getLeftRight1());
} else {
@ -451,14 +398,16 @@ public class PlcService {
log.info("sensor tray code:{}", trayCode);
//如果无货物判断是否
for (String code : trayCode.split(";")) {
for (String code : trayCode.getCode().split(";")) {
log.info("sick ocr info:{},wmsCode{}", code,wmsTrayCode);
if (!code.endsWith(org.apache.commons.lang3.StringUtils.leftPad(wmsTrayCode, 6, '0'))) {
trayCheck = Boolean.FALSE;
// trayCode.setStatus(1);
log.info("sick ocr error:{}", trayCode);
} else {
// trayCode.setStatus(1);
trayCheck = Boolean.TRUE;
log.info("sick ocr success:{}", trayCode);
break;
@ -466,7 +415,7 @@ public class PlcService {
}
}
plcCmdInfo.setTrayCode(trayCode);
plcCmdInfo.setTrayCode(trayCode.getCode());
plcCmdInfo.setTrayCheck(trayCheck);
log.info("tray code:{},sys trayCode:{},plcInfo{}",trayCode,wmsTrayCode,plcCmdInfo.toString());
return trayCode;
@ -633,7 +582,7 @@ public class PlcService {
// 其他逻辑...
//托盘码
String trayCode = "";
ReadOCR trayCode = new ReadOCR();
Boolean trayCheck = Boolean.TRUE;
trayCode = scan(plcCmdInfo,street,wmsTrayCode);
trayCheck = plcCmdInfo.getTrayCheck();
@ -645,8 +594,8 @@ public class PlcService {
IndustrialCameraVO scTransmission = new IndustrialCameraVO();
scTransmission.setWmsTrayCode(wmsTrayCode);
scTransmission.setTrayCode(trayCode);
scTransmission.setFlag(trayCheck?1:0);
scTransmission.setTrayCode(trayCode.getCode());
scTransmission.setFlag(trayCode.getStatus());
kuKouService.setHttp(scTransmission,trayCheck);
//核对异常
Integer status = 1;
@ -658,10 +607,10 @@ public class PlcService {
stock = Stock.builder()
.checkNum(plcCmdInfo.getOrderNum())
.lotnum(plcCmdInfo.getLotnum())
.code(trayCode)
.code(trayCode.getCode())
.wmsCode(wmsCode)
.wmsTrayCode(wmsTrayCode)
.trayCode(trayCode)
.trayCode(trayCode.getCode())
.streetId(orderInfo.getStreetId())
.direction(plcCmdInfo.getLeftRight1())
.side(orderInfo.getSeparation())
@ -677,9 +626,9 @@ public class PlcService {
stock.setExportTime(LocalDateTime.now());
stock.setCheckPic(path);
stock.setCheckNum(plcCmdInfo.getOrderNum());
stock.setTrayCode(trayCode);
stock.setTrayCode(trayCode.getCode());
stock.setWmsTrayCode(wmsTrayCode);
stock.setCode(trayCode);
stock.setCode(trayCode.getCode());
stock.setWmsCode(wmsCode);
stockMapper.updateById(stock);
}

@ -4,18 +4,24 @@ import com.alibaba.fastjson.JSONObject;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
/**
* JSON < >
*/
@Slf4j
public class KescEncoder extends MessageToByteEncoder<KsecInfo> {
private static final Logger tcpLogger = LoggerFactory.getLogger("tcp");
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, KsecInfo ksecInfo, ByteBuf byteBuf) throws Exception {
String body = "<" + JSONObject.toJSONString(ksecInfo) + ">";
tcpLogger.info("发送:{}",body);
byteBuf.writeBytes(body.getBytes(StandardCharsets.UTF_8));
}
}

@ -1,5 +1,6 @@
package com.zhehekeji.web.service.sick;
import com.zhehekeji.web.entity.ReadOCR;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,7 +14,13 @@ import java.nio.charset.StandardCharsets;
public class CognexSocket {
private static final Logger tcpLogger = LoggerFactory.getLogger("sick");
public static String readOCR(String ip,int port){
public static void main(String[] args) {
ReadOCR readOCR = readOCR("127.0.0.1", 2001);
System.out.println(readOCR);
}
public static ReadOCR readOCR(String ip, int port){
ReadOCR readOCR = new ReadOCR();
Socket socket = new Socket();
String code = "NOREAD";
OutputStream os = null;
@ -33,9 +40,15 @@ public class CognexSocket {
}
i++;
}
if ("NOREAD".equals(code)){
readOCR.setStatus(2);
}else {
readOCR.setStatus(1);
}
} catch (IOException e) {
tcpLogger.error("sick time out,ip:{},info:{}",ip,e);
log.error("sick time out,ip:{},info:{}",ip,e);
readOCR.setStatus(0);
}finally {
if(os != null){
try {
@ -56,8 +69,9 @@ public class CognexSocket {
} catch (IOException e) {
e.printStackTrace();
}
readOCR.setCode(code);
return code;
return readOCR;
}
}

@ -1,5 +1,6 @@
package com.zhehekeji.web.service.sick;
import com.zhehekeji.web.entity.ReadOCR;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,12 +17,10 @@ import java.nio.charset.StandardCharsets;
public class SickSocket {
private static final Logger tcpLogger = LoggerFactory.getLogger("sick");
public static void main(String[] args) {
String code = readOCR("192.168.8.236", 2002);
System.out.println(code);
}
public static String readOCR(String ip,int port){
public static ReadOCR readOCR(String ip, int port){
ReadOCR readOCR = new ReadOCR();
Socket socket = new Socket();
String code = "NoRead";
OutputStream os = null;
@ -41,9 +40,15 @@ public class SickSocket {
}
i++;
}
if ("NoRead".equals(code)){
readOCR.setStatus(2);
}else {
readOCR.setStatus(1);
}
} catch (Exception e) {
tcpLogger.error("sick time out,ip:{},info:{}",ip,e);
log.error("sick time out,ip:{},info:{}",ip,e);
readOCR.setStatus(0);
}finally {
if(os != null){
try {
@ -64,8 +69,11 @@ public class SickSocket {
} catch (IOException e) {
e.printStackTrace();
}
readOCR.setCode(code);
readOCR.setCode(code);
return code;
return readOCR;
}
}

Loading…
Cancel
Save