1.更详细说明随行路径

2.库存信息采用taskid
bozhou-古井贡酒
LAPTOP-S9HJSOEB\昊天 2 years ago
parent df2aa1d190
commit b853c28264

@ -33,7 +33,7 @@ public class VideoccController {
@PostMapping("/xiddata") @PostMapping("/xiddata")
@ApiOperation(value = "库存信息") @ApiOperation(value = "库存信息")
public VideoccResponse xiddata1(@RequestBody Videocc videocc ){ public VideoccResponse xiddata1(@RequestBody Videocc videocc ){
String orderNum = videocc.getLoc().substring(0,3)+ "_"+videocc.getJobNum(); String orderNum = videocc.getJobNum();
Set<String> list = new HashSet<>(); Set<String> list = new HashSet<>();
if(videocc.getDetails()!=null && videocc.getDetails().size()>0){ if(videocc.getDetails()!=null && videocc.getDetails().size()>0){
for(String detail:videocc.getDetails().keySet()){ for(String detail:videocc.getDetails().keySet()){

@ -80,55 +80,34 @@ public class OrderService {
} }
public String location(OrderVO orderVO,Street street){ public String location(OrderVO orderVO,Street street){
//from to 模型 StringBuilder goodsLocation = new StringBuilder();
if(orderVO.getRow1()!= 0 && orderVO.getColumn1()!=0) {
if (orderVO.getInOut1() != null && orderVO.getInOut2() != null) { goodsLocation.append(orderVO.getLeftRight1() == 1 ? "左侧" : "右侧") ;
//左右货架 货位号 goodsLocation.append( orderVO.getInOut1() == 1 ? "浅货位" : "深货位");
//库内转库内 看 to goodsLocation.append( orderVO.getRow1()+"行");
Integer column = 0; goodsLocation.append( orderVO.getColumn1() +"列");
Integer row = 0;
//左货架 右货架
Integer leftRight = 0;
if (orderVO.getInOut1() == 1 && orderVO.getInOut2() == 1) {
// 库内转库内
leftRight = orderVO.getLeftRight2();
column = orderVO.getColumn2();
row = orderVO.getRow2();
} else if (orderVO.getInOut1() == 1) {
// 库内到库外
leftRight = orderVO.getLeftRight1();
//看from
orderVO.setStreetType(orderVO.getLeftRight1());
column = orderVO.getColumn1();
row = orderVO.getRow1();
} else if (orderVO.getInOut2() == 1) {
//库外到库内
leftRight = orderVO.getLeftRight2();
//看to
orderVO.setStreetType(orderVO.getLeftRight2());
column = orderVO.getColumn2();
row = orderVO.getRow2();
}else { }else {
return "库外转库外"; goodsLocation.append( "库外");
} }
if (leftRight > 0) {
//PLC 1是左 2是由 goodsLocation.append( " 转 ");
if(street != null){ if(orderVO.getColumn2()!= 0 && orderVO.getRow2()!=0) {
if(leftRight == 1){ goodsLocation.append(orderVO.getLeftRight2() == 1 ? "左侧" : "右侧") ;
orderVO.setStreetType(street.getLeftType()); goodsLocation.append( orderVO.getInOut2() == 1 ? "浅货位" : "深货位");
goodsLocation.append(orderVO.getRow2()).append("行");
goodsLocation.append(orderVO.getColumn2()).append("列");
}else { }else {
orderVO.setStreetType(street.getRightType()); goodsLocation.append( "库外");
} }
} return goodsLocation.toString();
String leftRightS = leftRight == 1 ? "左" : "右";
String inOut = 2 == orderVO.getInOut2() ?"深":"浅";
//
String location = "%s-%s-%s列%s行";
return String.format(location, leftRightS, inOut,column, row);
}
}
return null;
} }

@ -102,7 +102,8 @@ public class PlcCmdInfo {
this.column2 = column2; this.column2 = column2;
this.row2 = row2; this.row2 = row2;
this.plcId = plcId; this.plcId = plcId;
this.orderNum = plcId + "_" + taskId; //this.orderNum = plcId + "_" + taskId;
this.orderNum = taskId;
this.separation1 = separation1; this.separation1 = separation1;
this.separation2 = separation2; this.separation2 = separation2;
this.lotnum = lotnum; this.lotnum = lotnum;
@ -131,23 +132,14 @@ public class PlcCmdInfo {
//针对单双伸货架 单伸的是空,双伸且为外侧为 Out //针对单双伸货架 单伸的是空,双伸且为外侧为 Out
public String getEndStr(int times){ public String getEndStr(int times,int around){
List<String > endString = new ArrayList<>(); List<String > endString = new ArrayList<>();
if (times <= 2) { if (around == 1) {
endString.add("F") ;
if (column1 == 65){ } else {
endString.add("B");
}else {
endString.add(column1%2 == 1 ? "F" : "B") ;
}
} else if(times <= 4) {
if (column2 == 65){
endString.add("B"); endString.add("B");
}else {
endString.add(column2%2 == 1 ? "F" : "B") ;
}
}else {
} }
if (times <= 2) { if (times <= 2) {
endString.add(leftRight1 == 1 ? "L" : "R") ; endString.add(leftRight1 == 1 ? "L" : "R") ;

@ -134,6 +134,9 @@ public class PlcService {
public void orderStart(PlcCmdInfo plcCmdInfo) { public void orderStart(PlcCmdInfo plcCmdInfo) {
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId()); Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
gyrateCameraByCode(cameraId, "C5", plcCmdInfo.getTaskId());
if (street != null) { if (street != null) {
if (plcCmdInfo.getLeftRight1() == 1) { if (plcCmdInfo.getLeftRight1() == 1) {
if (plcCmdInfo.getRow1() > street.getLeftRow() && plcCmdInfo.getColumn1() > street.getLeftColumn()) { if (plcCmdInfo.getRow1() > street.getLeftRow() && plcCmdInfo.getColumn1() > street.getLeftColumn()) {
@ -155,6 +158,10 @@ public class PlcService {
order.setLeftRight1(plcCmdInfo.getLeftRight1()); order.setLeftRight1(plcCmdInfo.getLeftRight1());
order.setColumn1(plcCmdInfo.getColumn1()); order.setColumn1(plcCmdInfo.getColumn1());
order.setRow1(plcCmdInfo.getRow1()); order.setRow1(plcCmdInfo.getRow1());
order.setInOut2(plcCmdInfo.getSide2());
order.setLeftRight2(plcCmdInfo.getLeftRight2());
order.setColumn2(plcCmdInfo.getColumn2());
order.setRow2(plcCmdInfo.getRow2());
//todo 昆船的项目 ,取货 放货是独立的 //todo 昆船的项目 ,取货 放货是独立的
//取货是是不知道放货的位置的所以订单开始的时候只写1位置 //取货是是不知道放货的位置的所以订单开始的时候只写1位置
//订单结束写2位置 //订单结束写2位置
@ -170,23 +177,36 @@ public class PlcService {
* @param plcCmdInfo * @param plcCmdInfo
*/ */
public void orderStop(PlcCmdInfo plcCmdInfo) { public void orderStop(PlcCmdInfo plcCmdInfo) {
LocalDateTime endTime = LocalDateTime.now(); LocalDateTime endTime = LocalDateTime.now();
Street street = streetMapper.getStreetByPlcId(plcCmdInfo.getPlcId());
if (street == null) {
return;
}
Order order = orderMapper.getOneByOrderNum(plcCmdInfo.getOrderNum()); Order order = orderMapper.getOneByOrderNum(plcCmdInfo.getOrderNum());
if (order == null) { if (order == null) {
log.error("订单结束信号订单不存在orderNum:{}", plcCmdInfo.getOrderNum()); log.error("订单结束信号订单不存在orderNum:{}", plcCmdInfo.getOrderNum());
return; return;
} }
Order update = new Order();
update.setId(order.getId()); //这里判断是不是双伸
update.setEndTime(endTime); if (order.getInOut2() == 2) {
update.setInOut2(plcCmdInfo.getSide2()); //深测货架延迟
update.setLeftRight2(plcCmdInfo.getLeftRight2()); try {
update.setColumn2(plcCmdInfo.getColumn2()); Thread.sleep(getConfigProperties().getCameraConfig().getB2OutDelayTime());
update.setRow2(plcCmdInfo.getRow2()); } catch (InterruptedException e) {
e.printStackTrace();
}
} else {
//浅侧延迟
try {
Thread.sleep(getConfigProperties().getCameraConfig().getB2DelayTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Street street = streetMapper.selectById(order.getStreetId());
LocalDateTime endDownLoadTime = endTime.plusSeconds(5); LocalDateTime endDownLoadTime = endTime.plusSeconds(5);
Duration duration = Duration.between(order.getStartTime(), endDownLoadTime); Duration duration = Duration.between(order.getStartTime(), endDownLoadTime);
@ -195,13 +215,13 @@ public class PlcService {
} }
if (street.getCamera1Id() != null) { if (street.getCamera1Id() != null) {
String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime); String path = cameraVideo(street.getCamera1Id(), order.getStartTime(), endDownLoadTime);
update.setVideoPath1(path); order.setVideoPath1(path);
} }
if (street.getCamera2Id() != null) { if (street.getCamera2Id() != null) {
String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime); String path = cameraVideo(street.getCamera2Id(), order.getStartTime(), endDownLoadTime);
update.setVideoPath2(path); order.setVideoPath2(path);
} }
orderMapper.updateById(update); orderMapper.updateById(order);
} }
@ -255,7 +275,7 @@ public class PlcService {
/** /**
* 使 * 使
*/ */
Integer cameraId = (plcCmdInfo.getFromAround() == 1)? street.getCamera1Id(): street.getCamera2Id(); Integer cameraId = (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
gyrateCameraByCode(cameraId, orderInfo.getCmdCode(), orderInfo.getOrderNum()); gyrateCameraByCode(cameraId, orderInfo.getCmdCode(), orderInfo.getOrderNum());
if (needCapture) { if (needCapture) {
Boolean delay = true; Boolean delay = true;
@ -282,7 +302,7 @@ public class PlcService {
} else { } else {
delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime(); delayTime = configProperties.getCameraConfig().getC2OutDelayCaptureTime();
} }
if(configProperties.getOrderTest() == 1 && plcCmdInfo.getFromAround() == 2) { if (configProperties.getOrderTest() == 1 && plcCmdInfo.getFromAround() == 2) {
checkTest(plcCmdInfo); checkTest(plcCmdInfo);
} }
} else if (code.startsWith("C3")) { } else if (code.startsWith("C3")) {
@ -303,14 +323,9 @@ public class PlcService {
captureUpdateOrderAndStock(orderInfo, path); captureUpdateOrderAndStock(orderInfo, path);
} }
//转向原点位 //转向原点位
if (times == 2) { if (times == 2 || times == 4) {
gyrateCameraByCodeTimeLater(cameraId, "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
if (street.getCamera2Id() != null) {
gyrateCameraByCodeTimeLater(street.getCamera2Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
}
if (street.getCamera1Id() != null) {
gyrateCameraByCodeTimeLater(street.getCamera1Id(), "C5", configProperties.getCameraConfig().getC2OutDelayCaptureTime() + 500);
}
} }
// threadPoolExecutor.execute(()->{ // threadPoolExecutor.execute(()->{
// rfidLiveService.rfidOrderStock(plcCmdInfo, times, code); // rfidLiveService.rfidOrderStock(plcCmdInfo, times, code);
@ -372,7 +387,7 @@ public class PlcService {
public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) { public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) {
//String path = PathUtil.createFileName("jpg",cameraId); //String path = PathUtil.createFileName("jpg",cameraId);
String realPath = configProperties.getSavePath().getMediaPath() + path; String realPath = configProperties.getSavePath().getMediaPath() + path;
log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath,delayTime); log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath, delayTime);
if (delay) { if (delay) {
TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime); TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime);
} else { } else {
@ -564,52 +579,11 @@ public class PlcService {
} }
} }
public Integer getCameraByPlcCmd(PlcCmdInfo plcCmdInfo, Integer leftRight) {
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
//判断单双伸 type=0 单伸 1为双伸
Integer type;
if (leftRight == 1) {
type = street.getLeftType();
} else {
type = street.getRightType();
}
if (type == 0) {
//单伸
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
if (leftRight == 1) {
return street.getCamera2Id();
} else {
return street.getCamera1Id();
}
} else {
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
return cameraId;
}
} else {
if (street.getCamera1Id() != null && street.getCamera2Id() != null && street.getCamera1Id() != 0 && street.getCamera2Id() != 0) {
//双伸 todo 这个因项目而异,看现场的情况
//默认是 左侧返回camera1 右侧返回camera2
if (plcCmdInfo.getLeftRight1() == 1) {
return street.getCamera1Id();
} else {
return street.getCamera2Id();
}
} else {
Integer cameraId = street.getCamera1Id() != null && street.getCamera1Id() != 0 ? street.getCamera1Id() : street.getCamera2Id();
return cameraId;
}
}
}
public Integer getCameraByPlcCmdE(PlcCmdInfo plcCmdInfo, Integer leftRight) { public Integer getCameraByPlcCmdE(PlcCmdInfo plcCmdInfo, Integer leftRight) {
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId()); Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
Integer type; //古井前后修改
//只进行相机方向判断左边 return (plcCmdInfo.getFromAround() == 1) ? street.getCamera1Id() : street.getCamera2Id();
if (plcCmdInfo.getFromDirection() == 1) {
return street.getCamera1Id();
} else {
return street.getCamera2Id();
}
} }
@Resource @Resource
@ -624,6 +598,7 @@ public class PlcService {
WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo), null); WebSocketServer.sendInfo(JSONObject.toJSONString(webSocketVo), null);
return JSONObject.toJSONString(webSocketVo); return JSONObject.toJSONString(webSocketVo);
} }
@Resource @Resource
AlgorithmService algorithmService; AlgorithmService algorithmService;
@ -639,21 +614,9 @@ public class PlcService {
}); });
log.info("盘点摄像头变化参数:" + plcCmdInfo.toString()); log.info("盘点摄像头变化参数:" + plcCmdInfo.toString());
Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1()); Integer cameraId = getCameraByPlcCmdE(plcCmdInfo, plcCmdInfo.getLeftRight1());
String code = "E1" + "-" + plcCmdInfo.getEndStr(1, plcCmdInfo.getFromAround());
if (plcCmdInfo.getSeparation1() == 1 && configProperties.getScanCodeMode().getTray() == 2) { gyrateCameraByCode(cameraId, code);
//内测
String c = cmdCode + "-" + plcCmdInfo.getLeftRightStr(1) + "-IN";
log.info("camera ptz" + c);
gyrateCameraByCode(cameraId, c);
} else {
String c = cmdCode + "1-" +plcCmdInfo.getEndStr(1);
gyrateCameraByCode(cameraId, c);
try {
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1()); String path = PathUtil.createFileNameByRowColumn("jpg", cameraId, plcCmdInfo.getRow1(), plcCmdInfo.getColumn1());
try { try {
@ -667,7 +630,7 @@ public class PlcService {
OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode); OrderInfo orderInfo = new OrderInfo(street, plcCmdInfo, 1, cmdCode);
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn()); Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(), plcCmdInfo.getFromDirection(), orderInfo.getSeparation(), orderInfo.getRow(), orderInfo.getColumn());
AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(street,dataInfo); AlgorithmPojo algorithmPojo = algorithmService.getGoodResult(street, dataInfo);
//货物使用球机扫码 //货物使用球机扫码
@ -675,7 +638,7 @@ public class PlcService {
//核对异常 //核对异常
Integer status = 1; Integer status = 1;
//托盘和货物都正确 //托盘和货物都正确
if (algorithmPojo.getResult()==1 if (algorithmPojo.getResult() == 1
&& algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult()) && algorithmPojo.getGoodsNumber().equals(algorithmPojo.getGoodsNumberResult())
&& algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) { && algorithmPojo.getGoodsType().equals(algorithmPojo.getGoodsTypeResult())) {
status = 2; status = 2;
@ -788,6 +751,7 @@ public class PlcService {
} }
public KsecDataInfo orderDecoder(KsecInfo ksecInfo) { public KsecDataInfo orderDecoder(KsecInfo ksecInfo) {
log.info("收到命令:{}", ksecInfo.toString());
KsecDataInfo dataInfo = ksecInfo.getData(); KsecDataInfo dataInfo = ksecInfo.getData();
if (Cmd.A.name().equals(ksecInfo.getType())) { if (Cmd.A.name().equals(ksecInfo.getType())) {
return dataInfo; return dataInfo;
@ -796,38 +760,44 @@ public class PlcService {
PlcCmdInfo plcCmdInfo = null; PlcCmdInfo plcCmdInfo = null;
String srmNumber = null; String srmNumber = null;
String cmdName = null; String cmdName = null;
if(dataInfo != null){ if (dataInfo != null) {
//古井贡酒没有side使用双伸单伸Separation代替全部side
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(), plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(),
dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(), dataInfo.getFromSeparation(), dataInfo.getFromDirection(), dataInfo.getFromColumn(),
dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(), dataInfo.getFromRow(), dataInfo.getFromSeparation(), dataInfo.getToSeparation(),
dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(), dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),
dataInfo.getToSeparation(),lotnum); dataInfo.getToSeparation(), lotnum);
plcCmdInfo.setFromDirection(dataInfo.getFromDirection()); plcCmdInfo.setFromDirection(dataInfo.getFromDirection());
plcCmdInfo.setToDirection(dataInfo.getToDirection()); plcCmdInfo.setToDirection(dataInfo.getToDirection());
plcCmdInfo.setToColumn(dataInfo.getToColumn()); plcCmdInfo.setToColumn(dataInfo.getToColumn());
plcCmdInfo.setToRow(dataInfo.getToRow()); plcCmdInfo.setToRow(dataInfo.getToRow());
plcCmdInfo.setFromRow(dataInfo.getFromRow()); plcCmdInfo.setFromRow(dataInfo.getFromRow());
plcCmdInfo.setFromColumn(dataInfo.getFromColumn()); plcCmdInfo.setFromColumn(dataInfo.getFromColumn());
plcCmdInfo.setFromSide(dataInfo.getFromSide()); plcCmdInfo.setFromSide(dataInfo.getFromSeparation());
plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation()); plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation());
plcCmdInfo.setToSeparation(dataInfo.getToSeparation()); plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
plcCmdInfo.setFromAround(dataInfo.getFromAround()); plcCmdInfo.setFromAround(dataInfo.getFromAround());
plcCmdInfo.setToSide(dataInfo.getToSide()); plcCmdInfo.setToSide(dataInfo.getToSeparation());
//左右不交换 //左右不交换
if(dataInfo.getFromDirection() == 1){ if (dataInfo.getFromDirection() != null) {
if (dataInfo.getFromDirection() == 1) {
//dataInfo.setFromDirection(2); //dataInfo.setFromDirection(2);
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
}else { } else {
//dataInfo.setFromDirection(1); //dataInfo.setFromDirection(1);
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
} }
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){ }
if (dataInfo.getToDirection() != null) {
if (dataInfo.getToDirection() == 1) {
//dataInfo.setToDirection(2); //dataInfo.setToDirection(2);
plcCmdInfo.setLeftRight2(dataInfo.getToDirection()); plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
}else { } else {
//dataInfo.setToDirection(1); //dataInfo.setToDirection(1);
plcCmdInfo.setLeftRight2(dataInfo.getToDirection()); plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
} }
}
srmNumber = dataInfo.getSRMNumber(); srmNumber = dataInfo.getSRMNumber();
cmdName = dataInfo.getCmdName(); cmdName = dataInfo.getCmdName();
} }
@ -838,35 +808,18 @@ public class PlcService {
//任务 //任务
if (Cmd.B1.name().equals(cmdName)) { if (Cmd.B1.name().equals(cmdName)) {
//昆船盘点模式下也会发B1 ,但是不会发送B2 //昆船盘点模式下也会发B1 ,但是不会发送B2
//这里判断下,是否存在盘点批次号 若存在既是盘点的B1,无需处理若不存在lotnum则是随行的B1
if(StringUtils.isEmpty(dataInfo.getLotnum())){
//任务开始 旋转到原点位 //任务开始 旋转到原点位
gyrateCamera(plcCmdInfo,Cmd.C5.name()); gyrateCamera(plcCmdInfo, Cmd.C5.name());
orderStart(plcCmdInfo); orderStart(plcCmdInfo);
}else {
log.info("check move");
}
} else if (Cmd.B2.name().equals(cmdName)) { } else if (Cmd.B2.name().equals(cmdName)) {
//B2 C4 一起发的需要停止等B2 //B2 C4 一起发的需要停止等B2
//这里判断是不是双伸
if(plcCmdInfo.getSeparation2() == 2){
//深测货架延迟
try {
Thread.sleep(getConfigProperties().getCameraConfig().getB2OutDelayTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
}else {
//浅侧延迟
try {
Thread.sleep(getConfigProperties().getCameraConfig().getB2DelayTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
gyrateCamera(plcCmdInfo,Cmd.C5.name());
orderStop(plcCmdInfo); orderStop(plcCmdInfo);
} }
} else if (Cmd.C.name().equals(ksecInfo.getType())) { } else if (Cmd.C.name().equals(ksecInfo.getType())) {
@ -878,30 +831,30 @@ public class PlcService {
//执行动作,需要保存执行到第几步了 //执行动作,需要保存执行到第几步了
Integer times = GoodsActionTimes.get(dataInfo.getCmdName()); Integer times = GoodsActionTimes.get(dataInfo.getCmdName());
plcCmdInfo.setTimes(times); plcCmdInfo.setTimes(times);
code = code + "-" + plcCmdInfo.getEndStr(times); code = code + "-" + plcCmdInfo.getEndStr(times, plcCmdInfo.getFromAround());
//执行动作 //执行动作
try { try {
action(plcCmdInfo, times, code); action(plcCmdInfo, times, code);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
}else { } else {
log.info("other C code :{}",code); log.info("other C code :{}", code);
} }
} else if (Cmd.D.name().equals(ksecInfo.getType())) { } else if (Cmd.D.name().equals(ksecInfo.getType())) {
} else if (Cmd.E.name().equals(ksecInfo.getType()) ) { } else if (Cmd.E.name().equals(ksecInfo.getType())) {
String code = dataInfo.getCmdName(); String code = dataInfo.getCmdName();
log.info("盘点指令:{}", ksecInfo); log.info("盘点指令:{}", ksecInfo);
if(configProperties.getOrderTest() == 0) { {
AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo); AlgorithmPojo algorithmPojo = check(plcCmdInfo, ksecInfo.getType(), dataInfo);
ksecInfo.getData().setAckStatus(1); ksecInfo.getData().setAckStatus(1);
dataInfo.setResult(algorithmPojo.getResult()); dataInfo.setResult(algorithmPojo.getResult());
dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult()); dataInfo.setGoodsTypeResult(algorithmPojo.getGoodsTypeResult());
dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult()); dataInfo.setGoodsNumberResult(algorithmPojo.getGoodsNumberResult());
log.info("盘点完成"); log.info("盘点完成");
}else { } if (configProperties.getOrderTest() == 1) {
checkTest(plcCmdInfo); checkTest(plcCmdInfo);
@ -918,27 +871,27 @@ public class PlcService {
OutputStream os = null; OutputStream os = null;
InputStream is = null; InputStream is = null;
try { try {
socket.connect(new InetSocketAddress(street.getPlcIp(),street.getPlcPort()),3000); socket.connect(new InetSocketAddress(street.getPlcIp(), street.getPlcPort()), 3000);
//socket.setSoTimeout(10000); //socket.setSoTimeout(10000);
os = socket.getOutputStream(); os = socket.getOutputStream();
Thread.sleep(100); Thread.sleep(100);
String startCmd = "trigger:1"; String startCmd = "trigger:1";
byte [] bytes = startCmd.getBytes(StandardCharsets.UTF_8); byte[] bytes = startCmd.getBytes(StandardCharsets.UTF_8);
os.write(bytes); os.write(bytes);
socket.close(); socket.close();
} catch (IOException e) { } catch (IOException e) {
log.error("hik contro time out,ip:{},info:{}",street.getPlcIp(),e); log.error("hik contro time out,ip:{},info:{}", street.getPlcIp(), e);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
if(os != null){ if (os != null) {
try { try {
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if(is != null){ if (is != null) {
try { try {
is.close(); is.close();
} catch (IOException e) { } catch (IOException e) {

@ -24,40 +24,5 @@ public class TestService {
public void CheckTest(String plcId,Integer leftRight){ public void CheckTest(String plcId,Integer leftRight){
Street street = streetService.getStreetByPlcId(plcId);
if(street == null){
return;
}
Integer row = street.getLeftRow();
Integer column = street.getLeftColumn();
if(leftRight == 2){
row = street.getRightRow();
column = street.getRightColumn();
}
for(int i = 1;i<=row;i++){
for(int j = 1; j<= column;j++){
String code = "123456789013";
if(j % 11 == 0){
code = "dddd";
}
String taskId = i +"-"+ j+"-"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("hhmmss"));
PlcCmdInfo plcCmdInfo = new PlcCmdInfo(street.getPlcId(),taskId,1,leftRight,j,i,1,1,1,1,1,1,"");
plcCmdInfo.setTimes(1);
int co = j%3 + 1;
// plcService.check(plcCmdInfo,"E"+co,code,code);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
plcService.gyrateCameraByCode(plcService.getCameraByPlcCmd(plcCmdInfo,leftRight),"C5");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} }
} }

@ -23,11 +23,13 @@ public class KsecInfos {
public static List<KsecInfo> getList(KsecInfos ksecInfos){ public static List<KsecInfo> getList(KsecInfos ksecInfos){
List<KsecInfo> list = new ArrayList<>(); List<KsecInfo> list = new ArrayList<>();
for (KsecDataInfo ksecDataInfo :ksecInfos.getData()){ for (KsecDataInfo ksecDataInfo :ksecInfos.getData()){
KsecInfo ksecInfo = new KsecInfo( ksecInfos.getHeader(), ksecInfos.getType(),ksecDataInfo); String ksecType = ksecDataInfo.getCmdName().substring(0,1);
KsecInfo ksecInfo = new KsecInfo( ksecInfos.getHeader(), ksecType,ksecDataInfo);
list.add(ksecInfo); list.add(ksecInfo);
} }
return list; return list;
} }
} }

Loading…
Cancel
Save