rev:提交
This commit is contained in:
@@ -462,6 +462,78 @@
|
||||
<artifactId>hivemq-mqtt-client</artifactId>
|
||||
<version>1.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lib.bx06</groupId>
|
||||
<artifactId>bx06.message</artifactId>
|
||||
<version>0.6.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.lib.bx06</groupId>
|
||||
<artifactId>bx06</artifactId>
|
||||
<version>0.6.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>gnu.io</groupId>
|
||||
<artifactId>rxtx</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.simpleframework</groupId>
|
||||
<artifactId>simple-xml</artifactId>
|
||||
<version>2.7.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.stream</groupId>
|
||||
<artifactId>stax</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.stream</groupId>
|
||||
<artifactId>stax-api</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uia</groupId>
|
||||
<artifactId>uia-comm</artifactId>
|
||||
<version>0.5.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uia</groupId>
|
||||
<artifactId>uia-message</artifactId>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uia</groupId>
|
||||
<artifactId>uia-utils</artifactId>
|
||||
<version>0.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xmlpull</groupId>
|
||||
<artifactId>xpp3</artifactId>
|
||||
<version>1.1.3.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Instruction> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ProgramBxFile> plist = new ArrayList<ProgramBxFile>( );
|
||||
plist.add( pf );
|
||||
plist.add( pf_2 );
|
||||
|
||||
screen.writePrograms( plist );
|
||||
|
||||
// 如果需要,可以从控制器回读控制器上已有的节目列表
|
||||
List<String> 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<String> 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<ReturnControllerStatus> 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<ReturnNetwork> 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<DeviceAssignedMapper, DeviceAssigned> implements DeviceAssignedService {
|
||||
|
||||
private final DeviceAssignedMapper deviceAssignedMapper;
|
||||
@Autowired
|
||||
private DeviceAssignedMapper deviceAssignedMapper;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
|
||||
@Override
|
||||
public PageInfo<DeviceAssignedDto> queryAll(DeviceAssignedQueryParam query, Pageable pageable) {
|
||||
@@ -284,6 +291,34 @@ public class DeviceAssignedServiceImpl extends CommonServiceImpl<DeviceAssignedM
|
||||
}
|
||||
});
|
||||
});
|
||||
return ConvertUtil.convertList(newList, DeviceAssignedDto.class);
|
||||
List<DeviceAssigned> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> PINKS_TASK_NEXT_CODE = Arrays.asList("1308", "1311");
|
||||
|
||||
/**
|
||||
* 不需要记录日志的点位
|
||||
*/
|
||||
private static final List<String> 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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<JSONObject> request = CommonRequest
|
||||
.<JSONObject>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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Integer> AGAIN_ERROR = Arrays.asList(ErrorEnum.MR.getCode(), ErrorEnum.KC.getCode(), ErrorEnum.ZD.getCode());
|
||||
|
||||
|
||||
/**
|
||||
* 不需要记录日志的点位
|
||||
*/
|
||||
private static final List<String> 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<JSONObject> 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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>builder()
|
||||
.service("ErrorTask")
|
||||
.type("rm")
|
||||
.data(param)
|
||||
.build();
|
||||
UnifiedResponse<JSONObject> 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<JSONObject> 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<JSONObject> request = CommonRequest
|
||||
.<JSONObject>builder()
|
||||
.service("ErrorTask")
|
||||
.type("ck")
|
||||
.data(param)
|
||||
.build();
|
||||
UnifiedResponse<JSONObject> 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<JSONObject> 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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>builder()
|
||||
.service("ErrorTask")
|
||||
.type("czd")
|
||||
.data(param)
|
||||
.build();
|
||||
UnifiedResponse<JSONObject> 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<JSONObject> 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<JSONObject> request = CommonRequest.<JSONObject>builder()
|
||||
.service("ErrorTask")
|
||||
.type("rzd")
|
||||
.data(param)
|
||||
.build();
|
||||
UnifiedResponse<JSONObject> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装指令
|
||||
*
|
||||
|
||||
@@ -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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>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<JSONObject> request =
|
||||
CommonRequest.<JSONObject>builder()
|
||||
.service("InStorage")
|
||||
.type("groupInStorage")
|
||||
.data(param)
|
||||
@@ -148,6 +150,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -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<SocketChannel>() {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import org.nl.config.IdUtil;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CommonRequest {
|
||||
public class CommonRequest<T> {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -543,4 +543,5 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
||||
Instruction findReadyInstBySpecialDeviceAndStartDeviceCode(List<String> getDeviceCodeList, List<String> specialGetDevice, List<String> specialPutDevice, String front_start_device_code);
|
||||
|
||||
void cancelInstAndTaskNoSendWms(String instruction_id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1800,7 +1800,19 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
.filter(inst -> 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<InstructionMapper,
|
||||
.filter(inst -> 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<InstructionMapper,
|
||||
if (entity == null) {
|
||||
throw new BadRequestException(LangProcess.msg("error_sysAuth"));
|
||||
}
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setInstruction_status(InstructionStatusEnum.CANCEL.getIndex());
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
// String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
// String now = DateUtil.now();
|
||||
// entity.setUpdate_time(now);
|
||||
// entity.setUpdate_by(currentUsername);
|
||||
// entity.setInstruction_status(InstructionStatusEnum.CANCEL.getIndex());
|
||||
// InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
// instructionMapper.updateById(ins);
|
||||
instructionMapper.deleteById(instruction_id);
|
||||
removeByCodeFromCache(entity.getInstruction_code());
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(entity.getTask_code());
|
||||
if (taskDto != null) {
|
||||
@@ -1961,5 +1987,4 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.nl.acs.device.device.service.DeviceService;
|
||||
import org.nl.acs.device.device.service.dto.DeviceAssignedDto;
|
||||
import org.nl.acs.device.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device.driver.DeviceDriverDefination;
|
||||
import org.nl.acs.ext.UnifiedResponse;
|
||||
import org.nl.acs.ext.wms.data.req.CommonRequest;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
@@ -56,6 +57,7 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.dto.TaskQueryParam;
|
||||
import org.nl.acs.task.service.mapper.TaskMapper;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
@@ -105,6 +107,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
private DeviceAssignedService deviceAssignedService;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
/**
|
||||
* 缓存
|
||||
@@ -1252,16 +1256,20 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> 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<JSONObject> request =
|
||||
CommonRequest
|
||||
.builder()
|
||||
.<JSONObject>builder()
|
||||
.service("Task")
|
||||
.type("status")
|
||||
.data(param)
|
||||
.build();
|
||||
acstowmsService.apply(request);
|
||||
UnifiedResponse<Object> resp = acstowmsService.apply(request);
|
||||
if (!resp.isSuccess()) {
|
||||
//将失败信息存储到redis中,LMS自己去取并做处理
|
||||
redisUtils.sSet("task:status", JSON.toJSONString(request));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1284,7 +1292,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGV_TYPE).getValue(), "3")) {
|
||||
try {
|
||||
JSONObject reqParam = new JSONObject();
|
||||
reqParam.put("id",taskDto.getTask_code());
|
||||
reqParam.put("id", taskDto.getTask_code());
|
||||
agvService.markComplete(reqParam);
|
||||
} catch (Exception e) {
|
||||
log.error("关闭运单异常,原因:{}", e.getMessage());
|
||||
@@ -1310,7 +1318,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findReadyTaskByXDeviceCode(List<String> xDeviceCodeList, String noY) {
|
||||
// String currentNoY = noY == null ? "" : noY;
|
||||
// String currentNoY = noY == null ? "" : noY;
|
||||
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(",")));
|
||||
|
||||
return Optional.ofNullable(this.tasks)
|
||||
@@ -1320,7 +1328,10 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getStart_device_code()))
|
||||
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getNext_device_code()))
|
||||
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
// .sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
// .thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.sorted(Comparator.comparing((TaskDto taskDto) -> !taskDto.getVehicle_code().contains("YCZJ"))
|
||||
.thenComparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -1346,8 +1357,33 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.filter(taskDto -> taskDto.getFrom_x().equals(front_from_x) && taskDto.getFrom_z().equals(front_from_z))
|
||||
.filter(taskDto -> taskDto.getTo_x().equals(front_to_x) && taskDto.getTo_z().equals(front_to_z))
|
||||
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
|
||||
.filter(taskDto -> (Integer.parseInt(front_to_y) / 4 == Integer.parseInt(taskDto.getTo_y()) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 4))
|
||||
.filter(taskDto -> (Integer.parseInt(front_from_y) / 4 == Integer.parseInt(taskDto.getFrom_y()) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
|
||||
// .filter(taskDto -> ((Integer.parseInt(front_to_y) - 1) / 4 == (Integer.parseInt(taskDto.getTo_y()) - 1) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 4))
|
||||
//.filter(taskDto -> ((Integer.parseInt(front_from_y) - 1) / 4 == (Integer.parseInt(taskDto.getFrom_y()) - 1) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
|
||||
.filter(taskDto -> {
|
||||
int frontToY = Integer.parseInt(front_to_y);
|
||||
int taskDtoToY = Integer.parseInt(taskDto.getTo_y());
|
||||
int frontGroup = (frontToY - 1) / 4;
|
||||
int taskDtoGroup = (taskDtoToY - 1) / 4;
|
||||
if (frontGroup != taskDtoGroup) {
|
||||
return false;
|
||||
}
|
||||
int frontMod = frontToY % 4;
|
||||
int taskDtoMod = taskDtoToY % 4;
|
||||
return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4);
|
||||
})
|
||||
.filter(taskDto -> {
|
||||
int frontFromY = Integer.parseInt(front_from_y);
|
||||
int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y());
|
||||
int frontGroup = (frontFromY - 1) / 4;
|
||||
int taskDtoGroup = (taskDtoFromY - 1) / 4;
|
||||
if (frontGroup != taskDtoGroup) {
|
||||
return false;
|
||||
}
|
||||
int frontMod = frontFromY % 4;
|
||||
int taskDtoMod = taskDtoFromY % 4;
|
||||
return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4);
|
||||
})
|
||||
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.findFirst()
|
||||
@@ -1370,7 +1406,19 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.filter(taskDto -> !taskDto.getTask_code().equals(front_task_code))
|
||||
.filter(taskDto -> taskDto.getFrom_x().equals(front_from_x) && taskDto.getFrom_z().equals(front_from_z))
|
||||
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
|
||||
.filter(taskDto -> (Integer.parseInt(front_from_y) / 4 == Integer.parseInt(taskDto.getFrom_y()) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
|
||||
//.filter(taskDto -> ((Integer.parseInt(front_from_y) - 1) / 4 == (Integer.parseInt(taskDto.getFrom_y()) - 1) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
|
||||
.filter(taskDto -> {
|
||||
int frontFromY = Integer.parseInt(front_from_y);
|
||||
int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y());
|
||||
int frontGroup = (frontFromY - 1) / 4;
|
||||
int taskDtoGroup = (taskDtoFromY - 1) / 4;
|
||||
if (frontGroup != taskDtoGroup) {
|
||||
return false;
|
||||
}
|
||||
int frontMod = frontFromY % 4;
|
||||
int taskDtoMod = taskDtoFromY % 4;
|
||||
return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4);
|
||||
})
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.findFirst()
|
||||
@@ -1389,14 +1437,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
throw new BadRequestException(LangProcess.msg("task_insRun"));
|
||||
}
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setTask_status(TaskStatusEnum.CANCEL.getIndex());
|
||||
|
||||
Task task = ConvertUtil.convert(entity, Task.class);
|
||||
taskMapper.updateById(task);
|
||||
// String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
// String now = DateUtil.now();
|
||||
// entity.setUpdate_time(now);
|
||||
// entity.setUpdate_by(currentUsername);
|
||||
// entity.setTask_status(TaskStatusEnum.CANCEL.getIndex());
|
||||
//
|
||||
// Task task = ConvertUtil.convert(entity, Task.class);
|
||||
// taskMapper.updateById(task);
|
||||
taskMapper.deleteById(task_id);
|
||||
//移除任务缓存信息
|
||||
this.removeByCodeFromCache(entity.getTask_code());
|
||||
}
|
||||
|
||||
@@ -78,17 +78,21 @@ public class LuceneServiceImpl implements LuceneService {
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("method") != null) {
|
||||
Query termQuery = new TermQuery(new Term("method", (String) whereJson.get("method")));
|
||||
WildcardQuery termQuery = new WildcardQuery(new Term("method", "*" + (String) whereJson.get("method") + "*"));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("request_url") != null) {
|
||||
Query termQuery = new TermQuery(new Term("request_url", (String) whereJson.get("request_url")));
|
||||
WildcardQuery termQuery = new WildcardQuery(new Term("request_url", "*" + (String) whereJson.get("request_url") + "*"));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("request_direction") != null) {
|
||||
Query termQuery = new TermQuery(new Term("request_direction", (String) whereJson.get("request_direction")));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("request_param") != null) {
|
||||
WildcardQuery termQuery = new WildcardQuery(new Term("request_param", "*" + (String) whereJson.get("request_param") + "*"));
|
||||
booleanQueryBuilder.add(termQuery, BooleanClause.Occur.MUST);
|
||||
}
|
||||
if (whereJson.get("blurry") != null) {
|
||||
WildcardQuery query = new WildcardQuery(new Term("fieldContent", "*" + (String) whereJson.get("blurry") + "*"));
|
||||
booleanQueryBuilder.add(query, BooleanClause.Occur.MUST);
|
||||
|
||||
@@ -138,6 +138,12 @@ public class MqttService {
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 不需要记录日志的点位
|
||||
*/
|
||||
private static final List<String> NO_SET_LOG_KEYS = Arrays.asList("heartbeat");
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
initTopicMap();
|
||||
@@ -316,8 +322,14 @@ public class MqttService {
|
||||
tagsValues.forEach(tag -> {
|
||||
Object value = TagsUtil.parseValue(tag.getV());
|
||||
if (!ObjectUtil.equals(value, ACCESSOR_VALUE.getValue(tag.getId()))) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(deviceCode, DeviceLogTypeEnum.MQTT.getCode(), "MQTT上报,信号:" + tag.getId() + ",由" + ACCESSOR_VALUE.getValue(tag.getId()) + "->" + value + ",信号健康值:" + tag.isQ()));
|
||||
ACCESSOR_VALUE.setValue(tag.getId(), value);
|
||||
if (!tag.getId().contains(HEARTBEAT)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(deviceCode, DeviceLogTypeEnum.MQTT.getCode(), "MQTT上报,信号:" + tag.getId() + ",由" + ACCESSOR_VALUE.getValue(tag.getId()) + "->" + value + ",信号健康值:" + tag.isQ()));
|
||||
}
|
||||
if (value != null && value instanceof String) {
|
||||
ACCESSOR_VALUE.setValue(tag.getId(), ((String) value).trim().replace("", ""));
|
||||
} else {
|
||||
ACCESSOR_VALUE.setValue(tag.getId(), value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.nl.config.lucene.config.LuceneAppender;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* @author onepiece
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AutoCleanLuceneLog {
|
||||
|
||||
private static final long MAX_FILE_AGE_DAYS = 10;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Resource resource = new ClassPathResource("config/application.yml");
|
||||
YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
|
||||
yamlPropertiesFactoryBean.setResources(resource);
|
||||
Properties properties = yamlPropertiesFactoryBean.getObject();
|
||||
String logDirectory = properties.getProperty("lucene.index.path");
|
||||
|
||||
Instant now = Instant.now();
|
||||
Instant cutoffTime = now.minus(MAX_FILE_AGE_DAYS, ChronoUnit.DAYS);
|
||||
String cutoffTimeStr = DateUtil.format(Date.from(cutoffTime), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
FSDirectory dir = FSDirectory.open(Paths.get(logDirectory));
|
||||
IndexWriter writer = LuceneAppender.indexWriter;
|
||||
|
||||
try (IndexReader reader = DirectoryReader.open(dir)) {
|
||||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
Query query = new TermRangeQuery("logTime", new BytesRef(""), new BytesRef(cutoffTimeStr), true, true);
|
||||
TopDocs topDocs = searcher.search(query, Integer.MAX_VALUE);
|
||||
for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
|
||||
Document doc = searcher.doc(scoreDoc.doc);
|
||||
writer.deleteDocuments(new Term("logTime", doc.get("logTime")));
|
||||
}
|
||||
}
|
||||
writer.commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device.domain.Device;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.device.driver.storage.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动创建堆垛机出库指令
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AutoCreateDDJInst {
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
@Autowired
|
||||
private RouteLineService routeLineService;
|
||||
@Autowired
|
||||
private DeviceAppService deviceAppService;
|
||||
|
||||
|
||||
public void run() throws Exception {
|
||||
List<TaskDto> list = taskService.queryAllByStatus("0");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TaskDto acsTask = list.get(i);
|
||||
String start_device_code = acsTask.getStart_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (startDevice != null && startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
String taskid = acsTask.getTask_id();
|
||||
String taskcode = acsTask.getTask_code();
|
||||
String task_type = acsTask.getTask_type();
|
||||
String vehiclecode = acsTask.getVehicle_code();
|
||||
String storage_task_type = acsTask.getStorage_task_type();
|
||||
String priority = acsTask.getPriority();
|
||||
String is_send = acsTask.getIs_send();
|
||||
|
||||
String start_point_code = acsTask.getStart_point_code();
|
||||
|
||||
String put_device_code = acsTask.getPut_device_code();
|
||||
String put_point_code = acsTask.getPut_point_code();
|
||||
|
||||
String next_device_code = acsTask.getNext_device_code();
|
||||
String next_point_code = acsTask.getNext_point_code();
|
||||
|
||||
String start_point_code2 = acsTask.getStart_point_code2();
|
||||
String start_device_code2 = acsTask.getStart_device_code2();
|
||||
|
||||
String next_point_code2 = acsTask.getNext_point_code2();
|
||||
String next_device_code2 = acsTask.getNext_device_code2();
|
||||
|
||||
String route_plan_code = acsTask.getRoute_plan_code();
|
||||
String vehicleType = acsTask.getVehicle_type();
|
||||
String agv_system_type = acsTask.getAgv_system_type();
|
||||
|
||||
String start_height = acsTask.getStart_height();
|
||||
String next_height = acsTask.getNext_height();
|
||||
|
||||
|
||||
if (StrUtil.equals(is_send, "0")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(acsTask.getStart_device_code(), acsTask.getNext_device_code(), route_plan_code);
|
||||
if (CollectionUtil.isEmpty(shortPathsList)) {
|
||||
shortPathsList = routeLineService.getShortPathLinesByCode(acsTask.getStart_device_code(), route_plan_code);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(shortPathsList)) {
|
||||
acsTask.setRemark("路由不通");
|
||||
taskService.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String[] str = path.split("->");
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
index = m + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
next_device_code = pathlist.get(index);
|
||||
|
||||
if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(acsTask.getRemark());
|
||||
instdto.setMaterial(acsTask.getMaterial());
|
||||
instdto.setQuantity(acsTask.getQuantity());
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setVehicle_code(vehiclecode);
|
||||
String now = DateUtil.now();
|
||||
instdto.setCreate_time(now);
|
||||
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
|
||||
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setPut_device_code(put_device_code);
|
||||
instdto.setPut_point_code(put_point_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
|
||||
instdto.setStart_point_code2(start_point_code2);
|
||||
instdto.setStart_device_code2(start_device_code2);
|
||||
instdto.setNext_point_code2(next_point_code2);
|
||||
instdto.setNext_device_code2(next_device_code2);
|
||||
|
||||
instdto.setPriority(priority);
|
||||
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
instdto.setAgv_system_type(agv_system_type);
|
||||
instdto.setStart_height(start_height);
|
||||
instdto.setNext_height(next_height);
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark("指令创建失败");
|
||||
taskService.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskService.update(acsTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import org.nl.acs.device.device.service.impl.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -23,6 +22,7 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.config.lucene.service.impl.LuceneExecuteLogServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -35,6 +35,17 @@ import java.util.List;
|
||||
@Component
|
||||
public class AutoCreateInst {
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
@Autowired
|
||||
private RouteLineService routeLineService;
|
||||
@Autowired
|
||||
private DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
private LuceneExecuteLogService logService;
|
||||
|
||||
/**
|
||||
* 根据任务状态创建指令、生成下一条指令
|
||||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.ext.UnifiedResponse;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 定时查询AGV状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("queryAGVStatus")
|
||||
public class QueryAGVStatus {
|
||||
|
||||
@Autowired
|
||||
private XianGongAgvService agvService;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
UnifiedResponse<JSONObject> resp = agvService.queryXZAgvInstStatus(JSONObject.class);
|
||||
if (resp.isSuccess()) {
|
||||
JSONObject data = resp.getData();
|
||||
JSONArray list = data.getJSONArray("list");
|
||||
if (list == null) return;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject one = list.getJSONObject(i);
|
||||
String inst_code = one.getString("id");
|
||||
Instruction inst = instructionService.findByCodeFromCache(inst_code);
|
||||
|
||||
if (ObjectUtil.isEmpty(inst)) continue;
|
||||
|
||||
//子任务状态 待以后处理
|
||||
JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
|
||||
for (int j = 0; j < blocks.size(); j++) {
|
||||
JSONObject blocksjo = (JSONObject) blocks.get(j);
|
||||
String blockId = blocksjo.getString("blockId");
|
||||
String device_code = blocksjo.getString("location");
|
||||
String state = blocksjo.getString("state");
|
||||
}
|
||||
|
||||
String state = one.getString("state");
|
||||
if (!StrUtil.isEmpty(one.getString("vehicle"))) {
|
||||
String carno = one.getString("vehicle");
|
||||
inst.setCarno(carno);
|
||||
}
|
||||
// 已创建=CREATED,
|
||||
// 待分配=TOBEDISPATCHED,
|
||||
// 正在执行=RUNNING,
|
||||
// 完成=FINISHED,
|
||||
// 失败=FAILED(主动失败),
|
||||
// 终止=STOPPED(被人为终止),
|
||||
// 无法执行=Error(参数错误),
|
||||
// 等待=WAITING
|
||||
//执行中
|
||||
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
} else if ("FINISHED".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ spring:
|
||||
username: root
|
||||
password: 123456
|
||||
cleanSession: true
|
||||
url: 192.168.81.251
|
||||
url: 192.168.1.218
|
||||
clientId: hs_mqtt21
|
||||
topics:
|
||||
- HS/#
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
server:
|
||||
port: 8010
|
||||
port: 8011
|
||||
#配置数据源
|
||||
spring:
|
||||
messages:
|
||||
basename: language/login/login,language/error/error,language/buss/buss,language/task/task,language/monitor/one_device/one_device,language/monitor/two_device/two_device,language/monitor/universal/universal
|
||||
datasource:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.121}:${DB_PORT:3306}/${DB_NAME:yy_lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:123456}
|
||||
# 初始连接数
|
||||
@@ -15,6 +17,8 @@ spring:
|
||||
min-idle: 15
|
||||
# 最大连接数
|
||||
max-active: 60
|
||||
# 超时时间(以秒数为单位)
|
||||
remove-abandoned-timeout: 180
|
||||
# 获取连接超时时间
|
||||
max-wait: 5000
|
||||
# 连接有效性检测时间
|
||||
@@ -73,11 +77,11 @@ spring:
|
||||
active: true
|
||||
username: root
|
||||
password: 123456
|
||||
url: 10.211.55.3
|
||||
clientId: hs_mqtt21
|
||||
url: 192.168.1.218
|
||||
clientId: hs_mqtt_prod
|
||||
cleanSession: false
|
||||
topics:
|
||||
- A/#
|
||||
- HS/#
|
||||
qoss:
|
||||
- 2
|
||||
timeout: 30
|
||||
@@ -146,7 +150,7 @@ file:
|
||||
avatarMaxSize: 5
|
||||
logging:
|
||||
file:
|
||||
path: /app/jar/logs
|
||||
path: C:\logs\acs
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
# Sa-Token配置
|
||||
@@ -168,5 +172,35 @@ sa-token:
|
||||
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
|
||||
# token 前缀
|
||||
token-prefix: Bearer
|
||||
is-read-cookie: false
|
||||
is-read-body: false
|
||||
sso:
|
||||
# Ticket有效期 (单位: 秒),默认五分钟
|
||||
ticket-timeout: 300
|
||||
# 所有允许的授权回调地址
|
||||
allow-url: "*"
|
||||
# 是否打开单点注销功能
|
||||
is-slo: true
|
||||
|
||||
# ------- SSO-模式三相关配置 (下面的配置在SSO模式三并且 is-slo=true 时打开)
|
||||
# 是否打开模式三
|
||||
isHttp: true
|
||||
# 接口调用秘钥(用于SSO模式三的单点注销功能)
|
||||
secretkey: kQwIOrYvnXmSDkwEiFngrKidMcdrgKor
|
||||
# ---- 除了以上配置项,你还需要为 Sa-Token 配置http请求处理器(文档有步骤说明)
|
||||
is-read-cookie: true
|
||||
is-print: false
|
||||
# 未登录 StpUtil.getTokenSession() 设置值,获取值 @SaIgnore 得忽略接口
|
||||
token-session-check-login: false
|
||||
alone-redis:
|
||||
# Redis数据库索引(默认为0)
|
||||
database: 2
|
||||
# Redis服务器地址
|
||||
host: 127.0.0.1
|
||||
# Redis服务器连接端口
|
||||
port: 6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
|
||||
agvToAcs:
|
||||
addr: http://localhost
|
||||
|
||||
@@ -2,6 +2,8 @@ server:
|
||||
port: 8010
|
||||
#配置数据源
|
||||
spring:
|
||||
messages:
|
||||
basename: language/login/login,language/error/error,language/buss/buss,language/task/task,language/monitor/one_device/one_device,language/monitor/two_device/two_device,language/monitor/universal/universal
|
||||
datasource:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
@@ -106,7 +106,7 @@ rsa:
|
||||
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
||||
logging:
|
||||
file:
|
||||
path: C:\log\wms
|
||||
path: C:\logs\acs
|
||||
config: classpath:logback-spring.xml
|
||||
# sa-token白名单配置
|
||||
security:
|
||||
|
||||
Reference in New Issue
Block a user