fix
This commit is contained in:
@@ -82,7 +82,10 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
int nextAddress = 520;
|
||||
if(!inst.getInstruction_type().equals("3")){
|
||||
deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
}
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(1);
|
||||
@@ -145,13 +148,14 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X0C,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
(byte) phasehigh, (byte) phaselow,
|
||||
(byte) nextPointHigh,(byte) nextPointLow
|
||||
};
|
||||
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
|
||||
@@ -219,6 +219,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
//到达放货等待点
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x06) {
|
||||
data = getData(data, index, inst, task);
|
||||
//到达放货点
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x07) {
|
||||
@@ -332,34 +333,16 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
|
||||
private byte[] getData(byte[] data, int index, Instruction inst, TaskDto task) {
|
||||
String next_point;
|
||||
String start_point;
|
||||
int next_height;
|
||||
int start_height;
|
||||
if (!"2".equals(task.getTask_type())) {
|
||||
BaseRequest request = new BaseRequest();
|
||||
request.setRequestNo(IdUtil.simpleUUID());
|
||||
request.setTaskId(task.getExt_task_id());
|
||||
JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request));
|
||||
if ("200".equals(resp.getString("code"))) {
|
||||
start_height = resp.getJSONObject("parameters").getInteger("start_height");
|
||||
next_height = resp.getJSONObject("parameters").getInteger("next_height");
|
||||
start_point = resp.getJSONObject("parameters").getString("start_point");
|
||||
next_point = resp.getJSONObject("parameters").getString("next_point");
|
||||
task.setStart_height(String.valueOf(start_height));
|
||||
task.setNext_height(String.valueOf(next_height));
|
||||
task.setStart_point_code(start_point);
|
||||
task.setStart_device_code(start_point);
|
||||
task.setNext_point_code(next_point);
|
||||
task.setNext_device_code(next_point);
|
||||
int start_address = deviceService.queryAddressBydeviceCode(start_point);
|
||||
int next_address = deviceService.queryAddressBydeviceCode(next_point);
|
||||
String resp = acsToWmsService.requestTaskAgain(task.getNext_point_code(),task.getExt_task_id(),inst.getVehicle_code());
|
||||
JSONObject respjson = JSONObject.parseObject(resp);
|
||||
String next_device_code = respjson.getString("next_point_code");
|
||||
task.setNext_point_code(next_device_code);
|
||||
int start_address = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int next_address = deviceService.queryAddressBydeviceCode(next_device_code);
|
||||
taskService.update(task);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, start_address, next_address, start_height, next_height);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, start_address, next_address, 0, 0);
|
||||
log.info("指令号:{},phase:{},acs请求wms申请成功", inst.getInstruction_code(), phase);
|
||||
} else {
|
||||
log.info("指令号:{},phase:{},acs请求wms申请失败", inst.getInstruction_code(), phase);
|
||||
}
|
||||
} else {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.auto.run.AbstractAutoRunnable;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.config.thread.TheadFactoryName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
@@ -15,6 +17,7 @@ import java.util.concurrent.*;
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@Lazy
|
||||
public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService;
|
||||
@@ -89,32 +92,35 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
log.info("设备执行线程开始...");
|
||||
|
||||
while (true) {
|
||||
Thread.sleep((long) this.loop_time_millions);
|
||||
List<ExecutableDeviceDriver> deviceDrivers = this.deviceAppService.findDeviceDriver(ExecutableDeviceDriver.class);
|
||||
|
||||
Iterator it = deviceDrivers.iterator();
|
||||
while (it.hasNext()) {
|
||||
final ExecutableDeviceDriver deviceDriver = (ExecutableDeviceDriver) it.next();
|
||||
//不包含正在执行的线程,则进行执行
|
||||
if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) {
|
||||
BlockedRunable runnable = new BlockedRunable() {
|
||||
@Override
|
||||
public void subRun() throws Exception {
|
||||
deviceDriver.executeAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return deviceDriver.getDeviceCode();
|
||||
}
|
||||
};
|
||||
try {
|
||||
Thread.sleep((long) this.loop_time_millions);
|
||||
List<ExecutableDeviceDriver> deviceDrivers = this.deviceAppService.findDeviceDriver(ExecutableDeviceDriver.class);
|
||||
Iterator it = deviceDrivers.iterator();
|
||||
while (it.hasNext()) {
|
||||
final ExecutableDeviceDriver deviceDriver = (ExecutableDeviceDriver) it.next();
|
||||
//不包含正在执行的线程,则进行执行
|
||||
if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) {
|
||||
this.runs.put(deviceDriver.getDeviceCode(), runnable);
|
||||
}
|
||||
BlockedRunable runnable = new BlockedRunable() {
|
||||
@Override
|
||||
public void subRun() throws Exception {
|
||||
deviceDriver.executeAuto();
|
||||
}
|
||||
|
||||
runnable.setIndex(this.runs);
|
||||
this.executorService.submit(runnable);
|
||||
@Override
|
||||
public String getCode() {
|
||||
return deviceDriver.getDeviceCode();
|
||||
}
|
||||
};
|
||||
if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) {
|
||||
this.runs.put(deviceDriver.getDeviceCode(), runnable);
|
||||
}
|
||||
|
||||
runnable.setIndex(this.runs);
|
||||
this.executorService.submit(runnable);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.info("设备执行线程失败DeviceExecuteAutoRun:{}{}",e,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,13 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.domain.DeviceExtra;
|
||||
import org.nl.acs.device.service.mapper.DeviceExtraMapper;
|
||||
import org.nl.acs.device.service.mapper.DeviceMapper;
|
||||
import org.nl.acs.device.service.mapper.DeviceRunpointMapper;
|
||||
import org.nl.acs.opc.domain.Opc;
|
||||
import org.nl.acs.opc.domain.OpcPlc;
|
||||
import org.nl.acs.opc.service.mapper.OpcMapper;
|
||||
import org.nl.acs.opc.service.mapper.OpcPlcMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,11 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
|
||||
@Autowired
|
||||
@@ -48,19 +41,24 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
|
||||
@Override
|
||||
public List<DeviceManageDto> queryAllWithExtra() {
|
||||
// JSONArray arr = WQLObject.getWQLObject("acs_device").query().getResultJSONArray(0);
|
||||
// 获取所有的设备
|
||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper).list();
|
||||
List<Device> deviceList= new LambdaQueryChainWrapper<>(deviceMapper).list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
|
||||
|
||||
// 获取列表扩展
|
||||
List<DeviceExtra> deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper).list();
|
||||
// JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query().getResultJSONArray(0);
|
||||
List<DeviceExtra> deviceExtraList= new LambdaQueryChainWrapper<>(deviceExtraMapper).list();
|
||||
JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList));
|
||||
|
||||
// 设备+扩展DTO
|
||||
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
|
||||
|
||||
// WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
|
||||
// WQLObject opcTab = WQLObject.getWQLObject("acs_opc");
|
||||
//OPC_PLC表【acs_opc_plc】
|
||||
// WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc");
|
||||
List<DeviceManageDto> devices = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
@@ -69,23 +67,18 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
String opc_plc_id = json.getString("opc_plc_id");
|
||||
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
|
||||
//OPC表【acs_opc】
|
||||
Opc opc = new LambdaQueryChainWrapper<>(opcMapper).apply("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'")
|
||||
.one();
|
||||
if (opc == null) {
|
||||
log.info("设备:{},配置的OPC数据源不存在,opc_id:{}", json.getString("device_code"), opc_server_id);
|
||||
continue;
|
||||
}
|
||||
device.setOpc_server_code(opc.getOpc_code());
|
||||
if (ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one())) {
|
||||
// String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
|
||||
String opc_code = new LambdaQueryChainWrapper<>(opcMapper).apply("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").one().getOpc_code();
|
||||
device.setOpc_server_code(opc_code);
|
||||
// if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
|
||||
if(ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one()))
|
||||
{
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
OpcPlc opcPlc = new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one();
|
||||
if (opcPlc == null) {
|
||||
log.info("设备:{},配置的PLC数据源不存在,plc_id:{}", json.getString("device_code"), opc_plc_id);
|
||||
continue;
|
||||
}
|
||||
device.setOpc_plc_code(opcPlc.getPlc_code());
|
||||
// String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
|
||||
String plc_code = new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one().getPlc_code();
|
||||
device.setOpc_plc_code(plc_code);
|
||||
}
|
||||
devices.add(device);
|
||||
}
|
||||
@@ -100,6 +93,10 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
if (extra.getDevice_id().equals(device.getDevice_id())) {
|
||||
device.getExtra().add(extra);
|
||||
if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) {
|
||||
// String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods");
|
||||
// String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type");
|
||||
// String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch");
|
||||
// String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock");
|
||||
String has_goods = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getHasgoods();
|
||||
String material_type = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getMaterial_type();
|
||||
String batch = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getBatch();
|
||||
@@ -118,15 +115,21 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
|
||||
@Override
|
||||
public List<DeviceManageDto> queryAllWithExtra(String device_code) {
|
||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper).eq(Device::getDevice_code, device_code).list();
|
||||
// JSONArray arr = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + " '").getResultJSONArray(0);
|
||||
List<Device> deviceList= new LambdaQueryChainWrapper<>(deviceMapper).eq(Device::getDevice_code,device_code).list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
|
||||
|
||||
List<DeviceExtra> deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_code, device_code).list();
|
||||
// JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query("device_code = '" + device_code + " '").getResultJSONArray(0);
|
||||
List<DeviceExtra> deviceExtraList= new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_code,device_code).list();
|
||||
JSONArray extArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList));
|
||||
|
||||
List<DeviceExtraManageDto> extras = extArr.toJavaList(DeviceExtraManageDto.class);
|
||||
|
||||
// WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
|
||||
// WQLObject opcTab = WQLObject.getWQLObject("acs_opc");
|
||||
//OPC_PLC表【acs_opc_plc】
|
||||
// WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc");
|
||||
List<DeviceManageDto> devices = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
@@ -134,17 +137,22 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
String opc_server_id = json.getString("opc_server_id");
|
||||
String opc_plc_id = json.getString("opc_plc_id");
|
||||
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
|
||||
//OPC表【acs_opc】
|
||||
// JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
|
||||
Opc opc = new LambdaQueryChainWrapper<>(opcMapper).apply("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").one();
|
||||
if (ObjectUtil.isEmpty(opc)) {
|
||||
if(ObjectUtil.isEmpty(opc)){
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
String opc_code = opc.getOpc_code();
|
||||
String opc_code=opc.getOpc_code();
|
||||
device.setOpc_server_code(opc_code);
|
||||
if (ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one())) {
|
||||
// if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
|
||||
if(ObjectUtil.isEmpty(new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one()))
|
||||
{
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
// String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
|
||||
String plc_code = new LambdaQueryChainWrapper<>(opcPlcMapper).apply("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").one().getPlc_code();
|
||||
device.setOpc_plc_code(plc_code);
|
||||
}
|
||||
@@ -161,6 +169,10 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
if (extra.getDevice_id().equals(device.getDevice_id())) {
|
||||
device.getExtra().add(extra);
|
||||
if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) {
|
||||
// String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods");
|
||||
// String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type");
|
||||
// String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch");
|
||||
// String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock");
|
||||
String has_goods = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getHasgoods();
|
||||
String material_type = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getMaterial_type();
|
||||
String batch = new LambdaQueryChainWrapper<>(deviceRunpointMapper).apply("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").one().getBatch();
|
||||
|
||||
@@ -117,7 +117,7 @@ public class GHCMLTask extends AbstractTask {
|
||||
task.setGroup_id(setGroupPlate(jsonObject));
|
||||
// 设置等待点并修改创建成功状态
|
||||
// task.setNext_wait_point(point.getPoint_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
task.setPoint_code2("DDD");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
task.setRemark("");
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
@@ -126,10 +126,6 @@ public class GHCMLTask extends AbstractTask {
|
||||
PointUtils.setUpdateByAcs(point);
|
||||
pointService.updateById(point);
|
||||
|
||||
//任务创建后锁住起点
|
||||
startPoint.setIng_task_code(task.getTask_code());
|
||||
pointService.updateById(startPoint);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +148,10 @@ public class GHCMLTask extends AbstractTask {
|
||||
.eq(SchBasePoint::getRow_num, sameMaterialPoints.getRow_num())
|
||||
.eq(SchBasePoint::getIs_used, true)
|
||||
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode())
|
||||
// 当前执行的任务为空或者NULL,有数据表示锁住
|
||||
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
|
||||
.or()
|
||||
.eq(SchBasePoint::getIng_task_code, ""))
|
||||
.orderByAsc(SchBasePoint::getCol_num), false);
|
||||
if (ObjectUtil.isNotEmpty(point)) {
|
||||
return point;
|
||||
@@ -299,54 +299,61 @@ public class GHCMLTask extends AbstractTask {
|
||||
if (ObjectUtil.isEmpty(task)) {
|
||||
throw new BadRequestException("任务:[" + task_id + "]不存在!");
|
||||
}
|
||||
String waitPoint = task.getNext_wait_point();
|
||||
if (ObjectUtil.isEmpty(waitPoint)) {
|
||||
throw new BadRequestException("找不到任务:[" + task_id + "]等待点!");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(task.getPoint_code2())) {
|
||||
throw new BadRequestException("任务:[" + task_id + "]已请求过!");
|
||||
}
|
||||
SchBasePoint waitPointObj = pointService.getById(waitPoint);
|
||||
SchBasePoint result;
|
||||
// 找到这排对应的准确货位,
|
||||
// hint: 需要考虑前后空,中间有货的情况,有货之后的即使是空也不能放。
|
||||
// 寻找有货的数据
|
||||
List<SchBasePoint> points = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
.eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
|
||||
.eq(SchBasePoint::getIs_used, true)
|
||||
.orderByDesc(SchBasePoint::getIn_order_seq));
|
||||
if (points.size() > 0) {
|
||||
SchBasePoint basePoint = points.get(0);
|
||||
// 找到物料位置的下一个位置
|
||||
result = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
.eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
.eq(SchBasePoint::getCol_num, basePoint.getCol_num() - 1)
|
||||
// 当前执行的任务为空或者NULL,有数据表示锁住
|
||||
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
|
||||
.or()
|
||||
.eq(SchBasePoint::getIng_task_code, ""))
|
||||
.eq(SchBasePoint::getIs_used, true));
|
||||
if (ObjectUtil.isEmpty(result)) {
|
||||
throw new BadRequestException("点位错误");
|
||||
}
|
||||
} else {
|
||||
// 空的话代表这排是新的一排,找个位置就行
|
||||
points = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
.eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode())
|
||||
// 当前执行的任务为空或者NULL,有数据表示锁住
|
||||
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
|
||||
.or()
|
||||
.eq(SchBasePoint::getIng_task_code, ""))
|
||||
.eq(SchBasePoint::getIs_used, true)
|
||||
.orderByAsc(SchBasePoint::getIn_order_seq));
|
||||
// 获取第一条
|
||||
result = points.get(0);
|
||||
// String waitPoint = task.getNext_wait_point();
|
||||
// if (ObjectUtil.isEmpty(waitPoint)) {
|
||||
// throw new BadRequestException("找不到任务:[" + task_id + "]等待点!");
|
||||
// }
|
||||
if (!"DDD".equals(task.getPoint_code2())) {
|
||||
log.info("任务号{}已请求过二次分配,直接返回已分配地址{}",task_id,task.getPoint_code2());
|
||||
return task.getPoint_code2();
|
||||
}
|
||||
// SchBasePoint waitPointObj = pointService.getById(waitPoint);
|
||||
// SchBasePoint result;
|
||||
// // 找到这排对应的准确货位,
|
||||
// // hint: 需要考虑前后空,中间有货的情况,有货之后的即使是空也不能放。
|
||||
// // 寻找有货的数据
|
||||
// List<SchBasePoint> points = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
// .eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
// .eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
// .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
|
||||
// .eq(SchBasePoint::getIs_used, true)
|
||||
// .orderByDesc(SchBasePoint::getIn_order_seq));
|
||||
// if (points.size() > 0) {
|
||||
// SchBasePoint basePoint = points.get(0);
|
||||
// // 找到物料位置的下一个位置
|
||||
// result = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
|
||||
// .eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
// .eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
// .eq(SchBasePoint::getCol_num, basePoint.getCol_num() - 1)
|
||||
// // 当前执行的任务为空或者NULL,有数据表示锁住
|
||||
// .and(la -> la.isNull(SchBasePoint::getIng_task_code)
|
||||
// .or()
|
||||
// .eq(SchBasePoint::getIng_task_code, ""))
|
||||
// .eq(SchBasePoint::getIs_used, true));
|
||||
// if (ObjectUtil.isEmpty(result)) {
|
||||
// throw new BadRequestException("点位错误");
|
||||
// }
|
||||
// } else {
|
||||
// // 空的话代表这排是新的一排,找个位置就行
|
||||
// points = pointService.list(new LambdaQueryWrapper<SchBasePoint>()
|
||||
// .eq(SchBasePoint::getRegion_code, waitPointObj.getRegion_code())
|
||||
// .eq(SchBasePoint::getRow_num, waitPointObj.getRow_num())
|
||||
// .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode())
|
||||
// // 当前执行的任务为空或者NULL,有数据表示锁住
|
||||
// .and(la -> la.isNull(SchBasePoint::getIng_task_code)
|
||||
// .or()
|
||||
// .eq(SchBasePoint::getIng_task_code, ""))
|
||||
// .eq(SchBasePoint::getIs_used, true)
|
||||
// .orderByAsc(SchBasePoint::getIn_order_seq));
|
||||
// // 获取第一条
|
||||
// result = points.get(0);
|
||||
// }
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
JSONObject jsonObject = JSONObject.parseObject(task.getRequest_param());
|
||||
SchBasePoint result = findNextPoint(nextRegionStr, jsonObject);
|
||||
// 锁住货位点
|
||||
PointUtils.setUpdateByAcs(result);
|
||||
result.setIng_task_code(task.getTask_code());
|
||||
|
||||
Reference in New Issue
Block a user