第一版错误修改后的存档。
This commit is contained in:
@@ -1,7 +1,19 @@
|
|||||||
package com.niuan.erp.common.exception;
|
package com.niuan.erp.common.exception;
|
||||||
|
|
||||||
public class BusinessException extends RuntimeException {
|
public class BusinessException extends RuntimeException {
|
||||||
|
private final String[] args;
|
||||||
|
|
||||||
public BusinessException(String message) {
|
public BusinessException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
this.args = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessException(String message, String... args) {
|
||||||
|
super(message);
|
||||||
|
this.args = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getArgs() {
|
||||||
|
return args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,9 @@ public class GlobalExceptionHandler {
|
|||||||
*/
|
*/
|
||||||
@ExceptionHandler(BusinessException.class)
|
@ExceptionHandler(BusinessException.class)
|
||||||
public ResponseEntity<?> handleBusinessException(BusinessException e, Locale locale) {
|
public ResponseEntity<?> handleBusinessException(BusinessException e, Locale locale) {
|
||||||
|
String message = messageSource.getMessage(e.getMessage(), e.getArgs(), locale);
|
||||||
return ResponseEntity.ok().body(
|
return ResponseEntity.ok().body(
|
||||||
BaseResult.error(3, messageSource.getMessage(e.getMessage(), null, locale)));
|
BaseResult.error(3, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,6 +43,14 @@ public class FinishedProductReceiptController {
|
|||||||
public BaseResult<IPage<FinishedProductReceiptDto>> getFinishedProductReceiptPage(@Validated BasePageReqParams pageParams,
|
public BaseResult<IPage<FinishedProductReceiptDto>> getFinishedProductReceiptPage(@Validated BasePageReqParams pageParams,
|
||||||
@Validated(Get.class) FinishedProductReceiptDto searchParams) {
|
@Validated(Get.class) FinishedProductReceiptDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<Document>();
|
var wrapper = new LambdaQueryWrapper<Document>();
|
||||||
|
if (searchParams != null && searchParams.searchCode() != null) {
|
||||||
|
String searchCode = searchParams.searchCode();
|
||||||
|
wrapper.and(w -> w.like(Document::getFormCode, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormName, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormMark, searchCode));
|
||||||
|
}
|
||||||
return BaseResult.successWithData(finishedProductReceiptService.getFinishedProductReceiptPage(pageParams, wrapper));
|
return BaseResult.successWithData(finishedProductReceiptService.getFinishedProductReceiptPage(pageParams, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ public class FinishedProductShipmentController {
|
|||||||
public BaseResult<IPage<FinishedProductShipmentDto>> getFinishedProductShipmentPage(@Validated BasePageReqParams pageParams,
|
public BaseResult<IPage<FinishedProductShipmentDto>> getFinishedProductShipmentPage(@Validated BasePageReqParams pageParams,
|
||||||
@Validated(Get.class) FinishedProductShipmentDto searchParams) {
|
@Validated(Get.class) FinishedProductShipmentDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<Document>();
|
var wrapper = new LambdaQueryWrapper<Document>();
|
||||||
|
if (searchParams != null && searchParams.searchCode() != null) {
|
||||||
|
String searchCode = searchParams.searchCode();
|
||||||
|
wrapper.and(w -> w.like(Document::getFormCode, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormName, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormMark, searchCode));
|
||||||
|
}
|
||||||
return BaseResult.successWithData(finishedProductShipmentService.getFinishedProductShipmentPage(pageParams, wrapper));
|
return BaseResult.successWithData(finishedProductShipmentService.getFinishedProductShipmentPage(pageParams, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ public class ProductionIssueController {
|
|||||||
public BaseResult<IPage<ProductionIssueDto>> getProductionIssuePage(@Validated BasePageReqParams pageParams,
|
public BaseResult<IPage<ProductionIssueDto>> getProductionIssuePage(@Validated BasePageReqParams pageParams,
|
||||||
@Validated(Get.class) ProductionIssueDto searchParams) {
|
@Validated(Get.class) ProductionIssueDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<Document>();
|
var wrapper = new LambdaQueryWrapper<Document>();
|
||||||
|
if (searchParams != null && searchParams.searchCode() != null) {
|
||||||
|
String searchCode = searchParams.searchCode();
|
||||||
|
wrapper.and(w -> w.like(Document::getFormCode, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormMark, searchCode));
|
||||||
|
}
|
||||||
return BaseResult.successWithData(productionIssueService.getProductionIssuePage(pageParams, wrapper));
|
return BaseResult.successWithData(productionIssueService.getProductionIssuePage(pageParams, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ public class ProductionReturnController {
|
|||||||
@Validated(Get.class) ProductionReturnDto searchParams) {
|
@Validated(Get.class) ProductionReturnDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<Document>();
|
var wrapper = new LambdaQueryWrapper<Document>();
|
||||||
wrapper.eq(Document::getFormType, DocumentType.PRODUCTION_RETURN.getCode());
|
wrapper.eq(Document::getFormType, DocumentType.PRODUCTION_RETURN.getCode());
|
||||||
|
if (searchParams != null && searchParams.searchCode() != null) {
|
||||||
|
String searchCode = searchParams.searchCode();
|
||||||
|
wrapper.and(w -> w.like(Document::getFormCode, searchCode)
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormMark, searchCode));
|
||||||
|
}
|
||||||
return BaseResult.successWithData(productionReturnService.getProductionReturnPage(pageParams, wrapper));
|
return BaseResult.successWithData(productionReturnService.getProductionReturnPage(pageParams, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ public record FinishedProductReceiptDto(
|
|||||||
Integer outStoreNo,
|
Integer outStoreNo,
|
||||||
String outStoreName,
|
String outStoreName,
|
||||||
Integer groupId,
|
Integer groupId,
|
||||||
Integer customerId) {}
|
Integer customerId,
|
||||||
|
String searchCode) {}
|
||||||
@@ -50,4 +50,6 @@ public record FinishedProductShipmentDto(
|
|||||||
@Schema(description = "客户ID")
|
@Schema(description = "客户ID")
|
||||||
Integer customerId,
|
Integer customerId,
|
||||||
@Schema(description = "出库明细列表")
|
@Schema(description = "出库明细列表")
|
||||||
java.util.List<FinishedProductShipmentItemDto> shipmentItems) {}
|
java.util.List<FinishedProductShipmentItemDto> shipmentItems,
|
||||||
|
@Schema(description = "搜索关键词")
|
||||||
|
String searchCode) {}
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ public record ProductionIssueDto(
|
|||||||
Integer outStoreNo,
|
Integer outStoreNo,
|
||||||
String outStoreName,
|
String outStoreName,
|
||||||
Integer groupId,
|
Integer groupId,
|
||||||
Integer customerId) {}
|
Integer customerId,
|
||||||
|
String searchCode) {}
|
||||||
@@ -11,4 +11,5 @@ public record ProductionReturnDto(
|
|||||||
String formMark,
|
String formMark,
|
||||||
String partNumber,
|
String partNumber,
|
||||||
String productSpecs,
|
String productSpecs,
|
||||||
Integer returnQty) {}
|
Integer returnQty,
|
||||||
|
String searchCode) {}
|
||||||
@@ -51,9 +51,9 @@ public class FinishedProductShipmentServiceImpl extends ServiceImpl<DocumentMapp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<FinishedProductShipmentDto> getFinishedProductShipmentPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
public IPage<FinishedProductShipmentDto> getFinishedProductShipmentPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
||||||
wrapper.eq(Document::getFormType, DocumentType.FINISHED_PRODUCT_SHIPMENT)
|
wrapper.and(w -> w.eq(Document::getFormType, DocumentType.FINISHED_PRODUCT_SHIPMENT)
|
||||||
.or()
|
.or()
|
||||||
.eq(Document::getFormType, DocumentType.WAREHOUSE_ISSUE);
|
.eq(Document::getFormType, DocumentType.WAREHOUSE_ISSUE));
|
||||||
// 按创建时间倒序排列
|
// 按创建时间倒序排列
|
||||||
wrapper.orderByDesc(Document::getCreateDate);
|
wrapper.orderByDesc(Document::getCreateDate);
|
||||||
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
||||||
@@ -238,6 +238,7 @@ public class FinishedProductShipmentServiceImpl extends ServiceImpl<DocumentMapp
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.APPROVE);
|
entity.setFormStatus(FormStatus.APPROVE);
|
||||||
|
entity.setStatus(1);
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
@@ -293,6 +294,7 @@ public class FinishedProductShipmentServiceImpl extends ServiceImpl<DocumentMapp
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.NO_APPROVE);
|
entity.setFormStatus(FormStatus.NO_APPROVE);
|
||||||
|
entity.setStatus(0);
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class ProductionIssueServiceImpl extends ServiceImpl<DocumentMapper, Docu
|
|||||||
@Override
|
@Override
|
||||||
public IPage<ProductionIssueDto> getProductionIssuePage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
public IPage<ProductionIssueDto> getProductionIssuePage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
||||||
wrapper.eq(Document::getFormType, DocumentType.PRODUCTION_ISSUE)
|
wrapper.eq(Document::getFormType, DocumentType.PRODUCTION_ISSUE)
|
||||||
|
.eq(Document::getCustomerId, SecurityUtils.getCustomerId())
|
||||||
.eq(Document::getGroupId, SecurityUtils.getLoginUser().getUser().getProjectId())
|
.eq(Document::getGroupId, SecurityUtils.getLoginUser().getUser().getProjectId())
|
||||||
.orderByDesc(Document::getCreateDate);
|
.orderByDesc(Document::getCreateDate);
|
||||||
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class ProductionPlanServiceImpl extends ServiceImpl<ProductionPlanMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<ProductionPlanDto> getProductionPlanPage(BasePageReqParams pageParams, LambdaQueryWrapper<ProductionPlan> wrapper) {
|
public IPage<ProductionPlanDto> getProductionPlanPage(BasePageReqParams pageParams, LambdaQueryWrapper<ProductionPlan> wrapper) {
|
||||||
|
wrapper.eq(ProductionPlan::getCustomerId, SecurityUtils.getCustomerId());
|
||||||
IPage<ProductionPlan> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
IPage<ProductionPlan> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
||||||
return result.convert(productionPlanConverter::toDto);
|
return result.convert(productionPlanConverter::toDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,14 @@ public class PurchasePlanController {
|
|||||||
@Validated(Get.class) PurchasePlanDto searchParams) {
|
@Validated(Get.class) PurchasePlanDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<PurchasePlan>();
|
var wrapper = new LambdaQueryWrapper<PurchasePlan>();
|
||||||
if (searchParams != null) {
|
if (searchParams != null) {
|
||||||
if (StringUtils.hasText(searchParams.vendorName())) {
|
if (StringUtils.hasText(searchParams.searchCode())) {
|
||||||
wrapper.like(PurchasePlan::getVendorName, searchParams.vendorName());
|
wrapper.and(w -> w.like(PurchasePlan::getPlanNo, searchParams.searchCode())
|
||||||
|
.or()
|
||||||
|
.like(PurchasePlan::getPlanName, searchParams.searchCode())
|
||||||
|
.or()
|
||||||
|
.like(PurchasePlan::getRemask, searchParams.searchCode()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 按创建时间倒序排序
|
|
||||||
wrapper.orderByDesc(PurchasePlan::getCreateDate);
|
wrapper.orderByDesc(PurchasePlan::getCreateDate);
|
||||||
return BaseResult.successWithData(purchasePlanService.getPurchasePlanPage(pageParams, wrapper));
|
return BaseResult.successWithData(purchasePlanService.getPurchasePlanPage(pageParams, wrapper));
|
||||||
}
|
}
|
||||||
@@ -85,6 +88,13 @@ public class PurchasePlanController {
|
|||||||
return BaseResult.successWithData(purchasePlanService.getPurchasePlanItemsWithVendorSuggestions(planId));
|
return BaseResult.successWithData(purchasePlanService.getPurchasePlanItemsWithVendorSuggestions(planId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取采购计划明细", operationId = "getPurchasePlanItems")
|
||||||
|
@GetMapping("/getPurchasePlanItems")
|
||||||
|
@PreAuthorize("hasAuthority('purchase_plan:index')")
|
||||||
|
public BaseResult<List<PurchasePlanItemDto>> getPurchasePlanItems(@RequestParam Long planId) {
|
||||||
|
return BaseResult.successWithData(purchasePlanService.getPurchasePlanItems(planId));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiLog(type = OperationType.UPDATE, remark = "生成采购订单")
|
@ApiLog(type = OperationType.UPDATE, remark = "生成采购订单")
|
||||||
@Operation(summary = "生成采购订单", operationId = "generatePurchaseOrder")
|
@Operation(summary = "生成采购订单", operationId = "generatePurchaseOrder")
|
||||||
@PostMapping("/generatePurchaseOrder")
|
@PostMapping("/generatePurchaseOrder")
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ public record PurchasePlanDto(
|
|||||||
Integer planStatus,
|
Integer planStatus,
|
||||||
String storeName,
|
String storeName,
|
||||||
String remask,
|
String remask,
|
||||||
String planName) {}
|
String planName,
|
||||||
|
String searchCode) {}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.niuan.erp.module.sale.controller;
|
package com.niuan.erp.module.sale.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.niuan.erp.common.annotation.ModuleLog;
|
import com.niuan.erp.common.annotation.ModuleLog;
|
||||||
import com.niuan.erp.common.base.BasePageReqParams;
|
import com.niuan.erp.common.base.BasePageReqParams;
|
||||||
@@ -7,16 +8,28 @@ import com.niuan.erp.common.base.BaseResult;
|
|||||||
import com.niuan.erp.common.base.CommonValidateGroup.Get;
|
import com.niuan.erp.common.base.CommonValidateGroup.Get;
|
||||||
import com.niuan.erp.module.sale.controller.dto.DeviceQueryDto;
|
import com.niuan.erp.module.sale.controller.dto.DeviceQueryDto;
|
||||||
import com.niuan.erp.module.sale.controller.dto.DeviceResultDto;
|
import com.niuan.erp.module.sale.controller.dto.DeviceResultDto;
|
||||||
|
import com.niuan.erp.module.sale.controller.dto.DeviceValidateRequest;
|
||||||
|
import com.niuan.erp.module.sale.controller.dto.DeviceValidateResponse;
|
||||||
|
import com.niuan.erp.module.sale.entity.Device;
|
||||||
import com.niuan.erp.module.sale.service.DeviceService;
|
import com.niuan.erp.module.sale.service.DeviceService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Tag(name = "SN溯源")
|
@Tag(name = "SN溯源")
|
||||||
@ModuleLog("SN溯源管理")
|
@ModuleLog("SN溯源管理")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -33,4 +46,81 @@ public class DeviceController {
|
|||||||
@Validated(Get.class) DeviceQueryDto searchParams) {
|
@Validated(Get.class) DeviceQueryDto searchParams) {
|
||||||
return BaseResult.successWithData(deviceService.getDeviceSnPage(pageParams, searchParams));
|
return BaseResult.successWithData(deviceService.getDeviceSnPage(pageParams, searchParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "验证设备SN码、MAC地址、序列号是否重复", operationId = "validateDevices")
|
||||||
|
@PostMapping("/validateDevices")
|
||||||
|
@PreAuthorize("hasAnyAuthority('finished_product_receipt:add', 'finished_product_receipt:update')")
|
||||||
|
public BaseResult<DeviceValidateResponse> validateDevices(@Validated @RequestBody DeviceValidateRequest request) {
|
||||||
|
if (request.devices() == null || request.devices().isEmpty()) {
|
||||||
|
return BaseResult.successWithData(new DeviceValidateResponse(true, List.of(), List.of(), List.of(), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> productSns = request.devices().stream()
|
||||||
|
.map(item -> item.productSn())
|
||||||
|
.filter(StringUtils::hasText)
|
||||||
|
.toList();
|
||||||
|
List<String> macs = request.devices().stream()
|
||||||
|
.map(item -> item.mac())
|
||||||
|
.filter(StringUtils::hasText)
|
||||||
|
.toList();
|
||||||
|
List<String> serialNums = request.devices().stream()
|
||||||
|
.map(item -> item.serialNum())
|
||||||
|
.filter(StringUtils::hasText)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
Set<String> duplicateProductSns = new HashSet<>();
|
||||||
|
Set<String> duplicateMacs = new HashSet<>();
|
||||||
|
Set<String> duplicateSerialNums = new HashSet<>();
|
||||||
|
|
||||||
|
if (!productSns.isEmpty()) {
|
||||||
|
Set<String> existingProductSns = deviceService.getDeviceMapper().selectList(
|
||||||
|
new LambdaQueryWrapper<Device>().in(Device::getProductSn, productSns))
|
||||||
|
.stream()
|
||||||
|
.map(Device::getProductSn)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
duplicateProductSns.addAll(existingProductSns);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!macs.isEmpty()) {
|
||||||
|
Set<String> existingMacs = deviceService.getDeviceMapper().selectList(
|
||||||
|
new LambdaQueryWrapper<Device>().in(Device::getMac, macs))
|
||||||
|
.stream()
|
||||||
|
.map(Device::getMac)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
duplicateMacs.addAll(existingMacs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serialNums.isEmpty()) {
|
||||||
|
Set<String> existingSerialNums = deviceService.getDeviceMapper().selectList(
|
||||||
|
new LambdaQueryWrapper<Device>().in(Device::getSerialNum, serialNums))
|
||||||
|
.stream()
|
||||||
|
.map(Device::getSerialNum)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
duplicateSerialNums.addAll(existingSerialNums);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean valid = duplicateProductSns.isEmpty() && duplicateMacs.isEmpty() && duplicateSerialNums.isEmpty();
|
||||||
|
String message = null;
|
||||||
|
if (!valid) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (!duplicateProductSns.isEmpty()) {
|
||||||
|
sb.append("重复的SN码:").append(String.join(", ", duplicateProductSns)).append(";");
|
||||||
|
}
|
||||||
|
if (!duplicateMacs.isEmpty()) {
|
||||||
|
sb.append("重复的MAC地址:").append(String.join(", ", duplicateMacs)).append(";");
|
||||||
|
}
|
||||||
|
if (!duplicateSerialNums.isEmpty()) {
|
||||||
|
sb.append("重复的序列号:").append(String.join(", ", duplicateSerialNums)).append(";");
|
||||||
|
}
|
||||||
|
message = sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return BaseResult.successWithData(new DeviceValidateResponse(
|
||||||
|
valid,
|
||||||
|
new ArrayList<>(duplicateProductSns),
|
||||||
|
new ArrayList<>(duplicateMacs),
|
||||||
|
new ArrayList<>(duplicateSerialNums),
|
||||||
|
message
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,12 @@ public class SaleOrderController {
|
|||||||
@Validated(Get.class) SaleOrderDto searchParams) {
|
@Validated(Get.class) SaleOrderDto searchParams) {
|
||||||
var wrapper = new LambdaQueryWrapper<Document>();
|
var wrapper = new LambdaQueryWrapper<Document>();
|
||||||
if (searchParams != null) {
|
if (searchParams != null) {
|
||||||
if (StringUtils.hasText(searchParams.customerName())) {
|
if (StringUtils.hasText(searchParams.searchCode())) {
|
||||||
wrapper.like(Document::getStoreName, searchParams.customerName());
|
wrapper.and(w -> w.like(Document::getFormCode, searchParams.searchCode())
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormName, searchParams.searchCode())
|
||||||
|
.or()
|
||||||
|
.like(Document::getFormMark, searchParams.searchCode()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BaseResult.successWithData(saleOrderService.getSaleOrderPage(pageParams, wrapper));
|
return BaseResult.successWithData(saleOrderService.getSaleOrderPage(pageParams, wrapper));
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ public record SaleOrderDto(
|
|||||||
Integer formStatus,
|
Integer formStatus,
|
||||||
Integer customerId,
|
Integer customerId,
|
||||||
String customerName,
|
String customerName,
|
||||||
Double totalValue
|
Double totalValue,
|
||||||
|
String searchCode
|
||||||
) {}
|
) {}
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.niuan.erp.common.base.BasePageReqParams;
|
import com.niuan.erp.common.base.BasePageReqParams;
|
||||||
import com.niuan.erp.module.sale.controller.dto.DeviceQueryDto;
|
import com.niuan.erp.module.sale.controller.dto.DeviceQueryDto;
|
||||||
import com.niuan.erp.module.sale.controller.dto.DeviceResultDto;
|
import com.niuan.erp.module.sale.controller.dto.DeviceResultDto;
|
||||||
|
import com.niuan.erp.module.sale.mapper.DeviceMapper;
|
||||||
|
|
||||||
public interface DeviceService {
|
public interface DeviceService {
|
||||||
|
|
||||||
IPage<DeviceResultDto> getDeviceSnPage(BasePageReqParams pageParams, DeviceQueryDto searchParams);
|
IPage<DeviceResultDto> getDeviceSnPage(BasePageReqParams pageParams, DeviceQueryDto searchParams);
|
||||||
|
|
||||||
|
DeviceMapper getDeviceMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,4 +32,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
searchCode,
|
searchCode,
|
||||||
keyAccountId);
|
keyAccountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceMapper getDeviceMapper() {
|
||||||
|
return this.baseMapper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.niuan.erp.common.base.BasePageReqParams;
|
import com.niuan.erp.common.base.BasePageReqParams;
|
||||||
import com.niuan.erp.common.base.BaseResult;
|
import com.niuan.erp.common.base.BaseResult;
|
||||||
import com.niuan.erp.common.base.CommonValidateGroup.Get;
|
import com.niuan.erp.common.base.CommonValidateGroup.Get;
|
||||||
|
import com.niuan.erp.common.base.CommonValidateGroup.Add;
|
||||||
|
import com.niuan.erp.module.warehouse.controller.dto.StockCheckDto;
|
||||||
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
||||||
import com.niuan.erp.module.warehouse.service.StockService;
|
import com.niuan.erp.module.warehouse.service.StockService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -12,6 +14,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -30,4 +34,12 @@ public class StockController {
|
|||||||
@Validated(Get.class) StockDto searchParams) {
|
@Validated(Get.class) StockDto searchParams) {
|
||||||
return BaseResult.successWithData(stockService.getStockPage(pageParams, searchParams));
|
return BaseResult.successWithData(stockService.getStockPage(pageParams, searchParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "库存检测", operationId = "checkStock")
|
||||||
|
@PostMapping("/checkStock")
|
||||||
|
@PreAuthorize("hasAnyAuthority('stock_transfer_order:add', 'stock_transfer_order:update')")
|
||||||
|
public BaseResult<?> checkStock(@Validated(Add.class) @RequestBody StockCheckDto dto) {
|
||||||
|
stockService.checkStock(dto);
|
||||||
|
return BaseResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class StockTransferOrderController {
|
|||||||
@ApiLog(type = OperationType.UPDATE, remark = "更新一条StockTransferOrder记录")
|
@ApiLog(type = OperationType.UPDATE, remark = "更新一条StockTransferOrder记录")
|
||||||
@Operation(summary = "更新StockTransferOrder", operationId = "updateStockTransferOrder")
|
@Operation(summary = "更新StockTransferOrder", operationId = "updateStockTransferOrder")
|
||||||
@PostMapping("/updateStockTransferOrder")
|
@PostMapping("/updateStockTransferOrder")
|
||||||
@PreAuthorize("hasAuthority('stock_transfer_order:update')")
|
@PreAuthorize("hasAuthority('stock_transfer_order:edit')")
|
||||||
public BaseResult<?> updateStockTransferOrder(@Validated(Update.class) @RequestBody StockTransferOrderAddDto dto) {
|
public BaseResult<?> updateStockTransferOrder(@Validated(Update.class) @RequestBody StockTransferOrderAddDto dto) {
|
||||||
stockTransferOrderService.updateStockTransferOrder(dto);
|
stockTransferOrderService.updateStockTransferOrder(dto);
|
||||||
return BaseResult.success();
|
return BaseResult.success();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
* @param formCode
|
* @param formCode
|
||||||
* @param formName
|
* @param formName
|
||||||
* @param formMark
|
* @param formMark
|
||||||
* @param formStatus
|
* @param status
|
||||||
* @param orderItems
|
* @param orderItems
|
||||||
*/
|
*/
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@@ -29,5 +29,5 @@ public record StockTransferOrderDto(
|
|||||||
String formCode,
|
String formCode,
|
||||||
String formName,
|
String formName,
|
||||||
String formMark,
|
String formMark,
|
||||||
Integer formStatus,
|
Integer status,
|
||||||
List<StockTransferOrderItemDto> orderItems) {}
|
List<StockTransferOrderItemDto> orderItems) {}
|
||||||
@@ -8,6 +8,7 @@ import com.niuan.erp.module.warehouse.controller.dto.StockTransferOrderDto;
|
|||||||
import com.niuan.erp.module.warehouse.controller.dto.StockTransferOrderItemAddDto;
|
import com.niuan.erp.module.warehouse.controller.dto.StockTransferOrderItemAddDto;
|
||||||
import com.niuan.erp.module.warehouse.controller.dto.StockTransferOrderItemDto;
|
import com.niuan.erp.module.warehouse.controller.dto.StockTransferOrderItemDto;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,6 +17,8 @@ import java.util.List;
|
|||||||
public interface StockTransferOrderConverter {
|
public interface StockTransferOrderConverter {
|
||||||
Document toEntity(StockTransferOrderDto dto);
|
Document toEntity(StockTransferOrderDto dto);
|
||||||
Document toEntity(StockTransferOrderAddDto dto);
|
Document toEntity(StockTransferOrderAddDto dto);
|
||||||
|
|
||||||
|
@Mapping(source = "formStatus.value", target = "status")
|
||||||
StockTransferOrderDto toDto(Document entity);
|
StockTransferOrderDto toDto(Document entity);
|
||||||
|
|
||||||
DocumentMaterial toEntity(StockTransferOrderItemAddDto dto);
|
DocumentMaterial toEntity(StockTransferOrderItemAddDto dto);
|
||||||
|
|||||||
@@ -24,4 +24,7 @@ public interface WarehouseItemMapper extends BaseMapper<WarehouseItem> {
|
|||||||
@MapKey("partNumber")
|
@MapKey("partNumber")
|
||||||
Map<String, Map<String, Object>> getWarehouseItemStockListByPartNumbers(List<String> partNumbers);
|
Map<String, Map<String, Object>> getWarehouseItemStockListByPartNumbers(List<String> partNumbers);
|
||||||
|
|
||||||
|
@MapKey("partNumber")
|
||||||
|
Map<String, Map<String, Object>> getWarehouseItemStockListByPartNumbersWithStore(List<String> partNumbers, Integer storeNo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.niuan.erp.module.warehouse.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.niuan.erp.common.base.BasePageReqParams;
|
import com.niuan.erp.common.base.BasePageReqParams;
|
||||||
|
import com.niuan.erp.module.warehouse.controller.dto.StockCheckDto;
|
||||||
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
||||||
|
|
||||||
public interface StockService {
|
public interface StockService {
|
||||||
|
|
||||||
IPage<StockDto> getStockPage(BasePageReqParams pageParams, StockDto searchParams);
|
IPage<StockDto> getStockPage(BasePageReqParams pageParams, StockDto searchParams);
|
||||||
|
|
||||||
|
void checkStock(StockCheckDto dto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class InventoryCountServiceImpl extends ServiceImpl<DocumentMapper, Docum
|
|||||||
@Override
|
@Override
|
||||||
public IPage<InventoryCountDto> getInventoryCountPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
public IPage<InventoryCountDto> getInventoryCountPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
||||||
wrapper.eq(Document::getFormType, DocumentType.INVENTORY_COUNT);
|
wrapper.eq(Document::getFormType, DocumentType.INVENTORY_COUNT);
|
||||||
|
wrapper.eq(Document::getCustomerId, SecurityUtils.getCustomerId());
|
||||||
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
||||||
return result.convert(inventoryCountConverter::toDto);
|
return result.convert(inventoryCountConverter::toDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.niuan.erp.module.warehouse.service.impl;
|
package com.niuan.erp.module.warehouse.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.niuan.erp.common.base.BasePageReqParams;
|
import com.niuan.erp.common.base.BasePageReqParams;
|
||||||
|
import com.niuan.erp.common.exception.BusinessException;
|
||||||
import com.niuan.erp.common.utils.SecurityUtils;
|
import com.niuan.erp.common.utils.SecurityUtils;
|
||||||
|
import com.niuan.erp.module.warehouse.controller.dto.StockCheckDto;
|
||||||
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
import com.niuan.erp.module.warehouse.controller.dto.StockDto;
|
||||||
import com.niuan.erp.module.warehouse.converter.StockConverter;
|
import com.niuan.erp.module.warehouse.converter.StockConverter;
|
||||||
import com.niuan.erp.module.warehouse.entity.Stock;
|
import com.niuan.erp.module.warehouse.entity.Stock;
|
||||||
@@ -14,6 +17,9 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -29,4 +35,33 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|||||||
searchParams, SecurityUtils.getUserId());
|
searchParams, SecurityUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkStock(StockCheckDto dto) {
|
||||||
|
if (dto.storeNo() == null) {
|
||||||
|
throw new BusinessException("warehouse.stock_check.validate.store_no_not_null");
|
||||||
|
}
|
||||||
|
if (dto.items() == null || dto.items().isEmpty()) {
|
||||||
|
throw new BusinessException("warehouse.stock_check.validate.items_not_empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
var partNumbers = dto.items().stream()
|
||||||
|
.map(StockCheckDto.StockCheckItem::partNumber)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
var stockWrapper = new LambdaQueryWrapper<Stock>()
|
||||||
|
.eq(Stock::getStoreNo, dto.storeNo())
|
||||||
|
.in(Stock::getPartNumber, partNumbers);
|
||||||
|
var stockList = this.baseMapper.selectList(stockWrapper);
|
||||||
|
|
||||||
|
var stockMap = stockList.stream()
|
||||||
|
.collect(Collectors.toMap(Stock::getPartNumber, s -> s));
|
||||||
|
|
||||||
|
for (var item : dto.items()) {
|
||||||
|
var stock = stockMap.get(item.partNumber());
|
||||||
|
if (stock == null || stock.getProductCount() == null || stock.getProductCount() < item.requiredCount()) {
|
||||||
|
throw new BusinessException("warehouse.stock_check.exception.insufficient_stock", item.partNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
order.getFormCode(),
|
order.getFormCode(),
|
||||||
order.getFormName(),
|
order.getFormName(),
|
||||||
order.getFormMark(),
|
order.getFormMark(),
|
||||||
order.getFormStatus().getValue(),
|
order.getStatus(),
|
||||||
items.stream()
|
items.stream()
|
||||||
.filter(item -> item.getDocumentNo().equals(order.getId().intValue()))
|
.filter(item -> item.getDocumentNo().equals(order.getId().intValue()))
|
||||||
.map(stockTransferOrderConverter::toItemDto).toList()));
|
.map(stockTransferOrderConverter::toItemDto).toList()));
|
||||||
@@ -109,7 +109,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
entity.setCreateUserId(SecurityUtils.getUserId());
|
entity.setCreateUserId(SecurityUtils.getUserId());
|
||||||
entity.setCreateUserName(SecurityUtils.getUserName());
|
entity.setCreateUserName(SecurityUtils.getUserName());
|
||||||
entity.setCreateDate(LocalDateTime.now());
|
entity.setCreateDate(LocalDateTime.now());
|
||||||
entity.setStatus(0);
|
entity.setStatus(FormStatus.NO_APPROVE.getValue());
|
||||||
entity.setCustomerId(SecurityUtils.getCustomerId());
|
entity.setCustomerId(SecurityUtils.getCustomerId());
|
||||||
entity.setFormType(DocumentType.STOCK_TRANSFER_ORDER);
|
entity.setFormType(DocumentType.STOCK_TRANSFER_ORDER);
|
||||||
entity.setFormStatus(FormStatus.NO_APPROVE);
|
entity.setFormStatus(FormStatus.NO_APPROVE);
|
||||||
@@ -118,9 +118,9 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
List<DocumentMaterial> materials = stockTransferOrderConverter.toEntityList(dto.transferOrderItems());
|
List<DocumentMaterial> materials = stockTransferOrderConverter.toEntityList(dto.transferOrderItems());
|
||||||
|
|
||||||
Map<String, Map<String, Object>> warehouseItems =
|
Map<String, Map<String, Object>> warehouseItems =
|
||||||
warehouseItemMapper.getWarehouseItemStockListByPartNumbers(materials.stream()
|
warehouseItemMapper.getWarehouseItemStockListByPartNumbersWithStore(materials.stream()
|
||||||
.map(DocumentMaterial::getPartNumber)
|
.map(DocumentMaterial::getPartNumber)
|
||||||
.toList());
|
.toList(), dto.outStoreNo());
|
||||||
|
|
||||||
materials.forEach(m -> {
|
materials.forEach(m -> {
|
||||||
m.setDocumentNo(entity.getId().intValue());
|
m.setDocumentNo(entity.getId().intValue());
|
||||||
@@ -177,9 +177,9 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
List<DocumentMaterial> materials = stockTransferOrderConverter.toEntityList(dto.transferOrderItems());
|
List<DocumentMaterial> materials = stockTransferOrderConverter.toEntityList(dto.transferOrderItems());
|
||||||
|
|
||||||
Map<String, Map<String, Object>> warehouseItems =
|
Map<String, Map<String, Object>> warehouseItems =
|
||||||
warehouseItemMapper.getWarehouseItemStockListByPartNumbers(materials.stream()
|
warehouseItemMapper.getWarehouseItemStockListByPartNumbersWithStore(materials.stream()
|
||||||
.map(DocumentMaterial::getPartNumber)
|
.map(DocumentMaterial::getPartNumber)
|
||||||
.toList());
|
.toList(), dto.outStoreNo());
|
||||||
|
|
||||||
materials.forEach(m -> {
|
materials.forEach(m -> {
|
||||||
m.setDocumentNo(entity.getId().intValue());
|
m.setDocumentNo(entity.getId().intValue());
|
||||||
@@ -268,7 +268,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
for (DocumentMaterial material : materialList) {
|
for (DocumentMaterial material : materialList) {
|
||||||
Stock outStock = outStockMap.get(material.getPartNumber());
|
Stock outStock = outStockMap.get(material.getPartNumber());
|
||||||
if (outStock == null || outStock.getProductCount() < material.getProductCount()) {
|
if (outStock == null || outStock.getProductCount() < material.getProductCount()) {
|
||||||
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock");
|
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock", material.getPartNumber());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +318,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.APPROVE);
|
entity.setFormStatus(FormStatus.APPROVE);
|
||||||
|
entity.setStatus(FormStatus.APPROVE.getValue());
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
@@ -389,10 +390,10 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
for (DocumentMaterial material : materialList) {
|
for (DocumentMaterial material : materialList) {
|
||||||
Stock inStock = inStockMap.get(material.getPartNumber());
|
Stock inStock = inStockMap.get(material.getPartNumber());
|
||||||
if (inStock == null) {
|
if (inStock == null) {
|
||||||
throw new BusinessException("warehouse.stock_transfer_order.exception.stock_not_found");
|
throw new BusinessException("warehouse.stock_transfer_order.exception.stock_not_found", material.getPartNumber());
|
||||||
}
|
}
|
||||||
if (inStock.getProductCount() < material.getProductCount()) {
|
if (inStock.getProductCount() < material.getProductCount()) {
|
||||||
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock_for_unapprove");
|
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock_for_unapprove", material.getPartNumber());
|
||||||
}
|
}
|
||||||
inStock.setProductCount(inStock.getProductCount() - material.getProductCount());
|
inStock.setProductCount(inStock.getProductCount() - material.getProductCount());
|
||||||
inStock.setUpdateDate(LocalDateTime.now());
|
inStock.setUpdateDate(LocalDateTime.now());
|
||||||
@@ -402,6 +403,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.NO_APPROVE);
|
entity.setFormStatus(FormStatus.NO_APPROVE);
|
||||||
|
entity.setStatus(FormStatus.NO_APPROVE.getValue());
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
@@ -433,7 +435,7 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
|
|
||||||
List<String> partNumbers = new ArrayList<>(partCountMap.keySet());
|
List<String> partNumbers = new ArrayList<>(partCountMap.keySet());
|
||||||
Map<String, Map<String, Object>> warehouseItems =
|
Map<String, Map<String, Object>> warehouseItems =
|
||||||
warehouseItemMapper.getWarehouseItemStockListByPartNumbers(partNumbers);
|
warehouseItemMapper.getWarehouseItemStockListByPartNumbersWithStore(partNumbers, dto.outStoreNo());
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> entry : partCountMap.entrySet()) {
|
for (Map.Entry<String, Integer> entry : partCountMap.entrySet()) {
|
||||||
String partNumber = entry.getKey();
|
String partNumber = entry.getKey();
|
||||||
@@ -441,12 +443,12 @@ public class StockTransferOrderServiceImpl extends ServiceImpl<DocumentMapper, D
|
|||||||
|
|
||||||
Map<String, Object> stockInfo = warehouseItems.get(partNumber);
|
Map<String, Object> stockInfo = warehouseItems.get(partNumber);
|
||||||
if (stockInfo == null) {
|
if (stockInfo == null) {
|
||||||
throw new BusinessException("warehouse.stock_transfer_order.exception.part_not_found");
|
throw new BusinessException("warehouse.stock_transfer_order.exception.part_not_found", partNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
Long stockCount = (Long) stockInfo.get("productCount");
|
Long stockCount = (Long) stockInfo.get("productCount");
|
||||||
if (stockCount == null || stockCount < totalTransfer) {
|
if (stockCount == null || stockCount < totalTransfer) {
|
||||||
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock");
|
throw new BusinessException("warehouse.stock_transfer_order.exception.insufficient_stock", partNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class WarehouseReceiptServiceImpl extends ServiceImpl<DocumentMapper, Doc
|
|||||||
@Override
|
@Override
|
||||||
public IPage<WarehouseReceiptDto> getWarehouseReceiptPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
public IPage<WarehouseReceiptDto> getWarehouseReceiptPage(BasePageReqParams pageParams, LambdaQueryWrapper<Document> wrapper) {
|
||||||
wrapper.eq(Document::getFormType, DocumentType.WAREHOUSE_RECEIPT)
|
wrapper.eq(Document::getFormType, DocumentType.WAREHOUSE_RECEIPT)
|
||||||
|
.eq(Document::getCustomerId, SecurityUtils.getCustomerId())
|
||||||
.orderByDesc(Document::getCreateDate);
|
.orderByDesc(Document::getCreateDate);
|
||||||
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
IPage<Document> result = this.baseMapper.selectPage(new Page<>(pageParams.page(), pageParams.pageSize()), wrapper);
|
||||||
return result.convert(warehouseReceiptConverter::toDto);
|
return result.convert(warehouseReceiptConverter::toDto);
|
||||||
@@ -211,6 +212,7 @@ public class WarehouseReceiptServiceImpl extends ServiceImpl<DocumentMapper, Doc
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.APPROVE);
|
entity.setFormStatus(FormStatus.APPROVE);
|
||||||
|
entity.setStatus(1);
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
@@ -266,6 +268,7 @@ public class WarehouseReceiptServiceImpl extends ServiceImpl<DocumentMapper, Doc
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setFormStatus(FormStatus.NO_APPROVE);
|
entity.setFormStatus(FormStatus.NO_APPROVE);
|
||||||
|
entity.setStatus(0);
|
||||||
entity.setUpdateDate(LocalDateTime.now());
|
entity.setUpdateDate(LocalDateTime.now());
|
||||||
entity.setUpdateUserId(SecurityUtils.getUserId());
|
entity.setUpdateUserId(SecurityUtils.getUserId());
|
||||||
entity.setUpdateUserName(SecurityUtils.getUserName());
|
entity.setUpdateUserName(SecurityUtils.getUserName());
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ warehouse.inventory_count.exception.no_items=盘点单没有明细
|
|||||||
warehouse.inventory_count.exception.file_empty=文件不能为空
|
warehouse.inventory_count.exception.file_empty=文件不能为空
|
||||||
warehouse.inventory_count.exception.import_failed=导入失败
|
warehouse.inventory_count.exception.import_failed=导入失败
|
||||||
warehouse.inventory_count.exception.stock_not_found_for_unapprove=反审核时找不到对应库存记录
|
warehouse.inventory_count.exception.stock_not_found_for_unapprove=反审核时找不到对应库存记录
|
||||||
|
warehouse.stock_check.validate.store_no_not_null=仓库不能为空
|
||||||
|
warehouse.stock_check.validate.items_not_empty=物料明细不能为空
|
||||||
|
warehouse.stock_check.exception.insufficient_stock=物料 {0} 库存不足
|
||||||
|
|
||||||
|
|
||||||
# ==========>> 生产管理
|
# ==========>> 生产管理
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ warehouse.inventory_count.exception.stock_not_found_for_unapprove=物料 {0} 在
|
|||||||
warehouse.inventory_count.exception.file_empty=请选择要上传的文件
|
warehouse.inventory_count.exception.file_empty=请选择要上传的文件
|
||||||
warehouse.inventory_count.exception.import_failed=导入文件失败
|
warehouse.inventory_count.exception.import_failed=导入文件失败
|
||||||
warehouse.inventory_count.exception.init_already_exists=当前仓库已经有初始库存单
|
warehouse.inventory_count.exception.init_already_exists=当前仓库已经有初始库存单
|
||||||
|
warehouse.stock_check.validate.store_no_not_null=仓库不能为空
|
||||||
|
warehouse.stock_check.validate.items_not_empty=物料明细不能为空
|
||||||
|
warehouse.stock_check.exception.insufficient_stock=物料 {0} 库存不足
|
||||||
production.finished_product_receipt.validate.form_code.not_null=单据编号不能为空
|
production.finished_product_receipt.validate.form_code.not_null=单据编号不能为空
|
||||||
production.finished_product_receipt.validate.form_name.not_null=单据名称不能为空
|
production.finished_product_receipt.validate.form_name.not_null=单据名称不能为空
|
||||||
production.finished_product_receipt.validate.store_no.not_null=仓库不能为空
|
production.finished_product_receipt.validate.store_no.not_null=仓库不能为空
|
||||||
|
|||||||
@@ -53,4 +53,19 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getWarehouseItemStockListByPartNumbersWithStore" resultType="java.util.Map">
|
||||||
|
SELECT p.PartNumber AS partNumber, COALESCE(s.ProductCount, 0) AS productCount
|
||||||
|
FROM product p
|
||||||
|
LEFT JOIN storagecount s ON p.PartNumber = s.PartNumber
|
||||||
|
<where>
|
||||||
|
p.PartNumber IN
|
||||||
|
<foreach collection="partNumbers" item="partNumber" open="(" separator=", " close=")">
|
||||||
|
#{partNumber}
|
||||||
|
</foreach>
|
||||||
|
<if test="storeNo != null">
|
||||||
|
AND s.StoreNo = #{storeNo}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user