|
|
|
|
@ -32,6 +32,8 @@ import java.util.*;
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -82,9 +84,9 @@ public class PlcService {
|
|
|
|
|
@Resource
|
|
|
|
|
private CheckStreetSummaryMapper checkStreetSummaryMapper;
|
|
|
|
|
|
|
|
|
|
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,8,200,TimeUnit.MINUTES,new ArrayBlockingQueue<>(100000));
|
|
|
|
|
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 8, 200, TimeUnit.MINUTES, new ArrayBlockingQueue<>(100000));
|
|
|
|
|
|
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule){
|
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule) {
|
|
|
|
|
this.cameraControlModule = cameraControlModule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -122,17 +124,18 @@ public class PlcService {
|
|
|
|
|
public void orderStopByWarn(String orderNum) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void verticalAdjustment(Integer cameraId){
|
|
|
|
|
log.info("球机"+cameraId+"重置垂直方向开始");
|
|
|
|
|
|
|
|
|
|
public void verticalAdjustment(Integer cameraId) {
|
|
|
|
|
log.info("球机" + cameraId + "重置垂直方向开始");
|
|
|
|
|
Double origin = null;
|
|
|
|
|
int i = 10 ;
|
|
|
|
|
while (i >=0){
|
|
|
|
|
i-- ;
|
|
|
|
|
CameraPtzPojo cameraPtzPojo = cameraControlModule.ptzGetDVRConfig(cameraId);
|
|
|
|
|
if(cameraPtzPojo.isGetSuccess()) {
|
|
|
|
|
int i = 10;
|
|
|
|
|
while (i >= 0) {
|
|
|
|
|
i--;
|
|
|
|
|
CameraPtzPojo cameraPtzPojo = cameraControlModule.ptzGetDVRConfig(cameraId);
|
|
|
|
|
if (cameraPtzPojo.isGetSuccess()) {
|
|
|
|
|
cameraControlModule.ptzControlDownStart(cameraId, 0, 0, 1);
|
|
|
|
|
log.info("球机控制向下");
|
|
|
|
|
System.out.println("获取的垂直位置"+cameraPtzPojo.getWTiltPos());
|
|
|
|
|
System.out.println("获取的垂直位置" + cameraPtzPojo.getWTiltPos());
|
|
|
|
|
if (origin == null) {
|
|
|
|
|
origin = cameraPtzPojo.getWTiltPos();
|
|
|
|
|
} else if (cameraPtzPojo.getWTiltPos() <= origin) {
|
|
|
|
|
@ -145,19 +148,19 @@ public class PlcService {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("球机"+cameraId+"重置垂直方向成功");
|
|
|
|
|
cameraControlModule.ptzControlDownEnd(cameraId,0);
|
|
|
|
|
gyrateCameraByCode(cameraId,"C1");
|
|
|
|
|
log.info("球机" + cameraId + "重置垂直方向成功");
|
|
|
|
|
cameraControlModule.ptzControlDownEnd(cameraId, 0);
|
|
|
|
|
gyrateCameraByCode(cameraId, "C1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void verticalAdjustmentByStreet(String SRMNumber){
|
|
|
|
|
public void verticalAdjustmentByStreet(String SRMNumber) {
|
|
|
|
|
|
|
|
|
|
Street street = streetService.getStreetByPlcId(SRMNumber);
|
|
|
|
|
//南京烟草物流只有一个相机
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id():street.getCamera1Id();
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id() : street.getCamera1Id();
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime()*1000);
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime() * 1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
@ -165,16 +168,13 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String cameraVideo(Integer cameraId, LocalDateTime startTime, LocalDateTime endTime) {
|
|
|
|
|
String path = PathUtil.createFileName("mp4",cameraId);
|
|
|
|
|
String path = PathUtil.createFileName("mp4", cameraId);
|
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
String realPath = configProperties.getSavePath().getMp4Path() + path;
|
|
|
|
|
TaskDelayExecutor.addMp4DelayTask(cameraId,realPath,startTime,endTime,configProperties.getCameraConfig().getDelayDownloadMp4());
|
|
|
|
|
TaskDelayExecutor.addMp4DelayTask(cameraId, realPath, startTime, endTime, configProperties.getCameraConfig().getDelayDownloadMp4());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
thread.start();
|
|
|
|
|
@ -208,79 +208,79 @@ public class PlcService {
|
|
|
|
|
* 右侧转camera2
|
|
|
|
|
* 没有就不管了
|
|
|
|
|
*/
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,orderInfo.getLeftRight());
|
|
|
|
|
gyrateCameraByCode(cameraId,orderInfo.getCmdCode());
|
|
|
|
|
if(needCapture){
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo, orderInfo.getLeftRight());
|
|
|
|
|
gyrateCameraByCode(cameraId, orderInfo.getCmdCode());
|
|
|
|
|
if (needCapture) {
|
|
|
|
|
Boolean delay = true;
|
|
|
|
|
Integer row = 0;
|
|
|
|
|
Integer column = 0;
|
|
|
|
|
Integer sep = 0;
|
|
|
|
|
if(times<=2){
|
|
|
|
|
if (times <= 2) {
|
|
|
|
|
row = plcCmdInfo.getRow1();
|
|
|
|
|
column = plcCmdInfo.getColumn1();
|
|
|
|
|
sep = plcCmdInfo.getSeparation1();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
row = plcCmdInfo.getRow2();
|
|
|
|
|
column = plcCmdInfo.getColumn2();
|
|
|
|
|
sep = plcCmdInfo.getSeparation2();
|
|
|
|
|
}
|
|
|
|
|
long delayTime = 0;
|
|
|
|
|
if(code.startsWith("C1")){
|
|
|
|
|
if (code.startsWith("C1")) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC1DelayCaptureTime();
|
|
|
|
|
}else if(code.startsWith("C2")){
|
|
|
|
|
if(sep == 1){
|
|
|
|
|
} else if (code.startsWith("C2")) {
|
|
|
|
|
if (sep == 1) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2DelayCaptureTime();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
|
|
|
|
|
}
|
|
|
|
|
}else if(code.startsWith("C3")){
|
|
|
|
|
} else if (code.startsWith("C3")) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC3DelayCaptureTime();
|
|
|
|
|
|
|
|
|
|
}else if(code.startsWith("C4")){
|
|
|
|
|
if(sep == 1){
|
|
|
|
|
} else if (code.startsWith("C4")) {
|
|
|
|
|
if (sep == 1) {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC4DelayCaptureTime();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
delayTime = configProperties.getCameraConfig().getC4OutDelayCaptureTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
path = PathUtil.createFileNameByRowColumn("jpg",cameraId,row,column);
|
|
|
|
|
path = cameraCapture(cameraId,delay,delayTime,path);
|
|
|
|
|
path = PathUtil.createFileNameByRowColumn("jpg", cameraId, row, column);
|
|
|
|
|
path = cameraCapture(cameraId, delay, delayTime, path);
|
|
|
|
|
}
|
|
|
|
|
//update order info after capture
|
|
|
|
|
if (path != null && needCapture) {
|
|
|
|
|
captureUpdateOrderAndStock(orderInfo, path);
|
|
|
|
|
}
|
|
|
|
|
//转向原点位
|
|
|
|
|
if(times == 2){
|
|
|
|
|
if(street.getCamera2Id() != null){
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera2Id(),"C5",configProperties.getCameraConfig().getC2OutDelayCaptureTime()+500);
|
|
|
|
|
if (times == 2) {
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera2Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera1Id() != null){
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(),"C5",configProperties.getCameraConfig().getC2OutDelayCaptureTime()+500);
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo,String code){
|
|
|
|
|
public void gyrateCamera(PlcCmdInfo plcCmdInfo, String code) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
if(street == null){
|
|
|
|
|
if (street == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera1Id() != null){
|
|
|
|
|
gyrateCameraByCode(street.getCamera1Id(),code);
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
gyrateCameraByCode(street.getCamera1Id(), code);
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera2Id() != null){
|
|
|
|
|
gyrateCameraByCode(street.getCamera2Id(),code);
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
gyrateCameraByCode(street.getCamera2Id(), code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void warnAction(PlcCmdInfo plcCmdInfo,String warnCode){
|
|
|
|
|
public void warnAction(PlcCmdInfo plcCmdInfo, String warnCode) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
if(street.getCamera1Id() != null){
|
|
|
|
|
gyrateCameraByCode(street.getCamera1Id(),warnCode);
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
gyrateCameraByCode(street.getCamera1Id(), warnCode);
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera2Id() != null){
|
|
|
|
|
gyrateCameraByCode(street.getCamera2Id(),warnCode);
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
gyrateCameraByCode(street.getCamera2Id(), warnCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -303,13 +303,13 @@ public class PlcService {
|
|
|
|
|
*
|
|
|
|
|
* @Return pic address
|
|
|
|
|
*/
|
|
|
|
|
public String cameraCapture(Integer cameraId,Boolean delay,Long delayTime,String path) {
|
|
|
|
|
public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) {
|
|
|
|
|
//String path = PathUtil.createFileName("jpg",cameraId);
|
|
|
|
|
String realPath = configProperties.getSavePath().getMediaPath() + path;
|
|
|
|
|
if(delay){
|
|
|
|
|
TaskDelayExecutor.addPicDelayTask(cameraId,realPath,delayTime);
|
|
|
|
|
}else {
|
|
|
|
|
cameraControlModule.pic(cameraId,0,realPath);
|
|
|
|
|
if (delay) {
|
|
|
|
|
TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime);
|
|
|
|
|
} else {
|
|
|
|
|
cameraControlModule.pic(cameraId, 0, realPath);
|
|
|
|
|
}
|
|
|
|
|
log.info("capture the photo: {}", realPath);
|
|
|
|
|
return path;
|
|
|
|
|
@ -325,17 +325,17 @@ public class PlcService {
|
|
|
|
|
Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId);
|
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
|
cameraControlModule.toPtz(ptzId,cameraId);
|
|
|
|
|
cameraControlModule.toPtz(ptzId, cameraId);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void gyrateCameraByCodeTimeLater(Integer cameraId, String code,long times) {
|
|
|
|
|
public void gyrateCameraByCodeTimeLater(Integer cameraId, String code, long times) {
|
|
|
|
|
Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId);
|
|
|
|
|
if (ptzId != null && ptzId >= 0) {
|
|
|
|
|
log.info("gyrate camera by code, code:{},cameraId:{},ptId:{}", code, cameraId, ptzId);
|
|
|
|
|
TaskDelayExecutor.addGyrateCameraTask(cameraId,times,ptzId);
|
|
|
|
|
TaskDelayExecutor.addGyrateCameraTask(cameraId, times, ptzId);
|
|
|
|
|
//cameraControlModule.toPtz(ptzId,cameraId);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("ptz not found ,code:{},cameraId:{}", code, cameraId);
|
|
|
|
|
@ -373,7 +373,7 @@ public class PlcService {
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderNum);
|
|
|
|
|
if (order != null) {
|
|
|
|
|
//stop the order
|
|
|
|
|
log.debug("plcId:{},warn start and stop the order",plcId);
|
|
|
|
|
log.debug("plcId:{},warn start and stop the order", plcId);
|
|
|
|
|
orderStopByWarn(orderNum);
|
|
|
|
|
OrderVO orderVO = new OrderVO();
|
|
|
|
|
BeanUtils.copyProperties(order, orderVO);
|
|
|
|
|
@ -412,11 +412,11 @@ public class PlcService {
|
|
|
|
|
//结束该告警,并录像
|
|
|
|
|
warn.setEndTime(LocalDateTime.now());
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera1Id(),warn.getStartTime(),LocalDateTime.now());
|
|
|
|
|
String path = cameraVideo(street.getCamera1Id(), warn.getStartTime(), LocalDateTime.now());
|
|
|
|
|
warn.setVideoPath1(path);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera2Id(),warn.getStartTime(),LocalDateTime.now());
|
|
|
|
|
String path = cameraVideo(street.getCamera2Id(), warn.getStartTime(), LocalDateTime.now());
|
|
|
|
|
warn.setVideoPath2(path);
|
|
|
|
|
}
|
|
|
|
|
warnMapper.updateById(warn);
|
|
|
|
|
@ -435,16 +435,16 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getCameraByPlcCmd(PlcCmdInfo plcCmdInfo,Integer leftRight){
|
|
|
|
|
public Integer getCameraByPlcCmd(PlcCmdInfo plcCmdInfo, Integer leftRight) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
//判断单双伸 type=0 单伸 1为双伸
|
|
|
|
|
Integer type;
|
|
|
|
|
if(leftRight == 1){
|
|
|
|
|
if (leftRight == 1) {
|
|
|
|
|
type = street.getLeftType();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
type = street.getRightType();
|
|
|
|
|
}
|
|
|
|
|
if(type == 0){
|
|
|
|
|
if (type == 0) {
|
|
|
|
|
//单伸
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
if (leftRight == 1) {
|
|
|
|
|
@ -456,13 +456,13 @@ public class PlcService {
|
|
|
|
|
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
|
|
|
|
|
return cameraId;
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
|
|
|
|
|
//双伸 todo 这个因项目而异,看现场的情况
|
|
|
|
|
//默认是 左侧返回camera2 右侧返回camera1
|
|
|
|
|
if(plcCmdInfo.getLeftRight1() == 1){
|
|
|
|
|
if (plcCmdInfo.getLeftRight1() == 1) {
|
|
|
|
|
return street.getCamera2Id();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
return street.getCamera1Id();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@ -478,7 +478,7 @@ public class PlcService {
|
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkLog(Stock stock){
|
|
|
|
|
public void checkLog(Stock stock) {
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setCheckNum(stock.getCheckNum());
|
|
|
|
|
checkLog.setPic(stock.getCheckPic());
|
|
|
|
|
@ -497,60 +497,63 @@ public class PlcService {
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
log.info("checkLogMapper insert");
|
|
|
|
|
}
|
|
|
|
|
public void truncateStock(){
|
|
|
|
|
|
|
|
|
|
public void truncateStock() {
|
|
|
|
|
stockMapper.truncate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RFIDCheck(PlcCmdInfo plcCmdInfo){
|
|
|
|
|
public void RFIDCheck(PlcCmdInfo plcCmdInfo) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
if(street != null){
|
|
|
|
|
if (street != null) {
|
|
|
|
|
RFID rfid = rfidService.getRFIDByPlc(street.getId());
|
|
|
|
|
if(rfid != null){
|
|
|
|
|
RFIDStart(rfid.getIp(),rfid.getPort(),street.getId());
|
|
|
|
|
if (rfid != null) {
|
|
|
|
|
RFIDStart(rfid.getIp(), rfid.getPort(), street.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RFIDStart(String ip,Integer port,Integer streetId){
|
|
|
|
|
RFIDSocket rfidSocket = new RFIDSocket(ip,port);
|
|
|
|
|
public void RFIDStart(String ip, Integer port, Integer streetId) {
|
|
|
|
|
RFIDSocket rfidSocket = new RFIDSocket(ip, port);
|
|
|
|
|
rfidSocket.startCheck();
|
|
|
|
|
rfidSocket.readData();
|
|
|
|
|
RFIDMap.put(streetId,rfidSocket);
|
|
|
|
|
RFIDMap.put(streetId, rfidSocket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Set<String> RFIDStop(PlcCmdInfo plcCmdInfo){
|
|
|
|
|
public Set<String> RFIDStop(PlcCmdInfo plcCmdInfo) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
|
|
|
|
|
RFIDSocket rfidSocket = RFIDMap.get(street.getId());
|
|
|
|
|
Set<String> tags = null;
|
|
|
|
|
if(rfidSocket != null){
|
|
|
|
|
if (rfidSocket != null) {
|
|
|
|
|
tags = rfidSocket.getTags();
|
|
|
|
|
log.info("tags:{}",tags);
|
|
|
|
|
log.info("tags:{}", tags);
|
|
|
|
|
rfidSocket.close();
|
|
|
|
|
RFIDMap.remove(street.getId());
|
|
|
|
|
}
|
|
|
|
|
return tags;
|
|
|
|
|
}
|
|
|
|
|
public ConfigProperties getConfigProperties(){
|
|
|
|
|
|
|
|
|
|
public ConfigProperties getConfigProperties() {
|
|
|
|
|
return configProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 相机转动,拍照,并返回图片地址
|
|
|
|
|
* 顶部拍照 C1
|
|
|
|
|
*
|
|
|
|
|
* @param SRMNumber
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String IntoStock(String SRMNumber,String taskId,String goodsLocation){
|
|
|
|
|
public String IntoStock(String SRMNumber, String taskId, String goodsLocation) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(SRMNumber);
|
|
|
|
|
if (street == null){
|
|
|
|
|
if (street == null) {
|
|
|
|
|
log.error("SRMNum: {} 对应的巷道不存在", SRMNumber);
|
|
|
|
|
}
|
|
|
|
|
//南京烟草物流只有一个相机
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id():street.getCamera1Id();
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(8,10));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(5,8));
|
|
|
|
|
Integer leftRight = Integer.valueOf(goodsLocation.substring(4,5));
|
|
|
|
|
Integer inout = Integer.valueOf(goodsLocation.substring(11,12));
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id() : street.getCamera1Id();
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(8, 10));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(5, 8));
|
|
|
|
|
Integer leftRight = Integer.valueOf(goodsLocation.substring(4, 5));
|
|
|
|
|
Integer inout = Integer.valueOf(goodsLocation.substring(11, 12));
|
|
|
|
|
log.info("camera id:{}, row:{}, column:{}, direction:{}, inout:{}", cameraId, row, column, leftRight, inout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -573,27 +576,26 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 相机转动,拍照,并返回图片地址
|
|
|
|
|
*
|
|
|
|
|
* @param SRMNumber
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String IntoStockOver(String SRMNumber,String taskId,String goodsLocation){
|
|
|
|
|
public String IntoStockOver(String SRMNumber, String taskId, String goodsLocation) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(SRMNumber);
|
|
|
|
|
//南京烟草物流只有一个相机
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id():street.getCamera1Id();
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(8,10));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(5,8));
|
|
|
|
|
Integer leftRight = Integer.valueOf(goodsLocation.substring(4,5));
|
|
|
|
|
Integer inout = Integer.valueOf(goodsLocation.substring(11,12));
|
|
|
|
|
Integer cameraId = street.getCamera1Id() == null ? street.getCamera2Id() : street.getCamera1Id();
|
|
|
|
|
Integer row = Integer.valueOf(goodsLocation.substring(8, 10));
|
|
|
|
|
Integer column = Integer.valueOf(goodsLocation.substring(5, 8));
|
|
|
|
|
Integer leftRight = Integer.valueOf(goodsLocation.substring(4, 5));
|
|
|
|
|
Integer inout = Integer.valueOf(goodsLocation.substring(11, 12));
|
|
|
|
|
log.info("camera id:{}, row:{}, column:{}, direction:{}, inout:{}", cameraId, row, column, leftRight, inout);
|
|
|
|
|
String inoutString = inout == 1 ? "IN" : "OUT";
|
|
|
|
|
String leftRightString = leftRight == 1 ? "L":"R";
|
|
|
|
|
String leftRightString = leftRight == 1 ? "L" : "R";
|
|
|
|
|
//转动拍照
|
|
|
|
|
String PTZCode = String.format("C2-%s-%s", inoutString,leftRightString);
|
|
|
|
|
gyrateCameraByCode(cameraId,PTZCode);
|
|
|
|
|
String PTZCode = String.format("C2-%s-%s", inoutString, leftRightString);
|
|
|
|
|
gyrateCameraByCode(cameraId, PTZCode);
|
|
|
|
|
//等待2s再拍照
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(2000l);
|
|
|
|
|
@ -601,98 +603,100 @@ public class PlcService {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,row,column, goodsLocation);
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, row, column, goodsLocation);
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(taskId);
|
|
|
|
|
if(order != null){
|
|
|
|
|
if (order != null) {
|
|
|
|
|
Order upd = new Order();
|
|
|
|
|
upd.setId(order.getId());
|
|
|
|
|
upd.setIntoStockOverPic(path);
|
|
|
|
|
upd.setIntoStockOverTime(LocalDateTime.now());
|
|
|
|
|
orderMapper.updateById(upd);
|
|
|
|
|
}
|
|
|
|
|
cameraCapture(cameraId,false,0l,path);
|
|
|
|
|
return configProperties.getIP()+":9007/api/pic/"+path;
|
|
|
|
|
cameraCapture(cameraId, false, 0l, path);
|
|
|
|
|
return configProperties.getIP() + ":9007/api/pic/" + path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void check(PlcCmdInfo plcCmdInfo, KsecDataInfo dataInfo ) {
|
|
|
|
|
Lock lock = new ReentrantLock();
|
|
|
|
|
|
|
|
|
|
public void check(PlcCmdInfo plcCmdInfo, KsecDataInfo dataInfo) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(dataInfo.getSRMNumber());
|
|
|
|
|
|
|
|
|
|
//开始盘点具体货位
|
|
|
|
|
if(dataInfo.getCmdName().equals("SC01")){
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setStreetId(street.getId());
|
|
|
|
|
checkLog.setLotnum(dataInfo.getLotnum());
|
|
|
|
|
checkLog.setDirection(dataInfo.getFromDirection());
|
|
|
|
|
checkLog.setSide(dataInfo.getFromSide());
|
|
|
|
|
checkLog.setRow(dataInfo.getFromRow());
|
|
|
|
|
checkLog.setColumn(dataInfo.getFromColumn());
|
|
|
|
|
checkLog.setTaskId((dataInfo.getTaskId()));
|
|
|
|
|
//默认未盘点
|
|
|
|
|
checkLog.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
checkLog.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
checkLog.setCount(dataInfo.getQuantity());
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(street.getId(),dataInfo.getFromDirection(),dataInfo.getFromSide(),dataInfo.getFromRow(),dataInfo.getFromColumn());
|
|
|
|
|
if(stock== null) {
|
|
|
|
|
stock = new Stock();
|
|
|
|
|
}
|
|
|
|
|
stock.setStreetId(street.getId());
|
|
|
|
|
stock.setCheckNum(checkLog.getId().toString());
|
|
|
|
|
stock.setLotnum(dataInfo.getLotnum());
|
|
|
|
|
stock.setDirection(dataInfo.getFromDirection());
|
|
|
|
|
stock.setSide(dataInfo.getFromSide());
|
|
|
|
|
stock.setRow(dataInfo.getFromRow());
|
|
|
|
|
stock.setColumn(dataInfo.getFromColumn());
|
|
|
|
|
stock.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
stock.setCount(dataInfo.getQuantity());
|
|
|
|
|
stock.setTaskId((dataInfo.getTaskId()));
|
|
|
|
|
//默认未盘点
|
|
|
|
|
stock.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
if(stock.getId() == null){
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
}else stockMapper.updateById(stock);
|
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo( checkLog ,street);
|
|
|
|
|
ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setStreetId(street.getId());
|
|
|
|
|
checkLog.setLotnum(dataInfo.getLotnum());
|
|
|
|
|
checkLog.setDirection(dataInfo.getFromDirection());
|
|
|
|
|
checkLog.setSide(dataInfo.getFromSide());
|
|
|
|
|
checkLog.setRow(dataInfo.getFromRow());
|
|
|
|
|
checkLog.setColumn(dataInfo.getFromColumn());
|
|
|
|
|
checkLog.setTaskId((dataInfo.getTaskId()));
|
|
|
|
|
//默认未盘点
|
|
|
|
|
checkLog.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
checkLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
checkLog.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
checkLog.setCount(dataInfo.getQuantity());
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(street.getId(), dataInfo.getFromDirection(), dataInfo.getFromSide(), dataInfo.getFromRow(), dataInfo.getFromColumn());
|
|
|
|
|
if (stock == null) {
|
|
|
|
|
stock = new Stock();
|
|
|
|
|
}
|
|
|
|
|
stock.setStreetId(street.getId());
|
|
|
|
|
stock.setCheckNum(checkLog.getId().toString());
|
|
|
|
|
stock.setLotnum(dataInfo.getLotnum());
|
|
|
|
|
stock.setDirection(dataInfo.getFromDirection());
|
|
|
|
|
stock.setSide(dataInfo.getFromSide());
|
|
|
|
|
stock.setRow(dataInfo.getFromRow());
|
|
|
|
|
stock.setColumn(dataInfo.getFromColumn());
|
|
|
|
|
stock.setCategory(dataInfo.getTypeNum());
|
|
|
|
|
stock.setCount(dataInfo.getQuantity());
|
|
|
|
|
stock.setTaskId((dataInfo.getTaskId()));
|
|
|
|
|
//默认未盘点
|
|
|
|
|
stock.setStatus(StockStatus.PENDING.getStatus());
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
if (stock.getId() == null) {
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
} else stockMapper.updateById(stock);
|
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo(checkLog, street);
|
|
|
|
|
ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.ST));
|
|
|
|
|
|
|
|
|
|
//取货完成进行拍照
|
|
|
|
|
else if(dataInfo.getCmdName().equals("SC02")){
|
|
|
|
|
CheckLog checkLog = checkLogMapper.selectOne(new QueryWrapper<CheckLog>()
|
|
|
|
|
.eq("direction",dataInfo.getFromDirection())
|
|
|
|
|
.eq("street_id",street.getId())
|
|
|
|
|
.orderByDesc("id").last("limit 1"));
|
|
|
|
|
TransmissionPojo transmissionPojo = new TransmissionPojo( checkLog,street );
|
|
|
|
|
if(GetPhotoDelayExecutor.cameraDelayTasks.size()==0){
|
|
|
|
|
try {
|
|
|
|
|
if (lock.tryLock()) {
|
|
|
|
|
//队列中没有任务,发送取图指令
|
|
|
|
|
ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.GPS));
|
|
|
|
|
|
|
|
|
|
Thread.sleep(50L);
|
|
|
|
|
} else {
|
|
|
|
|
//将取图指令放入队列等待上条取图结束,或队列超时调用
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(), transmissionPojo.toString(TransmissionType.GPS), configProperties.getQueueSpanTime());
|
|
|
|
|
}
|
|
|
|
|
//将取图指令放入队列等待上条取图结束,或队列超时调用
|
|
|
|
|
GetPhotoDelayExecutor.addCameraDelayTask(street.getPlcId(),transmissionPojo.toString(TransmissionType.GPS),2000L);
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("取图命令 error", e);
|
|
|
|
|
} finally {
|
|
|
|
|
lock.unlock();
|
|
|
|
|
}
|
|
|
|
|
// ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush();
|
|
|
|
|
|
|
|
|
|
// ClientChanel.get(dataInfo.getSRMNumber()).writeAndFlush();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void visualCalculationResults(TransmissionPojo transmissionPojo) {
|
|
|
|
|
CheckLog checkLog = checkLogMapper.selectById(transmissionPojo.getCheckId());
|
|
|
|
|
Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("check_Num",checkLog.getId()));
|
|
|
|
|
Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("check_Num", checkLog.getId()));
|
|
|
|
|
Street street = streetService.getStreetByPlcId(transmissionPojo.getStreetNumber());
|
|
|
|
|
if(transmissionPojo.getResult() != null && transmissionPojo.getResult() == 1){
|
|
|
|
|
if (transmissionPojo.getResult() != null && transmissionPojo.getResult() == 1) {
|
|
|
|
|
checkLog.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.SUCCESS.getStatus());
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
checkLog.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setStatus(StockStatus.ERROR.getStatus());
|
|
|
|
|
stock.setCount(transmissionPojo.getCount());
|
|
|
|
|
stock.setCategory(transmissionPojo.getCategory());
|
|
|
|
|
}
|
|
|
|
|
if (transmissionPojo.getPicsPath() != null && transmissionPojo.getPicsPath().length > 0){
|
|
|
|
|
if (transmissionPojo.getPicsPath() != null && transmissionPojo.getPicsPath().length > 0) {
|
|
|
|
|
|
|
|
|
|
String pics = Arrays.stream(transmissionPojo.getPicsPath()).map(v->{
|
|
|
|
|
return street.getPlcIp() + ":8007" + v;
|
|
|
|
|
String pics = Arrays.stream(transmissionPojo.getPicsPath()).map(v -> {
|
|
|
|
|
return "http://" + street.getPlcIp() + ":8007" + v;
|
|
|
|
|
}).collect(Collectors.joining(";"));
|
|
|
|
|
checkLog.setPic(pics);
|
|
|
|
|
stock.setCheckPic(pics);
|
|
|
|
|
@ -712,7 +716,7 @@ public class PlcService {
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public KsecInfo getKsecDataInfo(TransmissionPojo transmissionPojo,String type) {
|
|
|
|
|
public KsecInfo getKsecDataInfo(TransmissionPojo transmissionPojo, String type) {
|
|
|
|
|
KsecDataInfo ksecDataInfo = new KsecDataInfo();
|
|
|
|
|
CheckLog checkLog = checkLogMapper.selectById(transmissionPojo.getCheckId());
|
|
|
|
|
ksecDataInfo.setLotnum(checkLog.getLotnum());
|
|
|
|
|
@ -728,7 +732,7 @@ public class PlcService {
|
|
|
|
|
ksecDataInfo.setLotnum(checkLog.getLotnum());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KsecInfo ksecInfo = new KsecInfo("KC","SC",ksecDataInfo);
|
|
|
|
|
KsecInfo ksecInfo = new KsecInfo("KC", "SC", ksecDataInfo);
|
|
|
|
|
return ksecInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|