|
|
|
|
@ -79,9 +79,9 @@ public class PlcService {
|
|
|
|
|
@Resource
|
|
|
|
|
private CheckLogMapper checkLogMapper;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -92,7 +92,7 @@ public class PlcService {
|
|
|
|
|
|
|
|
|
|
public Integer plcStatus() {
|
|
|
|
|
Integer count = 1;
|
|
|
|
|
if(configProperties.getServerMode() == 0){
|
|
|
|
|
if (configProperties.getServerMode() == 0) {
|
|
|
|
|
count = streetMapper.selectCount(new QueryWrapper<>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -109,14 +109,14 @@ public class PlcService {
|
|
|
|
|
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());
|
|
|
|
|
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());
|
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -142,17 +142,18 @@ public class PlcService {
|
|
|
|
|
OrderRealtime.startOrder(street.getId(), plcCmdInfo.getOrderNum());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public boolean openStreetLightSource( Integer streetId){
|
|
|
|
|
|
|
|
|
|
public boolean openStreetLightSource(Integer streetId) {
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(streetId);
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.openDO(equip,configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,configProperties.getLightSource().getNum(),configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
if (configProperties.getLightSource().getType() == 1) {
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(), lightSource.getPort());
|
|
|
|
|
JYDamHelper.openDO(equip, configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip, configProperties.getLightSource().getNum(), configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}", lightSource.getIp(), status);
|
|
|
|
|
equip.DisConnect();
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
} else if (configProperties.getLightSource().getType() == 2) {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(), lightSource.getPort(), configProperties.getLightSource().getIndex(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
@ -160,67 +161,61 @@ public class PlcService {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void verticalAdjustmentByStreet(String SRMNumber){
|
|
|
|
|
public void verticalAdjustmentByStreet(String SRMNumber) {
|
|
|
|
|
Street street = streetService.getStreetByPlcId(SRMNumber);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime()*1000);
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime() * 1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera1Id()!=null){
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
//重置垂直方向球机
|
|
|
|
|
verticalAdjustment(street.getCamera1Id());
|
|
|
|
|
}
|
|
|
|
|
if(street.getCamera2Id()!=null){
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
//重置垂直方向球机
|
|
|
|
|
verticalAdjustment(street.getCamera2Id());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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()) {
|
|
|
|
|
cameraControlModule.ptzControlDownStart(cameraId, 0, 0, 1);
|
|
|
|
|
log.info("球机控制向下");
|
|
|
|
|
System.out.println("获取的垂直位置"+cameraPtzPojo.getWTiltPos());
|
|
|
|
|
if (origin == null) {
|
|
|
|
|
origin = cameraPtzPojo.getWTiltPos();
|
|
|
|
|
} else if (cameraPtzPojo.getWTiltPos() <= origin) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
CameraPtzPojo cameraPtzPojo = cameraControlModule.ptzGetDVRConfig(cameraId);
|
|
|
|
|
if (cameraPtzPojo.isGetSuccess()) {
|
|
|
|
|
cameraControlModule.ptzControlDownStart(cameraId, 0, 0, 1);
|
|
|
|
|
log.info("球机控制向下");
|
|
|
|
|
System.out.println("获取的垂直位置" + cameraPtzPojo.getWTiltPos());
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
//预设5秒回到原点位
|
|
|
|
|
Thread.sleep(5000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
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 boolean closeStreetLightSource( Integer streetId){
|
|
|
|
|
public boolean closeStreetLightSource(Integer streetId) {
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(streetId);
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.closeDO(equip,configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,configProperties.getLightSource().getNum(),configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
if (configProperties.getLightSource().getType() == 1) {
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(), lightSource.getPort());
|
|
|
|
|
JYDamHelper.closeDO(equip, configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip, configProperties.getLightSource().getNum(), configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}", lightSource.getIp(), status);
|
|
|
|
|
equip.DisConnect();
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
|
|
|
|
|
} else if (configProperties.getLightSource().getType() == 2) {
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(), lightSource.getPort(), configProperties.getLightSource().getIndex(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工单结束信息
|
|
|
|
|
* 判断有没有告警,有告警的不做处理
|
|
|
|
|
@ -249,17 +244,17 @@ public class PlcService {
|
|
|
|
|
update.setColumn2(plcCmdInfo.getColumn2());
|
|
|
|
|
update.setRow2(plcCmdInfo.getRow2());
|
|
|
|
|
LocalDateTime endDownLoadTime = endTime.plusSeconds(10);
|
|
|
|
|
Duration duration = Duration.between(order.getStartTime(),endDownLoadTime);
|
|
|
|
|
Duration duration = Duration.between(order.getStartTime(), endDownLoadTime);
|
|
|
|
|
|
|
|
|
|
if(duration.toMinutes() > 50){
|
|
|
|
|
if (duration.toMinutes() > 50) {
|
|
|
|
|
endDownLoadTime = order.getStartTime().plusMinutes(50);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera1Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera1Id(),order.getStartTime(),endDownLoadTime);
|
|
|
|
|
String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
|
update.setVideoPath1(path);
|
|
|
|
|
}
|
|
|
|
|
if (street.getCamera2Id() != null) {
|
|
|
|
|
String path = cameraVideo(street.getCamera2Id(),order.getStartTime(),endDownLoadTime);
|
|
|
|
|
String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime);
|
|
|
|
|
update.setVideoPath2(path);
|
|
|
|
|
}
|
|
|
|
|
orderMapper.updateById(update);
|
|
|
|
|
@ -281,12 +276,12 @@ 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();
|
|
|
|
|
@ -320,83 +315,83 @@ 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 (times == 2) {
|
|
|
|
|
|
|
|
|
|
if(street.getCamera2Id() != null){
|
|
|
|
|
gyrateCameraByCodeTimeLater(street.getCamera2Id(),"C5",configProperties.getCameraConfig().getC2OutDelayCaptureTime()+500);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -419,13 +414,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("cameraID: {} capture photo :{}", cameraId, path);
|
|
|
|
|
}
|
|
|
|
|
return path;
|
|
|
|
|
@ -441,17 +436,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);
|
|
|
|
|
@ -489,7 +484,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);
|
|
|
|
|
@ -528,11 +523,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);
|
|
|
|
|
@ -552,7 +547,7 @@ public class PlcService {
|
|
|
|
|
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")){
|
|
|
|
|
if (orderInfo.getCode().startsWith("C2") || orderInfo.getCode().startsWith("C4")) {
|
|
|
|
|
StockLog stockLog = new StockLog();
|
|
|
|
|
stockLog.setStreetId(orderInfo.getStreetId());
|
|
|
|
|
stockLog.setDirection(orderInfo.getLeftRight());
|
|
|
|
|
@ -560,7 +555,7 @@ public class PlcService {
|
|
|
|
|
stockLog.setRow(orderInfo.getRow());
|
|
|
|
|
stockLog.setColumn(orderInfo.getColumn());
|
|
|
|
|
stockLog.setPic(path);
|
|
|
|
|
String type = orderInfo.getCode().substring(1,2);
|
|
|
|
|
String type = orderInfo.getCode().substring(1, 2);
|
|
|
|
|
stockLog.setType(Integer.valueOf(type));
|
|
|
|
|
stockLog.setOrderNum(orderInfo.getOrderNum());
|
|
|
|
|
stockLog.setCreateTime(LocalDateTime.now());
|
|
|
|
|
@ -601,16 +596,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) {
|
|
|
|
|
@ -622,13 +617,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 {
|
|
|
|
|
@ -643,28 +638,28 @@ public class PlcService {
|
|
|
|
|
@Resource
|
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
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);
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(), lightSource.getPort(), configProperties.getLightSource().getIndex(), 1);
|
|
|
|
|
});
|
|
|
|
|
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
|
|
|
|
|
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){
|
|
|
|
|
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) {
|
|
|
|
|
//内测
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) ;
|
|
|
|
|
log.info("camera ptz"+c);
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1);
|
|
|
|
|
log.info("camera ptz" + c);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, c);
|
|
|
|
|
}else {
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) ;
|
|
|
|
|
log.info("camera ptz"+cmdCode);
|
|
|
|
|
} else {
|
|
|
|
|
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1);
|
|
|
|
|
log.info("camera ptz" + cmdCode);
|
|
|
|
|
gyrateCameraByCode(cameraIdTop, cmdCode);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
|
|
|
|
|
@ -674,7 +669,7 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
|
|
|
|
|
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
|
|
|
|
|
//拍照暂停1s再拍
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
|
|
|
|
|
@ -685,8 +680,8 @@ public class PlcService {
|
|
|
|
|
cameraCapture(cameraIdTop, false, null, path);
|
|
|
|
|
|
|
|
|
|
//成都蜜雪冰城 只拍照人工核对
|
|
|
|
|
String e2 = "E2-" + plcCmdInfo.getLeftRightStr(1) + "-TOP";
|
|
|
|
|
log.info("camera ptz"+e2);
|
|
|
|
|
String e2 = "E2-" + plcCmdInfo.getLeftRightStr(1) + "-TOP";
|
|
|
|
|
log.info("camera ptz" + e2);
|
|
|
|
|
gyrateCameraByCode(cameraId, e2);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -694,21 +689,21 @@ public class PlcService {
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
cameraCapture(cameraId,false,null,path+".jpg");
|
|
|
|
|
cameraCapture(cameraId, false, null, path + ".jpg");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(configProperties.getCameraConfig().getEDelayCaptureTime());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("camera capture error:{}",e.getMessage());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("camera capture error:{}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(),orderInfo.getLeftRight(),orderInfo.getSeparation(),orderInfo.getRow(),orderInfo.getColumn());
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
|
|
|
|
|
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), orderInfo.getLeftRight(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
|
|
|
|
|
//核对异常
|
|
|
|
|
if(stock == null){
|
|
|
|
|
if (stock == null) {
|
|
|
|
|
/* stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum()
|
|
|
|
|
,"", null,null,wmsCode,wmsCatagary,null,
|
|
|
|
|
wmsTrayCode,"",orderInfo.getStreetId(),
|
|
|
|
|
@ -738,7 +733,7 @@ public class PlcService {
|
|
|
|
|
.build();
|
|
|
|
|
stockMapper.insert(stock);
|
|
|
|
|
log.info("stockmapper insert new stock info.");
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
stock.setStatus(0);
|
|
|
|
|
stock.setLotnum(plcCmdInfo.getLotnum());
|
|
|
|
|
stock.setExportTime(LocalDateTime.now());
|
|
|
|
|
@ -764,10 +759,11 @@ public class PlcService {
|
|
|
|
|
// threadPoolExecutor.execute(stockCheckRunnable);
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
long s = end - startTime;
|
|
|
|
|
log.info("time:{}millisecond",s);
|
|
|
|
|
log.info("time:{}millisecond", s);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public void checkLog(Stock stock){
|
|
|
|
|
|
|
|
|
|
public void checkLog(Stock stock) {
|
|
|
|
|
CheckLog checkLog = new CheckLog();
|
|
|
|
|
checkLog.setCheckNum(stock.getCheckNum());
|
|
|
|
|
checkLog.setPic(stock.getCheckPic());
|
|
|
|
|
@ -776,6 +772,7 @@ public class PlcService {
|
|
|
|
|
checkLog.setSide(stock.getSide());
|
|
|
|
|
checkLog.setSubtag(stock.getSubtag());
|
|
|
|
|
checkLog.setCode(stock.getCode());
|
|
|
|
|
checkLog.setTaskId(stock.getTaskWMSId());
|
|
|
|
|
checkLog.setWmsCode(stock.getWmsCode());
|
|
|
|
|
checkLog.setStatus(stock.getStatus());
|
|
|
|
|
checkLog.setRow(stock.getRow());
|
|
|
|
|
@ -788,16 +785,17 @@ public class PlcService {
|
|
|
|
|
checkLogMapper.insert(checkLog);
|
|
|
|
|
log.info("checklogmapper insert new checklog info finished.");
|
|
|
|
|
}
|
|
|
|
|
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(),1);
|
|
|
|
|
if (rfid != null) {
|
|
|
|
|
RFIDStart(rfid.getIp(), rfid.getPort(), street.getId(), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -821,7 +819,8 @@ public class PlcService {
|
|
|
|
|
}
|
|
|
|
|
return tags;
|
|
|
|
|
}
|
|
|
|
|
public ConfigProperties getConfigProperties(){
|
|
|
|
|
|
|
|
|
|
public ConfigProperties getConfigProperties() {
|
|
|
|
|
return configProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|