From d63b6d72eafc1609f3c67c01afaebaa4887f486f Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Wed, 13 Mar 2024 16:46:49 +0800 Subject: [PATCH] =?UTF-8?q?rev:=E6=8E=A7=E5=88=B6=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/instruction/enums/InstTypeEnum.java | 80 +++---------------- .../service/InstructionService.java | 10 ++- .../service/impl/InstructionServiceImpl.java | 21 +++-- .../modules/quartz/task/AutoCreateInst.java | 9 +++ .../nl/modules/quartz/utils/ExecutionJob.java | 2 + .../main/resources/config/application-dev.yml | 12 +-- .../src/main/resources/log/AutoCreateInst.xml | 32 ++++++++ .../src/main/resources/logback-spring.xml | 54 ++++++++++++- 8 files changed, 138 insertions(+), 82 deletions(-) create mode 100644 acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java index 19f8487..55847e3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java +++ b/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.JSONObject; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; /** * 任务类型 */ +@Getter +@AllArgsConstructor public enum InstTypeEnum { - IN(1, "IN", "入库"), - OUT(2, "OUT", "整盘出库"), - PICK_OUT(3, "PICK_OUT", "拣选出库"), - AGV_ONE(4, "AGV_ONE", "AGV单工"), - AGV_TWO(5, "AGV_TWO", "AGV双工"); + _5("1", "5#镀锌"), + _4("2", "1#连退"), + _3("3", "2#连退"), + _2("4", "重卷送样"), + _1("5", "3#彩涂"); //索引 - private int index; - //编码 - private String code; + private String index; //名字 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; - } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 46960c5..32b697c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -195,7 +195,7 @@ public interface InstructionService { Instruction findByLinkNumSend(String code); /** - * 根据关联编号查询非下发任务 + * 根据关联编号查询非下发任务 * * @param code code * @return Instruction @@ -275,4 +275,12 @@ public interface InstructionService { */ Instruction findByInstCodeFromCache(String inst_code); + /** + * 查询 + * + * @param task_type + * @return + */ + boolean querySameTypeInst(String task_type); + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index dee7aaa..5b80373 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/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.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; 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.dto.Instruction; import org.nl.acs.opc.Device; @@ -49,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.regex.Pattern; /** @@ -67,7 +69,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu DeviceAppService deviceAppService; @Autowired NDCAgvService ndcAgvService; - @Autowired + @Autowired ParamService paramService; @Autowired RouteLineService routeLineService; @@ -290,7 +292,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setStart_parent_code(task.getStart_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()); } @@ -312,12 +314,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu RouteLineDto routeLineDto = shortPathsList.get(i); String route_device = routeLineDto.getDevice_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; break; } } - if (ObjectUtil.isEmpty(route)){ + if (ObjectUtil.isEmpty(route)) { throw new BadRequestException("未查询到相关路由!"); } if (StrUtil.equals(route.getType(), "1")) { @@ -1192,7 +1194,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } - @Override public Instruction findByInstCodeFromCache(String inst_code) { for (int i = 0; i < this.instructions.size(); i++) { @@ -1204,6 +1205,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu 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) { Iterator var3 = instructions.iterator(); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 12e30f3..c07995f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/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 lombok.extern.slf4j.Slf4j; 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.dto.Instruction; import org.nl.acs.opc.DeviceAppService; @@ -38,9 +39,17 @@ public class AutoCreateInst { DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); List list = taskserver.queryAll("task_status = '0'"); + log.info("查询到任务数量:{}", (ObjectUtil.isNotEmpty(list) ? list.size() : 0)); System.out.println("查询到任务数量为:" + (ObjectUtil.isNotEmpty(list) ? list.size() : 0)); for (int i = 0; i < list.size(); 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 taskcode = acsTask.getTask_code(); String vehiclecode = acsTask.getVehicle_code(); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java index ee4f685..2843083 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java +++ b/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.service.QuartzJobService; import org.nl.modules.wql.util.SpringContextHolder; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.quartz.QuartzJobBean; @@ -41,6 +42,7 @@ import java.util.concurrent.ThreadPoolExecutor; @Async @SuppressWarnings({"unchecked", "all"}) @Slf4j +@DisallowConcurrentExecution public class ExecutionJob extends QuartzJobBean { /** diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index a75e18c..eeaa8fb 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -7,10 +7,10 @@ spring: db-type: com.alibaba.druid.pool.DruidDataSource 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: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} password: ${DB_PWD:password} -# password: ${DB_PWD:Root.123456} + #password: ${DB_PWD:Root.123456} # 初始连接数 initial-size: 5 # 最小连接数 @@ -128,7 +128,7 @@ file: avatarMaxSize: 5 logging: file: - path: C:\log\acs + path: /Users/onepiece/myFile/acs_logs config: classpath:logback-spring.xml # Sa-Token配置 @@ -151,9 +151,9 @@ sa-token: # token 前缀 token-prefix: Bearer -loki: - url: http://localhost:3100/loki/api/v1 - systemName: acs +#loki: +# url: http://10.211.55.3:3100/loki/api/v1 +# systemName: acs agvToAcs: addr: http://127.0.0.1:8010 diff --git a/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml b/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml new file mode 100644 index 0000000..877588f --- /dev/null +++ b/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml @@ -0,0 +1,32 @@ + + + + + + + + + ${LOG_HOME}/自动创建诺宝AGV指令/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 2GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} + + + + + + + 512 + + + + + diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 0a5d959..6d6d4bc 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -23,6 +23,7 @@ https://juejin.cn/post/6844903775631572999 + @@ -49,6 +50,26 @@ https://juejin.cn/post/6844903775631572999 + + + error + + + + ${LOG_HOME}/ERROR/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 20GB + + + ${log.pattern} + ${log.charset} + + + 0 @@ -84,8 +105,39 @@ https://juejin.cn/post/6844903775631572999 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +