🐛 报废扣减库存
All checks were successful
Release / Release (push) Successful in 41s

This commit is contained in:
my_ong
2025-03-23 11:57:56 +08:00
parent 54a2a4e089
commit 8ecc84a7c3
2 changed files with 29 additions and 14 deletions

View File

@@ -76,10 +76,10 @@ public class ApplyFormController {
// 导出excel
String sheetName = "申请单列表";
String excelName = "申请单列表";
if(applyType == 1){
if (applyType == 1) {
excelName = "入库申请单列表";
sheetName = "入库";
}else if(applyType == 3){
} else if (applyType == 3) {
excelName = "出库申请单列表";
sheetName = "出库";
}
@@ -108,11 +108,11 @@ public class ApplyFormController {
@GetMapping("apply/audit/download-excel")
@Operation(summary = "导出盘点申请单列表")
public void downloadAuditExcel( @Parameter(description = "盘点类型") @RequestParam(name = "auditType", required = false) AuditTypeEnum auditType,
@Parameter(description = "盘点人") @RequestParam(name = "taker", required = false) String taker,
@Parameter(description = "创建日期") @RequestParam(name = "createDate", required = false) LocalDateTime createDate,
@Parameter(description = "审核状态") @RequestParam(name = "reviewResults", required = false) List<ReviewResultEnum> reviewResults,
HttpServletResponse response){
public void downloadAuditExcel(@Parameter(description = "盘点类型") @RequestParam(name = "auditType", required = false) AuditTypeEnum auditType,
@Parameter(description = "盘点人") @RequestParam(name = "taker", required = false) String taker,
@Parameter(description = "创建日期") @RequestParam(name = "createDate", required = false) LocalDateTime createDate,
@Parameter(description = "审核状态") @RequestParam(name = "reviewResults", required = false) List<ReviewResultEnum> reviewResults,
HttpServletResponse response) {
IPage<ApplyForm> applyFormIPage = searchAuditPage(1, 10000, auditType, taker, createDate, reviewResults);
List<ApplyForm> applyFormList = applyFormIPage.getRecords();
// 导出excel
@@ -156,7 +156,7 @@ public class ApplyFormController {
for (ApplyDetail applyDetail : applyInfo.getApplyDetails()) {
applyDetail.setApplyId(applyInfo.getApplyForm().getId());
// 如果市无须赋码的情况,设置确认数量为申请数量
if (applyType == ApplyTypeEnum.LOAN_OUT && !applyDetail.getAssignRule()) {
if (!applyDetail.getAssignRule()) {
applyDetail.setConfirmQuantity(applyDetail.getQuantity());
}
}
@@ -241,12 +241,23 @@ public class ApplyFormController {
if (reviewDTO.getReviewResult() == ReviewResultEnum.PASS) {
// 修改物料状态
List<String> barcodeList = scrapOutCacheMap.get(reviewDTO.getApplyId());
if (barcodeList == null || barcodeList.isEmpty()) {
return;
if (barcodeList != null) {
barcodeList.forEach(barcode -> materialStockDetailService.update(Wrappers.<MaterialStockDetail>lambdaUpdate()
.set(MaterialStockDetail::getStatus, StockStatusEnum.SCRAP_OUT)
.eq(MaterialStockDetail::getBarcode, barcode)));
}
barcodeList.forEach(barcode -> materialStockDetailService.update(Wrappers.<MaterialStockDetail>lambdaUpdate()
.set(MaterialStockDetail::getStatus, StockStatusEnum.SCRAP_OUT)
.eq(MaterialStockDetail::getBarcode, barcode)));
}
// 处理报废扣减库存
List<ApplyDetail> applyDetails = applyDetailService.list(Wrappers.<ApplyDetail>lambdaQuery()
.eq(ApplyDetail::getApplyId, reviewDTO.getApplyId()));
if (!applyDetails.isEmpty()) {
// 直接扣库存
applyDetails.forEach(detail ->
materialService.update(Wrappers.<Material>lambdaUpdate()
.setSql("m_stock = m_stock - " + detail.getQuantity())
.eq(Material::getId, detail.getMaterialId())
)
);
}
// 删除缓存
scrapOutCacheMap.remove(reviewDTO.getApplyId());

View File

@@ -43,7 +43,11 @@ public class ApplyDetail extends IdBaseEntity {
@ColDefine(notNull = false)
private Long applyId;
@TableField(exist = false)
@Schema(description = "是否需要赋码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@TableField("ad_assign_rule")
@Column("ad_assign_rule")
@Comment("是否需要赋码")
@ColDefine(notNull = false)
private Boolean assignRule;
@Schema(description = "物料Id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)