中威获取球机当前位置

merge-requests/6/head
yiming 4 years ago
parent dc14848a5c
commit c33599566e

@ -3,12 +3,16 @@ package com.zhehekeji.web.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.sun.jna.ptr.IntByReference;
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.Camera; import com.zhehekeji.web.entity.Camera;
import com.zhehekeji.web.entity.CameraIO; import com.zhehekeji.web.entity.CameraIO;
import com.zhehekeji.web.entity.CameraIOConfig; import com.zhehekeji.web.entity.CameraIOConfig;
import com.zhehekeji.web.lib.CameraConnMap;
import com.zhehekeji.web.lib.CameraControlModule; import com.zhehekeji.web.lib.CameraControlModule;
import com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl;
import com.zhehekeji.web.lib.joyware.NetSDKLib;
import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq; import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq;
import com.zhehekeji.web.pojo.camera.CameraIOPtz; import com.zhehekeji.web.pojo.camera.CameraIOPtz;
import com.zhehekeji.web.pojo.street.StreetSearch; import com.zhehekeji.web.pojo.street.StreetSearch;
@ -133,6 +137,25 @@ public class CameraController {
return Result.success(); return Result.success();
} }
@PostMapping("/{cameraId}/io/xy")
@ApiOperation(value = "获取球机的当前位置坐标")
public Result xy(@PathVariable Integer cameraId) {
NetSDKLib.NET_PTZ_LOCATION_INFO ptzLocationInfo = new NetSDKLib.NET_PTZ_LOCATION_INFO();
IntByReference intRetLen = new IntByReference();
int nType = NetSDKLib.NET_DEVSTATE_PTZ_LOCATION;
ptzLocationInfo.write();
boolean bRet = JoywareLoginModuleImpl.netsdk.CLIENT_QueryDevState(CameraConnMap.getConnId(cameraId), nType, ptzLocationInfo.getPointer(), ptzLocationInfo.size(), intRetLen, 3000);
ptzLocationInfo.read();
String s = "水平:%d,垂直:%d";
if (bRet) {
String ss = String.format(s,ptzLocationInfo.nPTZPan,ptzLocationInfo.nPTZTilt);
log.info(ss);
return Result.success(ss);
}
return Result.success(s);
}
@GetMapping("/downloadConfig") @GetMapping("/downloadConfig")
@ApiOperation(value = "视频直播配置") @ApiOperation(value = "视频直播配置")
public Result downloadConfig() throws IOException { public Result downloadConfig() throws IOException {

@ -10,6 +10,7 @@ import com.zhehekeji.web.pojo.stock.*;
import com.zhehekeji.web.service.StockService; import com.zhehekeji.web.service.StockService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -27,6 +28,7 @@ import java.util.Map;
@Api(value = "Stock", tags = "库存管理") @Api(value = "Stock", tags = "库存管理")
@RestController @RestController
@RequestMapping("/stock") @RequestMapping("/stock")
@Slf4j
public class StockController { public class StockController {
@Resource @Resource
@ -115,8 +117,13 @@ public class StockController {
@ApiOperation(value = "获取盘点信息") @ApiOperation(value = "获取盘点信息")
@RequestMapping(value = "/checkInfo", method = RequestMethod.POST) @RequestMapping(value = "/checkInfo", method = RequestMethod.POST)
public Result<Stock> checkInfo(@RequestBody StockCheckSearch stockCheck) { public Result<Stock> checkInfo(@RequestBody StockCheckSearch stockCheck) {
int a = Integer.valueOf(stockCheck.getSRMNumber());
String ss = String.format("%03d", a);
stockCheck.setSRMNumber(ss);
validatorUtil.validate(stockCheck); validatorUtil.validate(stockCheck);
log.info("stockCheck:{}",stockCheck);
Stock stock = stockService.stock(stockCheck); Stock stock = stockService.stock(stockCheck);
log.info("stockCheck:res:{}",stock);
return Result.success(stock); return Result.success(stock);
} }
@ -134,4 +141,14 @@ public class StockController {
return Result.success(stockService.checkByMan(checkByMan)); return Result.success(stockService.checkByMan(checkByMan));
} }
public static void main(String[] args) {
String s = "4";
String ss = String.format("%03d", 4);
System.out.println(ss);
String bb = "10";
String bbb = String.format("%03d", 10);
System.out.println(bbb);
}
} }

@ -1,5 +1,6 @@
package com.zhehekeji.web.service; package com.zhehekeji.web.service;
import codeDetector.BarcodeDetector;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhehekeji.common.util.PathUtil; import com.zhehekeji.common.util.PathUtil;
import com.zhehekeji.web.config.ConfigProperties; import com.zhehekeji.web.config.ConfigProperties;
@ -8,6 +9,7 @@ import com.zhehekeji.web.lib.*;
import com.zhehekeji.web.mapper.*; import com.zhehekeji.web.mapper.*;
import com.zhehekeji.web.pojo.OrderVO; import com.zhehekeji.web.pojo.OrderVO;
import com.zhehekeji.web.service.RFID.RFIDSocket; import com.zhehekeji.web.service.RFID.RFIDSocket;
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
import com.zhehekeji.web.service.ksec.KsecNettyClient; import com.zhehekeji.web.service.ksec.KsecNettyClient;
import com.zhehekeji.web.service.sick.SickSocket; import com.zhehekeji.web.service.sick.SickSocket;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -573,11 +575,18 @@ public class PlcService {
} }
@Resource
private LightSourceMapper lightSourceMapper;
public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){ public Boolean check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId()); Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
CronTab.putTime(street.getId()); CronTab.putTime(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);
});
Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1()); Integer cameraId = getCameraByPlcCmd(plcCmdInfo,plcCmdInfo.getLeftRight1());
gyrateCameraByCode(cameraId, cmdCode); gyrateCameraByCode(cameraId, cmdCode);
try { try {
@ -630,15 +639,86 @@ public class PlcService {
//RFID //RFID
RFID rfid = rfidService.getRFIDByPlc(street.getId()); RFID rfid = rfidService.getRFIDByPlc(street.getId());
} }
StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun); OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
threadPoolExecutor.execute(stockCheckRunnable); Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn());
String scanCode = null;
Boolean codeCheck = Boolean.TRUE;
Boolean trayCodeCheck = Boolean.TRUE;
//货物使用球机扫码
if(configProperties.getScanCodeMode().getTray() == 2 && plcCmdInfo.getSeparation1() == 2){
//托盘使用球机扫码
if("".equals(wmsTrayCode)){
//空货物的处理
//如果系统货物为空,则只要扫码识别未出结果,就认为无货物
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath()+path,configProperties.getScanCodeMode().getTrayCodeTypes());
log.info("tray code:{},sys trayCode:{}",trayCode,wmsTrayCode);
if(StringUtils.isEmpty(trayCode)|| trayCode.equals("Unrecognized")){
trayCheck = Boolean.TRUE;
trayCode = "";
}else {
trayCheck = wmsTrayCode.equals(trayCode);
}
}else {
trayCode = BarcodeDetector.detectBestCodeUntilOK(configProperties.getSavePath().getMediaPath()+path,configProperties.getScanCodeMode().getTrayCodeTypes());
if(StringUtils.isEmpty(trayCode)){
log.error("row:{},cloumn:{}",plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
log.error("detectBestBarCode:{}",trayCode);
trayCode = "识别异常";
trayCheck = Boolean.FALSE;
}else {
trayCheck = wmsTrayCode.equals(trayCode);
}
}
}
log.info("code:{}",scanCode);
//核对异常
Integer status = 1;
//托盘和货物都正确
if(trayCheck && codeCheck){
status = 2;
}
if(stock == null){
stock = new Stock(null,null,plcCmdInfo.getOrderNum(),plcCmdInfo.getLotnum(),scanCode, null,null,wmsCode,null,null,wmsTrayCode,trayCode,orderInfo.getShelveId(),orderInfo.getRow(),orderInfo.getColumn(),status,null,null,path, LocalDateTime.now());
stockMapper.insert(stock);
}else {
stock.setStatus(status);
stock.setLotnum(plcCmdInfo.getLotnum());
stock.setExportTime(LocalDateTime.now());
stock.setCheckPic(path);
stock.setCheckNum(plcCmdInfo.getOrderNum());
stock.setTrayCode(trayCode);
stock.setWmsTrayCode(wmsTrayCode);
stock.setCode(scanCode);
stock.setWmsCode(wmsCode);
stockMapper.updateById(stock);
}
checkLog(stock);
// StockCheckRunnable stockCheckRunnable = new StockCheckRunnable(street,plcCmdInfo,cmdCode,stockMapper,path,checkLogMapper,configProperties.getScanCodeMode().getGoods(),wmsCode,wmsTrayCode,trayCode,trayCheck,configProperties,sensorGun);
// threadPoolExecutor.execute(stockCheckRunnable);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
long s = end - startTime; long s = end - startTime;
log.info("time:{}millisecond",s); log.info("time:{}millisecond",s);
return true; return true;
} }
public void checkLog(Stock stock){
CheckLog checkLog = new CheckLog();
checkLog.setCheckNum(stock.getCheckNum());
checkLog.setPic(stock.getCheckPic());
checkLog.setShelveId(stock.getShelveId());
checkLog.setCode(stock.getCode());
checkLog.setWmsCode(stock.getWmsCode());
checkLog.setStatus(stock.getStatus());
checkLog.setRow(stock.getRow());
checkLog.setColumn(stock.getColumn());
checkLog.setCreateTime(LocalDateTime.now());
checkLog.setTrayCode(stock.getTrayCode());
checkLog.setWmsTrayCode(stock.getWmsTrayCode());
checkLog.setLotnum(stock.getLotnum());
checkLogMapper.insert(checkLog);
}
public void truncateStock(){ public void truncateStock(){
stockMapper.truncate(); stockMapper.truncate();
} }

@ -370,38 +370,45 @@ public class StreetService {
*/ */
public String getShevelId(String SRMNumber,Integer direction,Integer separation){ public String getShevelId(String SRMNumber,Integer direction,Integer separation){
Street street = getStreetByPlcId(SRMNumber); Street street = getStreetByPlcId(SRMNumber);
if(street == null){
return null;
}
return getShevelIdByStreet(street,direction,separation); return getShevelIdByStreet(street,direction,separation);
} }
public String getShevelId(Integer streetId,Integer direction,Integer separation){ public String getShevelId(Integer streetId,Integer direction,Integer separation){
Street street = streetById(streetId); Street street = streetById(streetId);
if(street == null){
return null;
}
return getShevelIdByStreet(street,direction,separation); return getShevelIdByStreet(street,direction,separation);
} }
public String getShevelIdByStreet(Street street,Integer direction,Integer separation){ public String getShevelIdByStreet(Street street,Integer direction,Integer separation){
log.info("street:{},direction:{},sep:{}",street,direction,separation);
//判断单双伸 type=1 单伸 2为双伸 //todo 左右互换
//判断单双伸 type=0 单伸 1为双伸
Integer type; Integer type;
if(direction == 1){ if(direction == 2){
type = street.getLeftType(); type = street.getLeftType();
}else { }else {
type = street.getRightType(); type = street.getRightType();
} }
if(type == 1){ if(type == 0){
//单伸只需要判断左右 //单伸只需要判断左右
if(direction == 1){ if(direction == 2){
return street.getLeftShelveId(); return street.getLeftShelveId();
}else { }else {
return street.getRightShelveId(); return street.getRightShelveId();
} }
}else { }else {
//双伸,还需要判断内外 //双伸,还需要判断内外
if(direction == 1){ if(direction == 2){
if(separation == 1){ if(separation == 1){
return street.getLeftInsideShelveId(); return street.getLeftInsideShelveId();
}else { }else {
return street.getRightShelveId(); return street.getLeftOutsideShelveId();
} }
}else { }else {
if(separation == 1){ if(separation == 1){

@ -23,19 +23,25 @@ public class SickSocket {
public static String readOCR(String ip,int port){ public static String readOCR(String ip,int port){
Socket socket = new Socket(); Socket socket = new Socket();
String code = null; String code = "NoRead";
OutputStream os = null; OutputStream os = null;
InputStream is = null; InputStream is = null;
try { try {
socket.connect(new InetSocketAddress(ip,port),3000); socket.connect(new InetSocketAddress(ip,port),3000);
os = socket.getOutputStream(); os = socket.getOutputStream();
writeCmd(os);
is = socket.getInputStream(); is = socket.getInputStream();
code = read(is); int i = 0;
tcpLogger.info("ip:{},code:{}",ip,code); while ("NoRead".equals(code) && i <= 4){
if(code!= null){ writeCmd(os);
code = code.replace("\\n",""); code = read(is);
tcpLogger.info("count:{},ip:{},code:{}",i,ip,code);
if(code!= null){
code = code.replace("\\n","");
}
i++;
} }
} catch (IOException e) { } catch (IOException e) {
tcpLogger.error("sick time out,ip:{},info:{}",ip,e); tcpLogger.error("sick time out,ip:{},info:{}",ip,e);
log.error("sick time out,ip:{},info:{}",ip,e); log.error("sick time out,ip:{},info:{}",ip,e);

Loading…
Cancel
Save