指令修改
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
|
||||
package org.nl.acs.instruction.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
@@ -64,7 +62,7 @@ import java.util.stream.Collectors;
|
||||
* @author ldjun
|
||||
* @description 服务实现
|
||||
* @date 2021-03-18
|
||||
**/
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -72,18 +70,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
NDCAgvService ndcAgvService;
|
||||
@Autowired
|
||||
ParamService paramService;
|
||||
@Autowired
|
||||
RouteLineService routeLineService;
|
||||
@Autowired
|
||||
TaskService taskService;
|
||||
@Autowired
|
||||
AcsToLiKuService acsToLiKuService;
|
||||
@Autowired DeviceAppService deviceAppService;
|
||||
@Autowired NDCAgvService ndcAgvService;
|
||||
@Autowired ParamService paramService;
|
||||
@Autowired RouteLineService routeLineService;
|
||||
@Autowired TaskService taskService;
|
||||
@Autowired AcsToLiKuService acsToLiKuService;
|
||||
|
||||
@Override
|
||||
public void autoInitial() {
|
||||
@@ -100,7 +92,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
/*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();
|
||||
// this.reload();
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
String code = (String) whereJson.get("code");
|
||||
@@ -132,12 +124,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
Integer currentPageNumber = page.getPageNumber() + 1;
|
||||
Integer pageMaxSize = page.getPageSize();
|
||||
final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
|
||||
final JSONObject jo =
|
||||
WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
|
||||
JSONArray jsonArray = jo.getJSONArray("content");
|
||||
List<Instruction> instructions = jsonArray.toJavaList(Instruction.class);
|
||||
List<Instruction> instDtoList = instructions.stream().skip((currentPageNumber - 1) * pageMaxSize).limit(pageMaxSize).collect(Collectors.toList());
|
||||
jo.put("content",instDtoList);
|
||||
jo.put("totalElements",jsonArray.size());
|
||||
List<Instruction> instDtoList =
|
||||
instructions.stream()
|
||||
.skip((currentPageNumber - 1) * pageMaxSize)
|
||||
.limit(pageMaxSize)
|
||||
.collect(Collectors.toList());
|
||||
jo.put("content", instDtoList);
|
||||
jo.put("totalElements", jsonArray.size());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@@ -172,7 +169,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
map.put("end_time", end_time);
|
||||
}
|
||||
|
||||
final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
|
||||
final JSONObject jo =
|
||||
WQL.getWO("QINST_QUERY")
|
||||
.addParamMap(map)
|
||||
.pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
|
||||
return jo;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
public Instruction findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json)){
|
||||
if (ObjectUtil.isEmpty(json)) {
|
||||
return null;
|
||||
}
|
||||
final Instruction obj = json.toJavaObject(Instruction.class);
|
||||
@@ -275,7 +275,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Override
|
||||
public void create(Instruction dto) {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
dto = foramte(dto);
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
@@ -309,10 +309,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
dto.setInstruction_type("3");
|
||||
}
|
||||
|
||||
|
||||
//起点设备与终点设备相同则为初始指令
|
||||
// 起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
dto.setCompound_inst("1");
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
@@ -337,7 +337,8 @@ 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()));
|
||||
}
|
||||
|
||||
@@ -345,13 +346,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
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);
|
||||
List<RouteLineDto> shortPathsList =
|
||||
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);
|
||||
String route_device = routeLineDto.getDevice_code();
|
||||
String route_next_device = routeLineDto.getNext_device_code();
|
||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
|
||||
if (route_device.equals(dto.getStart_device_code())
|
||||
&& route_next_device.equals(dto.getNext_device_code())) {
|
||||
route = routeLineDto;
|
||||
break;
|
||||
}
|
||||
@@ -359,15 +363,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (ObjectUtil.isEmpty(route)) {
|
||||
throw new BadRequestException("未查询到相关路由!");
|
||||
}
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto);
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
} else {
|
||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(),dto);
|
||||
if(StrUtil.equals(resp.result,"true")){
|
||||
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto);
|
||||
if (StrUtil.equals(resp.result, "true")) {
|
||||
dto.setSend_status("1");
|
||||
} else {
|
||||
dto.setSend_status("2");
|
||||
@@ -388,11 +393,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create2(Instruction dto) throws Exception {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
dto = foramte(dto);
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
@@ -426,10 +430,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
dto.setInstruction_type("3");
|
||||
}
|
||||
|
||||
|
||||
//起点设备与终点设备相同则为初始指令
|
||||
// 起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
dto.setCompound_inst("1");
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
@@ -454,7 +458,8 @@ 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()));
|
||||
}
|
||||
|
||||
@@ -462,13 +467,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
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);
|
||||
List<RouteLineDto> shortPathsList =
|
||||
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);
|
||||
String route_device = routeLineDto.getDevice_code();
|
||||
String route_next_device = routeLineDto.getNext_device_code();
|
||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
|
||||
if (route_device.equals(dto.getStart_device_code())
|
||||
&& route_next_device.equals(dto.getNext_device_code())) {
|
||||
route = routeLineDto;
|
||||
break;
|
||||
}
|
||||
@@ -476,13 +484,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (ObjectUtil.isEmpty(route)) {
|
||||
throw new BadRequestException("未查询到相关路由!");
|
||||
}
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto);
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
} else {
|
||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -498,12 +507,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void createAgain(Instruction dto) throws Exception {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||
@@ -518,19 +525,34 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (StrUtil.isEmpty(dto.getInstruction_id())) {
|
||||
dto.setInstruction_id(IdUtil.simpleUUID());
|
||||
}
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
||||
List<RouteLineDto> shortPathsList =
|
||||
routeLineService.getShortPathLines(
|
||||
dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||
}
|
||||
String type = shortPathsList.get(0).getType();
|
||||
if (!StrUtil.equals(type, "0")) {
|
||||
JSONObject instcheckjson = instwo.query(" instruction_status <3 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
JSONObject instcheckjson =
|
||||
instwo
|
||||
.query(
|
||||
" instruction_status <3 and next_point_code= '"
|
||||
+ dto.getNext_point_code()
|
||||
+ "'"
|
||||
+ " and start_point_code = '"
|
||||
+ dto.getStart_point_code()
|
||||
+ "'"
|
||||
+ " and task_id = '"
|
||||
+ dto.getTask_id()
|
||||
+ "'")
|
||||
.uniqueResult(0);
|
||||
if (instcheckjson != null) {
|
||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||
}
|
||||
}
|
||||
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||
&& StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
dto.setCompound_inst("1");
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
@@ -545,7 +567,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
wo.insert(json);
|
||||
|
||||
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
|
||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||
@@ -556,20 +577,21 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) {
|
||||
String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString();
|
||||
Device lamddevice = appService.findDeviceByCode(lamd_device);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// != 0 为agv任务
|
||||
// if(!StrUtil.equals(type,"0")){
|
||||
// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")) {
|
||||
// agvService.sendAgvInstToMagic(dto);
|
||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
// agvService.sendAgvInstToNDC(dto);
|
||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
|
||||
// agvService.addOrderSequences(dto);
|
||||
// }
|
||||
// }
|
||||
// if(!StrUtil.equals(type,"0")){
|
||||
// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1"))
|
||||
// {
|
||||
// agvService.sendAgvInstToMagic(dto);
|
||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(),
|
||||
// "2")) {
|
||||
// agvService.sendAgvInstToNDC(dto);
|
||||
// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(),
|
||||
// "3")) {
|
||||
// agvService.addOrderSequences(dto);
|
||||
// }
|
||||
// }
|
||||
instructions.add(dto);
|
||||
}
|
||||
}
|
||||
@@ -578,7 +600,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Instruction dto) {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
@@ -588,16 +610,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
wo.update(json);
|
||||
|
||||
// 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")) {
|
||||
// instructions.add(dto);
|
||||
// }
|
||||
// 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")) {
|
||||
// instructions.add(dto);
|
||||
// }
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
@@ -656,7 +679,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(String id) {
|
||||
Instruction entity = this.findById(id);
|
||||
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
// if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
@@ -738,7 +761,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(Instruction dto) {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
String now = DateUtil.now();
|
||||
dto.setInstruction_status("2");
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
@@ -767,11 +790,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return;
|
||||
}
|
||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||
// device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
@@ -794,14 +818,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishAndCreateNextInst(Instruction dto){
|
||||
public void finishAndCreateNextInst(Instruction dto) {
|
||||
dto = foramte(dto);
|
||||
String device_code = dto.getNext_device_code();
|
||||
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
TaskDto acsTask = taskjson.toJavaObject(TaskDto.class);
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||
List<RouteLineDto> list = routeLineService.getShortPathLines(dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code());
|
||||
List<RouteLineDto> list =
|
||||
routeLineService.getShortPathLines(
|
||||
dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code());
|
||||
if (ObjectUtils.isEmpty(list)) {
|
||||
throw new BadRequestException("路由不通");
|
||||
}
|
||||
@@ -819,8 +845,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
String start_device_code = dto.getNext_device_code();
|
||||
String start_point_code = null;
|
||||
String next_point_code = null;
|
||||
String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
||||
String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
||||
String start_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(start_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
String next_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(next_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
if (StrUtil.equals("storage", start_device)) {
|
||||
start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z();
|
||||
} else {
|
||||
@@ -854,15 +892,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
this.create(instdto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("完成并创建下一条指令",e.getMessage());
|
||||
log.error("完成并创建下一条指令", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String id) throws Exception {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
//flag= true时取消指令
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
// flag= true时取消指令
|
||||
boolean flag = false;
|
||||
Instruction entity = this.findById(id);
|
||||
if (entity == null) {
|
||||
@@ -881,7 +919,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
flag = true;
|
||||
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
//NDC agv指令不当场取消指令,需要等agv上报
|
||||
// NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
ndcAgvService.deleteAgvInstToNDC(entity);
|
||||
} else {
|
||||
@@ -889,7 +927,8 @@ 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 {
|
||||
@@ -898,30 +937,29 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
if (flag) {
|
||||
|
||||
if(StrUtil.equals(entity.getInstruction_type(),"7")){
|
||||
if (StrUtil.equals(entity.getInstruction_type(), "7")) {
|
||||
CancelTaskRequest cancelTaskRequest = new CancelTaskRequest();
|
||||
cancelTaskRequest.setOrderId(entity.getInstruction_code());
|
||||
cancelTaskRequest.setPalletCode(entity.getVehicle_code());
|
||||
cancelTaskRequest.setSrcLocation(entity.getStart_point_code());
|
||||
cancelTaskRequest.setDestLocation(entity.getNext_point_code());
|
||||
//1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库
|
||||
// 1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库
|
||||
int type = 0;
|
||||
if(StrUtil.equals(task.getStorage_task_type(),"1")){
|
||||
if (StrUtil.equals(task.getStorage_task_type(), "1")) {
|
||||
type = 1;
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(),"2")){
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(), "2")) {
|
||||
type = 4;
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(),"3")){
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(), "3")) {
|
||||
type = 2;
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(),"4")){
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(), "4")) {
|
||||
type = 5;
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(),"5")){
|
||||
} else if (StrUtil.equals(task.getStorage_task_type(), "5")) {
|
||||
type = 3;
|
||||
}
|
||||
cancelTaskRequest.setTaskType(type);
|
||||
acsToLiKuService.cancelTask(cancelTaskRequest);
|
||||
}
|
||||
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
@@ -938,7 +976,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "0");
|
||||
@@ -971,8 +1010,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Override
|
||||
public void forceCancel(String id) throws Exception {
|
||||
Class var2 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
//flag= true时取消指令
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
// flag= true时取消指令
|
||||
boolean flag = false;
|
||||
Instruction entity = this.findById(id);
|
||||
if (entity == null) {
|
||||
@@ -997,7 +1036,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "0");
|
||||
@@ -1023,15 +1063,13 @@ 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时取消指令
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
// flag= true时取消指令
|
||||
Instruction entity = this.findById(id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
@@ -1057,7 +1095,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "0");
|
||||
@@ -1086,11 +1125,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Instruction findByLinkNumSend(String code) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) {
|
||||
return inst;
|
||||
@@ -1100,12 +1138,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Instruction> findByLinkNum(String code) {
|
||||
List<Instruction> list = new ArrayList<>();
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
||||
list.add(inst);
|
||||
@@ -1117,7 +1154,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Override
|
||||
public Instruction findByLinkNumNoSend(String code) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
|
||||
return inst;
|
||||
@@ -1130,7 +1167,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Override
|
||||
public Instruction findByCodeFromCache(String code) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(code, inst.getInstruction_code())) {
|
||||
return inst;
|
||||
@@ -1139,11 +1176,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Instruction findByBarcodeFromCache(String barcode) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(barcode, inst.getVehicle_code())) {
|
||||
return inst;
|
||||
@@ -1155,7 +1191,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
@Override
|
||||
public Instruction findByIdFromCache(String id) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(id, inst.getInstruction_id())) {
|
||||
return inst;
|
||||
@@ -1189,7 +1225,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
inst.setFrom_y(start_point[1]);
|
||||
inst.setFrom_z(start_point[2]);
|
||||
} else {
|
||||
String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
||||
String start_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(start_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
if (StrUtil.equals("storage", start_device)) {
|
||||
String[] start_point = start_point_code.split("-");
|
||||
inst.setFrom_x(start_point[0]);
|
||||
@@ -1209,7 +1251,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
inst.setTo_z(next_point[2]);
|
||||
} else {
|
||||
|
||||
String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
|
||||
String next_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(next_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
if (StrUtil.equals("storage", next_device)) {
|
||||
String[] next_point = start_point_code.split("-");
|
||||
inst.setTo_x(next_point[0]);
|
||||
@@ -1227,18 +1275,29 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
public Instruction findByDeviceCodeFromCache(String devicecode) {
|
||||
|
||||
List<Instruction> instructionList = instructions;
|
||||
ListUtil.sort(instructionList, new Comparator<Instruction>() {
|
||||
try {
|
||||
ListUtil.sort(
|
||||
instructionList,
|
||||
new Comparator<Instruction>() {
|
||||
@Override
|
||||
public int compare(Instruction o1, Instruction o2) {
|
||||
return o1.getCreate_time().compareTo(o2.getCreate_time());
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < instructionList.size(); i++) {
|
||||
Instruction inst = instructionList.get(i);
|
||||
if (StrUtil.equals(devicecode, inst.getStart_device_code()) && inst.getInstruction_status().equals("0")) {
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(devicecode, inst.getStart_device_code())
|
||||
&& inst.getInstruction_status().equals("0")) {
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("指令排序按照创建时间执执行失败!重新执行");
|
||||
//失败之后重新查找指令
|
||||
return findByDeviceCodeFromCache(devicecode);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1247,14 +1306,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return instructions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer querySameDestinationInst(String devicecode) {
|
||||
int num = 0;
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
//处理空盘位站点
|
||||
// 处理空盘位站点
|
||||
String next_code = inst.getNext_point_code();
|
||||
if (next_code.indexOf(".") != -1) {
|
||||
next_code = next_code.substring(0, next_code.indexOf("."));
|
||||
@@ -1271,7 +1329,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
public Integer querySameInstType(String inst_type) {
|
||||
int num = 0;
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
if (StrUtil.equals(inst.getInstruction_type(), inst_type)) {
|
||||
num = num + 1;
|
||||
@@ -1284,9 +1342,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
public Integer querySameOriginInst(String devicecode) {
|
||||
int num = 0;
|
||||
Iterator<Instruction> it = instructions.iterator();
|
||||
while (it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
Instruction inst = it.next();
|
||||
//处理空盘位站点
|
||||
// 处理空盘位站点
|
||||
String start_code = inst.getStart_point_code();
|
||||
if (start_code.indexOf(".") != -1) {
|
||||
start_code = start_code.substring(0, start_code.indexOf("."));
|
||||
@@ -1312,15 +1370,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createLkInst(String type, Instruction dto) {
|
||||
Class var3 = TaskInstructionLock.class;
|
||||
synchronized(TaskInstructionLock.class) {
|
||||
//入库
|
||||
synchronized (TaskInstructionLock.class) {
|
||||
// 入库
|
||||
AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class);
|
||||
Resp resp = null;
|
||||
if(StrUtil.equals(type,"1")){
|
||||
if (StrUtil.equals(type, "1")) {
|
||||
InStoreRequest request = new InStoreRequest();
|
||||
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
||||
request.setType(1);
|
||||
@@ -1329,8 +1386,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
request.setSrcLocation(dto.getStart_point_code());
|
||||
request.setDestLocation(dto.getNext_point_code());
|
||||
resp = acsToLiKuService.inStore(request);
|
||||
//空托入库
|
||||
} else if (StrUtil.equals(type,"2")){
|
||||
// 空托入库
|
||||
} else if (StrUtil.equals(type, "2")) {
|
||||
InStoreRequest request = new InStoreRequest();
|
||||
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
|
||||
request.setType(2);
|
||||
@@ -1339,8 +1396,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
request.setSrcLocation(dto.getStart_point_code());
|
||||
request.setDestLocation(dto.getNext_point_code());
|
||||
resp = acsToLiKuService.inStore(request);
|
||||
//出库
|
||||
} else if (StrUtil.equals(type,"3")){
|
||||
// 出库
|
||||
} else if (StrUtil.equals(type, "3")) {
|
||||
OutStoreRequest outStore = new OutStoreRequest();
|
||||
BaseStoreRequest baseReq = new BaseStoreRequest();
|
||||
List<BaseStoreRequest> list = new ArrayList();
|
||||
@@ -1353,8 +1410,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
outStore.setOrderInfos(list);
|
||||
outStore.setGroupId(dto.getInstruction_code());
|
||||
resp = acsToLiKuService.outStore(outStore);
|
||||
//空托出库
|
||||
} else if (StrUtil.equals(type,"4")) {
|
||||
// 空托出库
|
||||
} else if (StrUtil.equals(type, "4")) {
|
||||
EmptyVehicleOutStoreRequest emptyVehicleOutStoreRequest = new EmptyVehicleOutStoreRequest();
|
||||
emptyVehicleOutStoreRequest.setOrderId(dto.getInstruction_code());
|
||||
emptyVehicleOutStoreRequest.setFloorNo(Integer.parseInt(dto.getFrom_z()));
|
||||
@@ -1362,8 +1419,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
emptyVehicleOutStoreRequest.setDestLocation(dto.getNext_point_code());
|
||||
emptyVehicleOutStoreRequest.setPalletCode(dto.getVehicle_code());
|
||||
resp = acsToLiKuService.emptyVehicleOutStore(emptyVehicleOutStoreRequest);
|
||||
//转库
|
||||
} else if (StrUtil.equals(type,"5")) {
|
||||
// 转库
|
||||
} else if (StrUtil.equals(type, "5")) {
|
||||
MoveStoreRequest moveStoreRequest = new MoveStoreRequest();
|
||||
BaseStoreRequest baseReq = new BaseStoreRequest();
|
||||
List<BaseStoreRequest> list = new ArrayList();
|
||||
@@ -1378,8 +1435,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
resp = acsToLiKuService.moveStore(moveStoreRequest);
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNotEmpty(resp)){
|
||||
if(StrUtil.equals(resp.getResult(),"true")){
|
||||
if (ObjectUtil.isNotEmpty(resp)) {
|
||||
if (StrUtil.equals(resp.getResult(), "true")) {
|
||||
dto.setSend_status("1");
|
||||
} else {
|
||||
dto.setSend_status("2");
|
||||
@@ -1395,7 +1452,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Instruction findByContainer(String container_code) {
|
||||
Iterator var3 = instructions.iterator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user