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 203e45e..115d348 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 @@ -276,4 +276,6 @@ public interface InstructionService { void init(String id); + + List findByTaskCodeFromCache(String task_code); } 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 6ffe24f..e409e4a 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 @@ -1435,4 +1435,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); } } + + @Override + public List findByTaskCodeFromCache(String task_code) { + return Optional.ofNullable(instructions) + .orElse(new ArrayList<>()) + .stream() + .filter(instruction -> instruction.getTask_code().equals(task_code)) + .collect(Collectors.toList()); + } } 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 946e29e..3e6b76e 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 @@ -2,6 +2,7 @@ package org.nl.modules.quartz.task; 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 lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; @@ -39,7 +40,11 @@ public class AutoCreateInst { List list = taskserver.queryAll("task_status = '0'"); for (int i = 0; i < list.size(); i++) { TaskDto acsTask = list.get(i); - if(StrUtil.equals(acsTask.getTask_type(),"7") && !StrUtil.startWith(acsTask.getTask_code(), "-") ){ + List instructionList = instructionService.findByTaskCodeFromCache(acsTask.getTask_code()); + if (ObjectUtil.isNotEmpty(instructionList)) { + continue; + } + if (StrUtil.equals(acsTask.getTask_type(), "7") && !StrUtil.startWith(acsTask.getTask_code(), "-")) { continue; } String taskid = acsTask.getTask_id(); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java index 32ff1df..36013d3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java @@ -15,6 +15,8 @@ import org.nl.modules.wql.util.WqlUtil; import org.springframework.cache.annotation.CacheConfig; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashMap; @@ -98,13 +100,14 @@ public class GenCodeServiceImpl implements GenCodeService { } @Override + @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public String codeDemo(Map form) { String code = (String) form.get("code"); String id = this.queryIdByCode(code); //如果flag=1就执行更新数据库的操作 String flag = (String) form.get("flag"); WQLObject wo = WQLObject.getWQLObject("sys_code_rule_detail"); - JSONArray ja = wo.query("code_rule_id = '" + id + "'", " sort_num,type FOR UPDATE").getResultJSONArray(0); + JSONArray ja = wo.query("code_rule_id = '" + id + "'", " sort_num,type").getResultJSONArray(0); String demo = ""; boolean is_same = true; for (int i = 0; i < ja.size(); i++) {