This commit is contained in:
2023-02-06 16:16:34 +08:00
parent f977ceed49
commit 77ac88d8d4
2 changed files with 1377 additions and 1361 deletions

View File

@@ -53,6 +53,7 @@ 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.concurrent.CopyOnWriteArrayList;
import java.util.function.Predicate;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -68,12 +69,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
List<Instruction> instructions = new CopyOnWriteArrayList(); List<Instruction> instructions = new CopyOnWriteArrayList();
@Autowired DeviceAppService deviceAppService; @Autowired
@Autowired NDCAgvService ndcAgvService; DeviceAppService deviceAppService;
@Autowired ParamService paramService; @Autowired
@Autowired RouteLineService routeLineService; NDCAgvService ndcAgvService;
@Autowired TaskService taskService; @Autowired
@Autowired AcsToLiKuService acsToLiKuService; ParamService paramService;
@Autowired
RouteLineService routeLineService;
@Autowired
TaskService taskService;
@Autowired
AcsToLiKuService acsToLiKuService;
@Override @Override
public void autoInitial() { public void autoInitial() {
@@ -82,9 +89,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override @Override
public synchronized void reload() { public synchronized void reload() {
synchronized (TaskInstructionLock.class) { List list = this.queryAll("instruction_status <2 and is_delete =0");
this.instructions = this.queryAll("instruction_status <2 and is_delete =0"); this.instructions = new CopyOnWriteArrayList<>(list);
}
} }
@Override @Override
@@ -1337,15 +1343,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override @Override
public boolean removeByCodeFromCache(String code) { public boolean removeByCodeFromCache(String code) {
synchronized (InstructionServiceImpl.class) { synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> iterator = instructions.iterator(); CopyOnWriteArrayList<Instruction> instructions = (CopyOnWriteArrayList<Instruction>) this.instructions;
while (iterator.hasNext()) { instructions.removeIf((instruction) -> {
Instruction instruction = iterator.next(); instruction.getInstruction_code().equals(code);
if (instruction.getInstruction_code().equals(code)) { return true;
iterator.remove(); });
// while (iterator.hasNext()) {
// Instruction instruction = iterator.next();
// if (instruction.getInstruction_code().equals(code)) {
// iterator.remove();
// return true;
// }
// }
return true; return true;
}
}
return false;
} }
} }

View File

@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig; import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.agv.server.XianGongAgvService;
@@ -88,7 +89,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
} }
public synchronized void reload() { public synchronized void reload() {
this.tasks = this.queryAll("task_status <2 and is_delete =0 order by create_time"); List list = this.queryAll("task_status <2 and is_delete =0 order by create_time");
tasks = new CopyOnWriteArrayList<>(list);
} }
@Override @Override
@@ -533,8 +536,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
JSONObject json = (JSONObject) JSONObject.toJSON(dto); JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json); wo.insert(json);
synchronized(TaskServiceImpl.class){
tasks.add(dto); tasks.add(dto);
} }
}
/** /**
* 常规任务保存 * 常规任务保存
@@ -804,6 +809,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
System.out.println(feefbackdto == null);
JSONObject feed_jo = new JSONObject(); JSONObject feed_jo = new JSONObject();
feed_jo.put("task_id", entity.getTask_id()); feed_jo.put("task_id", entity.getTask_id());
feed_jo.put("task_code", entity.getTask_code()); feed_jo.put("task_code", entity.getTask_code());