代码更新

This commit is contained in:
ludj
2023-02-05 17:51:04 +08:00
parent c47b61abdc
commit 7f51a4e3e9
3 changed files with 608 additions and 652 deletions

View File

@@ -5,27 +5,25 @@ 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 cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.*;
import org.nl.acs.agv.server.MagicAgvService;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.wms.liKuData.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
@@ -84,7 +82,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public synchronized void reload() {
Class var1 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
this.instructions = this.queryAll("instruction_status <2 and is_delete =0");
}
@@ -92,10 +89,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
/*WQLObject wo = WQLObject.getWQLObject("acs_instruction");
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc");
*/
// this.reload();
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
String code = (String) whereJson.get("code");
@@ -214,7 +207,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public List queryAll(String whereJson) {
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONArray arr = wo.query(whereJson).getResultJSONArray(0);
JSONArray arr = wo.query(whereJson, "create_time").getResultJSONArray(0);
List<Instruction> list = arr.toJavaList(Instruction.class);
return list;
}
@@ -251,7 +244,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByTaskcodeAndStatus(String code) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator var3 = instructions.iterator();
while (var3.hasNext()) {
Instruction instruction = (Instruction) var3.next();
@@ -262,7 +255,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return null;
}
}
@Override
@@ -280,13 +272,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public void create(Instruction dto) {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
@@ -345,14 +334,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver =
(HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
}
@@ -361,8 +348,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
String next_device_code = dto.getNext_device_code();
String route_plan_code = task.getRoute_plan_code();
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, next_device_code, route_plan_code);
routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto route = null;
for (int i = 0; i < shortPathsList.size(); i++) {
RouteLineDto routeLineDto = shortPathsList.get(i);
@@ -405,12 +391,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
wo.insert(json);
instructions.add(dto);
}
}
@Override
public void create2(Instruction dto) throws Exception {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
@@ -472,8 +455,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver =
(HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
}
@@ -482,8 +464,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
String next_device_code = dto.getNext_device_code();
String route_plan_code = task.getRoute_plan_code();
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, next_device_code, route_plan_code);
routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto route = null;
for (int i = 0; i < shortPathsList.size(); i++) {
RouteLineDto routeLineDto = shortPathsList.get(i);
@@ -519,12 +500,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
wo.insert(json);
instructions.add(dto);
}
}
@Override
public void createAgain(Instruction dto) throws Exception {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
@@ -608,12 +586,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
// }
instructions.add(dto);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Instruction dto) {
synchronized (TaskInstructionLock.class) {
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
dto.setUpdate_time(now);
@@ -625,7 +601,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
this.reload();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@@ -762,8 +737,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
@Transactional(rollbackFor = Exception.class)
public void finish(Instruction dto) {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
String now = DateUtil.now();
dto.setInstruction_status("2");
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
@@ -817,7 +790,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
removeByCodeFromCache(dto.getInstruction_code());
// this.reload();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@@ -901,8 +873,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public void cancel(String id) throws Exception {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
// flag= true时取消指令
boolean flag = false;
Instruction entity = this.findById(id);
@@ -930,8 +900,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")
&& !StrUtil.equals(entity.getSend_status(), "2")) {
XianGongAgvService xianGongAgvService =
SpringContextHolder.getBean(XianGongAgvService.class);
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
flag = true;
} else {
@@ -1008,12 +977,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
this.reload();
}
}
@Override
public void forceCancel(String id) throws Exception {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
// flag= true时取消指令
boolean flag = false;
Instruction entity = this.findById(id);
@@ -1066,12 +1032,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
removeByCodeFromCache(entity.getInstruction_code());
}
}
@Override
public void cancelNOSendAgv(String id) throws Exception {
Class var2 = TaskInstructionLock.class;
synchronized (TaskInstructionLock.class) {
// flag= true时取消指令
Instruction entity = this.findById(id);
if (entity == null) {
@@ -1126,7 +1089,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
removeByCodeFromCache(entity.getInstruction_code());
}
}
@Override
public Instruction findByLinkNumSend(String code) {
@@ -1145,7 +1107,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public List<Instruction> findByLinkNum(String code) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
List<Instruction> list = new ArrayList<>();
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
@@ -1156,13 +1118,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return list;
}
}
@Override
public Instruction findByLinkNumNoSend(String code) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
@@ -1173,12 +1133,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return null;
}
}
@Override
public Instruction findByCodeFromCache(String code) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
@@ -1188,13 +1147,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return null;
}
}
@Override
public Instruction findByBarcodeFromCache(String barcode) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
@@ -1208,7 +1165,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByIdFromCache(String id) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
@@ -1344,7 +1301,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Integer querySameInstType(String inst_type) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
int num = 0;
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
@@ -1355,12 +1312,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return num;
}
}
@Override
public Integer querySameOriginInst(String devicecode) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
int num = 0;
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
@@ -1376,13 +1332,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return num;
}
}
@Override
public boolean removeByCodeFromCache(String code) {
synchronized (InstructionServiceImpl.class){
synchronized (InstructionServiceImpl.class) {
Iterator<Instruction> iterator = instructions.iterator();
while (iterator.hasNext()) {
Instruction instruction = iterator.next();
@@ -1392,10 +1346,8 @@ synchronized (InstructionServiceImpl.class){
}
}
return false;
}
}
}
}
@Override
public boolean createLkInst(String type, Instruction dto) {

View File

@@ -202,8 +202,10 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
}
} catch (Exception var30) {
if (group != null) {
try {
group.getServer().dispose();
group.clear();
group.remove();
} catch (Exception var6) {

View File

@@ -138,7 +138,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
public Map<String, Object> queryAllByCache(Map whereJson, Pageable page) {
synchronized (TaskServiceImpl.class){
this.reload();
@@ -151,6 +151,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String task_type = (String) whereJson.get("task_type");
List<TaskDto> taskList = new ArrayList();
synchronized (TaskServiceImpl.class){
Iterator<TaskDto> it = tasks.iterator();
while (it.hasNext()) {
TaskDto task = it.next();
@@ -193,6 +194,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
DateUtil.parse(task2.getCreate_time())))
.collect(Collectors.toList());
}
Integer currentPageNumber = page.getPageNumber() + 1;
Integer pageMaxSize = page.getPageSize();
List<TaskDto> taskDtoList =
@@ -204,7 +207,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
jo.put("content", taskDtoList);
jo.put("totalElements", taskList.size());
return jo;
}
}
@Override
@@ -653,7 +656,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TaskDto dto) {
synchronized (TaskServiceImpl.class) {
TaskDto entity = this.findById(dto.getTask_id());
if (entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
@@ -669,6 +672,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
wo.update(json);
synchronized (TaskServiceImpl.class) {
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
@@ -679,6 +683,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
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")) {
@@ -767,7 +772,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
}
}
}
}
}
@Override
@@ -916,7 +921,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
try {
synchronized (TaskServiceImpl.class){
Iterator<TaskDto> it = tasks.iterator();
// 清理缓存
while (it.hasNext()) {
@@ -924,10 +929,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (taskDto.getTask_id().equals(id)) {
tasks.remove(taskDto);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}}
// 判断是否为WMS下发的任务如果是反馈任务状态给WMS
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
@@ -1089,7 +1092,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (acsTask == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
InstructionDto inst = instructionservice.findByTaskid(ids, "instruction_status < 2 ");