fix 任务指令
This commit is contained in:
@@ -51,6 +51,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +64,7 @@ import java.util.regex.Pattern;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial {
|
public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial {
|
||||||
|
|
||||||
List<Instruction> instructions = new ArrayList();
|
List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
private final DeviceAppService deviceAppService;
|
private final DeviceAppService deviceAppService;
|
||||||
|
|
||||||
@@ -80,7 +81,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void reload() {
|
public synchronized void reload() {
|
||||||
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
|
List list = this.queryAll("instruction_status <2 and is_delete =0");
|
||||||
|
this.instructions = new CopyOnWriteArrayList<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -442,14 +444,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||||
|
|
||||||
wo.update(json);
|
wo.update(json);
|
||||||
|
removeByCodeFromCache(dto.getInstruction_code());
|
||||||
|
|
||||||
|
// Iterator<Instruction> iterator = instructions.iterator();
|
||||||
|
// while (iterator.hasNext()) {
|
||||||
|
// Instruction instruction = iterator.next();
|
||||||
|
// if (instruction.getInstruction_code().equals(dto.getInstruction_code())) {
|
||||||
|
// iterator.remove();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
Iterator<Instruction> iterator = instructions.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Instruction instruction = iterator.next();
|
|
||||||
if (instruction.getInstruction_code().equals(dto.getInstruction_code())) {
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StrUtil.equals(dto.getInstruction_status(), "0") || StrUtil.equals(dto.getInstruction_status(), "1")) {
|
if (StrUtil.equals(dto.getInstruction_status(), "0") || StrUtil.equals(dto.getInstruction_status(), "1")) {
|
||||||
instructions.add(dto);
|
instructions.add(dto);
|
||||||
}
|
}
|
||||||
@@ -1160,15 +1164,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeByCodeFromCache(String code) {
|
public boolean removeByCodeFromCache(String code) {
|
||||||
|
//
|
||||||
Iterator<Instruction> iterator = instructions.iterator();
|
// Iterator<Instruction> iterator = instructions.iterator();
|
||||||
while (iterator.hasNext()) {
|
// while (iterator.hasNext()) {
|
||||||
Instruction instruction = iterator.next();
|
// Instruction instruction = iterator.next();
|
||||||
if (instruction.getInstruction_code().equals(code)) {
|
// if (instruction.getInstruction_code().equals(code)) {
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
CopyOnWriteArrayList<Instruction> instructions = (CopyOnWriteArrayList<Instruction>) this.instructions;
|
||||||
|
instructions.removeIf((inst) -> {
|
||||||
|
return inst.getInstruction_code().equals(code);
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ import java.util.regex.Pattern;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||||
|
|
||||||
List<TaskDto> tasks = new ArrayList();
|
List<TaskDto> tasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private final DeviceAppService deviceAppService;
|
private final DeviceAppService deviceAppService;
|
||||||
|
|
||||||
@@ -97,7 +98,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void reload() {
|
public synchronized void reload() {
|
||||||
this.tasks = this.queryAll("task_status <2 and is_delete =0");
|
List list = this.queryAll("task_status <2 and is_delete =0 order by create_time");
|
||||||
|
tasks = new CopyOnWriteArrayList<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -455,7 +457,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||||
|
|
||||||
wo.insert(json);
|
wo.insert(json);
|
||||||
tasks.add(dto);
|
synchronized(TaskServiceImpl.class){
|
||||||
|
tasks.add(dto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -590,12 +594,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
wo.update(json);
|
wo.update(json);
|
||||||
|
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
// while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
// TaskDto task = iterator.next();
|
||||||
if (task.getTask_code().equals(dto.getTask_code())) {
|
// if (task.getTask_code().equals(dto.getTask_code())) {
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
removeByCodeFromCache(entity.getTask_code());
|
||||||
|
|
||||||
if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) {
|
if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) {
|
||||||
tasks.add(dto);
|
tasks.add(dto);
|
||||||
}
|
}
|
||||||
@@ -1031,15 +1038,22 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeByCodeFromCache(String code) {
|
public boolean removeByCodeFromCache(String code) {
|
||||||
Iterator<TaskDto> iterator = tasks.iterator();
|
// Iterator<TaskDto> iterator = tasks.iterator();
|
||||||
while (iterator.hasNext()) {
|
// while (iterator.hasNext()) {
|
||||||
TaskDto task = iterator.next();
|
// TaskDto task = iterator.next();
|
||||||
if (task.getTask_code().equals(code)) {
|
// if (task.getTask_code().equals(code)) {
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
|
CopyOnWriteArrayList<TaskDto> taskDtos = (CopyOnWriteArrayList<TaskDto>) this.tasks;
|
||||||
|
taskDtos.removeIf((task) -> {
|
||||||
|
return task.getTask_code().equals(code);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,22 +8,26 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CodeUtil {
|
public class CodeUtil {
|
||||||
|
|
||||||
public static synchronized String getNewCode(String ruleCode) {
|
public static String getNewCode(String ruleCode){
|
||||||
GenCodeService service = new GenCodeServiceImpl();
|
synchronized (ruleCode) {
|
||||||
String flag = "1";
|
GenCodeService service=new GenCodeServiceImpl();
|
||||||
HashMap<String, String> map = new HashMap<>();
|
String flag = "1";
|
||||||
map.put("flag", flag);
|
HashMap<String,String> map = new HashMap<>();
|
||||||
map.put("code", ruleCode);
|
map.put("flag",flag);
|
||||||
return service.codeDemo(map);
|
map.put("code",ruleCode);
|
||||||
|
return service.codeDemo(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized List<String> getNewCodes(String ruleCode, Integer number) {
|
public static List<String> getNewCodes(String ruleCode, Integer number) {
|
||||||
GenCodeService service = new GenCodeServiceImpl();
|
synchronized (ruleCode) {
|
||||||
String flag = "1";
|
GenCodeService service = new GenCodeServiceImpl();
|
||||||
HashMap<String, String> map = new HashMap<>();
|
String flag = "1";
|
||||||
map.put("flag", flag);
|
HashMap<String, String> map = new HashMap<>();
|
||||||
map.put("code", ruleCode);
|
map.put("flag", flag);
|
||||||
map.put("number", number + "");
|
map.put("code", ruleCode);
|
||||||
return service.codeDemos(map);
|
map.put("number", number + "");
|
||||||
|
return service.codeDemos(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user