1.更详细说明随行路径

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

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

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

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

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

@ -24,40 +24,5 @@ public class TestService {
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){
List<KsecInfo> list = new ArrayList<>();
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);
}
return list;
}
}

Loading…
Cancel
Save