修改查找逻辑
parent
d45d6f8bfe
commit
dcd7f260ef
@ -1,93 +0,0 @@
|
||||
package cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo.CameraIoConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo.CameraIoConfigRespVO;
|
||||
import cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo.CameraIoConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.cameraioconfig.CameraIoConfigDO;
|
||||
import cn.iocoder.yudao.module.camera.service.cameraioconfig.CameraIoConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 预置点位配置")
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/camera-io-config")
|
||||
@Validated
|
||||
public class CameraIoConfigController {
|
||||
|
||||
@Resource
|
||||
private CameraIoConfigService cameraIoConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建预置点位配置")
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:create')")
|
||||
public CommonResult<Integer> createCameraIoConfig(@Valid @RequestBody CameraIoConfigSaveReqVO createReqVO) {
|
||||
return success(cameraIoConfigService.createCameraIoConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新预置点位配置")
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:update')")
|
||||
public CommonResult<Boolean> updateCameraIoConfig(@Valid @RequestBody CameraIoConfigSaveReqVO updateReqVO) {
|
||||
cameraIoConfigService.updateCameraIoConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除预置点位配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:delete')")
|
||||
public CommonResult<Boolean> deleteCameraIoConfig(@RequestParam("id") Integer id) {
|
||||
cameraIoConfigService.deleteCameraIoConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得预置点位配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:query')")
|
||||
public CommonResult<CameraIoConfigRespVO> getCameraIoConfig(@RequestParam("id") Integer id) {
|
||||
CameraIoConfigDO cameraIoConfig = cameraIoConfigService.getCameraIoConfig(id);
|
||||
return success(BeanUtils.toBean(cameraIoConfig, CameraIoConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得预置点位配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:query')")
|
||||
public CommonResult<PageResult<CameraIoConfigRespVO>> getCameraIoConfigPage(@Valid CameraIoConfigPageReqVO pageReqVO) {
|
||||
PageResult<CameraIoConfigDO> pageResult = cameraIoConfigService.getCameraIoConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CameraIoConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出预置点位配置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('logistics:camera-io-config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportCameraIoConfigExcel(@Valid CameraIoConfigPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<CameraIoConfigDO> list = cameraIoConfigService.getCameraIoConfigPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "预置点位配置.xls", "数据", CameraIoConfigRespVO.class,
|
||||
BeanUtils.toBean(list, CameraIoConfigRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
@Schema(description = "管理后台 - 预置点位配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CameraIoConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "预置点位code")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "预置点位名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 预置点位配置 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CameraIoConfigRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6144")
|
||||
@ExcelProperty("id")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "预置点位code")
|
||||
@ExcelProperty("预置点位code")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "预置点位名称", example = "赵六")
|
||||
@ExcelProperty("预置点位名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.camera.controller.admin.cameraioconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "管理后台 - 预置点位配置新增/修改 Request VO")
|
||||
@Data
|
||||
public class CameraIoConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6144")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "预置点位code")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "预置点位名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package ScanCodeType;
|
||||
|
||||
public enum ScanCodeType {
|
||||
SCANNING_GUN("1","scanning_gun"),
|
||||
SCANNING_RFID("2","scanning_rfid"),
|
||||
SCANNING_YOLO("3","scanning_yolo"),
|
||||
SCANNING_PCD("4","scanning_pcd");
|
||||
private String code;
|
||||
private String desc;
|
||||
ScanCodeType(String code,String desc){
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.camera.dal.dataobject.resources;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import org.glassfish.jaxb.core.v2.TODO;
|
||||
|
||||
/**
|
||||
* 相机 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("logistics_url_resources")
|
||||
@KeySequence("logistics_camera_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class URLResourcesDo extends BaseDO {
|
||||
/*
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 类型
|
||||
*
|
||||
* 枚举 {@link TODO camera_type 对应的类}
|
||||
*/
|
||||
private String uuid;
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private String little;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.camera.dal.entity;
|
||||
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.stock.StockDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ScanData extends StockDO {
|
||||
private Long id;
|
||||
private LocalDateTime createTime;
|
||||
private Integer stockId;
|
||||
private Integer checkLogId;
|
||||
private String code;
|
||||
private String trayCode;
|
||||
|
||||
private Integer direction;
|
||||
private String ip;
|
||||
private Integer port;
|
||||
private String statusString;
|
||||
private String colour;
|
||||
private DictDataDO dictDataDO;
|
||||
|
||||
private String uuid;
|
||||
private String statusVisionString;
|
||||
private List<ScanStatus> scan;
|
||||
private List<URLResourcesDo> images;
|
||||
|
||||
// Getters and Setters (if needed)
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.camera.dal.entity;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScanStatus extends DictDataDO {
|
||||
private String code;
|
||||
|
||||
private String title;
|
||||
private Integer status;
|
||||
private String wmsCode;
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.yudao.module.camera.dal.mysql.resources;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface URLResourcesMapper extends BaseMapperX<URLResourcesDo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.camera.service.plc;import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class AsyncExample {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
|
||||
// 启动异步任务1
|
||||
CompletableFuture<Void> future1 = CompletableFuture.runAsync(() -> {
|
||||
// 任务1逻辑
|
||||
method1();
|
||||
}).thenRun(() -> {
|
||||
// 任务1完成后的操作
|
||||
System.out.println("Method 1 has completed, now performing next operation.");
|
||||
});
|
||||
|
||||
// 启动异步任务2
|
||||
CompletableFuture<Void> future2 = CompletableFuture.runAsync(() -> {
|
||||
// 任务2逻辑
|
||||
method2();
|
||||
}).thenRun(() -> {
|
||||
// 任务2完成后的操作
|
||||
System.out.println("Method 2 has completed, now performing next operation.");
|
||||
});
|
||||
|
||||
// 启动异步任务3
|
||||
CompletableFuture<Void> future3 = CompletableFuture.runAsync(() -> {
|
||||
// 任务3逻辑
|
||||
method3();
|
||||
}).thenRun(() -> {
|
||||
// 任务3完成后的操作
|
||||
System.out.println("Method 3 has completed, now performing next operation.");
|
||||
});
|
||||
|
||||
// 等待所有任务完成
|
||||
CompletableFuture.allOf(future1, future2, future3).join();
|
||||
}
|
||||
|
||||
private static void method1() {
|
||||
try {
|
||||
Thread.sleep(3000); // 模拟延迟
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Executing method 1.");
|
||||
}
|
||||
|
||||
private static void method2() {
|
||||
try {
|
||||
Thread.sleep(1500); // 模拟延迟
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Executing method 2.");
|
||||
}
|
||||
|
||||
private static void method3() {
|
||||
try {
|
||||
Thread.sleep(2000); // 模拟延迟
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Executing method 3.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package cn.iocoder.yudao.module.camera.service.resources;
|
||||
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface URLResourcesService extends IService<URLResourcesDo> {
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.iocoder.yudao.module.camera.service.resources;
|
||||
|
||||
import cn.iocoder.yudao.module.camera.dal.dataobject.resources.URLResourcesDo;
|
||||
import cn.iocoder.yudao.module.camera.dal.mysql.resources.URLResourcesMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class URLResourcesServiceImpl extends ServiceImpl<URLResourcesMapper, URLResourcesDo> implements URLResourcesService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.module.camera.service.rfid;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* sick扫码枪
|
||||
*/
|
||||
@Slf4j
|
||||
public class RFIDSocket {
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
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.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 jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Slf4j
|
||||
@Service("opencvService")
|
||||
public class OpencvServiceImpl implements ScanService {
|
||||
@Resource
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@Resource
|
||||
URLResourcesService urlResourcesService;
|
||||
|
||||
@Override
|
||||
public ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
//
|
||||
ScanData scanData = new ScanData();
|
||||
scanData.setCode(dataInfo.getCategory());
|
||||
scanData.setIp(streetDO.getPlcIp());
|
||||
scanData.setPort(streetDO.getPlcPort());
|
||||
scanData.setUuid(stockDO.getCheckPic());
|
||||
scanData.setDirection(dataInfo.getFromDirection());
|
||||
HttpEntity<ScanData> request = new HttpEntity<>(scanData, headers);
|
||||
String url = "http://" + streetDO.getPlcIp() + ":" + streetDO.getPlcPort() + "/match/match2D";
|
||||
scanData = restTemplate.postForObject(url, request, ScanData.class);
|
||||
if (scanData != null && scanData.getImages() != null) {
|
||||
for (URLResourcesDo image:scanData.getImages()){
|
||||
urlResourcesService.save(image);
|
||||
}
|
||||
}
|
||||
return scanData;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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 jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Slf4j
|
||||
@Service("pcdService")
|
||||
public class PCDServiceImpl implements ScanService{
|
||||
|
||||
@Resource
|
||||
RestTemplate restTemplate;
|
||||
@Override
|
||||
public ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
//
|
||||
ScanData scanData = new ScanData();
|
||||
scanData.setCode(dataInfo.getCategory());
|
||||
scanData.setIp(streetDO.getPlcIp());
|
||||
scanData.setPort(streetDO.getPlcPort());
|
||||
scanData.setUuid(stockDO.getCheckPic());
|
||||
scanData.setDirection(dataInfo.getFromDirection());
|
||||
HttpEntity<ScanData> request = new HttpEntity<>(scanData, headers);
|
||||
String url = "http://"+streetDO.getPlcIp()+":"+streetDO.getPlcPort()+"/match/match3D";
|
||||
|
||||
return restTemplate.postForObject(url, request, ScanData.class);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
@Service("rfidScanService")
|
||||
public class RFIDScanServiceImpl implements ScanService{
|
||||
@Override
|
||||
public ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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.sensorgun.SensorGunService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Slf4j
|
||||
@Service("scanGunScanService")
|
||||
public class ScanGunScanServiceImpl implements ScanService{
|
||||
@Resource
|
||||
private SensorGunService sensorService;
|
||||
|
||||
public static String readOCR(String ip,int port){
|
||||
Socket socket = new Socket();
|
||||
String code = "NoRead";
|
||||
OutputStream os = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(ip,port),3000);
|
||||
os = socket.getOutputStream();
|
||||
is = socket.getInputStream();
|
||||
int i = 0;
|
||||
while ("NoRead".equals(code) && i <= 4){
|
||||
writeCmd(os);
|
||||
code = read(is);
|
||||
log.info("count:{},ip:{},code:{}",i,ip,code);
|
||||
if(code!= null){
|
||||
code = code.replace("\\n","");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("sick time out,ip:{},info:{}",ip,e);
|
||||
}finally
|
||||
{
|
||||
if(os != null){
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(is != null){
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeCmd(OutputStream os) throws IOException {
|
||||
String startCmd = "start";
|
||||
byte[]bytes = startCmd.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(bytes);
|
||||
}
|
||||
|
||||
private static String read(InputStream inStream) throws IOException {
|
||||
BufferedReader bd = new BufferedReader(new InputStreamReader(inStream));
|
||||
return bd.readLine();
|
||||
}
|
||||
@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()));
|
||||
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());
|
||||
}
|
||||
scanData.setCode(trayCode);
|
||||
return scanData;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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;
|
||||
|
||||
public interface ScanService {
|
||||
ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO);
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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 jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ScanServiceFactory {
|
||||
@Resource
|
||||
private PCDServiceImpl pcdService;
|
||||
@Resource
|
||||
private ScanGunScanServiceImpl scanGunScanService;
|
||||
@Resource
|
||||
private RFIDScanServiceImpl rfidScanService;
|
||||
@Resource
|
||||
private YoloServiceImpl yoloService;
|
||||
@Resource
|
||||
private OpencvServiceImpl opencvService;
|
||||
|
||||
|
||||
|
||||
public ScanData scan(String type, StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
|
||||
|
||||
switch (type) {
|
||||
case "0":
|
||||
return null;
|
||||
// 扫码枪扫码
|
||||
case "1":
|
||||
return scanGunScanService.scan(streetDO, dataInfo, stockDO);
|
||||
// RFID扫码
|
||||
case "2":
|
||||
return rfidScanService.scan(streetDO, dataInfo, stockDO);
|
||||
// 视觉扫码
|
||||
case "3":
|
||||
return yoloService.scan(streetDO, dataInfo, stockDO);
|
||||
|
||||
// 3D扫码
|
||||
case "4":
|
||||
return pcdService.scan(streetDO, dataInfo, stockDO);
|
||||
|
||||
// opencv扫码
|
||||
case "5":
|
||||
return opencvService.scan(streetDO, dataInfo, stockDO);
|
||||
|
||||
// 默认情况处理
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.camera.service.scan;
|
||||
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
@Service("yoloService")
|
||||
public class YoloServiceImpl implements ScanService{
|
||||
@Override
|
||||
public ScanData scan(StreetDO streetDO, KsecDataInfo dataInfo, StockDO stockDO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue