|
|
|
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.camera.dal.dataobject.sensorgun.SensorGunDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.stock.StockDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.stocklog.StockLogDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.street.StreetDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.entity.KescEntity;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.entity.ScanData;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.mysql.checklog.CheckLogMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.mysql.order.OrderMapper;
|
|
|
|
|
@ -23,7 +22,9 @@ import cn.iocoder.yudao.module.camera.service.camera.CameraService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.cameraio.CameraIoService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.checklog.CheckLogService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.resources.URLResourcesService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.scan.ScanGunScanServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.scan.ScanServiceFactory;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.sensorgun.SensorGunService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.stock.StockService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.street.StreetService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.threeInOneCode.ScanningGun;
|
|
|
|
|
@ -33,7 +34,6 @@ import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.service.sse.SseClient;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import de.danielbechler.util.Strings;
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -163,52 +163,17 @@ public class PLCServiceImpl implements PLCService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void action(KsecDataInfo dataInfo) {
|
|
|
|
|
OrderDO order = orderMapper.selectOne(new LambdaQueryWrapper<OrderDO>()
|
|
|
|
|
.eq(OrderDO::getTaskId, dataInfo.getTaskId())
|
|
|
|
|
.orderByDesc(OrderDO::getCreateTime)
|
|
|
|
|
.last("limit 1"));
|
|
|
|
|
StreetDO street = streetService.getStreetByPlcId(dataInfo.getSRMNumber());
|
|
|
|
|
if (street == null) {
|
|
|
|
|
log.error("street not found ,plcId :{}", dataInfo.getSRMNumber());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, times, code);
|
|
|
|
|
//判断是否拍照
|
|
|
|
|
boolean needCapture = false;
|
|
|
|
|
String picCmd = dataInfo.getCmdName().substring(0, 2);
|
|
|
|
|
Integer direction = dataInfo.getFromDirection();
|
|
|
|
|
if (picCmd.equals("C4") || picCmd.equals("C3")) {
|
|
|
|
|
needCapture = true;
|
|
|
|
|
direction = dataInfo.getToDirection();
|
|
|
|
|
} else if (picCmd.equals("C1") || picCmd.equals("C2")) {
|
|
|
|
|
needCapture = true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KescEntity kescEntity = new KescEntity();
|
|
|
|
|
kescEntity.setData(dataInfo);
|
|
|
|
|
// 判断巷道有几个相机 如果只有一个,则调用一个,如果是两个,先判断是否有对拍设置决定那个相机拍摄
|
|
|
|
|
CameraDO camera = getCameraByLeftRight(street, direction);
|
|
|
|
|
// 调用预置点位
|
|
|
|
|
gyrateCameraByCode(camera, picCmd);
|
|
|
|
|
int time = Integer.parseInt(dictDataService.parseDictData("camera_conf", "delay_preset_time").getValue());
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(time);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
if (dataInfo.getCmdName().equals(dictDataService.parseDictData("base_conf", "order_start").getValue() )){
|
|
|
|
|
KsecInfo kescEntity = new KsecInfo();
|
|
|
|
|
kescEntity.setData(dataInfo);
|
|
|
|
|
orderStart(dataInfo);
|
|
|
|
|
}
|
|
|
|
|
if (needCapture) {
|
|
|
|
|
String pathSrc = PathUtil.createFileName(dataInfo, street, picCmd, ".jpg");
|
|
|
|
|
pathSrc = cameraCapture(camera, false, pathSrc, dictDataService.getDictDataList("camera_conf"));
|
|
|
|
|
|
|
|
|
|
order.setPics(Strings.hasText(order.getPics()) ? order.getPics() + ";" + pathSrc : pathSrc);
|
|
|
|
|
orderMapper.updateById(order);
|
|
|
|
|
if (dataInfo.getCmdName().equals(dictDataService.parseDictData("base_conf", "order_stop").getValue() )){
|
|
|
|
|
KsecInfo kescEntity = new KsecInfo();
|
|
|
|
|
kescEntity.setData(dataInfo);
|
|
|
|
|
orderStop(kescEntity);
|
|
|
|
|
}
|
|
|
|
|
//转向原点位
|
|
|
|
|
gyrateCameraByCode(camera, "C5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
@ -478,11 +443,11 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
String picPath = algorithmDelayTask.getSRMNumber() + "-" + algorithmDelayTask.getCmdName() + "-" + algorithmDelayTask.getDirection() + "-" + "up";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String pathSrc = street.getPlcIp() + ":9007/pic/" + dataInfo.getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
String pathSrc = "http://"+ dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+street.getPlcId()+"/" + dataInfo.getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
urlResourcesService.save(URLResourcesDo.builder().url(pathSrc).uuid(uuid).type("1").little("拍照").build());
|
|
|
|
|
algorithmDelayTask.setPath(pathSrc);
|
|
|
|
|
getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String capitalize(String str) {
|
|
|
|
|
if (str == null || str.isEmpty()) {
|
|
|
|
|
return str;
|
|
|
|
|
@ -543,7 +508,7 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
.row(ksecDataInfo.getFromRow())
|
|
|
|
|
.column(ksecDataInfo.getFromColumn())
|
|
|
|
|
.status("0")
|
|
|
|
|
.checkPic("http://" + streetDO.getPlcIp() + ":9007/pic/" + ksecDataInfo.getTaskId() + "_" + cameraType + ".JPEG;")
|
|
|
|
|
.checkPic("http://" + streetDO.getPlcIp() + ":9007/pic"+streetDO.getPlcId()+"/" + ksecDataInfo.getTaskId() + "_" + cameraType + ".JPEG;")
|
|
|
|
|
.exportTime(LocalDateTime.now()).build();
|
|
|
|
|
stockService.save(stockDO);
|
|
|
|
|
} else {
|
|
|
|
|
@ -579,14 +544,14 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void stockSave(AlgorithmDelayTask algorithmDelayTask) {
|
|
|
|
|
StockDO stockDO = stockService.getOne(new QueryWrapper<StockDO>().eq("task_Wms_Id", algorithmDelayTask.getTaskId()));
|
|
|
|
|
StockDO stockDO = stockService.getOne(new QueryWrapper<StockDO>().eq("task_Wms_Id", algorithmDelayTask.getTaskId()).last("limit 1"));
|
|
|
|
|
if (stockDO != null) {
|
|
|
|
|
stockDO.setCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
stockDO.setWmsCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
stockDO.setTrayCode(algorithmDelayTask.getTrayCode());
|
|
|
|
|
stockService.updateById(stockDO);
|
|
|
|
|
}
|
|
|
|
|
CheckLogDO checkLogDO = checkLogService.getOne(new QueryWrapper<CheckLogDO>().eq("task_Id", algorithmDelayTask.getTaskId()));
|
|
|
|
|
CheckLogDO checkLogDO = checkLogService.getOne(new QueryWrapper<CheckLogDO>().eq("task_Id", algorithmDelayTask.getTaskId()).last("limit 1"));
|
|
|
|
|
if (checkLogDO != null) {
|
|
|
|
|
|
|
|
|
|
checkLogDO.setTrayCode(algorithmDelayTask.getTrayCode());
|
|
|
|
|
@ -679,15 +644,19 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
*
|
|
|
|
|
* @param
|
|
|
|
|
*/
|
|
|
|
|
@Resource
|
|
|
|
|
SensorGunService sensorService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void orderStop(KsecInfo kescEntity) {
|
|
|
|
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
|
|
|
StreetDO street = streetService.getStreetByPlcId(kescEntity.getData().getSRMNumber());
|
|
|
|
|
if (street == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
OrderDO order = orderMapper.selectOne(new QueryWrapper<OrderDO>().eq("task_id", kescEntity.getData().getTaskId()));
|
|
|
|
|
OrderDO order = orderMapper.selectOne(new QueryWrapper<OrderDO>().eq("task_id", kescEntity.getData().getTaskId()).last(" limit 1"));
|
|
|
|
|
if (order == null) {
|
|
|
|
|
log.error("订单结束信号,订单不存在,orderNum:{}", kescEntity.getData().getTaskId());
|
|
|
|
|
return;
|
|
|
|
|
@ -711,7 +680,17 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
sensorGunCode = ScanningGun.readOCR(sensorGunDO.getIp(), sensorGunDO.getPort(), "start", time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScanData scanData = new ScanData();
|
|
|
|
|
SensorGunDO sensorGun = sensorService.getOne(new QueryWrapper<SensorGunDO>()
|
|
|
|
|
.eq("street_id", street.getId())
|
|
|
|
|
.eq("direction", kescEntity.getData().getToDirection()));
|
|
|
|
|
String trayCode = "";
|
|
|
|
|
if (sensorGun == null) {
|
|
|
|
|
log.error("no sensor gun config in database ,street id:{},direction:{}", street.getId(), kescEntity.getData().getToDirection());
|
|
|
|
|
} else {
|
|
|
|
|
trayCode = ScanGunScanServiceImpl.readOCR(sensorGun.getIp(), sensorGun.getPort());
|
|
|
|
|
}
|
|
|
|
|
scanData.setCode(trayCode);
|
|
|
|
|
//拍照i
|
|
|
|
|
//CheckIntellBlinkChanel.pictures(street.getPlcId(), kescEntity.getData().getTaskId(),cameraType,dictDataService.parseDictData("camera_position", cameraType).getValue());
|
|
|
|
|
|
|
|
|
|
@ -721,10 +700,13 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
String picPath = algorithmDelayTask.getSRMNumber() + "-" + algorithmDelayTask.getCmdName() + "-" + algorithmDelayTask.getDirection() + "-" + "up";
|
|
|
|
|
KsecDataInfo ksecDataInfo = KsecDataInfo.toFrom(kescEntity.getData());
|
|
|
|
|
stockSave(ksecDataInfo, street, sensorGunCode);
|
|
|
|
|
String path = "http://" + dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+street.getPlcId()+"/"+ kescEntity.getData().getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
algorithmDelayTask.setPath(path);
|
|
|
|
|
getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
|
|
|
|
|
|
|
|
|
|
urlResourcesService.save(URLResourcesDo.builder().url(path).uuid(uuid).type("1").little("球机拍照").build());
|
|
|
|
|
|
|
|
|
|
order.setPics(order.getPics() == null ? "" : order.getPics() + "http://" + street.getPlcIp() + ":9007/pic/" + kescEntity.getData().getTaskId() + "_" + picPath + ".JPEG;");
|
|
|
|
|
order.setPics(order.getPics() == null ? path : order.getPics() + path+ ";");
|
|
|
|
|
orderMapper.updateById(order);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|