光源修改

玉溪
LAPTOP-S9HJSOEB\昊天 2 months ago
parent ae8065f611
commit 6f4b9ebc39

File diff suppressed because it is too large Load Diff

@ -20,6 +20,8 @@ import cn.iocoder.yudao.module.camera.dal.entity.echarts.EChartsOption;
import cn.iocoder.yudao.module.camera.service.checklog.CheckLogService;
import cn.iocoder.yudao.module.camera.service.plc.PLCServiceImpl;
import cn.iocoder.yudao.module.camera.service.resources.URLResourcesService;
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.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
@ -30,6 +32,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -47,6 +50,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@RestController
@RequestMapping("/logistics/stock")
@Validated
@Slf4j
public class StockController {
@Resource
@ -127,8 +131,44 @@ public class StockController {
@Resource
CheckLogService checkLogService;
@Resource
private ScanServiceFactory scanServiceFactory;
@Resource
private SensorGunService sensorService ;
//
// @PostMapping("/getStreetStatus")
// @Operation(summary = "获得巷道所有盘点状态")
// //@Parameter(name = "id", description = "巷道id", required = true, example = "1024")
// @PreAuthorize("@ss.hasPermission('logistics:stock:getStreetList')")
// public CommonResult<List<ScanDateReqs>> scan(@RequestBody ScanData scanData) {
// cn.iocoder.yudao.module.camera.dal.dataobject.sensorgun.SensorGunDO sensorGun = sensorService.getOne(new QueryWrapper<cn.iocoder.yudao.module.camera.dal.dataobject.sensorgun.SensorGunDO>()
// .eq("street_id", scanData.getId())
// .eq("direction", scanData.getDirection()));
//
// String trayCode = "";
// if (sensorGun == null) {
// log.error("no sensor gun config in database ,street id:{},direction:{}", scanData.getId(), scanData.getDirection());
// } else {
// Map<String, String> photos = getStart(sensorGun.getIp());
// if(photos.get("code") != null){
// photos.put("code",photos.get("code").replaceAll("^0+", ""));
// }
//
//
// scanData.setCode(photos.get("code"));
//
//
// String path = "http://" + dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic/"+ photos.get("url");
// urlResourcesService.save(URLResourcesDo.builder().url(path).uuid(stockDO.getCheckPic()).type("1").little("扫码枪").build());
//// trayCode = readOCR(sensorGun.getIp(), sensorGun.getPort());
// }
// return success(scanDataList);
// }
@Resource
URLResourcesService urlResourcesService;
@PostMapping("/getStockStatus")
@Operation(summary = "获得盘点状态")
//@Parameter(name = "id", description = "巷道id", required = true, example = "1024")

@ -173,7 +173,7 @@ public class StreetController {
LightFactory.LightController(lightSourceDO,1);
}
return success("开启全部光源");
return success("开启光源"+streetId);
}
@GetMapping("/lightSource/close/{streetId}")
@ -184,6 +184,6 @@ public class StreetController {
LightFactory.LightController(lightSourceDO,0);
}
return success("开启全部光源");
return success("close光源"+streetId);
}
}

@ -0,0 +1,4 @@
package cn.iocoder.yudao.module.camera.service.plc;
public class CodeExtractor {
}

@ -8,12 +8,14 @@ import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
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.LightSourceDO;
import cn.iocoder.yudao.module.camera.dal.dataobject.street.StreetDO;
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;
import cn.iocoder.yudao.module.camera.dal.mysql.sensorgun.SensorGunMapper;
import cn.iocoder.yudao.module.camera.dal.mysql.stocklog.StockLogMapper;
import cn.iocoder.yudao.module.camera.framework.light.LightFactory;
import cn.iocoder.yudao.module.camera.framework.netty.ksec.KsecDataInfo;
import cn.iocoder.yudao.module.camera.framework.netty.ksec.KsecInfo;
import cn.iocoder.yudao.module.camera.framework.netty.streetAlgorithm.executor.AlgorithmDelayTask;
@ -21,6 +23,7 @@ import cn.iocoder.yudao.module.camera.framework.netty.streetAlgorithm.executor.G
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.lightsource.LightSourceService;
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;
@ -183,6 +186,8 @@ public class PLCServiceImpl implements PLCService {
@Resource
ScanServiceFactory scanServiceFactory;
@Resource
LightSourceService lightSourceService;
ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
// 设置线程最大执行时间,单位为毫秒
@ -196,6 +201,8 @@ public class PLCServiceImpl implements PLCService {
//头部拍照
StreetDO street = streetService.getStreetByPlcId(dataInfo.getSRMNumber());
LightSourceDO lightSourceDO = lightSourceService.getOne(new QueryWrapper<LightSourceDO>().eq("street_id", street.getId()).last("limit 1"));
LightFactory.LightController(lightSourceDO,1);
// 获取记录
StockDO stock = stockService.getOne(
new QueryWrapper<StockDO>()
@ -316,6 +323,8 @@ public class PLCServiceImpl implements PLCService {
long end = System.currentTimeMillis();
long s = end - startTime;
log.info("time:{}millisecond", s);
LightFactory.LightController(lightSourceDO,0);
// //ocr识别
// AlgorithmDelayTask algorithmDelayTask = new AlgorithmDelayTask(dataInfo.getFromDirection(),street.getPlcId()
// ,dataInfo.getTaskId(),10000,code,"E1",dataInfo.getFromRow(),dataInfo.getFromColumn());
@ -329,6 +338,9 @@ public class PLCServiceImpl implements PLCService {
//头部拍照
StreetDO street = streetService.getStreetByPlcId(dataInfo.getSRMNumber());
LightSourceDO lightSourceDO = lightSourceService.getOne(new QueryWrapper<LightSourceDO>().eq("street_id", street.getId()).last("limit 1"));
LightFactory.LightController(lightSourceDO,1);
// 获取记录
StockDO stock = stockService.getOne(
new QueryWrapper<StockDO>()
@ -469,8 +481,10 @@ public class PLCServiceImpl implements PLCService {
algorithmDelayTask.setUuid(uuid);
getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
LightFactory.LightController(lightSourceDO,0);
}
public static String capitalize(String str) {
if (str == null || str.isEmpty()) {
return str;

@ -20,8 +20,7 @@ public class LightConstruct {
public void nettyClientInit(){
List<LightSourceDO> list = lightSourceService.list();
for(LightSourceDO lightSourceDO : list){
LightFactory.LightController(lightSourceDO,1);
LightFactory.LightController(lightSourceDO,0);
}
}
}

@ -1,20 +1,26 @@
package cn.iocoder.yudao.module.camera.service.scan;
import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
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.street.StreetDO;
import cn.iocoder.yudao.module.camera.dal.entity.ScanData;
import cn.iocoder.yudao.module.camera.framework.netty.ksec.KsecDataInfo;
import cn.iocoder.yudao.module.camera.service.resources.URLResourcesService;
import cn.iocoder.yudao.module.camera.service.sensorgun.SensorGunService;
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service("scanGunScanService")
@ -80,6 +86,10 @@ public class ScanGunScanServiceImpl implements ScanService{
byte[]bytes = startCmd.getBytes(StandardCharsets.UTF_8);
os.write(bytes);
}
@Resource
private URLResourcesService urlResourcesService;
@Resource
private DictDataService dictDataService;
private static String read(InputStream inStream) throws IOException {
BufferedReader bd = new BufferedReader(new InputStreamReader(inStream));
@ -88,14 +98,51 @@ public class ScanGunScanServiceImpl implements ScanService{
@Override
public ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
ScanData scanData = new ScanData();
SensorGunDO sensorGun = sensorService.getOne(new QueryWrapper<SensorGunDO>().eq("street_id", streetDO.getId()).eq("direction", dataInfo.getFromDirection()));
SensorGunDO sensorGun = sensorService.getOne(new QueryWrapper<SensorGunDO>()
.eq("street_id", streetDO.getId())
.eq("direction", dataInfo.getFromDirection()));
String trayCode = "";
if (sensorGun == null) {
log.error("no sensor gun config in database ,street id:{},direction:{}", streetDO.getId(), dataInfo.getFromDirection());
} else {
trayCode = readOCR(sensorGun.getIp(), sensorGun.getPort());
Map<String, String> photos = getStart(sensorGun.getIp());
if(photos.get("code") != null){
photos.put("code",photos.get("code").replaceAll("^0+", ""));
}
scanData.setCode(photos.get("code"));
String path = "http://" + dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic/"+ photos.get("url");
urlResourcesService.save(URLResourcesDo.builder().url(path).uuid(stockDO.getCheckPic()).type("1").little("扫码枪").build());
// trayCode = readOCR(sensorGun.getIp(), sensorGun.getPort());
}
scanData.setCode(trayCode);
return scanData;
}
@Resource
private RestTemplate restTemplate;
public Map<String, String> getStart(String ip) {
String url = String.format("http://127.0.0.1:9002/start?ip=%s", ip);
try {
// // 准备POST请求参数
// Map<String, Object> requestBody = new HashMap<>();
// requestBody.put("aisle", aisle);
// 发送POST请求并直接转换为Map
Map<String, String> response = restTemplate.getForObject(url, Map.class);
log.info("Received photo paths response: {}", response);
return response;
} catch (Exception e) {
// 处理异常
e.printStackTrace();
return new HashMap<>();
}
}
}

Loading…
Cancel
Save