fix 反向组盘

This commit is contained in:
张江玮
2023-07-20 11:19:52 +08:00
parent 1b3a849fd7
commit 3e06329f58
5 changed files with 56 additions and 21 deletions

View File

@@ -24,7 +24,7 @@ public interface OpcDeviceDriver extends DeviceDriver {
//设备扩展表【acs_device_extra】
WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra");
JSONArray arr = extraTab.query("filed_type='02' and device_id = '" + this.getDevice().getDevice_id() + "'").getResultJSONArray(0);
JSONArray arr = extraTab.query("filed_type IN ('02', '03') and device_id = '" + this.getDevice().getDevice_id() + "'").getResultJSONArray(0);
for (int i = 0; i < arr.size(); i++) {
JSONObject json = arr.getJSONObject(i);
OpcItemDto dto = new OpcItemDto();

View File

@@ -8,6 +8,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
@@ -22,6 +23,8 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -107,6 +110,9 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
String last_material;
int barcode;
int last_barcode;
int to_command;
int to_target;
int to_task;
@Override
public Device getDevice() {
@@ -130,6 +136,9 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
weight = this.itemProtocol.getWeight();
material = this.itemProtocol.getMaterial();
barcode = this.itemProtocol.getBarcode();
to_command = this.itemProtocol.getToCommand();
to_target = this.itemProtocol.getToTarget();
to_task = this.itemProtocol.getToTask();
if (mode != last_mode) {
this.setRequireSucess(false);
@@ -248,12 +257,6 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
}
}
break;
case 8:
//入窑扫码
// if (!requireSucess && this.move != 0) {
// reverseGroup();
// }
break;
case 11:
// 半托缓存强制去包装
if (ObjectUtil.isNotEmpty(ignore_pickup_check) && "true".equals(ignore_pickup_check.toString())) {
@@ -276,6 +279,11 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
sendEmpty();
}
}
case 17:
// 反向组盘
if (!requireSucess && this.move != 0 && this.task != 0) {
reverseGroup();
}
}
// switch (flag) {
@@ -533,18 +541,18 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
} else {
this.instruction_require_time = date;
String task_id = SpringContextHolder.getBean(InstructionService.class).findByCode(String.valueOf(task)).getTask_id();
String task_uuid = SpringContextHolder.getBean(TaskService.class).findById(task_id).getExt_task_uuid();
JSONObject json = new JSONObject();
json.put("task_id", task_uuid);
json.put("vehicle_code", barcode);
HttpResponse result = acsToWmsService.reverseGroup(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 || StrUtil.equals(jsonObject.getString("status"), "200")) {
this.writing(1);
this.setRequireSucess(true);
Instruction inst = SpringContextHolder.getBean(InstructionService.class).findByCode(String.valueOf(task));
if (!StrUtil.startWith(inst.getTask_code(), "-")) {
JSONObject json = new JSONObject();
json.put("task_code", inst.getTask_code());
json.put("vehicle_code", barcode);
HttpResponse result = acsToWmsService.reverseGroup(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 || StrUtil.equals(jsonObject.getString("status"), "200")) {
this.writing(this.mode);
this.setRequireSucess(true);
}
}
}
}
@@ -599,6 +607,20 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
}
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
server.disconnect();
logServer.deviceExecuteLog(this.device_code, "", "", param + " 写入 " + value);
}
@Override
public JSONObject getDeviceStatusName() throws Exception {
String mode;

View File

@@ -990,7 +990,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String wmsurl = acsConfigService.findByCode(AcsConfig.WMSURL).getValue();
HttpResponse result = null;
log.info("reverseGroup - 请求");
log.info("reverseGroup - 请求参数 {}", param);
AddressDto addressDto = addressService.findByCode("reverseGroup");
String methods_url = addressDto.getMethods_url();
try {

View File

@@ -755,7 +755,12 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
&& (lnshStationDeviceDriver.getIo_action() == 2 || lnshStationDeviceDriver.getIo_action() == 3)) {
inst.setExecute_status("6");
instructionService.update(inst);
lnshStationDeviceDriver.writing(3);
while (!inst.getInstruction_code().equals(String.valueOf(lnshStationDeviceDriver.getTo_task()))) {
lnshStationDeviceDriver.writing("to_task", inst.getInstruction_code());
}
while (lnshStationDeviceDriver.getTo_command() != 3) {
lnshStationDeviceDriver.writing(3);
}
data = AgvService.sendAgvOneModeInst(phase, index, 0);
lnshStationDeviceDriver.setMessage("");
flag = true;

View File

@@ -516,6 +516,14 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
throw new BadRequestException("任务编码不能为空!");
}
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_code = '" + task_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(task)) {
throw new BadRequestException("未查询到任务 [" + task_code + "] ");
}
JSONObject vd_update = new JSONObject();
vd_update.put("vehicle_code", vehicle_code);
WQLObject.getWQLObject("st_ivt_vehicle_detail").update(vd_update, "vd_id = " + task.getString("group_id"));
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "组盘成功!");