|
|
|
|
@ -10,7 +10,9 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.wms.domain.WmsAllocateTask;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsAllocateOrderDetailBo;
|
|
|
|
|
import org.dromara.wms.domain.bo.WmsAllocateTaskBo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsAllocateOrderDetailVo;
|
|
|
|
|
import org.dromara.wms.domain.vo.WmsAllocateTaskVo;
|
|
|
|
|
import org.dromara.wms.mapper.WmsAllocateTaskMapper;
|
|
|
|
|
import org.dromara.wms.service.IBaseMaterialInfoService;
|
|
|
|
|
@ -165,7 +167,7 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调拨分包打印
|
|
|
|
|
* 调拨分包打印 - 完善版本(只支持覆盖模式)
|
|
|
|
|
*
|
|
|
|
|
* @param allocateCode 调拨单号
|
|
|
|
|
* @param aoDId 调拨明细ID
|
|
|
|
|
@ -184,22 +186,25 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
throw new ServiceException("调拨明细不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证打印条件:只有出库数量等于调拨数量时才能打印
|
|
|
|
|
BigDecimal outSum = BigDecimal.valueOf(detailVo.getOutSum());
|
|
|
|
|
if (outSum.compareTo(detailVo.getAllocateOrderQty()) != 0) {
|
|
|
|
|
throw new ServiceException("只有出库数量等于调拨数量时才能打印,当前出库数量:" + outSum + ",调拨数量:" + detailVo.getAllocateOrderQty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取物料信息
|
|
|
|
|
org.dromara.wms.domain.vo.BaseMaterialInfoVo materialInfoVo = null;
|
|
|
|
|
if (detailVo.getMaterialId() != null) {
|
|
|
|
|
materialInfoVo = baseMaterialInfoService.queryById(detailVo.getMaterialId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Web端覆盖模式:如果已有打印记录,先删除再新增
|
|
|
|
|
// 覆盖模式:如果已有打印记录,强制删除再新增
|
|
|
|
|
List<WmsAllocateTaskVo> existingTasks = queryTasksByDetailId(aoDId);
|
|
|
|
|
if (!existingTasks.isEmpty()) {
|
|
|
|
|
// 新业务规则:只有出库数量等于调拨数量时才允许重新打印
|
|
|
|
|
BigDecimal outSum = BigDecimal.valueOf(detailVo.getOutSum());
|
|
|
|
|
if (outSum.compareTo(detailVo.getAllocateOrderQty()) != 0) {
|
|
|
|
|
throw new ServiceException("只有出库数量等于调拨数量时才能重新打印,当前出库数量:" + outSum + ",调拨数量:" + detailVo.getAllocateOrderQty());
|
|
|
|
|
}
|
|
|
|
|
// 删除现有任务(移除inboundStatus验证)
|
|
|
|
|
deleteTasksByDetailId(aoDId);
|
|
|
|
|
// 强制删除现有任务(覆盖模式)
|
|
|
|
|
deleteTasksByDetailIdInternal(aoDId);
|
|
|
|
|
// 记录日志
|
|
|
|
|
System.out.println("覆盖模式:删除调拨明细[" + aoDId + "]的" + existingTasks.size() + "个现有任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int splitInt = splitPackageCount != null ? splitPackageCount : 1;
|
|
|
|
|
@ -238,7 +243,7 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
totalPackaged = totalPackaged.add(currentPackageQty);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 重复打印逻辑(split == 1)
|
|
|
|
|
// 单包打印逻辑(split == 1)
|
|
|
|
|
if (copiesInt < 1) {
|
|
|
|
|
copiesInt = 1;
|
|
|
|
|
}
|
|
|
|
|
@ -252,11 +257,16 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新调拨明细的已分包数量
|
|
|
|
|
org.dromara.wms.domain.bo.WmsAllocateOrderDetailBo detailBo = new org.dromara.wms.domain.bo.WmsAllocateOrderDetailBo();
|
|
|
|
|
WmsAllocateOrderDetailBo detailBo = new WmsAllocateOrderDetailBo();
|
|
|
|
|
detailBo.setAoDId(detailVo.getAoDId());
|
|
|
|
|
detailBo.setPrintedQty(totalPackaged);
|
|
|
|
|
// 保持原有的出库数量不变
|
|
|
|
|
detailBo.setOutSum(detailVo.getOutSum());
|
|
|
|
|
allocateOrderDetailService.updateByBo(detailBo);
|
|
|
|
|
|
|
|
|
|
// 记录成功日志
|
|
|
|
|
System.out.println("调拨分包打印成功:调拨明细[" + aoDId + "],分包数量:" + splitInt + ",总打印数量:" + totalPackaged);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -423,9 +433,11 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
|
|
|
|
|
// 更新调拨明细的已分包数量
|
|
|
|
|
if (detailVo != null) {
|
|
|
|
|
org.dromara.wms.domain.bo.WmsAllocateOrderDetailBo detailBo = new org.dromara.wms.domain.bo.WmsAllocateOrderDetailBo();
|
|
|
|
|
WmsAllocateOrderDetailBo detailBo = new WmsAllocateOrderDetailBo();
|
|
|
|
|
detailBo.setAoDId(detailVo.getAoDId());
|
|
|
|
|
detailBo.setPrintedQty(BigDecimal.ZERO);
|
|
|
|
|
WmsAllocateOrderDetailVo wmsAllocateOrderDetailVo = allocateOrderDetailService.queryById(detailVo.getAoDId());
|
|
|
|
|
detailBo.setOutSum(wmsAllocateOrderDetailVo.getOutSum());
|
|
|
|
|
allocateOrderDetailService.updateByBo(detailBo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -435,6 +447,24 @@ public class WmsAllocateTaskServiceImpl implements IWmsAllocateTaskService {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 内部删除方法,不进行业务验证(用于覆盖模式)
|
|
|
|
|
*/
|
|
|
|
|
private Boolean deleteTasksByDetailIdInternal(Long aoDId) {
|
|
|
|
|
MPJLambdaWrapper<WmsAllocateTask> wrapper = JoinWrappers.lambda(WmsAllocateTask.class)
|
|
|
|
|
.eq(WmsAllocateTask::getAoDId, aoDId);
|
|
|
|
|
|
|
|
|
|
List<WmsAllocateTask> tasks = baseMapper.selectList(wrapper);
|
|
|
|
|
|
|
|
|
|
if (!tasks.isEmpty()) {
|
|
|
|
|
List<Long> taskIds = tasks.stream().map(WmsAllocateTask::getAllocateTaskId).toList();
|
|
|
|
|
int deleteCount = baseMapper.deleteByIds(taskIds);
|
|
|
|
|
return deleteCount > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成订单号
|
|
|
|
|
*/
|
|
|
|
|
|