add:手持空托盘入库
This commit is contained in:
@@ -1,10 +1,19 @@
|
|||||||
package org.nl.b_lms.pda.service.impl;
|
package org.nl.b_lms.pda.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.b_lms.pda.service.VehicleTwoService;
|
import org.nl.b_lms.pda.service.VehicleTwoService;
|
||||||
|
import org.nl.b_lms.sch.point.dao.SchBasePoint;
|
||||||
|
import org.nl.b_lms.sch.point.service.IschBasePointService;
|
||||||
|
import org.nl.b_lms.sch.tasks.TwoInEmpExcepTask;
|
||||||
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBoxManageService;
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBoxManageService;
|
||||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InVehicleManageService;
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InVehicleManageService;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -25,16 +34,111 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private InBoxManageService inBoxManageService;
|
private InBoxManageService inBoxManageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ACS服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private WmsToAcsService wmsToAcsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点位服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private IschBasePointService ischBasePointService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public JSONObject vehicleIn(JSONObject whereJson) {
|
public JSONObject vehicleIn(JSONObject whereJson) {
|
||||||
// 调用接口
|
|
||||||
whereJson.put("device_code", whereJson.getString("point_code"));
|
|
||||||
inVehicleManageService.inVehicle(whereJson);
|
|
||||||
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("message", "入库成功!");
|
|
||||||
|
|
||||||
|
String point_code = whereJson.getString("point_code");
|
||||||
|
String vehicle_type = whereJson.getString("vehicle_type");
|
||||||
|
|
||||||
|
// 判断起点是否存在
|
||||||
|
SchBasePoint pointDao = ischBasePointService.getOne(
|
||||||
|
new QueryWrapper<SchBasePoint>().lambda()
|
||||||
|
.eq(SchBasePoint::getPoint_code, point_code)
|
||||||
|
.eq(SchBasePoint::getIs_delete, IOSEnum.IS_NOTANDYES.code("否"))
|
||||||
|
.eq(SchBasePoint::getIs_used, IOSEnum.IS_NOTANDYES.code("是"))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(pointDao)) {
|
||||||
|
throw new BadRequestException("点位:"+point_code+"不存在或未启用!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断入库叠盘位的 托盘类型是否相同、是否叠满
|
||||||
|
JSONObject device_jo = new JSONObject();
|
||||||
|
device_jo.put("device_code", "RK1004");
|
||||||
|
device_jo.put("product_area", IOSEnum.PRODUCT_AREA.code("BLK"));
|
||||||
|
|
||||||
|
JSONArray device_ja = new JSONArray();
|
||||||
|
device_ja.add(device_jo);
|
||||||
|
JSONObject device_data = wmsToAcsService.getPointStatus(device_ja);
|
||||||
|
JSONObject data = device_data.getJSONArray("data").getJSONObject(0);
|
||||||
|
|
||||||
|
// 判断是否有货 且托盘类型相同、数量小于5
|
||||||
|
if (data.getString("move").equals(IOSEnum.IS_NOTANDYES.code("否")) ||
|
||||||
|
(data.getString("move").equals(IOSEnum.IS_NOTANDYES.code("是"))
|
||||||
|
&& vehicle_type.equals(data.getString("container_type"))
|
||||||
|
&& data.getIntValue("qty") < 5)
|
||||||
|
) {
|
||||||
|
// 生成入库叠盘机输送任务
|
||||||
|
JSONObject jsonTaskParam = new JSONObject();
|
||||||
|
jsonTaskParam.put("task_type", "010715");
|
||||||
|
jsonTaskParam.put("start_device_code", point_code);
|
||||||
|
jsonTaskParam.put("next_device_code", "RK1004");
|
||||||
|
jsonTaskParam.put("vehicle_code", whereJson.getString("vehicle_code"));
|
||||||
|
jsonTaskParam.put("vehicle_type", whereJson.getString("vehicle_type"));
|
||||||
|
|
||||||
|
TwoInEmpExcepTask taskBean = new TwoInEmpExcepTask();
|
||||||
|
taskBean.createTask(jsonTaskParam);
|
||||||
|
taskBean.immediateNotifyAcs(null);
|
||||||
|
|
||||||
|
result.put("message", "入库成功!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生层到出库口叠盘机任务
|
||||||
|
// 判断托盘类型
|
||||||
|
String next_device_code = "";
|
||||||
|
if (vehicle_type.equals(IOSEnum.IS_NOTANDYES.code("是"))) {
|
||||||
|
// 小托盘 CK2009
|
||||||
|
next_device_code = "CK2009";
|
||||||
|
} else {
|
||||||
|
// 大托盘 CK2011
|
||||||
|
next_device_code = "CK2011";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断点位状态
|
||||||
|
device_jo.put("device_code", next_device_code);
|
||||||
|
|
||||||
|
JSONArray device_ja2 = new JSONArray();
|
||||||
|
device_ja2.add(device_jo);
|
||||||
|
JSONObject device_data2 = wmsToAcsService.getPointStatus(device_ja2);
|
||||||
|
JSONObject data2 = device_data2.getJSONArray("data").getJSONObject(0);
|
||||||
|
|
||||||
|
// 判断是否有货 且数量小于5
|
||||||
|
if (data2.getString("move").equals(IOSEnum.IS_NOTANDYES.code("否")) ||
|
||||||
|
(data2.getString("move").equals(IOSEnum.IS_NOTANDYES.code("是"))
|
||||||
|
&& data2.getIntValue("qty") < 5)
|
||||||
|
) {
|
||||||
|
// 生层到出库口叠盘机任务
|
||||||
|
JSONObject jsonTaskParam = new JSONObject();
|
||||||
|
jsonTaskParam.put("task_type", "010714");
|
||||||
|
jsonTaskParam.put("start_device_code", point_code);
|
||||||
|
jsonTaskParam.put("next_device_code", next_device_code);
|
||||||
|
jsonTaskParam.put("vehicle_code", whereJson.getString("vehicle_code"));
|
||||||
|
jsonTaskParam.put("vehicle_type", whereJson.getString("vehicle_type"));
|
||||||
|
|
||||||
|
TwoInEmpExcepTask taskBean = new TwoInEmpExcepTask();
|
||||||
|
taskBean.createTask(jsonTaskParam);
|
||||||
|
taskBean.immediateNotifyAcs(null);
|
||||||
|
} else {
|
||||||
|
result.put("message", "入库失败! 出库叠盘位已叠满!"+next_device_code);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("message", "入库成功!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package org.nl.b_lms.sch.tasks;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||||
|
import org.nl.common.utils.SecurityUtils;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.nl.wms.sch.AcsTaskDto;
|
||||||
|
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||||
|
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二期空托盘入库异常任务类
|
||||||
|
* Created by Lxy on 2024/1/19.
|
||||||
|
*/
|
||||||
|
public class TwoInEmpExcepTask extends AbstractAcsTask {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理类
|
||||||
|
*/
|
||||||
|
private final String THIS_CLASS = TwoInEmpExcepTask.class.getName();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AcsTaskDto> addTask() {
|
||||||
|
/*
|
||||||
|
* 下发给ACS时需要特殊处理
|
||||||
|
*/
|
||||||
|
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
|
||||||
|
|
||||||
|
ArrayList<AcsTaskDto> resultList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
JSONObject json = arr.getJSONObject(i);
|
||||||
|
|
||||||
|
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"))
|
||||||
|
.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_code"))
|
||||||
|
.priority(json.getString("priority"))
|
||||||
|
.class_type(json.getString("task_type"))
|
||||||
|
.dtl_type("7")
|
||||||
|
.remark(json.getString("remark"))
|
||||||
|
.build();
|
||||||
|
resultList.add(dto);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||||
|
// 更新任务的参数
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1-执行中, 2-完成 ,0-acs取消
|
||||||
|
*/
|
||||||
|
// 执行中
|
||||||
|
if (status.equals(TaskStatusEnum.EXECUTING.getCode())) {
|
||||||
|
|
||||||
|
map.put("task_status", TaskStatusEnum.EXECUTING.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 完成
|
||||||
|
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
|
||||||
|
|
||||||
|
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消
|
||||||
|
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||||
|
|
||||||
|
if (taskObj.getIntValue("task_status") > Integer.valueOf(TaskStatusEnum.ISSUE.getCode())) {
|
||||||
|
throw new BadRequestException("任务已执行不能取消");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新任务表删除字段
|
||||||
|
map.put("is_delete", IOSEnum.IS_NOTANDYES.code("是"));
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||||
|
map.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||||
|
map.put("update_time", DateUtil.now());
|
||||||
|
|
||||||
|
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void findStartPoint() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void findNextPoint() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String createTask(JSONObject form) {
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(form.getString("task_type"))) {
|
||||||
|
throw new BadRequestException("业务类型不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(form.getString("start_device_code"))) {
|
||||||
|
throw new BadRequestException("起点不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(form.getString("next_device_code"))) {
|
||||||
|
throw new BadRequestException("终点不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(form.getString("vehicle_code"))) {
|
||||||
|
throw new BadRequestException("托盘号不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(form.getString("vehicle_type"))) {
|
||||||
|
throw new BadRequestException("托盘类型不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("task_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
json.put("task_code", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
json.put("task_type", form.getString("task_type"));
|
||||||
|
json.put("vehicle_code", form.getString("vehicle_code"));
|
||||||
|
json.put("vehicle_type", form.getString("vehicle_type"));
|
||||||
|
json.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||||
|
json.put("point_code1", form.getString("start_device_code"));
|
||||||
|
json.put("point_code2", form.getString("next_device_code"));
|
||||||
|
json.put("handle_class", this.getClass().getName());
|
||||||
|
json.put("create_id", SecurityUtils.getCurrentUserId());
|
||||||
|
json.put("create_name", SecurityUtils.getCurrentUsername());
|
||||||
|
json.put("create_time", DateUtil.now());
|
||||||
|
json.put("priority", "1");
|
||||||
|
json.put("acs_task_type", "7");
|
||||||
|
|
||||||
|
WQLObject.getWQLObject("SCH_BASE_Task").insert(json);
|
||||||
|
return json.getString("task_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void forceFinish(String task_id) {
|
||||||
|
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||||
|
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel(String task_id) {
|
||||||
|
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||||
|
this.updateTaskStatus(taskObj, IOSEnum.ACS_RESULT.code("取消"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,6 +91,9 @@ public enum IOSEnum {
|
|||||||
//外部系统
|
//外部系统
|
||||||
EXT_SYSTEM(MapOf.of("mes", "mes","sap","sap","crm","crm")),
|
EXT_SYSTEM(MapOf.of("mes", "mes","sap","sap","crm","crm")),
|
||||||
|
|
||||||
|
// 区域
|
||||||
|
PRODUCT_AREA(MapOf.of("BLK", "BLK")),
|
||||||
|
|
||||||
//acs申请任务
|
//acs申请任务
|
||||||
ACSTOLMS_TYPE(MapOf.of("成品入库任务", "1","空盘入库","2","空盘出库","3","异常处理位","4","木箱入库","5","贴标","1","捆扎","2")),
|
ACSTOLMS_TYPE(MapOf.of("成品入库任务", "1","空盘入库","2","空盘出库","3","异常处理位","4","木箱入库","5","贴标","1","捆扎","2")),
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user