|
|
|
|
@ -24,6 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.net.SocketTimeoutException;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
|
@ -100,7 +102,38 @@ public class PlcService {
|
|
|
|
|
* @param plcCmdInfo
|
|
|
|
|
*/
|
|
|
|
|
public void orderStart(PlcCmdInfo plcCmdInfo) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
|
|
|
|
|
if (street != null) {
|
|
|
|
|
if (plcCmdInfo.getLeftRight1() == 1) {
|
|
|
|
|
if (plcCmdInfo.getRow1() > street.getLeftRow() && plcCmdInfo.getColumn1() > street.getLeftColumn()) {
|
|
|
|
|
log.error("row:{},column:{},error in streetId:{} left", plcCmdInfo.getRow1(), plcCmdInfo.getColumn1(), street.getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (plcCmdInfo.getRow1() > street.getRightRow() && plcCmdInfo.getColumn1() > street.getRightColumn()) {
|
|
|
|
|
log.error("row:{},column:{},error in streetId:{} right", plcCmdInfo.getRow1(), plcCmdInfo.getColumn1(), street.getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
plcCmdInfo.setStreetId(street.getId());
|
|
|
|
|
Order order = new Order();
|
|
|
|
|
order.setOrderNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
order.setStatus(0);
|
|
|
|
|
order.setStartTime(LocalDateTime.now());
|
|
|
|
|
order.setStreetId(street.getId());
|
|
|
|
|
order.setInOut1(plcCmdInfo.getSide1());
|
|
|
|
|
order.setLeftRight1(plcCmdInfo.getLeftRight1());
|
|
|
|
|
order.setColumn1(plcCmdInfo.getColumn1());
|
|
|
|
|
order.setRow1(plcCmdInfo.getRow1());
|
|
|
|
|
order.setWmsTrayCode(plcCmdInfo.getWmsTrayCode());
|
|
|
|
|
order.setWmsCode(plcCmdInfo.getWmsCode());
|
|
|
|
|
//todo 昆船的项目 ,取货 放货是独立的
|
|
|
|
|
//取货是是不知道放货的位置的,所以订单开始的时候只写1位置
|
|
|
|
|
//订单结束写2位置
|
|
|
|
|
orderMapper.insert(order);
|
|
|
|
|
OrderRealtime.startOrder(street.getId(), plcCmdInfo.getOrderNum());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -111,6 +144,40 @@ public class PlcService {
|
|
|
|
|
* @param plcCmdInfo
|
|
|
|
|
*/
|
|
|
|
|
public void orderStop(PlcCmdInfo plcCmdInfo) {
|
|
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
|
|
|
Street street = streetMapper.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
if (street == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(plcCmdInfo.getOrderNum());
|
|
|
|
|
if (order == null) {
|
|
|
|
|
log.error("订单结束信号,订单不存在,orderNum:{}", plcCmdInfo.getOrderNum());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
plcCmdInfo.setStreetId(street.getId());
|
|
|
|
|
OrderRealtime.stopOrder(street.getId());
|
|
|
|
|
Order update = new Order();
|
|
|
|
|
update.setId(order.getId());
|
|
|
|
|
update.setEndTime(endTime);
|
|
|
|
|
update.setInOut2(plcCmdInfo.getSide2());
|
|
|
|
|
update.setLeftRight2(plcCmdInfo.getLeftRight2());
|
|
|
|
|
update.setColumn2(plcCmdInfo.getColumn2());
|
|
|
|
|
update.setRow2(plcCmdInfo.getRow2());
|
|
|
|
|
LocalDateTime endDownLoadTime = endTime.plusSeconds(10);
|
|
|
|
|
Duration duration = Duration.between(order.getStartTime(), endDownLoadTime);
|
|
|
|
|
|
|
|
|
|
if (duration.toMinutes() > 50) {
|
|
|
|
|
endDownLoadTime = order.getStartTime().plusMinutes(50);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
|
update.setVideoPath1(path);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
|
update.setVideoPath2(path);
|
|
|
|
|
}
|
|
|
|
|
orderMapper.updateById(update);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -256,28 +323,31 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode,String wmsCatagary){
|
|
|
|
|
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode,String wmsCatagary){
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
try {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("open light"+lightSource.getIp()+" error",e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
|
|
|
|
|
|
//蜜雪冰城拍摄货物顶部时用同侧相机
|
|
|
|
|
Integer leftRightTop = plcCmdInfo.getLeftRight1() == 1 ? 2 : 1;
|
|
|
|
|
Integer cameraIdTop = getCameraByPlcCmd(plcCmdInfo, leftRightTop);
|
|
|
|
|
if(plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2){
|
|
|
|
|
//内测
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) + "-IN";
|
|
|
|
|
log.info("camera ptz"+c);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, c);
|
|
|
|
|
gyrateCameraByCode(cameraId, c);
|
|
|
|
|
}else {
|
|
|
|
|
log.info("camera ptz"+cmdCode);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, cmdCode);
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1);
|
|
|
|
|
log.info("camera ptz"+c);
|
|
|
|
|
gyrateCameraByCode(cameraId, c);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
@ -383,13 +453,16 @@ public class PlcService {
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) {
|
|
|
|
|
if ((StringUtils.isEmpty(trayCode) || trayCode.equals("NoRead")) ){
|
|
|
|
|
trayCode = "扫码枪识别异常";
|
|
|
|
|
trayGoodCheck = Boolean.FALSE;
|
|
|
|
|
log.warn("sick ocr error:{}", trayCode);
|
|
|
|
|
} else {
|
|
|
|
|
//扫到就认为正常
|
|
|
|
|
} else if(trayCode.equals(wmsTrayCode)){
|
|
|
|
|
//扫到码
|
|
|
|
|
trayGoodCheck = Boolean.TRUE;
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
trayGoodCheck = Boolean.FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -465,7 +538,6 @@ public class PlcService {
|
|
|
|
|
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
|
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
//还原相机
|
|
|
|
|
gyrateCameraByCode(cameraId, "C5");
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
long s = end - startTime;
|
|
|
|
|
log.info("time:{}millisecond", s);
|
|
|
|
|
@ -644,7 +716,57 @@ public class PlcService {
|
|
|
|
|
* @param path
|
|
|
|
|
*/
|
|
|
|
|
public void captureUpdateOrderAndStock(OrderInfo orderInfo, String path) {
|
|
|
|
|
|
|
|
|
|
synchronized (orderInfo.getOrderNum().intern()) {
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderInfo.getOrderNum());
|
|
|
|
|
if (order != null) {
|
|
|
|
|
//update picPath in stock if code is C2/C4
|
|
|
|
|
if (orderInfo.getCode().startsWith("C2") || orderInfo.getCode().startsWith("C4")) {
|
|
|
|
|
StockLog stockLog = new StockLog();
|
|
|
|
|
stockLog.setStreetId(orderInfo.getStreetId());
|
|
|
|
|
stockLog.setDirection(orderInfo.getLeftRight());
|
|
|
|
|
stockLog.setSide(orderInfo.getSeparation());
|
|
|
|
|
stockLog.setRow(orderInfo.getRow());
|
|
|
|
|
stockLog.setColumn(orderInfo.getColumn());
|
|
|
|
|
stockLog.setPic(path);
|
|
|
|
|
String type = orderInfo.getCode().substring(1, 2);
|
|
|
|
|
stockLog.setType(Integer.valueOf(type));
|
|
|
|
|
stockLog.setOrderNum(orderInfo.getOrderNum());
|
|
|
|
|
stockLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
stockLogMapper.insert(stockLog);
|
|
|
|
|
// Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
|
// if (stock == null) {
|
|
|
|
|
// stock = new Stock();
|
|
|
|
|
// stock.setShelveId(orderInfo.getShelveId());
|
|
|
|
|
// stock.setColumn(orderInfo.getColumn());
|
|
|
|
|
// stock.setRow(orderInfo.getRow());
|
|
|
|
|
// //stock.setStatus(0);
|
|
|
|
|
// //if the stock is null,take over path only
|
|
|
|
|
// stock.setOveroperationPic(path);
|
|
|
|
|
// stock.setOrderNum(order.getOrderNum());
|
|
|
|
|
// stockMapper.insert(stock);
|
|
|
|
|
// } else {
|
|
|
|
|
// //take the previous picture path to the lasted over picture path
|
|
|
|
|
// //take the lasted picture path to the new one
|
|
|
|
|
// stock.setPreoperationPic(stock.getOveroperationPic());
|
|
|
|
|
// stock.setOveroperationPic(path);
|
|
|
|
|
// stock.setOrderNum(order.getOrderNum());
|
|
|
|
|
// //stock.setStatus(0);
|
|
|
|
|
// stockMapper.updateById(stock);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
String pics = order.getPicPaths();
|
|
|
|
|
if (StringUtils.isEmpty(pics)) {
|
|
|
|
|
order.setPicPaths(path);
|
|
|
|
|
} else {
|
|
|
|
|
order.setPicPaths(pics + "," + path);
|
|
|
|
|
}
|
|
|
|
|
Order update = new Order();
|
|
|
|
|
update.setId(order.getId());
|
|
|
|
|
update.setPicPaths(order.getPicPaths());
|
|
|
|
|
log.debug(" update order set pics:{},orderNum:{}", update.getPicPaths(), orderInfo.getOrderNum());
|
|
|
|
|
orderMapper.updateById(update);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getCameraByPlcCmd(PlcCmdInfo plcCmdInfo,Integer leftRight){
|
|
|
|
|
@ -871,7 +993,7 @@ public class PlcService {
|
|
|
|
|
order.setOrderNum(taskId);
|
|
|
|
|
order.setLeftRight1(leftRight);
|
|
|
|
|
order.setInOut1(inout);
|
|
|
|
|
order.setIntoStockTime(LocalDateTime.now());
|
|
|
|
|
order.setEndTime(LocalDateTime.now());
|
|
|
|
|
order.setRow1(row);
|
|
|
|
|
order.setColumn1(column);
|
|
|
|
|
// if (oldOrder != null){
|
|
|
|
|
@ -894,7 +1016,7 @@ public class PlcService {
|
|
|
|
|
String[] pics = picName.split(";");
|
|
|
|
|
String picNameDataBase = ip+pics[0]+";"+ ip+pics[1];
|
|
|
|
|
Order oldOrder = orderMapper.getOneByOrderNum(taskId);
|
|
|
|
|
oldOrder.setIntoStockPic(picNameDataBase);
|
|
|
|
|
oldOrder.setPicPaths(picNameDataBase);
|
|
|
|
|
orderMapper.updateById(oldOrder);
|
|
|
|
|
return ip+pics[0]+"*"+ ip+pics[1];
|
|
|
|
|
}
|
|
|
|
|
@ -991,8 +1113,8 @@ public class PlcService {
|
|
|
|
|
if(order != null){
|
|
|
|
|
Order upd = new Order();
|
|
|
|
|
upd.setId(order.getId());
|
|
|
|
|
upd.setIntoStockOverPic(path);
|
|
|
|
|
upd.setIntoStockOverTime(LocalDateTime.now());
|
|
|
|
|
upd.setPicPaths(path);
|
|
|
|
|
upd.setEndTime(LocalDateTime.now());
|
|
|
|
|
orderMapper.updateById(upd);
|
|
|
|
|
}
|
|
|
|
|
cameraCapture(cameraId,false,0l,path);
|
|
|
|
|
|