任务和指令加锁处理
This commit is contained in:
@@ -728,7 +728,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
||||
requireSucess = true;
|
||||
applySucess = false;
|
||||
} else {
|
||||
message = jo.get("message").toString();
|
||||
if (jo.get("message")!=null){
|
||||
message = jo.get("message").toString();
|
||||
}
|
||||
|
||||
List list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code","to_target");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,10 @@
|
||||
|
||||
package org.nl.acs.log.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.OpcUtl;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -13,45 +12,41 @@ import org.springframework.stereotype.Service;
|
||||
* @author loujf
|
||||
* @description 服务实现
|
||||
* @date 2022-02-25
|
||||
**/
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
|
||||
|
||||
@Override
|
||||
public void deviceItemValue(String device_code, String key, String value) {
|
||||
String now = DateUtil.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deviceItemValue(String device_code, String key, String value) {
|
||||
String now = DateUtil.now();
|
||||
|
||||
|
||||
@Override
|
||||
public void deviceExecuteLog(
|
||||
String device_code, String vehicle_code, String inst_code, String message) {
|
||||
try {
|
||||
MDC.put("device_code_log", device_code);
|
||||
log.info("{},{}", device_code, message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
MDC.remove("device_code_log");
|
||||
System.out.println("successNum:" + OpcUtl.successNum);
|
||||
System.out.println("errNum:" + OpcUtl.errNum);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deviceExecuteLog(String device_code, String vehicle_code, String inst_code, String message) {
|
||||
try {
|
||||
MDC.put("device_code_log", device_code);
|
||||
log.info("{},{}", device_code, message);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
finally {
|
||||
MDC.remove("device_code_log");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extLog(String name, String message) {
|
||||
try {
|
||||
MDC.put(name, name);
|
||||
log.info("{}", message);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
MDC.remove(name);
|
||||
}
|
||||
@Override
|
||||
public void extLog(String name, String message) {
|
||||
try {
|
||||
MDC.put(name, name);
|
||||
log.info("{}", message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
MDC.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,10 +18,14 @@ import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
public class OpcUtl {
|
||||
private static int timeout = 300000;
|
||||
private static int timeout = 1*60*1000;
|
||||
private static String key = "rpc.socketTimeout";
|
||||
private static int successNum=0;
|
||||
private static int errNum=0;
|
||||
public static int successNum=0;
|
||||
public static int errNum=0;
|
||||
|
||||
static {
|
||||
checkTimeout();
|
||||
}
|
||||
|
||||
public static void checkTimeout() {
|
||||
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
@Override
|
||||
public void autoInitial() throws Exception {
|
||||
Class var1 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAllByCache(Map whereJson, Pageable page) {
|
||||
synchronized (TaskServiceImpl.class){
|
||||
|
||||
|
||||
this.reload();
|
||||
String task_code = (String) whereJson.get("task_code");
|
||||
String vehicle_code = (String) whereJson.get("vehicle_code");
|
||||
@@ -201,6 +204,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
jo.put("content", taskDtoList);
|
||||
jo.put("totalElements", taskList.size());
|
||||
return jo;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,107 +292,119 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByDeviceCode(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByStartDeviceCode(String start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(start_device_code)
|
||||
|| task.getStart_device_code2().equals(start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(start_device_code)
|
||||
|| task.getStart_device_code2().equals(start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByBackDeviceCode(String back_start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if (task.getStart_device_code().equals(back_start_device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if (task.getStart_device_code().equals(back_start_device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(head_start_device_code)
|
||||
|| task.getStart_device_code2().equals(head_start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(head_start_device_code)
|
||||
|| task.getStart_device_code2().equals(head_start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<TaskDto> queryTaskByNextAndIntStatus(String back_start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(back_start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (!StrUtil.equals(task.getTask_type(), "6")) {
|
||||
continue;
|
||||
}
|
||||
if ((task.getStart_device_code().equals(back_start_device_code))
|
||||
&& StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -637,116 +653,118 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TaskDto dto) {
|
||||
TaskDto entity = this.findById(dto.getTask_id());
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_by(currentUsername);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.update(json);
|
||||
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(dto.getTask_code())) {
|
||||
iterator.remove();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
TaskDto entity = this.findById(dto.getTask_id());
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) {
|
||||
tasks.add(dto);
|
||||
}
|
||||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
|
||||
if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
|
||||
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
|
||||
JSONObject feed_jo = new JSONObject();
|
||||
feed_jo.put("task_id", entity.getExt_task_id());
|
||||
feed_jo.put("task_code", dto.getTask_code());
|
||||
feed_jo.put("task_status", dto.getTask_status());
|
||||
JSONArray ja = new JSONArray();
|
||||
ja.add(feed_jo);
|
||||
String message = null;
|
||||
HttpResponse body = null;
|
||||
boolean flag = false;
|
||||
try {
|
||||
body = acstowmsService.feedbackTaskStatusToWms(ja);
|
||||
} catch (Exception e) {
|
||||
flag = true;
|
||||
message = e.getMessage();
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
}
|
||||
if (flag) {
|
||||
if (ObjectUtil.isEmpty(feefbackdto)) {
|
||||
feefbackdto = new TaskFeedbackDto();
|
||||
feefbackdto.setTask_id(entity.getTask_id());
|
||||
feefbackdto.setTask_code(entity.getTask_code());
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setVehicle_type(entity.getVehicle_type());
|
||||
feefbackdto.setVehicle_code(entity.getVehicle_code());
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getStart_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setError_code("400");
|
||||
feefbackdto.setIs_finished("0");
|
||||
feefbackdto.setRemark(message);
|
||||
taskFeedbackService.create(feefbackdto);
|
||||
} else {
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getStart_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setError_code("400");
|
||||
feefbackdto.setRemark(message);
|
||||
taskFeedbackService.update(feefbackdto);
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_by(currentUsername);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.update(json);
|
||||
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(dto.getTask_code())) {
|
||||
iterator.remove();
|
||||
}
|
||||
} else {
|
||||
int status = body.getStatus();
|
||||
JSONObject jo = JSONObject.parseObject(body.body());
|
||||
if (ObjectUtil.isEmpty(feefbackdto)) {
|
||||
feefbackdto = new TaskFeedbackDto();
|
||||
feefbackdto.setTask_id(entity.getTask_id());
|
||||
feefbackdto.setTask_code(entity.getTask_code());
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setVehicle_type(entity.getVehicle_type());
|
||||
feefbackdto.setVehicle_code(entity.getVehicle_code());
|
||||
feefbackdto.setError_code(String.valueOf(body.getStatus()));
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
if (status == 200) {
|
||||
if (StrUtil.equals(entity.getTask_status(), "2")) {
|
||||
feefbackdto.setIs_finished("1");
|
||||
} else {
|
||||
feefbackdto.setIs_finished("0");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) {
|
||||
tasks.add(dto);
|
||||
}
|
||||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
|
||||
if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
|
||||
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
|
||||
JSONObject feed_jo = new JSONObject();
|
||||
feed_jo.put("task_id", entity.getExt_task_id());
|
||||
feed_jo.put("task_code", dto.getTask_code());
|
||||
feed_jo.put("task_status", dto.getTask_status());
|
||||
JSONArray ja = new JSONArray();
|
||||
ja.add(feed_jo);
|
||||
String message = null;
|
||||
HttpResponse body = null;
|
||||
boolean flag = false;
|
||||
try {
|
||||
body = acstowmsService.feedbackTaskStatusToWms(ja);
|
||||
} catch (Exception e) {
|
||||
flag = true;
|
||||
message = e.getMessage();
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
}
|
||||
if (flag) {
|
||||
if (ObjectUtil.isEmpty(feefbackdto)) {
|
||||
feefbackdto = new TaskFeedbackDto();
|
||||
feefbackdto.setTask_id(entity.getTask_id());
|
||||
feefbackdto.setTask_code(entity.getTask_code());
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setVehicle_type(entity.getVehicle_type());
|
||||
feefbackdto.setVehicle_code(entity.getVehicle_code());
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getStart_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setError_code("400");
|
||||
feefbackdto.setIs_finished("0");
|
||||
feefbackdto.setRemark(jo.getString("message"));
|
||||
}
|
||||
taskFeedbackService.create(feefbackdto);
|
||||
} else {
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
if (status == 200) {
|
||||
feefbackdto.setRemark(message);
|
||||
taskFeedbackService.create(feefbackdto);
|
||||
} else {
|
||||
if (StrUtil.equals(entity.getTask_status(), "2")) {
|
||||
feefbackdto.setIs_finished("1");
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getStart_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setError_code("400");
|
||||
feefbackdto.setRemark(message);
|
||||
taskFeedbackService.update(feefbackdto);
|
||||
}
|
||||
} else {
|
||||
int status = body.getStatus();
|
||||
JSONObject jo = JSONObject.parseObject(body.body());
|
||||
if (ObjectUtil.isEmpty(feefbackdto)) {
|
||||
feefbackdto = new TaskFeedbackDto();
|
||||
feefbackdto.setTask_id(entity.getTask_id());
|
||||
feefbackdto.setTask_code(entity.getTask_code());
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
feefbackdto.setVehicle_type(entity.getVehicle_type());
|
||||
feefbackdto.setVehicle_code(entity.getVehicle_code());
|
||||
feefbackdto.setError_code(String.valueOf(body.getStatus()));
|
||||
feefbackdto.setStart_device_code(entity.getStart_device_code());
|
||||
feefbackdto.setStart_point_code(entity.getNext_point_code());
|
||||
feefbackdto.setNext_device_code(entity.getNext_device_code());
|
||||
feefbackdto.setNext_point_code(entity.getNext_point_code());
|
||||
if (status == 200) {
|
||||
if (StrUtil.equals(entity.getTask_status(), "2")) {
|
||||
feefbackdto.setIs_finished("1");
|
||||
} else {
|
||||
feefbackdto.setIs_finished("0");
|
||||
}
|
||||
} else {
|
||||
feefbackdto.setIs_finished("0");
|
||||
feefbackdto.setRemark(jo.getString("message"));
|
||||
}
|
||||
taskFeedbackService.create(feefbackdto);
|
||||
} else {
|
||||
feefbackdto.setTask_status(entity.getTask_status());
|
||||
if (status == 200) {
|
||||
} else {
|
||||
if (StrUtil.equals(entity.getTask_status(), "2")) {
|
||||
feefbackdto.setIs_finished("1");
|
||||
} else {
|
||||
feefbackdto.setIs_finished("0");
|
||||
}
|
||||
}
|
||||
taskFeedbackService.update(feefbackdto);
|
||||
}
|
||||
taskFeedbackService.update(feefbackdto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -899,16 +917,16 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
wo.update(json);
|
||||
|
||||
try {
|
||||
Iterator<TaskDto> it = tasks.iterator();
|
||||
// 清理缓存
|
||||
while (it.hasNext()){
|
||||
TaskDto taskDto = it.next();
|
||||
if (taskDto.getTask_id().equals(id)) {
|
||||
tasks.remove(taskDto);
|
||||
}
|
||||
Iterator<TaskDto> it = tasks.iterator();
|
||||
// 清理缓存
|
||||
while (it.hasNext()) {
|
||||
TaskDto taskDto = it.next();
|
||||
if (taskDto.getTask_id().equals(id)) {
|
||||
tasks.remove(taskDto);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
|
||||
@@ -1251,15 +1269,17 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public boolean removeByCodeFromCache(String code) {
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(code)) {
|
||||
iterator.remove();
|
||||
return true;
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(code)) {
|
||||
iterator.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1268,41 +1288,47 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
}
|
||||
|
||||
public TaskDto findByContainer(String container_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getVehicle_code(), container_code)) {
|
||||
return task;
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getVehicle_code(), container_code)) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskDto findByCodeFromCache(String task_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getTask_code(), task_code)) {
|
||||
return task;
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getTask_code(), task_code)) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByNextCode(String device_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getNext_device_code(), device_code)) {
|
||||
return task;
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getNext_device_code(), device_code)) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1317,32 +1343,36 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public TaskDto findByStartCodeAndReady(String device_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
// if (!StrUtil.equals(task.getTask_type(), "5")) {
|
||||
// continue;
|
||||
// }
|
||||
if (StrUtil.equals(task.getStart_device_code(), device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
return task;
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
// if (!StrUtil.equals(task.getTask_type(), "5")) {
|
||||
// continue;
|
||||
// }
|
||||
if (StrUtil.equals(task.getStart_device_code(), device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByStartCode(String device_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(), device_code)) {
|
||||
return task;
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(), device_code)) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1484,14 +1514,16 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public void updateByCodeFromCache(TaskDto dto) {
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(dto.getTask_code())) {
|
||||
iterator.remove();
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_code().equals(dto.getTask_code())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
tasks.add(dto);
|
||||
}
|
||||
tasks.add(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1537,59 +1569,67 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(), start_device)
|
||||
&& StrUtil.equals(task.getNext_device_code(), next_device)
|
||||
&& StrUtil.equals(task.getTask_status(), status)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameTaskByType(String taskType) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameOriginTask(String code) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(),code)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameDestinationTask(String code) {
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getNext_device_code(),code)) {
|
||||
if (StrUtil.equals(task.getStart_device_code(), start_device)
|
||||
&& StrUtil.equals(task.getNext_device_code(), next_device)
|
||||
&& StrUtil.equals(task.getTask_status(), status)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameTaskByType(String taskType) {
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameOriginTask(String code) {
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(), code)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySameDestinationTask(String code) {
|
||||
synchronized (TaskServiceImpl.class) {
|
||||
int num = 0;
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getNext_device_code(), code)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user