add:新增更新任务点位状态接口

This commit is contained in:
2024-04-16 11:22:48 +08:00
parent abf7964c96
commit 8ef027be85
3 changed files with 95 additions and 0 deletions

View File

@@ -54,6 +54,13 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmstoacsService.updateDeviceGoodsFromWms(whereJson), HttpStatus.OK);
}
@PostMapping("/updateTask")
@Log(value = "WMS更新任务点位状态")
@SaIgnore
public ResponseEntity<Object> updateTask(@RequestBody String whereJson){
return new ResponseEntity<>(wmstoacsService.updateTask(whereJson), HttpStatus.OK);
}
@PostMapping("/areaControl")
@Log(value = "区域控制")
public ResponseEntity<Object> areaControl(@RequestBody JSONObject whereJson) {

View File

@@ -25,6 +25,14 @@ public interface WmsToAcsService {
*/
CreateTaskResponse crateTask(List<CreateTaskRequest> reqs);
/**
* 更新任务点位状态
*
* @param whereJson 条件
* @return Map<String, Object>
*/
Map<String, Object> updateTask(String whereJson);
/**
* 取消任务

View File

@@ -15,7 +15,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver;
import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.BoxPackageManipulatorDeviceDriver;
import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver;
import org.nl.acs.device_driver.paper_tube_device2.PaperTubeConveyor2DeviceDriver;
@@ -34,6 +36,7 @@ import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.ext.wms.service.WmsToAcsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.storage_cell.domain.StorageCell;
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
@@ -68,6 +71,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Autowired
private LuceneExecuteLogService luceneExecuteLogService;
@Autowired
private InstructionService instructionService;
@Autowired
private AcsToLiKuService acsToLiKuService;
@@ -387,6 +393,80 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return null;
}
@Override
public Map<String, Object> updateTask(String whereJson) {
JSONArray datas = JSONArray.parseArray(whereJson);
log.info("updateTask--------------:输入参数" + datas.toString());
JSONArray errArr = new JSONArray();
if (datas.size() > 0) {
for (int i = 0; i < datas.size(); i++) {
JSONObject jsonObject = datas.getJSONObject(i);
String device_code = jsonObject.getString("device_code");
String task_code = jsonObject.getString("task_code");
//1-允许取放; 2-允许离开
String option = jsonObject.getString("option");
Instruction inst = instructionService.findByTaskcode(task_code);
if (ObjectUtil.isEmpty(inst)) {
JSONObject jo = new JSONObject();
jo.put("task_code", task_code);
jo.put("message", "未找到对应任务");
errArr.add(jo);
continue;
} else {
String carNo = inst.getCarno();
if (ObjectUtil.isEmpty(carNo)) {
JSONObject jo = new JSONObject();
jo.put("task_code", task_code);
jo.put("message", "未找到任务对应车号");
errArr.add(jo);
continue;
} else {
Device device = deviceAppService.findDeviceByCode(carNo);
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
int phase = agvNdcTwoDeviceDriver.getPhase();
if (phase == 0x03 || phase == 0x05 || phase == 0x08) {
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
Device device_k = deviceAppService.findDeviceByCode(device_code + "_K");
Device device_m = deviceAppService.findDeviceByCode(device_code + "_M");
if (device_k.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_k.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option));
standardOrdinarySiteDeviceDriver.setTask_code(task_code);
}
if (device_m.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_m.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option));
standardOrdinarySiteDeviceDriver.setTask_code(task_code);
}
} else {
JSONObject jo = new JSONObject();
jo.put("task_code", task_code);
jo.put("message", "AGV未就绪无法设置");
errArr.add(jo);
continue;
}
}
}
}
}
}
JSONObject resultJson = new JSONObject();
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("status", HttpStatus.OK.value());
resultJson.put("message", "操作成功");
} else {
resultJson.put("status", HttpStatus.BAD_REQUEST.value());
resultJson.put("message", "操作失败");
if (ObjectUtil.isNotEmpty(errArr)) {
resultJson.put("errArr", errArr);
}
}
return resultJson;
}
@Override
public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List<org.nl.acs.ext.wms.data.one.CancelTaskRequest> reqs) throws Exception {
return null;