代码更新
This commit is contained in:
@@ -23,7 +23,6 @@ import org.nl.wms.sch.service.PointService;
|
|||||||
import org.nl.wms.sch.service.TaskService;
|
import org.nl.wms.sch.service.TaskService;
|
||||||
import org.nl.wms.sch.service.dto.TaskDto;
|
import org.nl.wms.sch.service.dto.TaskDto;
|
||||||
import org.nl.wms.sch.tasks.PointToPointTask;
|
import org.nl.wms.sch.tasks.PointToPointTask;
|
||||||
import org.nl.wms.sch.tasks.callEmpty.CallEmpVehicleTask;
|
|
||||||
import org.nl.wms.sch.tasks.callEmpty.GjxCallEmpVehicleTask;
|
import org.nl.wms.sch.tasks.callEmpty.GjxCallEmpVehicleTask;
|
||||||
import org.nl.wms.sch.tasks.callMaterial.CallMaterialTask;
|
import org.nl.wms.sch.tasks.callMaterial.CallMaterialTask;
|
||||||
import org.nl.wms.sch.tasks.sendEmpty.HtSendEmpVehicleTask;
|
import org.nl.wms.sch.tasks.sendEmpty.HtSendEmpVehicleTask;
|
||||||
@@ -230,7 +229,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
param.put("point_code2", point_code);
|
param.put("point_code2", point_code);
|
||||||
param.put("qty", vehicle_num);
|
param.put("qty", vehicle_num);
|
||||||
// 创建任务
|
// 创建任务
|
||||||
CallEmpVehicleTask taskBean = SpringContextHolder.getBean(CallEmpVehicleTask.class);
|
GjxCallEmpVehicleTask taskBean = SpringContextHolder.getBean(GjxCallEmpVehicleTask.class);
|
||||||
String task_id = taskBean.createTask(param);
|
String task_id = taskBean.createTask(param);
|
||||||
} else if (StrUtil.equals(type, "4")) {
|
} else if (StrUtil.equals(type, "4")) {
|
||||||
// 4.油漆线申请物料: 调用物料出库库处理类创建任务
|
// 4.油漆线申请物料: 调用物料出库库处理类创建任务
|
||||||
|
|||||||
@@ -1,301 +0,0 @@
|
|||||||
package org.nl.wms.sch.tasks.callEmpty;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
|
||||||
import org.nl.modules.common.utils.SecurityUtils;
|
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
|
||||||
import org.nl.modules.wql.WQL;
|
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
|
||||||
import org.nl.wms.pdm.service.DeviceService;
|
|
||||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
|
||||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
|
||||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
|
||||||
import org.nl.wms.sch.service.PointService;
|
|
||||||
import org.nl.wms.sch.service.dto.PointDto;
|
|
||||||
import org.nl.wms.sch.tasks.AcsTaskDto;
|
|
||||||
import org.nl.wms.sch.tasks.RegionTypeEnum;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class CallEmpVehicleTask extends AbstractAcsTask {
|
|
||||||
private final String THIS_CLASS = CallEmpVehicleTask.class.getName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
|
||||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
|
||||||
|
|
||||||
String task_id = taskObj.getString("task_id");
|
|
||||||
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
|
||||||
|
|
||||||
if (StrUtil.equals(status, "0")) {
|
|
||||||
// 取消删除任务
|
|
||||||
taskTab.delete("task_id = '" + task_id + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
|
|
||||||
// 更新任务状态为执行中
|
|
||||||
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
|
|
||||||
jsonTask.put("update_time", DateUtil.now());
|
|
||||||
jsonTask.put("car_no", taskObj.getString("car_no"));
|
|
||||||
taskTab.update(jsonTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
|
|
||||||
// 更改任务状态为完成
|
|
||||||
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
|
||||||
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
|
|
||||||
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
|
|
||||||
jsonTask.put("update_time", DateUtil.now());
|
|
||||||
taskTab.update(jsonTask);
|
|
||||||
|
|
||||||
PointService point = SpringContextHolder.getBean(PointService.class);
|
|
||||||
// 校验起点是否存在
|
|
||||||
PointDto point_code1 = point.findByCode(jsonTask.getString("point_code1"));
|
|
||||||
if (ObjectUtil.isEmpty(point_code1)) throw new BadRequestException("未找到可用点位:" + point_code1);
|
|
||||||
// 校验终点是否存在
|
|
||||||
PointDto point_code2 = point.findByCode(jsonTask.getString("point_code2"));
|
|
||||||
if (ObjectUtil.isEmpty(point_code1)) throw new BadRequestException("未找到可用点位:" + point_code2);
|
|
||||||
|
|
||||||
// 1.更新点位数量 2.解锁点位
|
|
||||||
int vehicle_qty = JSONObject.parseObject(JSON.toJSONString(point_code1)).getIntValue("vehicle_qty");
|
|
||||||
BigDecimal vehicle_qty_point = NumberUtil.sub(String.valueOf(vehicle_qty), String.valueOf(1));
|
|
||||||
|
|
||||||
point_code1.setVehicle_qty(vehicle_qty_point);
|
|
||||||
if (StrUtil.equals(vehicle_qty_point.toString(), "0")) {
|
|
||||||
point_code1.setPoint_status("00");
|
|
||||||
point_code1.setVehicle_type("");
|
|
||||||
}
|
|
||||||
point_code1.setLock_type("00");
|
|
||||||
pointTab.update(JSONObject.parseObject(JSON.toJSONString(point_code1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String createTask(JSONObject form) {
|
|
||||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
|
||||||
|
|
||||||
String point_code1 = form.getString("point_code1");
|
|
||||||
String point_code2 = form.getString("point_code2");
|
|
||||||
String qty = form.getString("qty");
|
|
||||||
String vehicle_type = form.getString("vehicle_type");
|
|
||||||
|
|
||||||
// 出库终点不能为空
|
|
||||||
if (ObjectUtil.isEmpty(point_code2)) {
|
|
||||||
throw new BadRequestException("终点不能为空");
|
|
||||||
} else {
|
|
||||||
// 判断终点是否有正在执行的任务
|
|
||||||
JSONObject beforTaskObj = taskTab.query("is_delete='0' and point_code2='" + point_code2 + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isNotEmpty(beforTaskObj))
|
|
||||||
throw new BadRequestException("存在任务号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
|
|
||||||
}
|
|
||||||
// 载具数量不能为空
|
|
||||||
if (ObjectUtil.isEmpty(qty)) throw new BadRequestException("载具数量不能为空");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 1. 点对点: 起点和终点都确定,直接创建任务
|
|
||||||
* 2. 终点确定: 需要找到对应起点,在创建任务 具体找起点货位的规则在findBeginPoint()中
|
|
||||||
*/
|
|
||||||
//起点不确定
|
|
||||||
if (ObjectUtil.isEmpty(point_code1)) {
|
|
||||||
|
|
||||||
JSONObject param = new JSONObject();
|
|
||||||
param.put("point_code2",point_code2);
|
|
||||||
param.put("vehicle_qty",qty);
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject json = this.findBeginPoint(param);
|
|
||||||
point_code1 = json.getString("start_point_code");
|
|
||||||
vehicle_type = json.getString("vehicle_type");
|
|
||||||
} else {
|
|
||||||
// 判断终点是否是空位
|
|
||||||
JSONObject jsonPoint = pointTab.query("point_code = '" + point_code1 + "' and lock_type = '00' and point_status <> '02' and is_delete = '0' and is_used = '1'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonPoint)) throw new BadRequestException("起点点位不可用或不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 创建任务
|
|
||||||
JSONObject jsonTask = new JSONObject();
|
|
||||||
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
|
||||||
|
|
||||||
jsonTask.put("task_id", task_id);
|
|
||||||
|
|
||||||
jsonTask.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
|
||||||
jsonTask.put("task_type", "04");
|
|
||||||
jsonTask.put("task_status", "01");
|
|
||||||
jsonTask.put("point_code1", point_code1);
|
|
||||||
jsonTask.put("point_code2", point_code2);
|
|
||||||
jsonTask.put("handle_class", THIS_CLASS);
|
|
||||||
jsonTask.put("vehicle_type", vehicle_type);
|
|
||||||
jsonTask.put("create_name", SecurityUtils.getCurrentUsername());
|
|
||||||
jsonTask.put("create_id", SecurityUtils.getCurrentUserId());
|
|
||||||
jsonTask.put("create_time", DateUtil.now());
|
|
||||||
jsonTask.put("acs_task_type", "1");
|
|
||||||
taskTab.insert(jsonTask);
|
|
||||||
|
|
||||||
// 锁定起点点位
|
|
||||||
JSONObject jsonPoint = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
|
|
||||||
jsonPoint.put("lock_type", "02");
|
|
||||||
pointTab.update(jsonPoint);
|
|
||||||
|
|
||||||
return 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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public JSONObject findBeginPoint(JSONObject json) {
|
|
||||||
String point_code2 = json.getString("point_code2");
|
|
||||||
String vehicle_qty = json.getString("vehicle_qty");
|
|
||||||
if (ObjectUtil.isEmpty(point_code2)) throw new BadRequestException("终点不能为空");
|
|
||||||
if (ObjectUtil.isEmpty(vehicle_qty)) throw new BadRequestException("载具数量不能为空");
|
|
||||||
|
|
||||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
|
||||||
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
|
|
||||||
WQLObject orderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
|
||||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
// 根据终点区域判断优先的起点区域
|
|
||||||
JSONObject jsonPointEnd = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonPointEnd)) throw new BadRequestException("终点点位不存在");
|
|
||||||
JSONObject jsonRegionEnd = regionTab.query("region_id ='" + jsonPointEnd.getString("region_id") + "'").uniqueResult(0);
|
|
||||||
|
|
||||||
// 根据起点找到对应设备,根据设备查询工单表中 - 正在运行的工单中的载具类型
|
|
||||||
String device_code = point_code2.substring(0, point_code2.indexOf("_"));
|
|
||||||
|
|
||||||
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
|
|
||||||
DeviceDto deviceDto = deviceBean.findByCode(device_code);
|
|
||||||
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
|
|
||||||
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
|
|
||||||
|
|
||||||
//当前设备所需要的载具类型
|
|
||||||
String vehicle_type = jsonOrder.getString("vehicle_type");
|
|
||||||
/*
|
|
||||||
* 空托盘出库任务:
|
|
||||||
* 1.叠盘架B区、养生A区 --> 共挤线 (优先级:1叠盘架B区 2养生A区)
|
|
||||||
* 2.叠盘架A区、养生A区 --> 油漆线 (优先级:1叠盘架A区 2养生A区)
|
|
||||||
*/
|
|
||||||
String point_code1 = "";
|
|
||||||
JSONObject map = new JSONObject();
|
|
||||||
if (StrUtil.equals(jsonRegionEnd.getString("region_code"), RegionTypeEnum.GJQY.getCode())) {
|
|
||||||
//1、判断是否有拆托盘任务。
|
|
||||||
taskTab.query("task_type= 'gjxsqkp' ");
|
|
||||||
|
|
||||||
//2、判断是否有到该叠盘位的堆叠任务。
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//1、判断叠盘架B是否有对应类型的空载具
|
|
||||||
JSONObject jsonDpjB = pointTab.query("point_status ='2' and lock_type='00' and can_vehicle_type = '" + vehicle_type + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonDpjB)) {//没有则去空托盘缓存区B和养生A区找
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 共挤线呼叫空托盘业务:查找叠盘架B区是否有满足条件的点位
|
|
||||||
map.put("flag", "1");
|
|
||||||
map.put("vehicle_qty", vehicle_qty);
|
|
||||||
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
|
|
||||||
map.put("region_code", RegionTypeEnum.DPJQB.getCode());
|
|
||||||
JSONObject jsonStartPointDPB = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonStartPointDPB)) {
|
|
||||||
point_code1 = jsonStartPointDPB.getString("point_code");
|
|
||||||
} else {
|
|
||||||
// 为空说明叠盘架B区没有,则去养生A区找 : 只能找数量为1的空托盘
|
|
||||||
map.put("flag", "3");
|
|
||||||
map.put("region_code", RegionTypeEnum.YSQA.getCode());
|
|
||||||
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonStartPointYSA)) {
|
|
||||||
point_code1 = jsonStartPointYSA.getString("point_code");
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("没有满足需求数量的点位");
|
|
||||||
/* // 如果没有则需要从养生区A区里找到 > 1的货位 出库到叠盘架B中
|
|
||||||
map.put("flag", "1");
|
|
||||||
map.put("region_code", RegionTypeEnum.YSQA.getCode());
|
|
||||||
// 起点
|
|
||||||
JSONObject jsonStart = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonStart)) throw new BadRequestException("没有满足需求数量的点位");
|
|
||||||
// 终点
|
|
||||||
JSONObject jsonEnd = pointTab.query("region_id = '" + RegionTypeEnum.DPJQB.getId() + "' and point_status = '00' and lock_type = '00' and is_used = '1' and is_delete = '0'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonEnd)) throw new BadRequestException("叠盘架B货位不足");
|
|
||||||
|
|
||||||
JSONObject parem = new JSONObject();
|
|
||||||
parem.put("point_code1",jsonStart.getString("point_code"));
|
|
||||||
parem.put("point_code2",jsonEnd.getString("point_code"));
|
|
||||||
parem.put("qty",jsonStart.getString("vehicle_qty"));
|
|
||||||
parem.put("vehicle_type",jsonStart.getString("vehicle_qty"));
|
|
||||||
String task_id = this.createTask(parem);
|
|
||||||
|
|
||||||
// 生成 叠盘架 -> 共挤线的任务 返回叠盘架B的点位code
|
|
||||||
point_code1 = jsonEnd.getString("point_code");*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (StrUtil.equals(jsonRegionEnd.getString("region_code"), RegionTypeEnum.YQQY.getCode())) {
|
|
||||||
// 油漆线呼叫空托盘业务:查找叠盘架A区是否有满足条件的点位
|
|
||||||
map.put("flag", "1");
|
|
||||||
map.put("vehicle_qty", vehicle_qty);
|
|
||||||
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
|
|
||||||
map.put("region_code", RegionTypeEnum.DPJQA.getCode());
|
|
||||||
JSONObject jsonStartPointDPA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonStartPointDPA)) {
|
|
||||||
point_code1 = jsonStartPointDPA.getString("point_code");
|
|
||||||
} else {
|
|
||||||
// 为空说明叠盘架A区没有,则去养生A区找
|
|
||||||
map.put("flag", "3");
|
|
||||||
map.put("region_code", RegionTypeEnum.YSQA.getCode());
|
|
||||||
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonStartPointYSA)) throw new BadRequestException("没有满足需求数量的点位");
|
|
||||||
point_code1 = jsonStartPointYSA.getString("point_code");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSONObject resuft = new JSONObject();
|
|
||||||
resuft.put("point_code1", point_code1);
|
|
||||||
resuft.put("vehicle_type", jsonOrder.getString("vehicle_type"));
|
|
||||||
return resuft;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AcsTaskDto> addTask() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -138,7 +138,7 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
|||||||
JSONObject whereParam = new JSONObject();
|
JSONObject whereParam = new JSONObject();
|
||||||
whereParam.put("flag", "1");
|
whereParam.put("flag", "1");
|
||||||
whereParam.put("vehicle_type", '%' + jsonTask.getString("vehicle_type") + "%");
|
whereParam.put("vehicle_type", '%' + jsonTask.getString("vehicle_type") + "%");
|
||||||
JSONObject outJsonObj = WQL.getWO("ST_VEHICLE_OUT_01").addParamMap(whereParam).process().uniqueResult(0);
|
JSONObject outJsonObj = WQL.getWO("QSCH_GjxCallEmpVehicleTask").addParamMap(whereParam).process().uniqueResult(0);
|
||||||
|
|
||||||
// 空托盘缓存货架或者养生A区------>叠盘架B区
|
// 空托盘缓存货架或者养生A区------>叠盘架B区
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[交易说明]
|
[交易说明]
|
||||||
交易名: 空载具出库业务
|
交易名: 共挤线申请空盘
|
||||||
所属模块:
|
所属模块:
|
||||||
功能简述:
|
功能简述:
|
||||||
版权所有:
|
版权所有:
|
||||||
Reference in New Issue
Block a user