|
|
|
@ -5,12 +5,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.gaotao.common.utils.PageUtils; |
|
|
|
import com.gaotao.modules.automatedWarehouse.mapper.NotifyDetailQueryMapper; |
|
|
|
import com.gaotao.modules.automatedWarehouse.service.NotifyDetailQueryService; |
|
|
|
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderList; |
|
|
|
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderListData; |
|
|
|
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 申请单明细通用查询Service实现类 - rqrq |
|
|
|
@ -56,5 +61,88 @@ public class NotifyDetailQueryServiceImpl implements NotifyDetailQueryService { |
|
|
|
System.out.println("查询申请单物料明细完成,共" + (rows != null ? rows.size() : 0) + "条记录 - rqrq"); |
|
|
|
return rows; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 关闭申请单任务 - rqrq |
|
|
|
* @param data 查询条件(包含site、notifyNo、itemNo、soorderNo) |
|
|
|
* @return String 成功消息(包含解除的栈板列表) |
|
|
|
* @author rqrq |
|
|
|
* @date 2026/03/05 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String closeNotifyTask(SOIssueNotifyOrderListData data) { |
|
|
|
System.out.println("开始关闭申请单任务 - rqrq,site=" + data.getSite() + ", notifyNo=" + data.getNotifyNo() + ", itemNo=" + data.getItemNo() + ", soorderNo=" + data.getSoorderNo()); |
|
|
|
|
|
|
|
// 1. 参数校验 - rqrq |
|
|
|
if (!StringUtils.hasText(data.getSite())) { |
|
|
|
throw new RuntimeException("工厂不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(data.getNotifyNo())) { |
|
|
|
throw new RuntimeException("领料单号不能为空"); |
|
|
|
} |
|
|
|
if (data.getItemNo() == null) { |
|
|
|
throw new RuntimeException("行号不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(data.getSoorderNo())) { |
|
|
|
throw new RuntimeException("订单号不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 查询该订单记录,校验条件(用主键查询)- rqrq |
|
|
|
SOIssueNotifyOrderList existOrder = notifyDetailQueryMapper.getOrderByPrimaryKey(data.getSite(), data.getNotifyNo(), data.getItemNo()); |
|
|
|
|
|
|
|
if (existOrder == null) { |
|
|
|
throw new RuntimeException("订单不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.1 校验pushWmsFlag必须是'Y' - rqrq |
|
|
|
if (!"Y".equals(existOrder.getPushWmsFlag())) { |
|
|
|
throw new RuntimeException("只能关闭已推送WCS的任务(推送WCS=是)"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.2 校验transportFlag必须是'N' - rqrq |
|
|
|
if (!"N".equals(existOrder.getTransportFlag())) { |
|
|
|
throw new RuntimeException("该任务已经是立库取出状态,无法关闭"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.3 校验pushWcsTime到当前时间超过1天 - rqrq |
|
|
|
Date pushWcsTime = existOrder.getPushWcsTime(); |
|
|
|
if (pushWcsTime == null) { |
|
|
|
throw new RuntimeException("该订单未记录推送WCS时间,无法关闭"); |
|
|
|
} |
|
|
|
|
|
|
|
long diffMillis = new Date().getTime() - pushWcsTime.getTime(); |
|
|
|
long diffDays = TimeUnit.MILLISECONDS.toDays(diffMillis); |
|
|
|
|
|
|
|
if (diffDays < 1) { |
|
|
|
throw new RuntimeException("推送WCS时间未超过1天,无法关闭任务(已推送" + diffDays + "天)"); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("校验通过,推送WCS时间=" + pushWcsTime + ",已超过1天 - rqrq"); |
|
|
|
|
|
|
|
// 3. 先查询要解除调用的栈板列表 - rqrq |
|
|
|
List<String> palletIds = notifyDetailQueryMapper.getPalletsToRelease(data.getSite(), data.getNotifyNo(), data.getSoorderNo()); |
|
|
|
System.out.println("查询到" + (palletIds != null ? palletIds.size() : 0) + "个栈板需要解除调用 - rqrq"); |
|
|
|
|
|
|
|
// 4. 更新SOIssueNotifyOrderList的transport_flag为'Y'(用主键site+notify_no+item_no)- rqrq |
|
|
|
notifyDetailQueryMapper.updateTransportFlag(data.getSite(), data.getNotifyNo(), data.getItemNo()); |
|
|
|
System.out.println("已更新transport_flag为Y - rqrq"); |
|
|
|
|
|
|
|
// 5. 解除相关栈板调用状态(用soorder_no匹配remark)- rqrq |
|
|
|
String resultMessage; |
|
|
|
if (palletIds != null && !palletIds.isEmpty()) { |
|
|
|
notifyDetailQueryMapper.releasePalletCallingFlag(data.getSite(), data.getNotifyNo(), data.getSoorderNo()); |
|
|
|
System.out.println("已解除栈板调用状态,栈板列表:" + String.join(", ", palletIds) + " - rqrq"); |
|
|
|
|
|
|
|
// 返回成功信息,包含解除的栈板列表 - rqrq |
|
|
|
resultMessage = "强制完成成功!已解除以下栈板的调用状态:" + String.join("、", palletIds); |
|
|
|
} else { |
|
|
|
System.out.println("未找到需要解除调用的栈板 - rqrq"); |
|
|
|
resultMessage = "强制完成成功!未找到需要解除调用的栈板"; |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("关闭申请单任务完成 - rqrq"); |
|
|
|
return resultMessage; |
|
|
|
} |
|
|
|
} |
|
|
|
|