相机如果报错,则返回识别失败

湖北-大华摄像头
LAPTOP-S9HJSOEB\昊天 1 year ago
parent 4cde4aa90d
commit 6e12cb63e2

@ -1,10 +1,12 @@
package com.zhehekeji.web.controller; package com.zhehekeji.web.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zhehekeji.common.util.ValidatorUtil; import com.zhehekeji.common.util.ValidatorUtil;
import com.zhehekeji.core.pojo.Result; import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.entity.Stock; import com.zhehekeji.web.entity.Stock;
import com.zhehekeji.web.mapper.StockMapper;
import com.zhehekeji.web.pojo.category.PageSearch; import com.zhehekeji.web.pojo.category.PageSearch;
import com.zhehekeji.web.pojo.stock.*; import com.zhehekeji.web.pojo.stock.*;
import com.zhehekeji.web.service.StockService; import com.zhehekeji.web.service.StockService;
@ -34,6 +36,8 @@ public class StockController {
private StockService stockService; private StockService stockService;
@Resource @Resource
private ValidatorUtil validatorUtil; private ValidatorUtil validatorUtil;
@Resource
StockMapper stockMapper;
@PostMapping("/import") @PostMapping("/import")
@ApiOperation(value = "库存导入") @ApiOperation(value = "库存导入")
@ -153,6 +157,15 @@ public class StockController {
stockService.allStockCheck(); stockService.allStockCheck();
return Result.success(); return Result.success();
} }
@ApiOperation(value = "全部盘点")
@RequestMapping(value = "/truncateStockCheck", method = RequestMethod.POST)
public Result truncateStockCheck(String lotnum) {
if (stockMapper.selectList(new QueryWrapper<Stock>().eq("lotnum",lotnum)).size()==0){
stockMapper.truncate();
}
return null;
}
@ApiOperation(value = "清空盘点") @ApiOperation(value = "清空盘点")

@ -300,7 +300,9 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
HCNetSDK.NET_DVR_JPEGPARA jpegpara = new HCNetSDK.NET_DVR_JPEGPARA(wPicSize, wPicQuality); HCNetSDK.NET_DVR_JPEGPARA jpegpara = new HCNetSDK.NET_DVR_JPEGPARA(wPicSize, wPicQuality);
boolean picResult = HikLoginModuleImpl.hcNetsdk.NET_DVR_CaptureJPEGPicture(lUserId, 1, jpegpara, path); boolean picResult = HikLoginModuleImpl.hcNetsdk.NET_DVR_CaptureJPEGPicture(lUserId, 1, jpegpara, path);
if (!picResult) { if (!picResult) {
int i =HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError();
log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId); log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId);
} }
return picResult; return picResult;

@ -85,7 +85,7 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
m_strLoginInfo.wPort = (short) m_nPort; m_strLoginInfo.wPort = (short) m_nPort;
m_strLoginInfo.bUseAsynLogin = true; //是否异步登录0- 否1- 是 m_strLoginInfo.bUseAsynLogin = false; //是否异步登录0- 否1- 是
m_strLoginInfo.write(); m_strLoginInfo.write();
HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30();//设备信息 HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30();//设备信息

@ -16,9 +16,9 @@ public class StockExportExcel {
@ExcelProperty(index = 5, value = "条码") @ExcelProperty(index = 5, value = "条码")
private String code; private String code;
//
@ExcelProperty(index = 8, value = "WMS条码") // @ExcelProperty(index = 8, value = "WMS条码")
private String wmsCode; // private String wmsCode;
@ExcelProperty(index = 1, value = "左右,1:左侧,2:右侧") @ExcelProperty(index = 1, value = "左右,1:左侧,2:右侧")
private Integer direction; private Integer direction;
@ -45,7 +45,7 @@ public class StockExportExcel {
@ExcelProperty(index = 7, value = "盘点结果", converter = StockStatusConvert.class) @ExcelProperty(index = 7, value = "盘点结果", converter = StockStatusConvert.class)
private Integer status; private Integer status;
@ExcelProperty(index = 9, value = "时间", converter = LocalDateTimeConvert.class) @ExcelProperty(index = 8, value = "时间", converter = LocalDateTimeConvert.class)
private LocalDateTime exportTime; private LocalDateTime exportTime;
} }

@ -29,6 +29,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.time.*; import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -63,7 +64,7 @@ public class CronTab {
private static int gByte = 1024* 1024 * 1024; private static int gByte = 1024* 1024 * 1024;
@Scheduled(cron = "0 0 0 * * ?") @Scheduled(cron = "0 10 0 * * ?")
//@Scheduled(cron = "0 0/1 * * * *") //@Scheduled(cron = "0 0/1 * * * *")
public void file() { public void file() {
log.info(" corn delete file"); log.info(" corn delete file");
@ -74,9 +75,9 @@ public class CronTab {
if(space > 150){ if(space > 150){
return; return;
} }
checkFileTime(dir,configProperties.getDeleteFileDays()); deleteOldFiles(dir,configProperties.getDeleteFileDays());
File dir2 = new File(configProperties.getSavePath().getMp4Path()); File dir2 = new File(configProperties.getSavePath().getMp4Path());
checkFileTime(dir2,configProperties.getDeleteFileDays()); deleteOldFiles(dir2,configProperties.getDeleteFileDays());
} }
public static void putTime(Integer streetId){ public static void putTime(Integer streetId){
@ -156,7 +157,10 @@ public class CronTab {
e.printStackTrace(); e.printStackTrace();
} }
// 创建时间 // 创建时间
Instant instant = attr.creationTime().toInstant(); Instant instant = null;
if (attr != null) {
instant = attr.creationTime().toInstant();
}
LocalDateTime createTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); LocalDateTime createTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
Duration duration = Duration.between(createTime,now); Duration duration = Duration.between(createTime,now);
if(days<=duration.toDays()){ if(days<=duration.toDays()){
@ -166,4 +170,38 @@ public class CronTab {
} }
} }
public static void deleteOldFiles( File folder,int days) {
if (!folder.exists() || !folder.isDirectory()) {
System.out.println("指定的路径不是一个有效的文件夹: " + folder.getName());
return;
}
LocalDateTime now = LocalDateTime.now();
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteOldFiles( file,days);
if (file.listFiles().length == 0) {
file.delete();
}
} else {
long fileAge = 0;
try {
fileAge = ChronoUnit.DAYS.between(
LocalDateTime.ofInstant(Files.getLastModifiedTime(file.toPath()).toInstant(), ZoneId.systemDefault()),
now
);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (fileAge > days) {
file.delete();
}
}
}
}
}
} }

@ -41,6 +41,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque; import java.util.concurrent.BlockingDeque;
@ -347,7 +348,7 @@ public class PlcService {
* camera2 * camera2
* *
*/ */
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,orderInfo.getLeftRight()); Integer cameraId = getCameraByPlcCmd(plcCmdInfo,orderInfo.getLeftRight() == 1 ? 2 : 1);
gyrateCameraByCode(cameraId,orderInfo.getCmdCode()); gyrateCameraByCode(cameraId,orderInfo.getCmdCode());
if(needCapture){ if(needCapture){
Boolean delay = true; Boolean delay = true;
@ -655,11 +656,42 @@ public class PlcService {
lightSourceService.controllerLightSource(lightSource,1); lightSourceService.controllerLightSource(lightSource,1);
}); });
boolean picBolean = true;
//南通通威拍摄货物顶部时按列号的单双来判断单数左侧 //南通通威拍摄货物顶部时按列号的单双来判断单数左侧
//Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getColumn1()%2==1?1:2); //Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getColumn1()%2==1?1:2);
//对侧拍摄二维码 //对侧拍摄二维码
Integer cameraIdQt = getCameraByPlcCmd(plcCmdInfo, plcCmdInfo.getLeftRight1() == 1 ? 2 : 1); Integer cameraIdQt = getCameraByPlcCmd(plcCmdInfo, plcCmdInfo.getLeftRight1() == 1 ? 2 : 1);
gyrateCameraByCode(cameraIdQt, "E1"); try {
gyrateCameraByCode(cameraIdQt, "C5");
log.info("cameraID: {} ", cameraIdQt);
//球机归正
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
cameraControlModule.ptzControlDownStart(cameraIdQt,0,0,1);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
cameraControlModule.ptzControlDownEnd(cameraIdQt,0);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
gyrateCameraByCode(cameraIdQt, "E1");
}catch (Exception e){
log.error("cameraID: {} capture error toptz:", cameraIdQt);
picBolean = false;
}
//球机拍照 //球机拍照
try { try {
Thread.sleep(4000); Thread.sleep(4000);
@ -669,10 +701,21 @@ public class PlcService {
String path = PathUtil.createFileNameByRowColumn("jpg",cameraIdQt,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1()); String path = PathUtil.createFileNameByRowColumn("jpg",cameraIdQt,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
//拍照识别一维码后,保存图片 //拍照识别一维码后,保存图片
//String code = blinkGetCode(cameraIdQt,path); //String code = blinkGetCode(cameraIdQt,path);
cameraCapture(cameraIdQt,false,null,path); // cameraCapture(cameraIdQt,false,null,path);
String realPath = configProperties.getSavePath().getMediaPath() + path;
try {
picBolean = cameraControlModule.pic(cameraIdQt, 0, realPath);
log.info("cameraID: {} capture photo :{}", cameraIdQt, path);
}catch (Exception e){
log.error("cameraID: {} capture error photo :{}\", cameraIdQt, path");
picBolean = false;
}
String code = wmsCode; String code = wmsCode;
if (!simulateQRCodeScan( configProperties.getCameraConfig().getIdentificationProbability())){ if (!picBolean || !simulateQRCodeScan( configProperties.getCameraConfig().getIdentificationProbability())){
// if (!picBolean){
code = ""; code = "";
} }
try { try {
Thread.sleep(generateRandomNumber(5000,configProperties.getCameraConfig().getMaximumRecognitionTime())); Thread.sleep(generateRandomNumber(5000,configProperties.getCameraConfig().getMaximumRecognitionTime()));
@ -680,6 +723,27 @@ public class PlcService {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode); OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
Stock stockOld = stockMapper.selectOne(new QueryWrapper<Stock>().orderByDesc("export_time").last("limit 1"));
LocalDateTime dateTime2 = LocalDateTime.now();
if(stockOld != null){
LocalDateTime dateTime1 = stockOld.getExportTime();
Duration duration = Duration.between(dateTime1, dateTime2);
long hours = duration.toHours();
if (hours > 6) {
plcCmdInfo.setLotnum(dateTime2.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
} else {
plcCmdInfo.setLotnum(stockOld.getLotnum());
}
}else {
plcCmdInfo.setLotnum(dateTime2.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
}
if (stockMapper.selectList(new QueryWrapper<Stock>().eq("lotnum",plcCmdInfo.getLotnum())).size()==0){
truncateStock();
}
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(),orderInfo.getLeftRight(),orderInfo.getSeparation(),orderInfo.getRow(),orderInfo.getColumn()); Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(),orderInfo.getLeftRight(),orderInfo.getSeparation(),orderInfo.getRow(),orderInfo.getColumn());
//核对异常 //核对异常
int codeIsRight = !"".equals(code)?2:1; int codeIsRight = !"".equals(code)?2:1;
@ -739,7 +803,7 @@ public class PlcService {
log.info("time:{}millisecond",s); log.info("time:{}millisecond",s);
return true; return codeIsRight==2;
} }
/** /**
* *
@ -775,11 +839,12 @@ public class PlcService {
} }
public static void main(String[] args) { public static void main(String[] args) {
int c = 0; LocalDateTime dateTime1 = LocalDateTime.now();
for (int i = 0; i < 5000; i++){
if (!simulateQRCodeScan(0.95)) Duration duration = Duration.between(LocalDateTime.now(), dateTime1);
System.out.println(c++);
} long hours = duration.toHours();
System.out.println(hours);
} }
/** /**

@ -17,6 +17,9 @@ import com.zhehekeji.web.mapper.StockMapper;
import com.zhehekeji.web.mapper.StreetMapper; import com.zhehekeji.web.mapper.StreetMapper;
import com.zhehekeji.web.pojo.category.PageSearch; import com.zhehekeji.web.pojo.category.PageSearch;
import com.zhehekeji.web.pojo.stock.*; import com.zhehekeji.web.pojo.stock.*;
import com.zhehekeji.web.service.ksec.KsecDataInfo;
import com.zhehekeji.web.service.ksec.KsecInfo;
import com.zhehekeji.web.service.ksec.KsecNettyClient;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -340,21 +343,46 @@ public class StockService {
Street street = streetService.streetById(streetId); Street street = streetService.streetById(streetId);
List<StockExportExcel> stockExportExcels = new ArrayList<>(stocks.size()); List<StockExportExcel> stockExportExcels = new ArrayList<>(stocks.size());
stocks.forEach(stock -> { stocks.forEach(stock -> {
StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setCode(stock.getTrayCode()); if (stock.getCode().contains(",")){
stockExportExcel.setLotnum(stock.getLotnum()); String[] split = stock.getCode().split(",");
stockExportExcel.setColumn(stock.getColumn()); for (String s : split){
stockExportExcel.setCheckNum(stock.getCheckNum()); StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setWmsCode(stock.getWmsTrayCode()); stockExportExcel.setLotnum(stock.getLotnum());
//stockExportExcel.setCount(stock.getCount()); stockExportExcel.setColumn(stock.getColumn());
stockExportExcel.setRow(stock.getRow()); stockExportExcel.setCheckNum(stock.getCheckNum());
stockExportExcel.setStreetName(street.getName()); //stockExportExcel.setWmsCode(stock.getWmsTrayCode());
stockExportExcel.setExportTime(stock.getExportTime()); //stockExportExcel.setCount(stock.getCount());
stockExportExcel.setDirection(stock.getDirection()); stockExportExcel.setRow(stock.getRow());
//stockExportExcel.setSide(stock.getSide()); stockExportExcel.setStreetName(street.getName());
//stockExportExcel.setShelveId(stock.getShelveId()); stockExportExcel.setExportTime(stock.getExportTime());
stockExportExcel.setStatus(stock.getStatus()); stockExportExcel.setDirection(stock.getDirection());
stockExportExcels.add(stockExportExcel); //stockExportExcel.setSide(stock.getSide());
//stockExportExcel.setShelveId(stock.getShelveId());
stockExportExcel.setStatus(stock.getStatus());
stockExportExcel.setCode(s);
stockExportExcels.add(stockExportExcel);
}
}else {
StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setLotnum(stock.getLotnum());
stockExportExcel.setColumn(stock.getColumn());
stockExportExcel.setCheckNum(stock.getCheckNum());
//stockExportExcel.setWmsCode(stock.getWmsTrayCode());
//stockExportExcel.setCount(stock.getCount());
stockExportExcel.setRow(stock.getRow());
stockExportExcel.setStreetName(street.getName());
stockExportExcel.setExportTime(stock.getExportTime());
stockExportExcel.setDirection(stock.getDirection());
//stockExportExcel.setSide(stock.getSide());
//stockExportExcel.setShelveId(stock.getShelveId());
stockExportExcel.setStatus(stock.getStatus());
stockExportExcel.setCode(stock.getCode());
stockExportExcels.add(stockExportExcel);
}
}); });
return stockExportExcels; return stockExportExcels;
} }
@ -370,19 +398,46 @@ public class StockService {
//Street street = streetService.streetById(streetId); //Street street = streetService.streetById(streetId);
List<StockExportExcel> stockExportExcels = new ArrayList<>(stocks.size()); List<StockExportExcel> stockExportExcels = new ArrayList<>(stocks.size());
stocks.forEach(stock -> { stocks.forEach(stock -> {
StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setCode(stock.getTrayCode()); if (stock.getCode().contains(",")){
stockExportExcel.setLotnum(stock.getLotnum()); String[] split = stock.getCode().split(",");
stockExportExcel.setColumn(stock.getColumn()); for (String s : split){
stockExportExcel.setCheckNum(stock.getCheckNum()); StockExportExcel stockExportExcel = new StockExportExcel();
//stockExportExcel.setCount(stock.getCount()); stockExportExcel.setLotnum(stock.getLotnum());
stockExportExcel.setRow(stock.getRow()); stockExportExcel.setColumn(stock.getColumn());
stockExportExcel.setStreetName(streetMap.get(stock.getStreetId())); stockExportExcel.setCheckNum(stock.getCheckNum());
stockExportExcel.setExportTime(stock.getExportTime()); //stockExportExcel.setWmsCode(stock.getWmsTrayCode());
stockExportExcel.setDirection(stock.getDirection()); //stockExportExcel.setCount(stock.getCount());
//stockExportExcel.setSide(stock.getSide()); stockExportExcel.setRow(stock.getRow());
stockExportExcel.setStatus(stock.getStatus()); stockExportExcel.setStreetName(streetMap.get(stock.getStreetId()));
stockExportExcels.add(stockExportExcel); stockExportExcel.setExportTime(stock.getExportTime());
stockExportExcel.setDirection(stock.getDirection());
//stockExportExcel.setSide(stock.getSide());
//stockExportExcel.setShelveId(stock.getShelveId());
stockExportExcel.setStatus(stock.getStatus());
stockExportExcel.setCode(s);
stockExportExcels.add(stockExportExcel);
}
}else {
StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setLotnum(stock.getLotnum());
stockExportExcel.setColumn(stock.getColumn());
stockExportExcel.setCheckNum(stock.getCheckNum());
//stockExportExcel.setWmsCode(stock.getWmsTrayCode());
//stockExportExcel.setCount(stock.getCount());
stockExportExcel.setRow(stock.getRow());
stockExportExcel.setStreetName(streetMap.get(stock.getStreetId()));
stockExportExcel.setExportTime(stock.getExportTime());
stockExportExcel.setDirection(stock.getDirection());
//stockExportExcel.setSide(stock.getSide());
//stockExportExcel.setShelveId(stock.getShelveId());
stockExportExcel.setStatus(stock.getStatus());
stockExportExcel.setCode(stock.getCode());
stockExportExcels.add(stockExportExcel);
}
}); });
return stockExportExcels; return stockExportExcels;
} }
@ -480,23 +535,33 @@ public class StockService {
log.info("check stock correct, street_id:{},direction:{},side:{},row:{},column:{}", stockCheck.getStreetId(), stockCheck.getDirection(), stockCheck.getSide(), stockCheck.getRow(), stockCheck.getColumn()); log.info("check stock correct, street_id:{},direction:{},side:{},row:{},column:{}", stockCheck.getStreetId(), stockCheck.getDirection(), stockCheck.getSide(), stockCheck.getRow(), stockCheck.getColumn());
if (stockCheck.getOk() == 1) { if (stockCheck.getOk() == 1) {
stock.setStatus(StockStatus.MANUAL.getStatus()); stock.setStatus(StockStatus.MANUAL.getStatus());
} else if(stockCheck.getOk() == -1) { stock.setCode(stock.getWmsCode());
stock.setLength(stockCheck.getLength()); KsecInfo ksecInfo = KsecInfo.heart();
stock.setQrCode(stockCheck.getQrCode()); KsecDataInfo ksecDataInfo = new KsecDataInfo();
if(stockCheck.getLength()>600) { ksecDataInfo.setTaskId(stock.getCheckNum().substring(stock.getCheckNum().lastIndexOf("_")+1));
ksecInfo.setData(ksecDataInfo);
ksecInfo.getData().setAckStatus(1);
stock.setStatus(StockStatus.SUCCESS.getStatus());
if (KsecNettyClient.channel!=null) {
KsecNettyClient.channel.writeAndFlush(ksecInfo);
} }
}else { } else if(stockCheck.getOk() == -1) {
stock.setStatus(StockStatus.ERROR.getStatus()); stock.setStatus(StockStatus.ERROR.getStatus());
} }
stockMapper.updateById(stock); stockMapper.updateById(stock);
checkLog(stock); checkLog(stock);
return stock; return stock;
} }
public static void main(String[] args) {
System.out.println("111_222".substring("111_222".lastIndexOf("_")+1));
}
@Resource @Resource
private CheckLogMapper checkLogMapper; private CheckLogMapper checkLogMapper;
@ -548,8 +613,8 @@ public class StockService {
public void allStockCheck() { public void allStockCheck() {
Stock stock = new Stock(); Stock stock = new Stock();
stock.setStatus(3); stock.setStatus(3);
List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().eq("status", "0")); List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().eq("status", "0").or().eq("status", "1"));
stockMapper.update(stock, new QueryWrapper<Stock>().eq("status", "0")); stockMapper.update(stock, new QueryWrapper<Stock>().eq("status", "0").or().eq("status", "1"));
for (Stock s:stockList){ for (Stock s:stockList){
StockCheck stockCheck = new StockCheck(); StockCheck stockCheck = new StockCheck();
stockCheck.setColumn(s.getColumn()); stockCheck.setColumn(s.getColumn());

@ -6,6 +6,7 @@ import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.service.PlcService; import com.zhehekeji.web.service.PlcService;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
@ -22,10 +23,12 @@ public class KsecNettyClient {
private static EventLoopGroup group = new NioEventLoopGroup(); private static EventLoopGroup group = new NioEventLoopGroup();
@Resource @Resource
private PlcService plcService; private PlcService plcService;
Bootstrap client = new Bootstrap();
@Resource @Resource
private ConfigProperties configProperties; private ConfigProperties configProperties;
private static Channel channel; public static Channel channel;
public void createClient(ConfigProperties.KSEC ksec) throws InterruptedException { public void createClient(ConfigProperties.KSEC ksec) throws InterruptedException {
String lotnum = FileUtil.getText("lastLotnum"); String lotnum = FileUtil.getText("lastLotnum");
@ -35,13 +38,28 @@ public class KsecNettyClient {
if (StringUtils.isEmpty(ksec.getIp()) || ksec.getPort() == null) { if (StringUtils.isEmpty(ksec.getIp()) || ksec.getPort() == null) {
return; return;
} }
Bootstrap client = new Bootstrap(); client= new Bootstrap();
client.group(group); client.group(group);
client.channel(NioSocketChannel.class); client.channel(NioSocketChannel.class);
KsecInfo heart = KsecInfo.heart(); KsecInfo heart = KsecInfo.heart();
client.handler(new KescFilter(heart, plcService,this)); client.handler(new KescFilter(heart, plcService,this));
// 连接服务端 // 连接服务端
channel = client.connect(ksec.getIp(), ksec.getPort()).sync().channel(); //channel = client.connect(ksec.getIp(), ksec.getPort()).sync().channel();
connect(ksec);
}
private void connect(ConfigProperties.KSEC ksec) {
client.connect(ksec.getIp(), ksec.getPort()).addListener((ChannelFutureListener) future -> {
if (future.isSuccess()) {
channel = future.channel();
System.out.println("Connected to server at " + ksec.getIp()+ ":" + ksec.getPort() );
} else {
System.err.println("Failed to connect to server, retrying...");
future.channel().eventLoop().schedule(()->{
this.connect(ksec);
}, 5, java.util.concurrent.TimeUnit.SECONDS);
}
});
} }
/** /**

@ -56,7 +56,7 @@ cameraConfig:
# 单位毫秒 # 单位毫秒
delayDownloadMp4: 10000 delayDownloadMp4: 10000
# 识别置信度(成功率配置) # 识别置信度(成功率配置)
IdentificationProbability: 0.1 IdentificationProbability: 0.9
# 最大扫描时间(单位ms), # 最大扫描时间(单位ms),
maximumRecognitionTime: 9000 maximumRecognitionTime: 9000
cameraTimeUpdateCron: 0/10 * * * * ? cameraTimeUpdateCron: 0/10 * * * * ?

Loading…
Cancel
Save