diff --git a/nladmin-system/nlsso-server/pom.xml b/nladmin-system/nlsso-server/pom.xml
index 0644044..cb273b9 100644
--- a/nladmin-system/nlsso-server/pom.xml
+++ b/nladmin-system/nlsso-server/pom.xml
@@ -462,6 +462,78 @@
hivemq-mqtt-client
1.3.3
+
+ com.lib.bx06
+ bx06.message
+ 0.6.0-SNAPSHOT
+
+
+
+ com.lib.bx06
+ bx06
+ 0.6.5-SNAPSHOT
+
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.2.11
+
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.2.11
+
+
+
+ gnu.io
+ rxtx
+ 2.1.7
+
+
+
+ org.simpleframework
+ simple-xml
+ 2.7.1
+
+
+
+ javax.xml.stream
+ stax
+ 1.2.0
+
+
+
+ javax.xml.stream
+ stax-api
+ 1.0.1
+
+
+
+ org.uia
+ uia-comm
+ 0.5.3-SNAPSHOT
+
+
+
+ org.uia
+ uia-message
+ 0.6.0
+
+
+
+ org.uia
+ uia-utils
+ 0.3.1
+
+
+
+ xmlpull
+ xpp3
+ 1.1.3.3
+
+
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java
index 38ce726..2797c3d 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import org.mybatis.spring.annotation.MapperScan;
+import org.nl.acs.ext.socket.HeartServer;
import org.nl.config.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -15,6 +16,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.net.InetSocketAddress;
+
/**
* 开启审计功能 -> @EnableJpaAuditing
* https://www.cnblogs.com/niceyoo/p/10908647.html
@@ -36,8 +39,9 @@ import org.springframework.web.bind.annotation.RestController;
public class AppRun {
public static void main(String[] args) {
-
SpringApplication.run(AppRun.class, args);
+ new HeartServer(new InetSocketAddress("127.0.0.1", 20889));
+ System.out.println("项目启动成功");
}
@Bean
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java
deleted file mode 100644
index 6db44de..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.nl.acs.agv;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.config.SpringContextHolder;
-import org.nl.system.service.param.ISysParamService;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * 定时查询AGV状态
- */
-@Slf4j
-@Component("queryAGVStatus")
-public class QueryAGVStatus {
-
- public void run() {
- InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
- ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
- List allInstFromCache = instructionService.findAllInstFromCache();
- if (CollUtil.isEmpty(allInstFromCache) || allInstFromCache.size() < 1) {
- return;
- }
- for (Instruction instruction : allInstFromCache) {
- if ("4".equals(instruction.getInstruction_type())) {
- String agvurl = paramService.findByCode(AcsConfig.AGV_URL).getValue();
- JSONObject param = new JSONObject();
- agvurl = agvurl + ":/" + instruction.getInstruction_code();
- log.info("根据运单号查询运单状态的请求:{}", agvurl);
- HttpResponse result = HttpRequest.get(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("根据运单号查询运单状态的请求反馈:{}", result);
- String body = result.body();
- JSONObject json = JSONObject.parseObject(body);
- if (result.getStatus() == 200 && json.getString("id").equals(instruction.getInstruction_code())) {
- // 已创建=CREATED,
- // 待分配=TOBEDISPATCHED,
- // 正在执行=RUNNING,
- // 完成=FINISHED,
- // 失败=FAILED(主动失败),
- // 终止=STOPPED(被人为终止),
- // 无法执行=Error(参数错误),
- // 等待=WAITING
- //执行中
- String state = json.getString("state");
- if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
- instruction.setInstruction_status("1");
- instructionService.update(instruction);
- } else if ("FINISHED".equals(state)) {
- instruction.setInstruction_status("2");
- try {
- instructionService.finish(instruction);
- } catch (Exception e) {
- log.error("执行完成,但无法更新状态,可能由于参数错误导致的异常");
- e.printStackTrace();
- }
- } else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
- instruction.setInstruction_status("1");
- instructionService.update(instruction);
- }
- }
- }
- }
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/bx06_demo.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/bx06_demo.java
new file mode 100644
index 0000000..ac92825
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/bx06_demo.java
@@ -0,0 +1,424 @@
+package org.nl.acs; /**
+ * Created by admin on 2019/8/21.
+ */
+
+import onbon.bx06.Bx6GEnv;
+import onbon.bx06.Bx6GScreen;
+import onbon.bx06.Bx6GScreenClient;
+import onbon.bx06.area.*;
+import onbon.bx06.area.page.ImageFileBxPage;
+import onbon.bx06.area.page.TextBxPage;
+import onbon.bx06.area.page.TextFileBxPage;
+import onbon.bx06.cmd.dyn.DynamicBxAreaRule;
+import onbon.bx06.file.ProgramBxFile;
+import onbon.bx06.message.common.ErrorType;
+import onbon.bx06.message.led.ReturnControllerStatus;
+import onbon.bx06.message.tcp.ReturnNetwork;
+import onbon.bx06.series.Bx6Card;
+import onbon.bx06.series.Bx6E;
+import onbon.bx06.utils.DisplayStyleFactory.DisplayStyle;
+import onbon.bx06.utils.DisplayStyleFactory;
+import onbon.bx06.utils.TextBinary;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @program: bx06_demo
+ * @description:
+ * @author: Mr.Feng
+ * @create: 2019-08-21 14:52
+ **/
+public class bx06_demo {
+ private static String ip = "192.168.81.56";
+ private static int port = 5005;
+ public static void main(String[] args)throws Exception
+ {
+ // 初始化API,此操作只在程序启动时候执行一次即可,多次执行会出现内存错误
+ Bx6GEnv.initial(30000);
+ SendDynamicProgram();
+ }
+
+ // 将一个节目发送到控制器
+ public static void SendProgram()throws Exception
+ {
+ // 关于显示特技
+ // 0:随机显示
+ // 1:静止显示
+ // 2:快速打出
+ // 3:向左移动
+ // 4:向左连移
+ // 5:向上移动
+ // 6:向上连移
+ // 7:闪烁
+ // 8:飘雪
+ // 9:冒泡
+ // 10:中间移出
+ // 11:左右移入
+ // 12:左右交叉移入
+ // 13:上下交叉移入
+ // 14:花卷闭合
+ // 15:花卷打开
+ // 16:向左拉伸
+ // 17:向右拉伸
+ // 18:向上拉伸
+ // 19:向下拉伸
+ // 20:向左镭射
+ // 21:向右镭射
+ // 22:向上镭射
+ // 23:向下镭射
+ // 24:左右交叉拉幕
+ // 25:上下交叉拉幕
+ // 26:分散左拉
+ // 27:水平百叶
+ // 28:垂直百叶
+ // 29:向左拉幕
+ // 30:向右拉幕
+ // 31:向上拉幕
+ // 32:向下拉幕
+ // 33:左右闭合
+ // 34:左右对开
+ // 35:上下闭合
+ // 36:上下对开
+ // 37;向右移动
+ // 38:向右连移
+ // 39:向下移动
+ // 40:向下连移
+ // 41:45度左旋
+ // 42:180度左旋
+ // 43:90度右旋
+ // 44:45度右旋
+ // 45:180度右旋
+ // 46:90度右旋
+ // 47:菱形打开
+ // 48:菱形闭合
+ DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]);
+
+ // 创建screen对象,用于与控制卡的交互
+ // 第二个参数是控制卡型号,只有型号对才能正常通讯,否则会出现逾时未回应,如果使用的型号API中未定义,用new Bx6M()替代
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+
+ // 连接控制器
+ screen.connect( ip,port);
+
+ // 创建节目 一个节目相当于一屏显示内容
+ ProgramBxFile pf = new ProgramBxFile( "P000",screen.getProfile() );
+
+ // 创建一个分区
+ // 分别输入X,Y,width,heigth
+ // 注意区域坐标和宽度高度不要越界
+ TextCaptionBxArea area = new TextCaptionBxArea( 0,0,160,64,screen.getProfile() );
+
+ // 创建一个数据页
+ // 第一行数据
+ TextBxPage page = new TextBxPage("仰邦科技欢迎你!");
+ // 第二行数据
+ page.newLine( "这是第二行数据" );
+ // 设置字体
+ page.setFont( new Font("宋体", Font.PLAIN,12) );
+ // 设置显示特技为快速打出
+ page.setDisplayStyle( styles[2] );
+
+ // 数据页可以是图片
+ ImageFileBxPage iPage = new ImageFileBxPage( "D:a/004.bmp" );
+
+ // 数据页可以是txt文件
+ TextFileBxPage tPage = new TextFileBxPage( "D:a/001.txt" );
+
+ // 将前面的page添加到area中,page不可以是表格,如果需要Led显示表格,请先将表格绘制成图片
+ area.addPage( page );
+ area.addPage( iPage );
+ area.addPage( tPage );
+
+ // 将area添加到节目中,节目中可以添加多个area
+ pf.addArea( area );
+
+ // 更新节目
+ screen.writeProgram( pf );
+
+ // 断开连接
+ screen.disconnect();
+
+ }
+
+ // 将多个节目发送到控制器并显示
+ public static void SendPrograms()throws Exception
+ {
+ DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]);
+
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+
+ screen.connect( ip,port );
+
+ ProgramBxFile pf = new ProgramBxFile( "P000",screen.getProfile() );
+
+ // 创建一个时间区
+ DateTimeBxArea dtArea = new DateTimeBxArea( 0,0,160,64,screen.getProfile() );
+
+ // 设定时间区多行显示
+ dtArea.setMultiline( true );
+
+ // 设定日期显示格式 NULL表示不显示日期
+ dtArea.setDateStyle( DateStyle.YYYY_MM_DD_1 );
+ // 设定时间显示格式 NULL表示不显示时间
+ dtArea.setTimeStyle( TimeStyle.HH12_MM_SS_1 );
+ // 设定星期显示格式 NULL表示不显示星期
+ dtArea.setWeekStyle( WeekStyle.CHINESE );
+ // 设定时间区字体
+ dtArea.setFont( new Font("宋体",Font.PLAIN,12) );
+
+ pf.addArea( dtArea );
+
+ // 创建第二个节目
+ ProgramBxFile pf_2 = new ProgramBxFile( "P001",screen.getProfile() );
+ TextCaptionBxArea area = new TextCaptionBxArea( 0,0,160,64,screen.getProfile() );
+ TextBxPage page = new TextBxPage( "Led控制系统首选仰邦" );
+ page.setDisplayStyle( styles[4] );
+ area.addPage( page );
+ pf_2.addArea( area );
+
+ // 创建一个list
+ ArrayList plist = new ArrayList( );
+ plist.add( pf );
+ plist.add( pf_2 );
+
+ screen.writePrograms( plist );
+
+ // 如果需要,可以从控制器回读控制器上已有的节目列表
+ List pfs = screen.readProgramList();
+ for(String program:pfs)
+ {
+ System.out.println( program );
+ }
+
+ screen.disconnect();
+ }
+
+ // 更新动态区
+ // 六代卡中,只有BX-6E系列、BX-6EX系列和BX-6Q系列支持动态区
+ // 动态区是完全独立于节目,其显示内容可以按区域单独更新
+ // 动态区可以与节目一起播放,也可以单独播放
+ // 动态区显示内容存储于ARM,掉电不保存,没有刷新次数限制
+
+ // 动态区单独播放
+ public static void SendDynamic()throws Exception
+ {
+ DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]);
+
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+
+ screen.connect( ip,port );
+
+ // 创建动态区
+ // BX-6E BX-6EX系列支持4个动态区,BX-6Q系列支持32个动态区
+ DynamicBxAreaRule rule = new DynamicBxAreaRule();
+ // 设定动态区ID ,此处ID为0 ,多个动态区ID不能相同
+ rule.setId(0);
+ // 设定异步节目停止播放,仅播放动态区
+ // 0:与异步节目一起播放
+ // 1:异步节目 停止播放,仅播放动态区
+ // 2:当播放完节目编号坐高的异步节目后播放该动态区
+ rule.setImmediatePlay( (byte)1 );
+ // 设定动态区循环播放
+ // 0:循环显示
+ // 1:显示完成后静止显示最后一页数据
+ // 2:循环显示,超过设定时间后数据仍未更新时不再显示
+ // 3:循环显示,超过设定时间后数据仍未更新时显示Logo信息
+ // 4:循环显示,显示完成最后一页后就不再显示
+ rule.setRunMode( (byte)0 );
+
+ DynamicBxArea area = new DynamicBxArea( 0,0,160,32,screen.getProfile() );
+
+ TextBxPage page = new TextBxPage( "第一个动态区" );
+
+ page.setFont( new Font( "宋体",Font.PLAIN,12 ) );
+
+ page.setDisplayStyle( styles[2] );
+
+ area.addPage( page );
+
+ screen.writeDynamic( rule,area );
+
+ // 创建第二个动态区
+ DynamicBxAreaRule rule_2 = new DynamicBxAreaRule();
+ rule_2.setId( 1 );
+ rule_2.setImmediatePlay( (byte)1 );
+ rule_2.setRunMode( (byte)0 );
+ DynamicBxArea area_2 = new DynamicBxArea( 0,32,160,32,screen.getProfile() );
+ TextBxPage page_2 = new TextBxPage( "第二个动态区" );
+ page_2.setFont( new Font("宋体",Font.PLAIN,12) );
+ page_2.setDisplayStyle( styles[2] );
+ area_2.addPage( page_2 );
+ screen.writeDynamic( rule_2,area_2 );
+
+ screen.disconnect();
+ }
+
+ // 动态区和节目一起播放
+ public static void SendDynamicProgram()throws Exception
+ {
+ DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]);
+
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+
+ screen.connect( ip,port );
+
+ ProgramBxFile pf = new ProgramBxFile( 0,screen.getProfile() );
+
+ TextCaptionBxArea area = new TextCaptionBxArea( 0,0,160,32,screen.getProfile() );
+
+ TextBxPage page = new TextBxPage( "这是节目" );
+
+ area.addPage( page );
+
+ pf.addArea( area );
+
+ screen.writeProgram( pf );
+
+ DynamicBxAreaRule rule = new DynamicBxAreaRule();
+ rule.setId(0);
+ rule.setRunMode( (byte)0 );
+ // 新增动态区关联异步节目
+ // 一旦关联了某个异步节目,则该节目和动态区一起播放
+ // 设置动态区和节目关联
+ // 设定是否关联全部节目
+ // true: 所有异步节目播放是都允许播放该动态区
+ // false:由规则来决定
+ rule.setRelativeAllPrograms( false );
+ rule.addRelativeProgram( 0 );
+
+ DynamicBxArea dArea = new DynamicBxArea( 0,32,160,32,screen.getProfile() );
+
+ TextBxPage dPage = new TextBxPage( "这是动态区" );
+ dPage.setDisplayStyle( styles[2] );
+ dPage.setFont( new Font( "宋体",Font.PLAIN,12 ) );
+
+ dArea.addPage( dPage );
+
+ screen.writeDynamic( rule,dArea );
+
+ List pfs = screen.readProgramList();
+ for(String program : pfs)
+ {
+ System.out.println( program );
+ }
+
+ screen.disconnect();
+ }
+
+ // 关于语音播报区域
+ // 语音播放目前只有六代部分卡支持
+ public static void SendSound()throws Exception
+ {
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+
+ screen.connect( ip,port );
+
+ DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]);
+
+ ProgramBxFile pf = new ProgramBxFile( "P000",screen.getProfile() );
+
+ // 语音部分
+ TextCaptionBxArea area_sound = new TextCaptionBxArea( 0,0,160,16,screen.getProfile());
+ area_sound.setVoiceContent( "黑A12345请到淀粉副产品库DF-01月台" );// 该字符串会被语音播报
+ area_sound.setVoiceFlag( true );
+ area_sound.setVoiceReplayTimes( 2 );// 设置重复播报3次,如果不设置,默认一直播报
+ // 语音的其他设置都在area_sound中设置
+
+ // 显示部分_1
+ TextCaptionBxArea area_display_1 = new TextCaptionBxArea( 0,0,160,48,screen.getProfile() );
+ TextBxPage page_display_1 = new TextBxPage( "黑A12345" );
+ page_display_1.setFont( new Font( "宋体",Font.PLAIN,30 ) );
+ page_display_1.setVerticalAlignment( TextBinary.Alignment.CENTER );// 设置水平居中
+ page_display_1.setHorizontalAlignment( TextBinary.Alignment.CENTER );// 设置垂直居中
+ page_display_1.setDisplayStyle( styles[2] );
+ area_display_1.addPage( page_display_1 );
+
+ // 显示部分_2
+ TextCaptionBxArea area_display_2 = new TextCaptionBxArea( 0,48,160,48,screen.getProfile() );
+ TextBxPage page_diaplay_2 = new TextBxPage( "请到淀粉副产品库" );
+ page_diaplay_2.newLine( "DF-01月台" );
+ page_diaplay_2.setFont( new Font( "宋体",Font.PLAIN,16 ) );
+ page_diaplay_2.setVerticalAlignment( TextBinary.Alignment.CENTER );
+ page_diaplay_2.setHorizontalAlignment( TextBinary.Alignment.CENTER );
+ page_diaplay_2.setDisplayStyle( styles[2] );
+ area_display_2.addPage( page_diaplay_2 );
+
+ pf.addArea( area_sound );
+ pf.addArea( area_display_1 );
+ pf.addArea( area_display_2 );
+
+ screen.writeProgram( pf );
+
+ screen.disconnect();
+ }
+
+ // 其他一些常用命令
+ public static void SendCmd()throws Exception
+ {
+ Bx6GScreenClient screen = new Bx6GScreenClient( "MyScreen",new Bx6E() );
+ screen.connect( ip,port );
+ // 关机命令
+ screen.turnOff();
+ // 开机命令
+ screen.turnOn();
+ // ping命令
+ screen.ping();
+ // 查询控制器状态
+ screen.checkControllerStatus();
+ // 查询控制器内存
+ screen.checkMemVolumes();
+ // 校时命令
+ screen.syncTime();
+ // 锁定屏幕当前画面
+ screen.lock();
+ // 解除锁定屏幕当前画面
+ screen.unlock();
+ // 通过以下接口回读控制器状态
+ Bx6GScreen.Result result = screen.checkControllerStatus();
+ if(result.isOK())
+ {
+ ReturnControllerStatus status = result.reply;
+ status.getBrightness(); // 取得亮度值
+ status.getTemperature1(); // 取得温度传感器温度值
+ // status 还有很多接口,根据实际应用进行调用
+ }
+ else
+ {
+ ErrorType error = result.getError();
+ System.out.println( error );
+ }
+
+
+ // WindSpeed 字节数 2 风速(除以10为当前值) 0xffff时无效
+ // WindDirction 字节数 2 风向(当前值) 0xffff时无效
+ // PM2.5 字节数 2 PM2.5值(当前值) 0xffff时无效
+ // PM10 字节数 2 PM10值(当前值) 0xffff时无效
+ Bx6GScreenClient.Result result1 = screen.searchNetwork();
+ byte[] temp = result1.reply.getReserved1(); // 返回的前8个字节为上面注释里的定义
+ if(temp[1]*256+temp[0]!=0xffff)
+ {
+ System.out.println("风速:"+(temp[1]*256+temp[0])/10);
+ }
+ else
+ {
+ System.out.println("无数据");
+ }
+ if (temp[3]*256+temp[2]!=0xffff)
+ {
+ System.out.println("风向:"+(temp[3]*256+temp[2])); //0:0°北风 1:45°东北风 2:90°东风 3:135°东南风 4:180°南风 5:225°西南风 6:270°西风 7:315°西北风
+ }
+ else
+ {
+ System.out.println("无数据");
+ }
+
+
+ System.out.println("保留字节:"+temp);
+ }
+
+
+
+
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device/service/impl/DeviceAssignedServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device/service/impl/DeviceAssignedServiceImpl.java
index 0863413..f337ef4 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device/service/impl/DeviceAssignedServiceImpl.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device/service/impl/DeviceAssignedServiceImpl.java
@@ -1,7 +1,9 @@
package org.nl.acs.device.device.service.impl;
+import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -18,11 +20,13 @@ import org.nl.acs.device.device.service.mapper.DeviceAssignedMapper;
import org.nl.acs.common.base.PageInfo;
import org.nl.acs.common.base.QueryHelpMybatisPlus;
import org.nl.acs.common.base.service.impl.CommonServiceImpl;
+import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.utils.ConvertUtil;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.FileUtil;
import org.nl.acs.utils.PageUtil;
import org.nl.common.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@@ -41,7 +45,10 @@ import java.util.*;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class DeviceAssignedServiceImpl extends CommonServiceImpl implements DeviceAssignedService {
- private final DeviceAssignedMapper deviceAssignedMapper;
+ @Autowired
+ private DeviceAssignedMapper deviceAssignedMapper;
+ @Autowired
+ private InstructionService instructionService;
@Override
public PageInfo queryAll(DeviceAssignedQueryParam query, Pageable pageable) {
@@ -284,6 +291,34 @@ public class DeviceAssignedServiceImpl extends CommonServiceImpl rList = new ArrayList<>();
+ newList.stream().forEach(olDeviceAssigned -> {
+ String[] instNextDeviceCodes = (olDeviceAssigned.getInst_nextDevice_code() == null ? "" : olDeviceAssigned.getInst_nextDevice_code()).split(",");
+ if (instNextDeviceCodes.length > 1) {
+ Arrays.stream(instNextDeviceCodes)
+ .filter(inst_next_device_code -> ObjectUtil.isEmpty(instructionService.findReadyInstByEnd(inst_next_device_code)))
+ .forEach(inst_next_device_code -> {
+ DeviceAssigned deviceAssigned = new DeviceAssigned();
+ deviceAssigned.setAssigned_id(olDeviceAssigned.getAssigned_id());
+ deviceAssigned.setDevice_code(olDeviceAssigned.getDevice_code());
+ deviceAssigned.setInst_nextDevice_code(inst_next_device_code);
+ deviceAssigned.setTask_nextDevice_code(task_nextDeice_code);
+ deviceAssigned.setParam(olDeviceAssigned.getParam());
+ rList.add(deviceAssigned);
+ });
+ } else {
+ Arrays.stream(instNextDeviceCodes)
+ .forEach(inst_next_device_code -> {
+ DeviceAssigned deviceAssigned = new DeviceAssigned();
+ deviceAssigned.setAssigned_id(olDeviceAssigned.getAssigned_id());
+ deviceAssigned.setDevice_code(olDeviceAssigned.getDevice_code());
+ deviceAssigned.setInst_nextDevice_code(inst_next_device_code);
+ deviceAssigned.setTask_nextDevice_code(task_nextDeice_code);
+ deviceAssigned.setParam(olDeviceAssigned.getParam());
+ rList.add(deviceAssigned);
+ });
+ }
+ });
+ return ConvertUtil.convertList(rList, DeviceAssignedDto.class);
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
index fabc6f3..4ae2508 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
@@ -19,6 +19,7 @@ import org.nl.acs.device.driver.*;
import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.enums.*;
import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
+import org.nl.acs.ext.socket.Online;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
@@ -180,6 +181,16 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
*/
private String handBarcode;
+ /**
+ * 拣选出库终点
+ */
+ private static final List PINKS_TASK_NEXT_CODE = Arrays.asList("1308", "1311");
+
+ /**
+ * 不需要记录日志的点位
+ */
+ private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey());
+
@Override
public Device getDevice() {
@@ -193,7 +204,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
@Override
public void setLog(String key, Object newValue, Object oldValue) {
- logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "自动线程读取信号:" + key + ",由" + oldValue + "->" + newValue));
+ if (!No_SET_LOG_KEYS.contains(key)) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "自动线程读取信号:" + key + ",由" + oldValue + "->" + newValue));
+ }
}
@Override
@@ -223,8 +236,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
JSONObject param = new JSONObject();
param.put("devicePoint", this.currentDeviceCode);
param.put("status", PinkEnum.getWmsValueByAcsValue(String.valueOf(this.mode)));
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("Device")
.type("status")
.data(param)
@@ -235,6 +248,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
}
}
}
+// if (requireSuccess) {
+// //去查询是否有该点位的执行中的终点任务
+// //如果没有就复位请求标记
+// }
}
@Override
@@ -251,7 +268,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.isError = false;
this.message = "";
//编写业务逻辑方法
- if (this.mode == AppModeEnum.MODE_2.getCode() && this.move > 0 && (StrUtil.isNotEmpty(this.barcode) || StrUtil.isNotEmpty(this.handBarcode)) && !requireSuccess) {
+ if (this.mode == AppModeEnum.MODE_2.getCode() && this.move > 0 && ((StrUtil.isNotEmpty(this.barcode) && !StrUtil.equals("Noread", this.barcode)) || StrUtil.isNotEmpty(this.handBarcode)) && !requireSuccess) {
this.message = "正在执行查找入库任务";
this.createInInstruction();
} else if (this.mode == AppModeEnum.MODE_2.getCode() && this.move == 0 && !requireSuccess) {
@@ -301,8 +318,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireTime = currentTimeMillis;
JSONObject param = new JSONObject();
param.put("vehicle", this.barcode);
- CommonRequest request = CommonRequest
- .builder()
+ CommonRequest request = CommonRequest
+ .builder()
.service("DeviceInfo")
.type("vehicle")
.data(param)
@@ -328,8 +345,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireTime = currentTimeMillis;
JSONObject param = new JSONObject();
param.put(this.barcode, this.currentDeviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("palletInStorageTask")
.data(param)
@@ -353,8 +370,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireTime = currentTimeMillis;
JSONObject param = new JSONObject();
param.put(this.barcode, this.currentDeviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("groupInStorage")
.data(param)
@@ -382,8 +399,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireTime = currentTimeMillis;
JSONObject param = new JSONObject();
param.put(barcode, this.currentDeviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("groupInStorage")
.data(param)
@@ -462,6 +479,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
return;
}
+ if (!taskDto.getTask_code().endsWith("-") && !Online.isOnline) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
+ this.unExecutedMessage = "WMS离线,不生成指令, 在线状态: " + Online.isOnline;
+ }
//判断入库任务的起点是否是双向点位,即既是起点又是终点
boolean toWayFlag = Optional.ofNullable(this.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
//如果是双向点位
@@ -588,13 +609,13 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
String next_device_code = assignedDto.getInst_nextDevice_code();
Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device != null) {
- String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse("");
- if (StrUtil.isNotEmpty(pinkDeviceCode)) {
+ if (PINKS_TASK_NEXT_CODE.contains(taskDto.getNext_device_code())) {
+ String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse("");
Device pinkDevice = deviceAppService.findDeviceByCode(pinkDeviceCode);
if (pinkDevice != null && pinkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice.getDeviceDriver();
if (appearanceInspectionScannerConveyorDeviceDriver.getMode() == 0) {
- this.unExecutedMessage = "拣选台 '" + pinkDeviceCode + "' 未启用,查找出库任务结束";
+ this.unExecutedMessage = "拣选台 " + pinkDeviceCode + " 未启用,查找出库任务结束";
return;
}
Instruction inst = instructionService.findReadyInstByEnd(next_device_code);
@@ -626,11 +647,12 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
return;
}
- //判断终点是否是双向点位
+ if (!taskDto.getTask_code().endsWith("-") && !Online.isOnline) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
+ this.unExecutedMessage = "WMS离线,不生成指令, 在线状态: " + Online.isOnline;
+ }
boolean toWayFlag = Optional.ofNullable(cacheDevice.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
- //如果是双向点位
if (toWayFlag) {
- //获取终点所属输送线
String belongToConveyor = Optional.ofNullable(cacheDevice.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null);
if (belongToConveyor != null) {
Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyor);
@@ -705,7 +727,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
- this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), inst.getInstruction_code(), address));
+ this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey()), Arrays.asList(inst.getInstruction_code()));
+ this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), address));
this.requireSuccess = true;
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
index 4882acc..cdc88f3 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
@@ -18,6 +18,7 @@ import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor
import org.nl.acs.device.driver.stacker.double_stacker.enums.*;
import org.nl.acs.device.driver.storage.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
+import org.nl.acs.ext.socket.Online;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
@@ -314,6 +315,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
private static final List AGAIN_ERROR = Arrays.asList(ErrorEnum.MR.getCode(), ErrorEnum.KC.getCode(), ErrorEnum.ZD.getCode());
+ /**
+ * 不需要记录日志的点位
+ */
+ private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey());
+
@Override
public Device getDevice() {
return this.device;
@@ -326,7 +332,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
@Override
public void setLog(String key, Object newValue, Object oldValue) {
- logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "自动线程读取信号:" + key + ",由" + oldValue + "->" + newValue));
+ if (!No_SET_LOG_KEYS.contains(key)) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "自动线程读取信号:" + key + ",由" + oldValue + "->" + newValue));
+ }
}
@Override
@@ -538,7 +546,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
this.applyTask();
} else {
- this.sendPutInfoToPlc(frontInst, backInst);
+ if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendGetInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
+ this.sendGetInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendGetInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo != 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendGetInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo == 0 && this.back_forkCargo != 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendGetInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo != 0 && this.back_forkCargo != 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendPutInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo == 0 && this.back_forkCargo != 0 && ObjectUtil.isEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ this.sendPutInfoToPlc(frontInst, backInst);
+ } else if (this.front_forkCargo != 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
+ this.sendPutInfoToPlc(frontInst, backInst);
+ }
this.requireSuccess = true;
}
}
@@ -704,6 +728,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
+
/**
* 放货阻挡、满入更改任务指令终点信息
*
@@ -789,6 +814,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
if (ObjectUtil.isNotEmpty(frontTaskDto) && ObjectUtil.isNotEmpty(backTaskDto)) {
+ if ((!frontTaskDto.getTask_code().endsWith("-") || !backTaskDto.getTask_code().endsWith("-")) && !Online.isOnline) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
+ this.unExecutedMessage = "WMS离线,不生成移库指令, 在线状态: " + Online.isOnline;
+ }
Instruction frontInst = new Instruction();
setInstruction(frontInst, frontTaskDto);
Instruction backInst = new Instruction();
@@ -809,6 +838,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
this.unExecutedMessage = null;
this.requireSuccess = true;
} else if (ObjectUtil.isNotEmpty(frontTaskDto)) {
+ if (!frontTaskDto.getTask_code().endsWith("-") && !Online.isOnline) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
+ this.unExecutedMessage = "WMS离线,不生成移库指令, 在线状态: " + Online.isOnline;
+ }
Instruction frontInst = new Instruction();
setInstruction(frontInst, frontTaskDto);
try {
@@ -824,6 +857,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
this.unExecutedMessage = null;
this.requireSuccess = true;
} else if (ObjectUtil.isNotEmpty(backTaskDto)) {
+ if (!backTaskDto.getTask_code().endsWith("-") && !Online.isOnline) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
+ this.unExecutedMessage = "WMS离线,不生成移库指令, 在线状态: " + Online.isOnline;
+ }
Instruction backInst = new Instruction();
setInstruction(backInst, backTaskDto);
try {
@@ -1315,6 +1352,99 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
+ private void sendGetInfoToPlc(Instruction frontInst, Instruction backInst) {
+ if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && isBindGet(frontInst, backInst)) {
+ String start_device_code = frontInst.getStart_device_code();
+ Device start_device = deviceAppService.findDeviceByCode(start_device_code);
+ if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
+ this.writing(this.getFBKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_THREE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ } else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ Integer x = this.handExtraIntValue(start_device, "currentX");
+ Integer y = this.handExtraIntValue(start_device, "currentY");
+ Integer z = this.handExtraIntValue(start_device, "currentZ");
+ this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_THREE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ }
+ } else if (this.front_forkCargo == 0) {
+ String start_device_code = frontInst.getStart_device_code();
+ Device start_device = deviceAppService.findDeviceByCode(start_device_code);
+ if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
+ this.writing(this.getFBKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ } else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ Integer x = this.handExtraIntValue(start_device, "currentX");
+ Integer y = this.handExtraIntValue(start_device, "currentY");
+ Integer z = this.handExtraIntValue(start_device, "currentZ");
+ this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ }
+ } else if (this.back_forkCargo == 0) {
+ String start_device_code = backInst.getStart_device_code();
+ Device start_device = deviceAppService.findDeviceByCode(start_device_code);
+ if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
+ this.writing(this.getFBKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ } else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ Integer x = this.handExtraIntValue(start_device, "currentX");
+ Integer y = this.handExtraIntValue(start_device, "currentY");
+ Integer z = this.handExtraIntValue(start_device, "currentZ");
+ this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ }
+ }
+ } else if (ObjectUtil.isNotEmpty(frontInst) && !isBindGet(frontInst, backInst)) {
+ String start_device_code = frontInst.getStart_device_code();
+ Device start_device = deviceAppService.findDeviceByCode(start_device_code);
+ if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
+ this.writing(this.getFrontKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), frontInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ } else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ Integer x = this.handExtraIntValue(start_device, "currentX");
+ Integer y = this.handExtraIntValue(start_device, "currentY");
+ Integer z = this.handExtraIntValue(start_device, "currentZ");
+ this.writing(this.getFrontKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ }
+ } else if (ObjectUtil.isNotEmpty(backInst) && !isBindGet(frontInst, backInst)) {
+ String start_device_code = backInst.getStart_device_code();
+ Device start_device = deviceAppService.findDeviceByCode(start_device_code);
+ if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
+ this.writing(this.getBackKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(backInst.getFrom_x())), Integer.parseInt(backInst.getFrom_y()), Integer.parseInt(backInst.getFrom_z()), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ } else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ Integer x = this.handExtraIntValue(start_device, "currentX");
+ Integer y = this.handExtraIntValue(start_device, "currentY");
+ Integer z = this.handExtraIntValue(start_device, "currentZ");
+ this.writing(this.getBackKeys(), Arrays.asList(x, y, z, backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
+ }
+ } else {
+ this.unExecutedMessage = "未执行放货原因, 堆垛机上报任务号不存在";
+ }
+ }
+
+ private boolean isBindGet(Instruction frontInst, Instruction backInst) {
+ if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
+ String front_start_device_code = frontInst.getStart_device_code();
+ String back_start_device_code = backInst.getStart_device_code();
+ Device front_device = deviceAppService.findDeviceByCode(front_start_device_code);
+ Device back_device = deviceAppService.findDeviceByCode(back_start_device_code);
+ String back_device_code = this.handExtraStringValue(front_device, "getLinkDeviceCode");
+
+ if (instanceStorage(front_device) && instanceStorage(back_device)) {
+ String front_from_x = frontInst.getFrom_x();
+ String front_from_y = frontInst.getFrom_y();
+ String front_from_z = frontInst.getFrom_z();
+
+ String back_from_x = backInst.getFrom_x();
+ String back_from_y = backInst.getFrom_y();
+ String back_from_z = backInst.getFrom_z();
+ boolean flagX = StrUtil.equals(front_from_x, back_from_x);
+ // TODO 需要验证规则是否生效
+ boolean flagY = ((Integer.parseInt(front_from_y) - 1) / 4 == (Integer.parseInt(back_from_y) - 1) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(back_from_y) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(back_from_z) % 4) == 4);
+ boolean flagZ = StrUtil.equals(front_from_z, back_from_z);
+ if (flagX && flagY && flagZ) {
+ return true;
+ }
+ } else if (StrUtil.equals(back_start_device_code, back_device_code)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void sendPutInfoToPlc(Instruction frontInst, Instruction backInst) {
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst) && isBindPut(frontInst, backInst)) {
String next_device_code = frontInst.getNext_device_code();
@@ -1372,7 +1502,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
String back_to_y = backInst.getTo_y();
String back_to_z = backInst.getTo_z();
boolean flagX = StrUtil.equals(front_to_x, back_to_x);
- boolean flagY = (Integer.parseInt(front_to_y) / 4 == Integer.parseInt(back_to_y) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_y) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_z) % 4) == 4);
+ // TODO 需要验证规则是否生效
+ boolean flagY = ((Integer.parseInt(front_to_y) - 1) / 4 == (Integer.parseInt(back_to_y) - 1) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_y) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_z) % 4) == 4);
boolean flagZ = StrUtil.equals(front_to_z, back_to_z);
if (flagX && flagY && flagZ) {
return true;
@@ -1407,30 +1538,37 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
* 满入
*/
private void mR(Integer task, String type) {
- Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
- if (inst != null) {
- JSONObject param = new JSONObject();
- param.put("taskCode", inst.getTask_code());
- CommonRequest request =
- CommonRequest.builder()
- .service("ErrorTask")
- .type("rm")
- .data(param)
- .build();
- UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
- if (response.isSuccess()) {
- JSONObject data = response.getData();
- String devicePoint = data.getString("devicePoint");
- if (devicePoint != null && devicePoint.contains("-") && devicePoint.split("-").length == 3) {
- this.updateNextPointCode(devicePoint, inst);
- //清警
- this.writing(ItemProtocol.TO_COMMAND.getKey(), 5);
- if (ForkTypeEnum.FRONT.getCode().equals(type)) {
- this.sendPutInfoToPlc(inst, null);
- } else {
- this.sendPutInfoToPlc(null, inst);
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
+ if (inst != null) {
+ JSONObject param = new JSONObject();
+ param.put("task_code", inst.getTask_code());
+ param.put("struct_code", inst.getNext_point_code());
+ CommonRequest request =
+ CommonRequest.builder()
+ .service("ErrorTask")
+ .type("rm")
+ .data(param)
+ .build();
+ UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
+ if (response.isSuccess()) {
+ JSONObject data = response.getData();
+ String devicePoint = data.getString("point_code2");
+ if (devicePoint != null && devicePoint.contains("-") && devicePoint.split("-").length == 3) {
+ this.updateNextPointCode(devicePoint, inst);
+ //清警
+ this.writing(ItemProtocol.TO_COMMAND.getKey(), 5);
+ if (ForkTypeEnum.FRONT.getCode().equals(type)) {
+ this.sendPutInfoToPlc(inst, null);
+ } else {
+ this.sendPutInfoToPlc(null, inst);
+ }
+ this.againRequireSuccess = true;
}
- this.againRequireSuccess = true;
}
}
}
@@ -1441,21 +1579,28 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
*/
@SneakyThrows
private void kC(Integer task) {
- Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
- if (inst != null) {
- JSONObject param = new JSONObject();
- param.put("taskCode", inst.getTask_code());
- CommonRequest request = CommonRequest
- .builder()
- .service("ErrorTask")
- .type("ck")
- .data(param)
- .build();
- UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
- if (response.isSuccess()) {
- instructionService.cancelInstAndTask(inst.getInstruction_id());
- this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
- this.againRequireSuccess = true;
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
+ if (inst != null) {
+ JSONObject param = new JSONObject();
+ param.put("task_code", inst.getTask_code());
+ param.put("struct_code", inst.getStart_point_code());
+ CommonRequest request = CommonRequest
+ .builder()
+ .service("ErrorTask")
+ .type("ck")
+ .data(param)
+ .build();
+ UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
+ if (response.isSuccess()) {
+ instructionService.cancelInstAndTask(inst.getInstruction_id());
+ this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
+ this.againRequireSuccess = true;
+ }
}
}
}
@@ -1464,23 +1609,39 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
* 取货阻挡
*/
private void getzD(Integer task) {
- Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
- if (inst != null) {
- JSONObject param = new JSONObject();
- param.put("taskCode", task);
- //通知WMS取货阻挡
- CommonRequest request =
- CommonRequest.builder()
- .service("ErrorTask")
- .type("czd")
- .data(param)
- .build();
- UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
- if (response.isSuccess()) {
- //取消ACS指令和任务
- instructionService.cancelInstAndTaskNoSendWms(inst.getInstruction_id());
- this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
- this.againRequireSuccess = true;
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
+ if (inst != null) {
+ JSONObject param = new JSONObject();
+ param.put("task_code", inst.getTask_code());
+ param.put("struct_code", getZdPoint(inst.getStart_point_code()));
+ //通知WMS取货阻挡
+ CommonRequest request =
+ CommonRequest.builder()
+ .service("ErrorTask")
+ .type("czd")
+ .data(param)
+ .build();
+ UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
+ if (response.isSuccess()) {
+ //取消ACS指令和任务
+ TaskDto taskDto = taskService.findByCodeFromCache(inst.getTask_code());
+ String next_device_code = taskDto.getNext_device_code();
+ instructionService.cancelInstAndTaskNoSendWms(inst.getInstruction_id());
+ Device next_device = deviceAppService.findDeviceByCode(next_device_code);
+ if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
+ AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) next_device.getDeviceDriver();
+ if (appearanceInspectionScannerConveyorDeviceDriver.isRequireSuccess()) {
+ appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(false);
+ }
+ }
+ this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
+ this.againRequireSuccess = true;
+ }
}
}
}
@@ -1489,34 +1650,56 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
* 放货阻挡
*/
private void putzD(Integer task, String type) {
- Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
- if (inst != null) {
- JSONObject param = new JSONObject();
- param.put("taskCode", task);
- CommonRequest request =
- CommonRequest.builder()
- .service("ErrorTask")
- .type("rzd")
- .data(param)
- .build();
- UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
- if (response.isSuccess()) {
- JSONObject data = response.getData();
- String devicePoint = data.getString("devicePoint");
- if (devicePoint != null && devicePoint.contains("-") && devicePoint.split("-").length == 3) {
- this.updateNextPointCode(devicePoint, inst);
- this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
- if (ForkTypeEnum.FRONT.getCode().equals(type)) {
- this.sendPutInfoToPlc(inst, null);
- } else {
- this.sendPutInfoToPlc(null, inst);
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
+ if (inst != null) {
+ JSONObject param = new JSONObject();
+ param.put("task_code", inst.getTask_code());
+ param.put("struct_code", getZdPoint(inst.getNext_point_code()));
+ CommonRequest request = CommonRequest.builder()
+ .service("ErrorTask")
+ .type("rzd")
+ .data(param)
+ .build();
+ UnifiedResponse response = acsToWmsService.apply(request, JSONObject.class);
+ if (response.isSuccess()) {
+ JSONObject data = response.getData();
+ String devicePoint = data.getString("point_code2");
+ if (devicePoint != null && devicePoint.contains("-") && devicePoint.split("-").length == 3) {
+ this.updateNextPointCode(devicePoint, inst);
+ this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum());
+ if (ForkTypeEnum.FRONT.getCode().equals(type)) {
+ this.sendPutInfoToPlc(inst, null);
+ } else {
+ this.sendPutInfoToPlc(null, inst);
+ }
+ this.againRequireSuccess = true;
}
- this.againRequireSuccess = true;
}
}
}
}
+
+ private String getZdPoint(String point_code) {
+ if (point_code == null || point_code.length() != 9) {
+ return null;
+ }
+ String type = point_code.substring(0, 1);
+ int row = Integer.parseInt(point_code.substring(1, 3));
+ String rest = point_code.substring(3);
+ if (row % 2 == 0) {
+ row -= 1;
+ } else {
+ row += 1;
+ }
+ return String.format("%s%02d%s", type, row, rest);
+ }
+
/**
* 封装指令
*
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java
index 0bb0cf8..c4435ab 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java
@@ -68,7 +68,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
@Override
public void execute() {
- device_code = this.getDeviceCode();
+ this.device_code = this.getDeviceCode();
Boolean applyTaskFlag = Optional.ofNullable(this.getExtraValue().get("applyTask")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (!applyTaskFlag) return;
long currentTimeMillis = System.currentTimeMillis();
@@ -96,8 +96,8 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (StrUtil.isEmpty(getLinkDeviceCode)) {
JSONObject param = new JSONObject();
param.put(appearanceInspectionScannerConveyorDeviceDriver.getBarcode(), deviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("groupInStorage")
.data(param)
@@ -108,6 +108,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
this.requireSuccess = true;
}
+ break;
} else {
Device linkDevice = deviceAppservice.findDeviceByCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(linkDevice) && linkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
@@ -118,8 +119,8 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
JSONObject param = new JSONObject();
param.put(appearanceInspectionScannerConveyorDeviceDriver.getBarcode(), deviceCode);
param.put(appearanceInspectionScannerConveyorDeviceDriver2.getBarcode(), getLinkDeviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("groupInStorage")
.data(param)
@@ -131,13 +132,14 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
appearanceInspectionScannerConveyorDeviceDriver2.setWithStationRequireSuccess(true);
}
+ break;
}
} else {
if (System.currentTimeMillis() - appearanceInspectionScannerConveyorDeviceDriver.getRequireInTaskTime() > waitTime * 1000) {
JSONObject param = new JSONObject();
param.put(appearanceInspectionScannerConveyorDeviceDriver.getBarcode(), deviceCode);
- CommonRequest request =
- CommonRequest.builder()
+ CommonRequest request =
+ CommonRequest.builder()
.service("InStorage")
.type("groupInStorage")
.data(param)
@@ -148,6 +150,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
this.requireSuccess = true;
}
+ break;
}
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/AbstraceServer.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/AbstraceServer.java
new file mode 100644
index 0000000..5824e33
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/AbstraceServer.java
@@ -0,0 +1,44 @@
+package org.nl.acs.ext.socket;
+
+import io.netty.bootstrap.AbstractBootstrap;
+import io.netty.channel.Channel;
+
+import java.net.SocketAddress;
+
+/*
+ * @author ZZQ
+ * @Date 2024/1/22 10:01
+ */
+public abstract class AbstraceServer {
+
+
+ public AbstraceServer(SocketAddress address) {
+ this.address = address;
+ if (channel!=null){
+ doDestroy();
+ }
+ doOpen();
+ doConnect();
+ }
+
+ public AbstractBootstrap server;
+ public SocketAddress address;
+ public Channel channel;
+
+ public abstract void doOpen();
+
+ public void doDestroy(){
+ if (channel!=null){
+ channel.close();
+ }
+ };
+
+ public abstract void doConnect() ;
+
+ public void doDisConnect(){
+ if (channel!=null){
+ channel.close();
+ doConnect();
+ }
+ };
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServer.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServer.java
new file mode 100644
index 0000000..683e023
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServer.java
@@ -0,0 +1,82 @@
+package org.nl.acs.ext.socket;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.timeout.IdleStateHandler;
+import io.netty.util.concurrent.Future;
+
+import java.net.SocketAddress;
+import java.util.concurrent.TimeUnit;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+/*
+ * @author ZZQ
+ * @Date 2024/7/5 14:53
+ */
+public class HeartServer extends AbstraceServer {
+
+ private static EventLoopGroup boss = new NioEventLoopGroup();
+ private static EventLoopGroup worker = new NioEventLoopGroup();
+
+ public HeartServer(SocketAddress address) {
+ super(address);
+ }
+
+ // 非阻塞IO线程组
+ @Override
+ public void doOpen() {
+ ServerBootstrap bootstrap = new ServerBootstrap();
+ AbstraceServer body = this;
+ bootstrap
+ .group(boss, worker)
+ .channel(NioServerSocketChannel.class)
+// .childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE)
+ .childHandler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(SocketChannel ch) throws Exception {
+ ch.pipeline()
+ .addLast("client-idle-handler", new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
+ .addLast( new StringEncoder())
+ .addLast( new StringDecoder())
+ .addLast(new HeartServerHandler(body));
+ }
+ });
+ server = bootstrap;
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> this.doDestroy()));
+
+ }
+
+ @Override
+ public void doDestroy(){
+ System.out.println("--------服务停机--------");
+ if (channel != null) {
+ channel.close();
+ }
+ Future> bossGroupShutdownFuture = boss.shutdownGracefully();
+ Future> workerGroupShutdownFuture = worker.shutdownGracefully();
+ bossGroupShutdownFuture.syncUninterruptibly();
+ workerGroupShutdownFuture.syncUninterruptibly();
+ }
+
+ @Override
+ public void doConnect() {
+ ChannelFuture future = server.bind(address);
+ boolean ret = future.awaitUninterruptibly(3000, MILLISECONDS);
+ if (ret && future.isSuccess()) {
+ Channel newChannel = future.channel();
+ if (channel != null) {
+ channel.close();
+ channel = newChannel;
+ }
+ } else if (future.cause() != null) {
+ Throwable cause = future.cause();
+ cause.printStackTrace();
+ }
+ }
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServerHandler.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServerHandler.java
new file mode 100644
index 0000000..0945067
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/HeartServerHandler.java
@@ -0,0 +1,56 @@
+package org.nl.acs.ext.socket;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.handler.timeout.IdleState;
+import io.netty.handler.timeout.IdleStateEvent;
+
+/*
+ * @author ZZQ
+ * @Date 2024/1/22 10:24
+ */
+public class HeartServerHandler extends SimpleChannelInboundHandler {
+ private AbstraceServer server;
+
+ public HeartServerHandler(AbstraceServer server) {
+ this.server = server;
+ }
+
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ Online.isOnline = false;
+ System.out.println("服务端断开连接-----");
+ ctx.close();
+ super.channelInactive(ctx);
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ Online.isOnline = true;
+ System.out.println("服务端收到连接-----连接");
+ super.channelActive(ctx);
+ }
+
+
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
+ if (!Online.isOnline) {
+ Online.isOnline = true;
+ }
+ System.out.println("接收到消息" + msg.toString());
+ }
+
+ @Override
+ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+ if (evt instanceof IdleStateEvent) {
+ IdleStateEvent stateEvent = (IdleStateEvent) evt;
+ System.out.println(stateEvent.state());
+ if (stateEvent.state() == IdleState.READER_IDLE) {
+ Online.isOnline = false;
+ System.out.println("--------手动关闭连接--------");
+ ctx.close();
+ }
+ }
+ super.userEventTriggered(ctx, evt);
+ }
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/Online.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/Online.java
new file mode 100644
index 0000000..058e713
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/socket/Online.java
@@ -0,0 +1,10 @@
+package org.nl.acs.ext.socket;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/7/9
+ */
+public class Online {
+ public static boolean isOnline = false;
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java
index d3fb1d7..36d7d92 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/req/CommonRequest.java
@@ -20,7 +20,7 @@ import org.nl.config.IdUtil;
@Builder
@AllArgsConstructor
@NoArgsConstructor
-public class CommonRequest {
+public class CommonRequest {
private String service;
@@ -35,7 +35,7 @@ public class CommonRequest {
@Builder.Default
private String trace_id = "trace_id_" + IdUtil.getStringId();
- private Object data;
+ private T data;
public JSONArray handleArray() {
@@ -43,6 +43,6 @@ public class CommonRequest {
}
public JSONObject handleObject() {
- return (JSONObject) data;
+ return JSONObject.parseObject(JSON.toJSONString(data));
}
}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/GateWayService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/GateWayService.java
index cdeab08..00688e7 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/GateWayService.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/GateWayService.java
@@ -2,8 +2,6 @@ package org.nl.acs.ext.wms.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.wms.data.req.CommonRequest;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -17,8 +15,6 @@ public class GateWayService {
@Autowired
private WmsToAcsService wmsToAcsService;
- @Autowired
- private LuceneExecuteLogService logService;
public JSONObject apply(CommonRequest request) {
JSONObject resp = new JSONObject();
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
index 3727770..379761c 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
@@ -69,7 +69,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", "任务号不能为空");
+ json.put("msg", "任务号不能为空");
errArr.add(json);
continue;
}
@@ -77,7 +77,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", "起点不能为空");
+ json.put("msg", "起点不能为空");
errArr.add(json);
continue;
}
@@ -85,7 +85,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", "终点不能为空");
+ json.put("msg", "终点不能为空");
errArr.add(json);
continue;
}
@@ -141,7 +141,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", "存在相同的任务号:" + task_code);
+ json.put("msg", "存在相同的任务号:" + task_code);
errArr.add(json);
continue;
}
@@ -151,7 +151,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code);
+ json.put("msg", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code);
errArr.add(json);
continue;
}
@@ -161,7 +161,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", start_device_code + " 该设备号未找到对应点位");
+ json.put("msg", start_device_code + " 该设备号未找到对应点位");
errArr.add(json);
continue;
}
@@ -169,7 +169,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", next_device_code + " 该设备号未找到对应点位");
+ json.put("msg", next_device_code + " 该设备号未找到对应点位");
errArr.add(json);
continue;
}
@@ -206,7 +206,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
- json.put("message", e.getMessage());
+ json.put("msg", e.getMessage());
errArr.add(json);
continue;
}
@@ -222,7 +222,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
} else {
resp.put("msg", "false");
}
- resp.put("errArr", errArr);
+ resp.put("data", errArr);
}
log.info("crateTask--------------:输出参数:" + JSON.toJSONString(resp));
return resp;
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java
index 046c4fa..1a397ca 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java
@@ -543,4 +543,5 @@ public interface InstructionService extends CommonService {
Instruction findReadyInstBySpecialDeviceAndStartDeviceCode(List getDeviceCodeList, List specialGetDevice, List specialPutDevice, String front_start_device_code);
void cancelInstAndTaskNoSendWms(String instruction_id);
+
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
index 779f3ff..bf94293 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
@@ -1800,7 +1800,19 @@ public class InstructionServiceImpl extends CommonServiceImpl inst.getStart_device_code().equals(link_device_code))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(inst.getTo_y()))
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getTo_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getTo_x())))
- .filter(inst -> (Integer.parseInt(frontInst.getTo_y()) / 4 == Integer.parseInt(inst.getTo_y()) / 4) && (((Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 2) || (Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 4))
+ // .filter(inst -> ((Integer.parseInt(frontInst.getTo_y()) - 1) / 4 == (Integer.parseInt(inst.getTo_y()) - 1) / 4) && (((Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 2) || (Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 4))
+ .filter(inst -> {
+ int frontToY = Integer.parseInt(frontInst.getTo_y());
+ int instToY = Integer.parseInt(inst.getTo_y());
+ int frontGroup = (frontToY - 1) / 4;
+ int instGroup = (instToY - 1) / 4;
+ if (frontGroup != instGroup) {
+ return false;
+ }
+ int frontMod = frontToY % 4;
+ int instMod = instToY % 4;
+ return (frontMod + instMod == 2 || frontMod + instMod == 4);
+ })
.filter(inst -> Integer.parseInt(inst.getTo_z()) == Integer.parseInt(frontInst.getTo_z()))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
@@ -1850,7 +1862,20 @@ public class InstructionServiceImpl extends CommonServiceImpl inst.getNext_device_code().equals(link_device_code))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getFrom_y()) && !currentNoY.contains(inst.getFrom_y()))
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getFrom_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())))
- .filter(inst -> (Integer.parseInt(frontInst.getFrom_y()) / 4 == Integer.parseInt(inst.getFrom_y()) / 4) && (((Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 2) || (Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 4))
+ //.filter(inst -> ((Integer.parseInt(frontInst.getFrom_y()) - 1) / 4 == (Integer.parseInt(inst.getFrom_y()) - 1) / 4) && (((Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 2) || (Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 4))
+ .filter(inst -> {
+ int frontY = Integer.parseInt(frontInst.getFrom_y());
+ int instY = Integer.parseInt(inst.getFrom_y());
+ int frontGroup = (frontY - 1) / 4;
+ int instGroup = (instY - 1) / 4;
+ if (frontGroup != instGroup) {
+ return false;
+ }
+ int frontMod = frontY % 4;
+ int instMod = instY % 4;
+ return (frontMod + instMod == 2 || frontMod + instMod == 4);
+ })
+
.filter(inst -> Integer.parseInt(inst.getFrom_z()) == Integer.parseInt(frontInst.getFrom_z()))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
@@ -1947,13 +1972,14 @@ public class InstructionServiceImpl extends CommonServiceImpl impleme
private DeviceAssignedService deviceAssignedService;
@Autowired
private InstructionService instructionService;
+ @Autowired
+ private RedisUtils redisUtils;
/**
* 缓存
@@ -1252,16 +1256,20 @@ public class TaskServiceImpl extends CommonServiceImpl impleme
String hasWms = paramService.findByCode(AcsConfig.HAS_WMS).getValue();
if (!StrUtil.startWith(taskDto.getTask_code(), CommonFinalParam.HYPHEN_) && StrUtil.equals(hasWms, CommonFinalParam.ONE)) {
JSONObject param = new JSONObject();
- param.put("taskCode", entity.getTask_code());
+ param.put("task_code", entity.getTask_code());
param.put("status", WmsTaskStatusEnum.getWmsStatusByAcsStatus(taskDto.getTask_status()));
- CommonRequest request =
+ CommonRequest request =
CommonRequest
- .builder()
+ .builder()
.service("Task")
.type("status")
.data(param)
.build();
- acstowmsService.apply(request);
+ UnifiedResponse