This commit is contained in:
USER-20220102CG\noblelift
2023-02-04 21:27:20 +08:00
parent 353a59a363
commit e19622efc3
7 changed files with 86 additions and 43 deletions

View File

@@ -163,7 +163,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
message = null;
if (move == 0 ) {
inst_message = null;
this.clearWrite();
// this.clearWrite();
}
if(move == 0 && last_move == 1 ){
last_vehicle_code = vehicle_code;
@@ -297,7 +297,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
break;
case 6:
//空托盘满垛入库申请
if (move > 0 && !requireSucess) {
if (move > 0 && !requireEmptyInSuccess) {
emptyIn();
}
if (move > 0 && !requireSucess) {
@@ -568,11 +568,11 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
message = "下发电气任务号成功";
requireSucess = true;
return true;
@@ -675,11 +675,11 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
}
// if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list);
// message = "重新下发电气信号";
// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
// }
} else {
//如果不存在则直接找对应指令
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
@@ -867,13 +867,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘入库接口不通";
requireSucess = true;
requireEmptyInSuccess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘入库成功";
requireSucess = true;
requireEmptyInSuccess = true;
} else {
requireSucess = true;
requireEmptyInSuccess = true;
message = "申请空盘入库失败," + jo.get("message").toString();
}
}

View File

@@ -474,7 +474,9 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
instruction = instructionService.findByCode(String.valueOf(task));
//instruction = instructionService.findByCode(String.valueOf(task));
message ="任务号:"+task +"未找到对应立库指令,请检查";
return false;
}
if(StrUtil.equals(instruction.getInstruction_status(),"1")){
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {

View File

@@ -1,6 +1,7 @@
package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
@@ -63,11 +64,16 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.header("Authorization", token)
.body(String.valueOf(jo))
.execute();
System.out.println(result2);
// ////System.out.println(result2);
} catch (Exception e) {
String msg = e.getMessage();
log.info("applyTaskToWms-----输出参数{}", msg);
//网络不通
System.out.println(msg);
// //System.out.println(msg);
}
if(ObjectUtil.isEmpty(result2)){
log.info("applyTaskToWms-----输出参数{}", "返回结果为空");
return null;
}
String type = "";
if (result2.getStatus() == 200) {
@@ -108,13 +114,16 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result2 = HttpRequest.post(wmsurl + methods_url)
.header("Authorization", token).body(String.valueOf(data))
.execute();
System.out.println(result2);
// //System.out.println(result2);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
// //System.out.println(msg);
log.info("feedbackTaskStatusToWms-----输出参数{}", msg);
}
String type = "";
if (result2.getStatus() == 200) {
type = "info";
@@ -149,12 +158,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result2 = HttpRequest.post(url)
.body(String.valueOf(jo))
.execute().body();
System.out.println(result2);
//System.out.println(result2);
log.info("requestTaskAgain----返回参数{}", result2);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result2;
}
@@ -183,7 +193,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -216,7 +226,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -240,7 +250,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -265,7 +275,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -286,7 +296,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
@@ -323,7 +333,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
@@ -356,7 +366,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -388,7 +398,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
//System.out.println(msg);
}
return result;
}
@@ -501,7 +511,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
public HttpResponse shipDeviceUpdate(JSONObject param) {
try {
MDC.put(log_file_type, log_type);
log.info("shipDeviceUpdate-----输入参数{}", param);
// log.info("shipDeviceUpdate-----输入参数{}", param);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("shipDeviceUpdate");

View File

@@ -121,6 +121,11 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
// inst.setInstruction_status("1");
// instructionService.finish(inst.getInstruction_id());
if(StrUtil.equals(task.getTask_type(),"7") && StrUtil.equals(task.getStorage_task_type(),"4")){
inst.setInstruction_status("2");
instructionService.finish(inst.getInstruction_id());
}
} else if(StrUtil.equals(status,"4")){
//5 取消指令
} else if(StrUtil.equals(status,"5")){

View File

@@ -92,7 +92,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public synchronized void reload() {
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
Class var1 = TaskInstructionLock.class;
synchronized(TaskInstructionLock.class) {
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
}
}
@Override
@@ -309,7 +312,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setInstruction_type("3");
}
//查询是否存在相同指令号
// if (!StrUtil.isEmpty(dto.getVehicle_code() )) {
// Instruction inst_dto = findByContainer(dto.getVehicle_code());
// if (inst_dto != null) {
// log.error("存在相同载具号任务,载具号"+dto.getVehicle_code());
// throw new BadRequestException("存在相同载具号任务!");
// }
// }
//起点设备与终点设备相同则为初始指令
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
@@ -794,6 +804,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
@Override
@Transactional(rollbackFor = Exception.class)
public void finishAndCreateNextInst(Instruction dto){
dto = foramte(dto);
String device_code = dto.getNext_device_code();

View File

@@ -32,7 +32,11 @@ public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
try {
MDC.put("device_code_log", device_code);
log.info("{},{}", device_code, message);
} finally {
} catch (Exception e){
e.printStackTrace();
}
finally {
MDC.remove("device_code_log");
}
}
@@ -42,6 +46,8 @@ public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
try {
MDC.put(name, name);
log.info("{}", message);
} catch (Exception e){
e.printStackTrace();
} finally {
MDC.remove(name);
}

View File

@@ -29,6 +29,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.service.TaskFeedbackService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
@@ -51,6 +52,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.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -64,7 +66,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@Slf4j
public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
List<TaskDto> tasks = new ArrayList();
List<TaskDto> tasks = new CopyOnWriteArrayList<>();
@Autowired DeviceAppService deviceAppService;
@Autowired RouteLineService routelineserver;
@@ -79,7 +81,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
public void autoInitial() throws Exception {
this.reload();
Class var1 = TaskInstructionLock.class;
synchronized(TaskInstructionLock.class) {
this.reload();
}
}
public synchronized void reload() {
@@ -893,13 +898,17 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
Iterator<TaskDto> it = tasks.iterator();
// 清理缓存
while (it.hasNext()){
TaskDto taskDto = it.next();
if (taskDto.getTask_id().equals(id)) {
tasks.remove(taskDto);
}
try {
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();
}
// 判断是否为WMS下发的任务如果是反馈任务状态给WMS
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();