feat(admin): 新增二维码与库存数量一致性检查业务逻辑
- 新增BaseControllerService类,封装二维码和库存数量一致性检查方法 - 增加判断物料是否生成二维码的功能 - 实现物料库存数量与二维码数量的校验逻辑 - 定义补码待办任务接口,待后续实现 - 新增NoScanningRequest和NoScanningItemRequest请求参数对象 - 设计物料非扫描明细及其数量、批次号、序列号和库位属性校验
This commit is contained in:
parent
536c5e807f
commit
452d924f9d
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.nflg.wms.admin.pojo.request;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NoScanningItemRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次号
|
||||||
|
*/
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列号
|
||||||
|
*/
|
||||||
|
private String serialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库位
|
||||||
|
*/
|
||||||
|
private String binNo;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.nflg.wms.admin.pojo.request;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NoScanningRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单项ID
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Long orderItemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编号
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 明细列表
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
@NotEmpty
|
||||||
|
private List<NoScanningItemRequest> items;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.nflg.wms.admin.service;
|
||||||
|
|
||||||
|
import com.nflg.wms.common.constant.BarCodeProcessStage;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventory;
|
||||||
|
import com.nflg.wms.repository.entity.WmsQrCodeMaster;
|
||||||
|
import com.nflg.wms.repository.service.IWmsInventoryService;
|
||||||
|
import com.nflg.wms.repository.service.IWmsQrCodeMasterService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BaseControllerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IWmsQrCodeMasterService qrCodeMasterService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IWmsInventoryService inventoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料是否生成过二维码
|
||||||
|
* @param materialNo 物料编号
|
||||||
|
* @return 是否生成过二维码
|
||||||
|
*/
|
||||||
|
protected boolean existsQrCode(String materialNo) {
|
||||||
|
return qrCodeMasterService.lambdaQuery()
|
||||||
|
.eq(WmsQrCodeMaster::getMaterialCode, materialNo)
|
||||||
|
.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料库存和物料二维码数量一致性检查
|
||||||
|
* @param materialNo 物料编号
|
||||||
|
* @param factoryNo 工厂编号
|
||||||
|
* @param warehouseNo 仓库编号
|
||||||
|
* @return 数量是否一致
|
||||||
|
*/
|
||||||
|
private boolean quantityConsistencyCheck(String materialNo, String factoryNo, String warehouseNo) {
|
||||||
|
BigDecimal quantityQr = qrCodeMasterService.lambdaQuery()
|
||||||
|
.select(WmsQrCodeMaster::getQuantity)
|
||||||
|
.eq(WmsQrCodeMaster::getMaterialCode, materialNo)
|
||||||
|
.eq(WmsQrCodeMaster::getFactoryCode, factoryNo)
|
||||||
|
.eq(WmsQrCodeMaster::getStorageLocation, warehouseNo)
|
||||||
|
.eq(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(WmsQrCodeMaster::getQuantity)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal quantityInventory = inventoryService.lambdaQuery()
|
||||||
|
.select(WmsInventory::getNum)
|
||||||
|
.eq(WmsInventory::getMaterialNo, materialNo)
|
||||||
|
.eq(WmsInventory::getFactoryNo, factoryNo)
|
||||||
|
.eq(WmsInventory::getWarehouseNo, warehouseNo)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(WmsInventory::getNum)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
return quantityQr.compareTo(quantityInventory) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void qrCodeCreateTask(String materialNo,String factoryNo, String warehouseNo){
|
||||||
|
if (!quantityConsistencyCheck(materialNo, factoryNo, warehouseNo)) {
|
||||||
|
//TODO 给仓库负责人创建补码的待办任务
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue