Compare commits
2 Commits
c5c3e50b60
...
82444f02bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82444f02bf | ||
|
|
a8726ede44 |
@@ -97,5 +97,12 @@ public class ProductOutTwoController {
|
||||
return new ResponseEntity<>(productOutTwoService.outExcepionPointPass(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/vehicleUnbind")
|
||||
@Log("空托盘解绑")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> vehicleUnbind(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(productOutTwoService.vehicleUnbind(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -92,4 +92,6 @@ public interface ProductOutTwoService {
|
||||
JSONObject boxOut(JSONObject whereJson);
|
||||
|
||||
JSONObject outExcepionPointPass(JSONObject whereJson);
|
||||
|
||||
JSONObject vehicleUnbind(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package org.nl.b_lms.pda.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.b_lms.pda.service.ProductOutTwoService;
|
||||
import org.nl.b_lms.pdm.info.dao.PdmBiOrderbominfo;
|
||||
import org.nl.b_lms.pdm.info.service.IPdmBiOrderbominfoService;
|
||||
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation;
|
||||
import org.nl.b_lms.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService;
|
||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
|
||||
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxlashboundService;
|
||||
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxlashbound;
|
||||
@@ -52,6 +58,12 @@ public class ProductOutTwoServiceImpl implements ProductOutTwoService {
|
||||
@Autowired
|
||||
private OutBoxManageService outBoxManageService;
|
||||
|
||||
@Autowired
|
||||
private IpdmBiSubpackagerelationService ipdmBiSubpackagerelationService;
|
||||
|
||||
@Autowired
|
||||
private IschBaseTaskService ischBaseTaskService;
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject ivtQuery(JSONObject whereJson) {
|
||||
@@ -238,4 +250,64 @@ public class ProductOutTwoServiceImpl implements ProductOutTwoService {
|
||||
result.put("message", "成功放行!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject vehicleUnbind(JSONObject whereJson) {
|
||||
String vehicle_code = whereJson.getString("vehicle_code");
|
||||
|
||||
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("托盘号不能为空!");
|
||||
}
|
||||
|
||||
WQLObject vehicle_ext = WQLObject.getWQLObject("md_pb_storagevehicleext");
|
||||
|
||||
JSONObject vehicle_info = vehicle_ext.query("storagevehicle_code = '" + vehicle_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(vehicle_info)) {
|
||||
throw new BadRequestException("未查询到载具【" + vehicle_code + "】对应的绑定关系");
|
||||
}
|
||||
|
||||
String box_no = vehicle_info.getString("pcsn");
|
||||
if (StringUtils.isEmpty(box_no)) {
|
||||
throw new BadRequestException("载具【" + vehicle_code + "】上未绑定木箱!");
|
||||
}
|
||||
|
||||
List<PdmBiSubpackagerelation> list = ipdmBiSubpackagerelationService.list(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getPackage_box_sn, box_no));
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
boolean anyMatch = list.stream().anyMatch(sub -> sub.getStatus().equals("1") || sub.getStatus().equals("2"));
|
||||
if (anyMatch) {
|
||||
throw new BadRequestException("载具上木箱【" + box_no + "】的包装关系为包装或者入库状态!");
|
||||
}
|
||||
}
|
||||
|
||||
String collect = list.stream().map(sub -> sub.getContainer_name()).collect(Collectors.joining("','"));
|
||||
|
||||
JSONArray ivt_arr = WQLObject.getWQLObject("st_ivt_structivt").query("pcsn IN ('" + collect + "')").getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(ivt_arr)) {
|
||||
throw new BadRequestException("载具【" + vehicle_code + "】上绑定的木箱【" + box_no + "】存在库存,不能进行解绑!");
|
||||
}
|
||||
|
||||
int hasTask = ischBaseTaskService.count(new QueryWrapper<SchBaseTask>()
|
||||
.eq("is_delete", "0")
|
||||
.eq("vehicle_code2", vehicle_code)
|
||||
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
|
||||
|
||||
if (hasTask > 0) {
|
||||
throw new BadRequestException("该托盘【" + vehicle_code + "】存在正在执行中的任务,不能进行解绑!");
|
||||
}
|
||||
|
||||
int hasTask2 = ischBaseTaskService.count(new QueryWrapper<SchBaseTask>()
|
||||
.eq("is_delete", "0")
|
||||
.eq("vehicle_code", box_no)
|
||||
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
|
||||
|
||||
if (hasTask2 > 0) {
|
||||
throw new BadRequestException("该木箱【" + box_no + "】存在正在执行中的任务,不能进行解绑!");
|
||||
}
|
||||
|
||||
vehicle_info.put("pcsn", "");
|
||||
vehicle_ext.update(vehicle_info);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("message", "操作成功!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,11 +179,6 @@ public class TwoOutBoxTask extends AbstractAcsTask {
|
||||
packageInfo.put("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("空载具"));
|
||||
packageInfo.put("container_name", jsonTask.getString("vehicle_code"));
|
||||
packageinfoivt.update(packageInfo);
|
||||
RedissonUtils.lock(c -> {
|
||||
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
|
||||
immediateNotifyAcs(null);
|
||||
}
|
||||
}, "zjInBound", 20, this);
|
||||
}
|
||||
// 取消
|
||||
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package org.nl.b_lms.sch.tasks.first_floor_area.auto;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.b_lms.sch.point.dao.BstIvtPackageinfoivt;
|
||||
import org.nl.b_lms.sch.point.service.IbstIvtPackageinfoivtService;
|
||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.sch.tasks.TwoOutBoxTask;
|
||||
import org.nl.b_lms.sch.tasks.first_floor_area.ShiftingTask;
|
||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBoxManageService;
|
||||
import org.nl.common.enums.PackageInfoIvtEnum;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.AcsTaskDto;
|
||||
import org.nl.wms.sch.AcsUtil;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.nl.wms.util.TaskUtil.getRoutePlanCode;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoIssueOutEmptyTask {
|
||||
|
||||
private final String TASK_CLASS = TwoOutBoxTask.class.getName();
|
||||
|
||||
@Autowired
|
||||
private OutBoxManageService outBoxManageService;
|
||||
|
||||
@Autowired
|
||||
private IschBaseTaskService ischBaseTaskService;
|
||||
|
||||
//自动执行等待的桁架任务
|
||||
public void run() {
|
||||
try {
|
||||
this.execute();
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a task that processes ACS (Automation Control System) tasks.
|
||||
*
|
||||
* This method checks the number of active tasks and ensures the limit is not exceeded.
|
||||
* If tasks are eligible for further processing, it retrieves task data from the
|
||||
* database, evaluates conditions based on their attributes, and issues new tasks
|
||||
* to the ACS system. The method also handles specific locking and task dependency
|
||||
* scenarios, ensuring that all conditions for task issuance are met.
|
||||
*
|
||||
* Key logic includes:
|
||||
* - Querying database tables to fetch and analyze task details.
|
||||
* - Ensuring task limits are respected to prevent excessive task submissions.
|
||||
* - Checking and managing task statuses and related storage attributes, such as
|
||||
* lock states and box specifications.
|
||||
* - Notifying the ACS system with the correctly formatted task data.
|
||||
* - Handling errors and updating task remarks in case of exceptions or conflicting conditions.
|
||||
*
|
||||
* This method operates with various modules such as task management, box handling services,
|
||||
* and ACS system notification utilities.
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void execute() {
|
||||
/*
|
||||
* 下发给ACS时需要特殊处理
|
||||
*/
|
||||
// 判断当前有多少个正在执行中的任务
|
||||
int num = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + TASK_CLASS + "' and task_status IN ('05','06') and is_delete ='0'")
|
||||
.getResultJSONArray(0).size();
|
||||
// 如果缓存了4个箱子则不下发任务
|
||||
if (num >= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + TASK_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' order by create_time").getResultJSONArray(0);
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
if (num >= 2) {
|
||||
break;
|
||||
}
|
||||
ArrayList<AcsTaskDto> resultList = new ArrayList<>();
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
JSONObject attr = attrTab.query("struct_code = '" + json.getString("point_code1") + "'").uniqueResult(0);
|
||||
|
||||
if (attr.getString("zdepth").equals(IOSEnum.ZDEPTH_STRUCT.code("深"))) {
|
||||
JSONObject 浅Attr = attrTab
|
||||
.query("zdepth = '1' and row_num = '" + attr.getString("row_num") + "' and col_num = '" + attr.getString("col_num") + "' and layer_num = '" + attr.getString("layer_num") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(浅Attr.getString("storagevehicle_code"))) {
|
||||
if (!浅Attr.getString("lock_type").equals(IOSEnum.LOCK_TYPE.code("未锁定"))) {
|
||||
json.put("remark", "当前仓位对应的浅货位【" + 浅Attr.getString("struct_code") + "被锁定无法下发任务!】");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(json);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (浅Attr.getString("lock_type").equals(IOSEnum.LOCK_TYPE.code("未锁定"))) {
|
||||
// 判断浅货位木箱和深货位木箱是否相同规格
|
||||
outBoxManageService.createBoxMove(浅Attr);
|
||||
} else if (浅Attr.getString("lock_type").equals(IOSEnum.LOCK_TYPE.code("验箱出库锁"))) {
|
||||
List<SchBaseTask> list = ischBaseTaskService.list(new QueryWrapper<SchBaseTask>()
|
||||
.eq("is_delete", "0")
|
||||
.eq("point_code1", 浅Attr.getString("struct_code"))
|
||||
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
json.put("remark", "当前仓位对应的浅货位【" + 浅Attr.getString("struct_code") + "有正在执行中的任务,任务完成后才能下发!】");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(json);
|
||||
continue;
|
||||
} else {
|
||||
outBoxManageService.createBoxMove(浅Attr);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}catch (Exception e){
|
||||
json.put("remark", e.getMessage());
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(json);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
char dtl_type = json.getString("task_type").charAt(json.getString("task_type").length() - 1);
|
||||
AcsTaskDto dto = AcsTaskDto.builder()
|
||||
.ext_task_id(json.getString("task_id"))
|
||||
.task_code(json.getString("task_code"))
|
||||
.route_plan_code(getRoutePlanCode(json.getString("point_code1")))
|
||||
.task_type(json.getString("acs_task_type"))
|
||||
.start_device_code(json.getString("point_code1"))
|
||||
.next_device_code(json.getString("point_code2"))
|
||||
.vehicle_code(json.getString("vehicle_code2"))
|
||||
.vehicle_code2(json.getString("vehicle_code"))
|
||||
.interaction_json(json.getJSONObject("request_param"))
|
||||
.priority(json.getString("priority"))
|
||||
.class_type(json.getString("task_type"))
|
||||
.dtl_type(String.valueOf(dtl_type))
|
||||
.product_area(IOSEnum.PRODUCT_AREA.code("BLK"))
|
||||
.remark(json.getString("remark"))
|
||||
.build();
|
||||
resultList.add(dto);
|
||||
JSONArray list = JSONArray.parseArray(JSON.toJSONString(resultList));
|
||||
AcsUtil.notifyAcs("api/wms/task", list);
|
||||
num += 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user