出库单按规则生成;执行单回显通知单备注;
This commit is contained in:
+8
@@ -46,4 +46,12 @@ public interface StockOutOrderMapper extends BaseMapper<StockOutOrder> {
|
||||
public String getOpWhLoc(@Param("id") Long id);
|
||||
|
||||
public String getInLotNo(@Param("inOrderNumber") String inOrderNumber, @Param("baseId") Long baseId);
|
||||
|
||||
/**
|
||||
* 跨4张入库单表查询指定前缀+组织+仓库的所有入库单号(用于取最大序号+1,防止删单后单号重复)
|
||||
* 包含: reserve_stock_in_order, reservation_stock_in_order, execution_stock_in_order, WMS stock_in_order
|
||||
*/
|
||||
List<String> getMaxStockOutOrderByPrefixAndOrgAndWarehouse(@Param("prefix") String prefix,
|
||||
@Param("organizationId") Long organizationId,
|
||||
@Param("warehouseId") Long warehouseId);
|
||||
}
|
||||
+66
-6
@@ -17,10 +17,7 @@ import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.OmsServiceFeign;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.domain.BatchDetailFeignPO;
|
||||
import com.mhd.system.api.domain.DeliveryDetailsLink;
|
||||
import com.mhd.system.api.domain.ElectronicSignatureSyncDTO;
|
||||
import com.mhd.system.api.domain.PackDetailFeignPO;
|
||||
import com.mhd.system.api.domain.*;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.wms.application.service.handoverTaskOrder.HandoverTaskOrderApplicationService;
|
||||
import com.mhd.wms.application.service.pickingOrder.PickingOrderApplicationService;
|
||||
@@ -91,6 +88,7 @@ import com.mhd.wms.domain.stockInOrder.repository.todo.StockInOrderDO;
|
||||
import com.mhd.wms.domain.stockInOrder.service.StockInOrderDomainService;
|
||||
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
|
||||
import com.mhd.wms.domain.waveOrder.factorys.WaveOrderServiceFactory;
|
||||
@@ -171,6 +169,8 @@ public class StockOutOrderDomainService {
|
||||
@Autowired
|
||||
private StockInOrderMapper stockInOrderMapper;
|
||||
@Autowired
|
||||
private StockOutOrderMapper stockOutOrderMapper;
|
||||
@Autowired
|
||||
private PickingOrderApplicationService pickingOrderApplicationService;
|
||||
@Autowired
|
||||
private HandoverTaskOrderApplicationService handoverTaskOrderApplicationService;
|
||||
@@ -201,7 +201,35 @@ public class StockOutOrderDomainService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 从单号列表中提取最大序号
|
||||
* 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001)
|
||||
* 即使中间有删单,也能保证序号递增不重复
|
||||
*
|
||||
* @param orderNumbers 匹配的单号列表
|
||||
* @param prefixLength 前缀长度(序号从该位置开始截取)
|
||||
* @return 最大序号值,列表为空时返回0
|
||||
*/
|
||||
private int extractMaxSequenceNumber(List<String> orderNumbers, int prefixLength) {
|
||||
if (orderNumbers == null || orderNumbers.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int maxSeq = 0;
|
||||
for (String orderNumber : orderNumbers) {
|
||||
if (orderNumber != null && orderNumber.length() > prefixLength) {
|
||||
try {
|
||||
String seqStr = orderNumber.substring(prefixLength);
|
||||
int seq = Integer.parseInt(seqStr);
|
||||
if (seq > maxSeq) {
|
||||
maxSeq = seq;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// 序号部分非数字,跳过
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxSeq;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -209,7 +237,39 @@ public class StockOutOrderDomainService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insert(StockOutOrderDO stockOutOrderDO) {
|
||||
stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK"));
|
||||
// stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK"));
|
||||
|
||||
//设置单号
|
||||
Long warehouseId = stockOutOrderDO.getWarehouseId();
|
||||
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId);
|
||||
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
throw new ServiceException("获取仓库信息失败");
|
||||
}
|
||||
//仓库信息
|
||||
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
|
||||
String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule();
|
||||
String prefix = warehouseFeignPO.getInOrderNoPrefix();
|
||||
if (prefix == null || prefix.isEmpty()) {
|
||||
prefix = "RK";
|
||||
}
|
||||
Long organizationId = stockOutOrderDO.getOrganizationId();
|
||||
Long warehouseIdForCount = stockOutOrderDO.getWarehouseId();
|
||||
if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) {
|
||||
//日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1
|
||||
String dateStr = new SimpleDateFormat("yyMMdd").format(new Date());
|
||||
String datePrefix = prefix + dateStr;
|
||||
List<String> orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount);
|
||||
int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length());
|
||||
String seq = String.format("%03d", maxSeq + 1);
|
||||
stockOutOrderDO.setOutOrderNumber(datePrefix + seq);
|
||||
} else {
|
||||
//历史累加: 前缀 + 历史最大序号+1
|
||||
List<String> orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount);
|
||||
int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length());
|
||||
String seq = String.format("%03d", maxSeq + 1);
|
||||
stockOutOrderDO.setOutOrderNumber(prefix + seq);
|
||||
}
|
||||
|
||||
//设置物料信息
|
||||
//setMaterialDetailInfo(stockOutOrderDO);
|
||||
//统计种类
|
||||
|
||||
Reference in New Issue
Block a user