Browse Source

rev:控制指令下发

master
gengby 9 months ago
parent
commit
d63b6d72ea
  1. 80
      acs/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java
  2. 10
      acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java
  3. 21
      acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  4. 9
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java
  5. 2
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java
  6. 12
      acs/nladmin-system/src/main/resources/config/application-dev.yml
  7. 32
      acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml
  8. 54
      acs/nladmin-system/src/main/resources/logback-spring.xml

80
acs/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java

@ -2,85 +2,27 @@ package org.nl.acs.instruction.enums;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
/** /**
* 任务类型 * 任务类型
*/ */
@Getter
@AllArgsConstructor
public enum InstTypeEnum { public enum InstTypeEnum {
IN(1, "IN", "入库"), _5("1", "5#镀锌"),
OUT(2, "OUT", "整盘出库"), _4("2", "1#连退"),
PICK_OUT(3, "PICK_OUT", "拣选出库"), _3("3", "2#连退"),
AGV_ONE(4, "AGV_ONE", "AGV单工"), _2("4", "重卷送样"),
AGV_TWO(5, "AGV_TWO", "AGV双工"); _1("5", "3#彩涂");
//索引 //索引
private int index; private String index;
//编码
private String code;
//名字 //名字
private String name; private String name;
//描述
private String desc;
// 构造方法
InstTypeEnum(int index, String code, String name) {
this.index = index;
this.code = code;
this.name = name;
}
public static JSONArray getList() {
JSONArray arr = new JSONArray();
JSONObject json = new JSONObject();
for (InstTypeEnum em : InstTypeEnum.values()) {
json.put("code", em.getCode());
json.put("name", em.getName());
arr.add(json);
}
return arr;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static String getName(String code) {
for (InstTypeEnum c : InstTypeEnum.values()) {
if (c.code == code) {
return c.name;
}
}
return null;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
} }

10
acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java

@ -195,7 +195,7 @@ public interface InstructionService {
Instruction findByLinkNumSend(String code); Instruction findByLinkNumSend(String code);
/** /**
* 根据关联编号查询非下发任务 * 根据关联编号查询非下发任务
* *
* @param code code * @param code code
* @return Instruction * @return Instruction
@ -275,4 +275,12 @@ public interface InstructionService {
*/ */
Instruction findByInstCodeFromCache(String inst_code); Instruction findByInstCodeFromCache(String inst_code);
/**
* 查询
*
* @param task_type
* @return
*/
boolean querySameTypeInst(String task_type);
} }

21
acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -21,6 +21,7 @@ import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyor
import org.nl.acs.device_driver.basedriver.haokai_auto_conveyor.HaoKaiAutoConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.haokai_auto_conveyor.HaoKaiAutoConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.instruction.enums.InstTypeEnum;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device; import org.nl.acs.opc.Device;
@ -49,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
@ -67,7 +69,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
DeviceAppService deviceAppService; DeviceAppService deviceAppService;
@Autowired @Autowired
NDCAgvService ndcAgvService; NDCAgvService ndcAgvService;
@Autowired @Autowired
ParamService paramService; ParamService paramService;
@Autowired @Autowired
RouteLineService routeLineService; RouteLineService routeLineService;
@ -290,7 +292,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setStart_parent_code(task.getStart_parent_code()); dto.setStart_parent_code(task.getStart_parent_code());
dto.setNext_parent_code(task.getNext_parent_code()); dto.setNext_parent_code(task.getNext_parent_code());
if(ObjectUtil.isNotEmpty(task.getTask_type())){ if (ObjectUtil.isNotEmpty(task.getTask_type())) {
dto.setInstruction_type(task.getTask_type()); dto.setInstruction_type(task.getTask_type());
} }
@ -312,12 +314,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
RouteLineDto routeLineDto = shortPathsList.get(i); RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code(); String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code(); String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())){ if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
route = routeLineDto; route = routeLineDto;
break; break;
} }
} }
if (ObjectUtil.isEmpty(route)){ if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!"); throw new BadRequestException("未查询到相关路由!");
} }
if (StrUtil.equals(route.getType(), "1")) { if (StrUtil.equals(route.getType(), "1")) {
@ -1192,7 +1194,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
} }
@Override @Override
public Instruction findByInstCodeFromCache(String inst_code) { public Instruction findByInstCodeFromCache(String inst_code) {
for (int i = 0; i < this.instructions.size(); i++) { for (int i = 0; i < this.instructions.size(); i++) {
@ -1204,6 +1205,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return null; return null;
} }
@Override
public boolean querySameTypeInst(String task_type) {
long count = Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(instruction -> instruction.getInstruction_type().equals(InstTypeEnum._1.getIndex())
|| instruction.getInstruction_type().equals(InstTypeEnum._2.getIndex())).count();
return count > 0;
}
public Instruction findByContainer(String container_code) { public Instruction findByContainer(String container_code) {
Iterator var3 = instructions.iterator(); Iterator var3 = instructions.iterator();

9
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.instruction.enums.InstTypeEnum;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
@ -38,9 +39,17 @@ public class AutoCreateInst {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
List<TaskDto> list = taskserver.queryAll("task_status = '0'"); List<TaskDto> list = taskserver.queryAll("task_status = '0'");
log.info("查询到任务数量:{}", (ObjectUtil.isNotEmpty(list) ? list.size() : 0));
System.out.println("查询到任务数量为:" + (ObjectUtil.isNotEmpty(list) ? list.size() : 0)); System.out.println("查询到任务数量为:" + (ObjectUtil.isNotEmpty(list) ? list.size() : 0));
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i); TaskDto acsTask = list.get(i);
String task_type = acsTask.getTask_type();
if (task_type.equals(InstTypeEnum._2.getIndex()) || task_type.equals(InstTypeEnum._1.getIndex())) {
boolean flag = instructionService.querySameTypeInst(task_type);
if (flag) {
continue;
}
}
String taskid = acsTask.getTask_id(); String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code(); String taskcode = acsTask.getTask_code();
String vehiclecode = acsTask.getVehicle_code(); String vehiclecode = acsTask.getVehicle_code();

2
acs/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java

@ -25,6 +25,7 @@ import org.nl.modules.quartz.domain.QuartzLog;
import org.nl.modules.quartz.repository.QuartzLogRepository; import org.nl.modules.quartz.repository.QuartzLogRepository;
import org.nl.modules.quartz.service.QuartzJobService; import org.nl.modules.quartz.service.QuartzJobService;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.scheduling.quartz.QuartzJobBean;
@ -41,6 +42,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@Async @Async
@SuppressWarnings({"unchecked", "all"}) @SuppressWarnings({"unchecked", "all"})
@Slf4j @Slf4j
@DisallowConcurrentExecution
public class ExecutionJob extends QuartzJobBean { public class ExecutionJob extends QuartzJobBean {
/** /**

12
acs/nladmin-system/src/main/resources/config/application-dev.yml

@ -7,10 +7,10 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:magang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:magang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:ndxy3_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true #url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:magang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root} username: ${DB_USER:root}
password: ${DB_PWD:password} password: ${DB_PWD:password}
# password: ${DB_PWD:Root.123456} #password: ${DB_PWD:Root.123456}
# 初始连接数 # 初始连接数
initial-size: 5 initial-size: 5
# 最小连接数 # 最小连接数
@ -128,7 +128,7 @@ file:
avatarMaxSize: 5 avatarMaxSize: 5
logging: logging:
file: file:
path: C:\log\acs path: /Users/onepiece/myFile/acs_logs
config: classpath:logback-spring.xml config: classpath:logback-spring.xml
# Sa-Token配置 # Sa-Token配置
@ -151,9 +151,9 @@ sa-token:
# token 前缀 # token 前缀
token-prefix: Bearer token-prefix: Bearer
loki: #loki:
url: http://localhost:3100/loki/api/v1 # url: http://10.211.55.3:3100/loki/api/v1
systemName: acs # systemName: acs
agvToAcs: agvToAcs:
addr: http://127.0.0.1:8010 addr: http://127.0.0.1:8010

32
acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="AutoCreateInst" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/自动创建诺宝AGV指令/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="AutoCreateInst" />
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.modules.quartz.task.AutoCreateInst" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

54
acs/nladmin-system/src/main/resources/logback-spring.xml

@ -23,6 +23,7 @@ https://juejin.cn/post/6844903775631572999
<!--引入默认的一些设置--> <!--引入默认的一些设置-->
<!--<include resource="log/XrToMes.xml"/> <!--<include resource="log/XrToMes.xml"/>
<include resource="log/MesToErp.xml"/>--> <include resource="log/MesToErp.xml"/>-->
<include resource="log/AutoCreateInst.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder> <encoder>
@ -49,6 +50,26 @@ https://juejin.cn/post/6844903775631572999
</encoder> </encoder>
</appender> </appender>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>error</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ERROR/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<!--异步到文件--> <!--异步到文件-->
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender"> <appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold> <discardingThreshold>0</discardingThreshold>
@ -84,8 +105,39 @@ https://juejin.cn/post/6844903775631572999
<!--生产环境:打印控制台和输出到文件--> <!--生产环境:打印控制台和输出到文件-->
<springProfile name="prod"> <springProfile name="prod">
<root level="info"> <root level="info">
<appender-ref ref="asyncLuceneAppender"/> <appender-ref ref="ERROR"/>
<appender-ref ref="asyncFileAppender"/> <appender-ref ref="asyncFileAppender"/>
</root> </root>
<!--logmanage -->
<logger name="org.nl.modules.lucene.service.impl.LuceneExecuteLogServiceImpl" level="info" additivity="false">
</logger>
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.openscada.opc.lib.da.Server" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<!--logmanage -->
<logger name="jdbc.audit" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="jdbc.resultset" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="springfox.documentation" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="jdbc.sqlonly" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="jdbc.sqltiming" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.jinterop" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
</springProfile> </springProfile>
</configuration> </configuration>

Loading…
Cancel
Save