|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.zhehekeji.web.service;
|
|
|
|
|
|
|
|
|
|
import codeDetector.BarcodeDetector;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.zhehekeji.common.util.PathUtil;
|
|
|
|
|
import com.zhehekeji.web.config.ConfigProperties;
|
|
|
|
|
@ -8,6 +9,7 @@ import com.zhehekeji.web.lib.*;
|
|
|
|
|
import com.zhehekeji.web.mapper.*;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
|
import com.zhehekeji.web.service.RFID.RFIDSocket;
|
|
|
|
|
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
|
|
|
|
|
import com.zhehekeji.web.service.ksec.KsecNettyClient;
|
|
|
|
|
import com.zhehekeji.web.service.sick.SickSocket;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@ -573,11 +575,18 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
|
|
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
CronTab.putTime(street.getId());
|
|
|
|
|
List<LightSource> lightSources = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
});
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
|
gyrateCameraByCode(cameraId, cmdCode);
|
|
|
|
|
try {
|
|
|
|
|
@ -630,15 +639,86 @@ public class PlcService {
|
|
|
|
|
//RFID
|
|
|
|
|
RFID rfid = rfidService.getRFIDByPlc(street.getId());
|
|
|
|
|
}
|
|
|
|
|
StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
|
threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
String scanCode = null;
|
|
|
|
|
Boolean codeCheck = Boolean.TRUE;
|
|
|
|
|
Boolean trayCodeCheck = Boolean.TRUE;
|
|
|
|
|
//货物使用球机扫码
|
|
|
|
|
|
|
|
|
|
if(configProperties.getScanCodeMode().getTray() == 2 && plcCmdInfo.getSeparation1() == 2){
|
|
|
|
|
//托盘使用球机扫码
|
|
|
|
|
if("".equals(wmsTrayCode)){
|
|
|
|
|
//空货物的处理
|
|
|
|
|
//如果系统货物为空,则只要扫码识别未出结果,就认为无货物
|
|
|
|
|
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath()+path,configProperties.getScanCodeMode().getTrayCodeTypes());
|
|
|
|
|
log.info("tray code:{},sys trayCode:{}",trayCode,wmsTrayCode);
|
|
|
|
|
if(StringUtils.isEmpty(trayCode)|| trayCode.equals("Unrecognized")){
|
|
|
|
|
trayCheck = Boolean.TRUE;
|
|
|
|
|
trayCode = "";
|
|
|
|
|
}else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath()+path,configProperties.getScanCodeMode().getTrayCodeTypes());
|
|
|
|
|
if(StringUtils.isEmpty(trayCode)){
|
|
|
|
|
log.error("row:{},cloumn:{}",plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
|
log.error("detectBestBarCode:{}",trayCode);
|
|
|
|
|
trayCode = "识别异常";
|
|
|
|
|
trayCheck = Boolean.FALSE;
|
|
|
|
|
}else {
|
|
|
|
|
trayCheck = wmsTrayCode.equals(trayCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
log.info("code:{}",scanCode);
|
|
|
|
|
//核对异常
|
|
|
|
|
Integer status = 1;
|
|
|
|
|
//托盘和货物都正确
|
|
|
|
|
if(trayCheck && codeCheck){
|
|
|
|
|
status = 2;
|
|
|
|
|
}
|
|
|
|
|
if(stock == null){
|
|
|
|
|
stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum(),scanCode, null,null,wmsCode,null,null,wmsTrayCode,trayCode,orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn(),status,null,null,path, LocalDateTime.now());
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
}else {
|
|
|
|
|
stock.setStatus(status);
|
|
|
|
|
stock.setLotnum(plcCmdInfo.getLotnum());
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
stock.setCheckPic(path);
|
|
|
|
|
stock.setCheckNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
stock.setTrayCode(trayCode);
|
|
|
|
|
stock.setWmsTrayCode(wmsTrayCode);
|
|
|
|
|
stock.setCode(scanCode);
|
|
|
|
|
stock.setWmsCode(wmsCode);
|
|
|
|
|
stockMapper.updateById(stock);
|
|
|
|
|
}
|
|
|
|
|
checkLog(stock);
|
|
|
|
|
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
long s = end - startTime;
|
|
|
|
|
log.info("time:{}millisecond",s);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void checkLog(Stock stock){
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setCheckNum(stock.getCheckNum());
|
|
|
|
|
checkLog.setPic(stock.getCheckPic());
|
|
|
|
|
checkLog.setShelveId(stock.getShelveId());
|
|
|
|
|
checkLog.setCode(stock.getCode());
|
|
|
|
|
checkLog.setWmsCode(stock.getWmsCode());
|
|
|
|
|
checkLog.setStatus(stock.getStatus());
|
|
|
|
|
checkLog.setRow(stock.getRow());
|
|
|
|
|
checkLog.setColumn(stock.getColumn());
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
checkLog.setTrayCode(stock.getTrayCode());
|
|
|
|
|
checkLog.setWmsTrayCode(stock.getWmsTrayCode());
|
|
|
|
|
checkLog.setLotnum(stock.getLotnum());
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
}
|
|
|
|
|
public void truncateStock(){
|
|
|
|
|
stockMapper.truncate();
|
|
|
|
|
}
|
|
|
|
|
|