diff --git a/core/api/src/main/java/com/wansenai/api/warehouse/OtherShipmentsController.java b/core/api/src/main/java/com/wansenai/api/warehouse/OtherShipmentsController.java new file mode 100644 index 00000000..270d6062 --- /dev/null +++ b/core/api/src/main/java/com/wansenai/api/warehouse/OtherShipmentsController.java @@ -0,0 +1,67 @@ +/* + * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://opensource.wansenai.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package com.wansenai.api.warehouse; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.wansenai.dto.warehouse.OtherShipmentDTO; +import com.wansenai.dto.warehouse.QueryOtherShipmentDTO; +import com.wansenai.service.warehouse.OtherShipmentsService; +import com.wansenai.utils.response.Response; +import com.wansenai.vo.warehouse.OtherShipmentDetailVO; +import com.wansenai.vo.warehouse.OtherShipmentVO; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +@RestController +@RequestMapping("warehouse/otherShipments") +public class OtherShipmentsController { + + private final OtherShipmentsService otherShipmentsService; + + public OtherShipmentsController(OtherShipmentsService otherShipmentsService) { + this.otherShipmentsService = otherShipmentsService; + } + + @PostMapping("addOrUpdate") + public Response addOrUpdateOtherShipments(@RequestBody OtherShipmentDTO otherShipmentDTO) { + return otherShipmentsService.addOrUpdateOtherShipments(otherShipmentDTO); + } + + @PostMapping("pageList") + public Response> getOtherShipmentsPageList(@RequestBody QueryOtherShipmentDTO queryOtherShipmentDTO) { + return otherShipmentsService.getOtherShipmentsPageList(queryOtherShipmentDTO); + } + + @GetMapping("getDetailById/{id}") + public Response getOtherShipmentsDetailById(@PathVariable("id") Long id) { + return otherShipmentsService.getOtherShipmentsDetail(id); + } + + @PutMapping("deleteByIds") + public Response deleteOtherShipmentsByIds(@RequestParam("ids") List ids) { + return otherShipmentsService.deleteBatchOtherShipments(ids); + } + + @PutMapping("updateStatusByIds") + public Response updateOtherShipmentsStatusByIds(@RequestParam("ids") List ids, @RequestParam("status") Integer status) { + return otherShipmentsService.updateOtherShipmentsStatus(ids, status); + } +} diff --git a/core/domain/src/main/java/com/wansenai/vo/warehouse/AllotReceiptDetailVO.java b/core/domain/src/main/java/com/wansenai/vo/warehouse/AllotReceiptDetailVO.java index 798edd5e..1f0b2efe 100644 --- a/core/domain/src/main/java/com/wansenai/vo/warehouse/AllotReceiptDetailVO.java +++ b/core/domain/src/main/java/com/wansenai/vo/warehouse/AllotReceiptDetailVO.java @@ -12,20 +12,26 @@ */ package com.wansenai.vo.warehouse; +import com.fasterxml.jackson.annotation.JsonFormat; import com.wansenai.bo.AllotStockBO; import com.wansenai.bo.FileDataBO; import lombok.Builder; import lombok.Data; +import java.time.LocalDateTime; import java.util.List; @Data @Builder public class AllotReceiptDetailVO { + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + private String receiptNumber; - private String receiptDate; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private LocalDateTime receiptDate; private String remark; diff --git a/core/domain/src/main/java/com/wansenai/vo/warehouse/AssembleReceiptDetailVO.java b/core/domain/src/main/java/com/wansenai/vo/warehouse/AssembleReceiptDetailVO.java index a9a1e47f..1bfb81b3 100644 --- a/core/domain/src/main/java/com/wansenai/vo/warehouse/AssembleReceiptDetailVO.java +++ b/core/domain/src/main/java/com/wansenai/vo/warehouse/AssembleReceiptDetailVO.java @@ -12,20 +12,26 @@ */ package com.wansenai.vo.warehouse; +import com.fasterxml.jackson.annotation.JsonFormat; import com.wansenai.bo.AssembleStockBO; import com.wansenai.bo.FileDataBO; import lombok.Builder; import lombok.Data; +import java.time.LocalDateTime; import java.util.List; @Data @Builder public class AssembleReceiptDetailVO { + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + private String receiptNumber; - private String receiptDate; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private LocalDateTime receiptDate; private String remark; diff --git a/core/domain/src/main/java/com/wansenai/vo/warehouse/DisassembleReceiptDetailVO.java b/core/domain/src/main/java/com/wansenai/vo/warehouse/DisassembleReceiptDetailVO.java index ff9b77e4..e60d781b 100644 --- a/core/domain/src/main/java/com/wansenai/vo/warehouse/DisassembleReceiptDetailVO.java +++ b/core/domain/src/main/java/com/wansenai/vo/warehouse/DisassembleReceiptDetailVO.java @@ -12,20 +12,26 @@ */ package com.wansenai.vo.warehouse; +import com.fasterxml.jackson.annotation.JsonFormat; import com.wansenai.bo.AssembleStockBO; import com.wansenai.bo.FileDataBO; import lombok.Builder; import lombok.Data; +import java.time.LocalDateTime; import java.util.List; @Data @Builder public class DisassembleReceiptDetailVO { + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + private String receiptNumber; - private String receiptDate; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private LocalDateTime receiptDate; private String remark; diff --git a/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherShipmentDetailVO.java b/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherShipmentDetailVO.java index 6f133102..6f0c1db4 100644 --- a/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherShipmentDetailVO.java +++ b/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherShipmentDetailVO.java @@ -18,12 +18,16 @@ import lombok.Builder; import lombok.Data; +import java.time.LocalDateTime; import java.util.List; @Data @Builder public class OtherShipmentDetailVO { + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + @JsonFormat(shape = JsonFormat.Shape.STRING) private Long customerId; @@ -31,7 +35,8 @@ public class OtherShipmentDetailVO { private String receiptNumber; - private String receiptDate; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private LocalDateTime receiptDate; private String remark; diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherShipmentsServiceImpl.java b/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherShipmentsServiceImpl.java index 5ea9c256..aaee3db8 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherShipmentsServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherShipmentsServiceImpl.java @@ -12,45 +12,375 @@ */ package com.wansenai.service.warehouse.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wansenai.bo.FileDataBO; +import com.wansenai.bo.StorageShipmentStockBO; import com.wansenai.dto.warehouse.OtherShipmentDTO; import com.wansenai.dto.warehouse.QueryOtherShipmentDTO; +import com.wansenai.entities.product.ProductStock; +import com.wansenai.entities.system.SysFile; +import com.wansenai.entities.user.SysUser; import com.wansenai.entities.warehouse.WarehouseReceiptMain; +import com.wansenai.entities.warehouse.WarehouseReceiptSub; +import com.wansenai.mappers.product.ProductStockMapper; +import com.wansenai.mappers.system.SysFileMapper; import com.wansenai.mappers.warehouse.WarehouseReceiptMainMapper; +import com.wansenai.service.common.CommonService; +import com.wansenai.service.product.ProductService; +import com.wansenai.service.user.ISysUserService; import com.wansenai.service.warehouse.OtherShipmentsService; +import com.wansenai.service.warehouse.WarehouseReceiptSubService; +import com.wansenai.utils.SnowflakeIdUtil; +import com.wansenai.utils.TimeUtil; +import com.wansenai.utils.constants.CommonConstants; +import com.wansenai.utils.enums.BaseCodeEnum; +import com.wansenai.utils.enums.OtherShipmentCodeEnum; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.OtherShipmentDetailVO; import com.wansenai.vo.warehouse.OtherShipmentVO; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; @Service public class OtherShipmentsServiceImpl extends ServiceImpl implements OtherShipmentsService { + private final WarehouseReceiptSubService warehouseReceiptSubService; + private final ProductService productService; + private final CommonService commonService; + private final ISysUserService userService; + private final SysFileMapper fileMapper; + private final ProductStockMapper productStockMapper; + + public OtherShipmentsServiceImpl(WarehouseReceiptSubService warehouseReceiptSubService, ProductService productService, CommonService commonService, ISysUserService userService, SysFileMapper fileMapper, ProductStockMapper productStockMapper) { + this.warehouseReceiptSubService = warehouseReceiptSubService; + this.productService = productService; + this.commonService = commonService; + this.userService = userService; + this.fileMapper = fileMapper; + this.productStockMapper = productStockMapper; + } + + private ArrayList processFiles(List files, Long retailId) { + var userId = userService.getCurrentUserId(); + var fid = new ArrayList(); + if (!files.isEmpty()) { + var receiptMain = getById(retailId); + if (receiptMain != null && StringUtils.hasLength(receiptMain.getFileId())) { + var ids = Arrays.stream(receiptMain.getFileId().split(",")) + .map(Long::parseLong) + .collect(Collectors.toList()); + fileMapper.deleteBatchIds(ids); + } + files.forEach(item -> { + var file = SysFile.builder() + .id(SnowflakeIdUtil.nextId()) + .uid(item.getUid()) + .fileName(item.getFileName()) + .fileType(item.getFileType()) + .fileSize(item.getFileSize()) + .fileUrl(item.getFileUrl()) + .createBy(userId) + .createTime(LocalDateTime.now()) + .build(); + fileMapper.insert(file); + fid.add(file.getId()); + }); + } + return fid; + } + + private void updateProductStock(List receiptSubList, int stockType) { + var stockMap = new ConcurrentHashMap(); + + receiptSubList.forEach(item -> { + var stock = productStockMapper.getProductSkuByBarCode(item.getProductBarcode(), item.getWarehouseId()); + if (stock != null) { + var stockNumber = stock.getStock(); + var productNumber = item.getProductNumber(); + if (stockType == 1) { + stockNumber += productNumber; + } else if (stockType == 2) { + stockNumber -= productNumber; + } + stockMap.put(stock.getId(), stockNumber); + } + }); + receiptSubList.forEach(item2 -> { + stockMap.forEach((key, value) -> { + var stock = ProductStock.builder() + .productSkuId(key) + .warehouseId(item2.getWarehouseId()) + .currentStockQuantity(BigDecimal.valueOf(value)) + .build(); + var wrapper = new LambdaUpdateWrapper() + .eq(ProductStock::getProductSkuId, stock.getProductSkuId()) + .eq(ProductStock::getWarehouseId, stock.getWarehouseId()) + .set(ProductStock::getCurrentStockQuantity, BigDecimal.valueOf(value)); + productStockMapper.update(stock, wrapper); + }); + }); + } + @Override public Response> getOtherShipmentsPageList(QueryOtherShipmentDTO queryOtherShipmentDTO) { - return null; + var result = new Page(); + var page = new Page(queryOtherShipmentDTO.getPage(), queryOtherShipmentDTO.getPageSize()); + + var wrapperMainMapper = lambdaQuery() + .eq(queryOtherShipmentDTO.getCustomerId() != null, WarehouseReceiptMain::getRelatedPersonId, queryOtherShipmentDTO.getCustomerId()) + .eq(queryOtherShipmentDTO.getOperatorId() != null, WarehouseReceiptMain::getCreateBy, queryOtherShipmentDTO.getOperatorId()) + .eq(queryOtherShipmentDTO.getStatus() != null, WarehouseReceiptMain::getStatus, queryOtherShipmentDTO.getStatus()) + .eq(StringUtils.hasLength(queryOtherShipmentDTO.getReceiptNumber()), WarehouseReceiptMain::getReceiptNumber, queryOtherShipmentDTO.getReceiptNumber()) + .eq(StringUtils.hasLength(queryOtherShipmentDTO.getOtherReceipt()), WarehouseReceiptMain::getReceiptNumber, queryOtherShipmentDTO.getOtherReceipt()) + .like(StringUtils.hasLength(queryOtherShipmentDTO.getRemark()), WarehouseReceiptMain::getRemark, queryOtherShipmentDTO.getRemark()) + .ge(StringUtils.hasLength(queryOtherShipmentDTO.getStartDate()), WarehouseReceiptMain::getCreateTime, queryOtherShipmentDTO.getStartDate()) + .le(StringUtils.hasLength(queryOtherShipmentDTO.getEndDate()), WarehouseReceiptMain::getCreateTime, queryOtherShipmentDTO.getEndDate()) + .eq(WarehouseReceiptMain::getType, "其他出库") + .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) + .page(page); + + var otherShipmentVOList = new ArrayList(wrapperMainMapper.getRecords().size() + 1); + wrapperMainMapper.getRecords().forEach(item -> { + + var product = productService.getById(item.getProductId()); + var productInfo = ""; + if(product != null) { + productInfo = product.getProductName() + "|" + product.getProductStandard() + "|" + product.getProductModel() + "|" + product.getProductUnit(); + } + + var operator = userService.getById(item.getCreateBy()); + var otherShipmentVO = OtherShipmentVO.builder() + .id(item.getId()) + .receiptNumber(item.getReceiptNumber()) + .productInfo(productInfo) + .customerName(commonService.getCustomerName(item.getRelatedPersonId())) + .receiptDate(item.getReceiptDate()) + .operator(Optional.ofNullable(operator).map(SysUser::getName).orElse("")) + .productNumber(item.getTotalProductNumber()) + .totalAmount(item.getTotalAmount()) + .status(item.getStatus()) + .build(); + + otherShipmentVOList.add(otherShipmentVO); + }); + result.setRecords(otherShipmentVOList); + result.setTotal(wrapperMainMapper.getTotal()); + return Response.responseData(result); } @Override public Response getOtherShipmentsDetail(Long id) { - return null; + if (id == null) { + return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL); + } + var receiptMain = lambdaQuery() + .eq(WarehouseReceiptMain::getId, id) + .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) + .one(); + + if (receiptMain != null) { + var otherShipmentDetailVO = OtherShipmentDetailVO.builder() + .id(receiptMain.getId()) + .customerId(receiptMain.getRelatedPersonId()) + .customerName(commonService.getCustomerName(receiptMain.getRelatedPersonId())) + .receiptNumber(receiptMain.getReceiptNumber()) + .receiptDate(receiptMain.getReceiptDate()) + .remark(receiptMain.getRemark()) + .status(receiptMain.getStatus()) + .build(); + var warehouseSubs = warehouseReceiptSubService.lambdaQuery() + .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, id) + .eq(WarehouseReceiptSub::getDeleteFlag, CommonConstants.NOT_DELETED) + .list(); + if (!warehouseSubs.isEmpty()) { + var tableData = new ArrayList(warehouseSubs.size() + 1); + warehouseSubs.forEach(warehouseReceiptSub -> { + var product = productStockMapper.getProductSkuByBarCode(warehouseReceiptSub.getProductBarcode(), warehouseReceiptSub.getWarehouseId()); + + var storageShipmentStockBO = StorageShipmentStockBO.builder() + .id(warehouseReceiptSub.getId()) + .warehouseId(warehouseReceiptSub.getWarehouseId()) + .warehouseName(commonService.getWarehouseName(warehouseReceiptSub.getWarehouseId())) + .barCode(warehouseReceiptSub.getProductBarcode()) + .productId(warehouseReceiptSub.getProductId()) + .productName(product.getProductName()) + .productUnit(product.getProductUnit()) + .productStandard(product.getProductStandard()) + .productModel(product.getProductModel()) + .productExtendInfo(product.getExtendInfo()) + .stock(product.getStock()) + .unitPrice(warehouseReceiptSub.getUnitPrice()) + .amount(warehouseReceiptSub.getTotalAmount()) + .productNumber(warehouseReceiptSub.getProductNumber()) + .remark(warehouseReceiptSub.getRemark()) + .build(); + tableData.add(storageShipmentStockBO); + }); + otherShipmentDetailVO.setTableData(tableData); + } + var fileList = commonService.getFileList(receiptMain.getFileId()); + otherShipmentDetailVO.setFiles(fileList); + return Response.responseData(otherShipmentDetailVO); + } + return Response.responseMsg(BaseCodeEnum.QUERY_DATA_EMPTY); } @Override public Response addOrUpdateOtherShipments(OtherShipmentDTO otherShipmentsDTO) { - return null; + var userId = userService.getCurrentUserId(); + var fid = processFiles(otherShipmentsDTO.getFiles(), otherShipmentsDTO.getId()); + var fileIds = StringUtils.collectionToCommaDelimitedString(fid); + var isUpdate = otherShipmentsDTO.getId() != null; + + var totalProductNumber = 0; + var totalAmount = BigDecimal.ZERO; + + if(!otherShipmentsDTO.getTableData().isEmpty()) { + for (StorageShipmentStockBO stockBO : otherShipmentsDTO.getTableData()) { + totalProductNumber += stockBO.getProductNumber(); + totalAmount = totalAmount.add(stockBO.getAmount()); + } + } + + if (isUpdate) { + var beforeReceipt = warehouseReceiptSubService.lambdaQuery() + .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, otherShipmentsDTO.getId()) + .list(); + if (!beforeReceipt.isEmpty()) { + updateProductStock(beforeReceipt, 1); + } + + var warehouseReceiptMain = lambdaUpdate() + .eq(WarehouseReceiptMain::getId, otherShipmentsDTO.getId()) + .set(otherShipmentsDTO.getCustomerId() != null, WarehouseReceiptMain::getRelatedPersonId, otherShipmentsDTO.getCustomerId()) + .set(otherShipmentsDTO.getStatus() != null, WarehouseReceiptMain::getStatus, otherShipmentsDTO.getStatus()) + .set(WarehouseReceiptMain::getTotalProductNumber, totalProductNumber) + .set(WarehouseReceiptMain::getTotalAmount, totalAmount) + .set(StringUtils.hasLength(otherShipmentsDTO.getReceiptDate()), WarehouseReceiptMain::getReceiptDate, otherShipmentsDTO.getReceiptDate()) + .set(StringUtils.hasLength(otherShipmentsDTO.getRemark()), WarehouseReceiptMain::getRemark, otherShipmentsDTO.getRemark()) + .set(StringUtils.hasLength(fileIds), WarehouseReceiptMain::getFileId, fileIds) + .set(WarehouseReceiptMain::getUpdateBy, userId) + .set(WarehouseReceiptMain::getUpdateTime, LocalDateTime.now()) + .update(); + + warehouseReceiptSubService.lambdaUpdate() + .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, otherShipmentsDTO.getId()) + .remove(); + + var shipmentStockList = otherShipmentsDTO.getTableData(); + var shipmentStock = shipmentStockList.stream() + .map(item -> WarehouseReceiptSub.builder() + .id(SnowflakeIdUtil.nextId()) + .warehouseReceiptMainId(otherShipmentsDTO.getId()) + .productId(item.getProductId()) + .warehouseId(item.getWarehouseId()) + .productBarcode(item.getBarCode()) + .productNumber(item.getProductNumber()) + .unitPrice(item.getUnitPrice()) + .totalAmount(item.getAmount()) + .remark(item.getRemark()) + .createBy(userId) + .createTime(LocalDateTime.now()) + .build()) + .collect(Collectors.toList()); + + var updateSubResult = warehouseReceiptSubService.saveBatch(shipmentStock); + updateProductStock(shipmentStock, 2); + + if (updateSubResult && warehouseReceiptMain) { + return Response.responseMsg(OtherShipmentCodeEnum.UPDATE_OTHER_SHIPMENT_STOCK_SUCCESS); + } + return Response.responseMsg(OtherShipmentCodeEnum.UPDATE_OTHER_SHIPMENT_STOCK_ERROR); + + } else { + var receiptMainId = SnowflakeIdUtil.nextId(); + var shipmentStockList = otherShipmentsDTO.getTableData(); + var shipmentStock = shipmentStockList.stream() + .map(item -> WarehouseReceiptSub.builder() + .id(SnowflakeIdUtil.nextId()) + .warehouseReceiptMainId(receiptMainId) + .productId(item.getProductId()) + .warehouseId(item.getWarehouseId()) + .productBarcode(item.getBarCode()) + .productNumber(item.getProductNumber()) + .unitPrice(item.getUnitPrice()) + .totalAmount(item.getAmount()) + .remark(item.getRemark()) + .createBy(userId) + .createTime(LocalDateTime.now()) + .build()) + .collect(Collectors.toList()); + var saveSubResult = warehouseReceiptSubService.saveBatch(shipmentStock); + + var warehouseReceiptMain = WarehouseReceiptMain.builder() + .id(receiptMainId) + .relatedPersonId(otherShipmentsDTO.getCustomerId()) + .productId(otherShipmentsDTO.getTableData().get(0).getProductId()) + .receiptNumber(otherShipmentsDTO.getReceiptNumber()) + .type("其他出库") + .initReceiptNumber(otherShipmentsDTO.getReceiptNumber()) + .receiptDate(TimeUtil.parse(otherShipmentsDTO.getReceiptDate())) + .totalAmount(totalAmount) + .totalProductNumber(totalProductNumber) + .remark(otherShipmentsDTO.getRemark()) + .fileId(fileIds) + .source(0) + .createBy(userId) + .createTime(LocalDateTime.now()) + .build(); + var saveMainResult = save(warehouseReceiptMain); + updateProductStock(shipmentStock, 2); + if (saveSubResult && saveMainResult) { + return Response.responseMsg(OtherShipmentCodeEnum.ADD_OTHER_SHIPMENT_STOCK_SUCCESS); + } + return Response.responseMsg(OtherShipmentCodeEnum.ADD_OTHER_SHIPMENT_STOCK_ERROR); + } } @Override public Response deleteBatchOtherShipments(List ids) { - return null; + if (ids == null || ids.isEmpty()) { + return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL); + } + var deleteResult = lambdaUpdate() + .set(WarehouseReceiptMain::getDeleteFlag, CommonConstants.DELETED) + .in(WarehouseReceiptMain::getId, ids) + .update(); + + warehouseReceiptSubService.lambdaUpdate() + .set(WarehouseReceiptSub::getDeleteFlag, CommonConstants.DELETED) + .in(WarehouseReceiptSub::getWarehouseReceiptMainId, ids) + .update(); + + if(!deleteResult) { + return Response.responseMsg(OtherShipmentCodeEnum.DELETE_OTHER_SHIPMENT_STOCK_ERROR); + } + return Response.responseMsg(OtherShipmentCodeEnum.DELETE_OTHER_SHIPMENT_STOCK_SUCCESS); } @Override public Response updateOtherShipmentsStatus(List ids, Integer status) { - return null; + if (ids == null || ids.isEmpty()) { + return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL); + } + var updateResult = lambdaUpdate() + .set(WarehouseReceiptMain::getStatus, status) + .in(WarehouseReceiptMain::getId, ids) + .update(); + if(!updateResult) { + return Response.responseMsg(OtherShipmentCodeEnum.UPDATE_OTHER_SHIPMENT_STOCK_ERROR); + } + return Response.responseMsg(OtherShipmentCodeEnum.UPDATE_OTHER_SHIPMENT_STOCK_SUCCESS); } } diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherStorageServiceImpl.java b/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherStorageServiceImpl.java index d1196a8e..490134eb 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherStorageServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/impl/OtherStorageServiceImpl.java @@ -147,6 +147,7 @@ public Response> getOtherStoragePageList(QueryOtherStorageD .like(StringUtils.hasLength(queryOtherStorageDTO.getRemark()), WarehouseReceiptMain::getRemark, queryOtherStorageDTO.getRemark()) .ge(StringUtils.hasLength(queryOtherStorageDTO.getStartDate()), WarehouseReceiptMain::getCreateTime, queryOtherStorageDTO.getStartDate()) .le(StringUtils.hasLength(queryOtherStorageDTO.getEndDate()), WarehouseReceiptMain::getCreateTime, queryOtherStorageDTO.getEndDate()) + .eq(WarehouseReceiptMain::getType, "其他入库") .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) .page(page); @@ -183,7 +184,11 @@ public Response getOtherStorageDetail(Long id) { if (id == null) { return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL); } - var receiptMain = getById(id); + var receiptMain = lambdaQuery() + .eq(WarehouseReceiptMain::getId, id) + .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) + .one(); + if (receiptMain != null) { var otherStorageDetailVO = OtherStorageDetailVO.builder() .id(receiptMain.getId()) @@ -238,6 +243,16 @@ public Response addOrUpdateOtherStorage(OtherStorageDTO otherStorageDTO) var fileIds = StringUtils.collectionToCommaDelimitedString(fid); var isUpdate = otherStorageDTO.getId() != null; + var totalProductNumber = 0; + var totalAmount = BigDecimal.ZERO; + + if(!otherStorageDTO.getTableData().isEmpty()) { + for (StorageShipmentStockBO stockBO : otherStorageDTO.getTableData()) { + totalProductNumber += stockBO.getProductNumber(); + totalAmount = totalAmount.add(stockBO.getAmount()); + } + } + if (isUpdate) { var beforeReceipt = warehouseReceiptSubService.lambdaQuery() .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, otherStorageDTO.getId()) @@ -250,7 +265,8 @@ public Response addOrUpdateOtherStorage(OtherStorageDTO otherStorageDTO) .eq(WarehouseReceiptMain::getId, otherStorageDTO.getId()) .set(otherStorageDTO.getSupplierId() != null, WarehouseReceiptMain::getRelatedPersonId, otherStorageDTO.getSupplierId()) .set(otherStorageDTO.getStatus() != null, WarehouseReceiptMain::getStatus, otherStorageDTO.getStatus()) - .set(WarehouseReceiptMain::getReceiptNumber, otherStorageDTO.getReceiptNumber()) + .set(WarehouseReceiptMain::getTotalProductNumber, totalProductNumber) + .set(WarehouseReceiptMain::getTotalAmount, totalAmount) .set(StringUtils.hasLength(otherStorageDTO.getReceiptDate()), WarehouseReceiptMain::getReceiptDate, otherStorageDTO.getReceiptDate()) .set(StringUtils.hasLength(otherStorageDTO.getRemark()), WarehouseReceiptMain::getRemark, otherStorageDTO.getRemark()) .set(StringUtils.hasLength(fileIds), WarehouseReceiptMain::getFileId, fileIds) @@ -307,20 +323,12 @@ public Response addOrUpdateOtherStorage(OtherStorageDTO otherStorageDTO) .collect(Collectors.toList()); var saveSubResult = warehouseReceiptSubService.saveBatch(storageShipmentStock); - var totalProductNumber = 0; - var totalAmount = BigDecimal.ZERO; - - for (WarehouseReceiptSub warehouseReceiptSub : storageShipmentStock) { - totalProductNumber += warehouseReceiptSub.getProductNumber(); - totalAmount = totalAmount.add(warehouseReceiptSub.getTotalAmount()); - } - var warehouseReceiptMain = WarehouseReceiptMain.builder() .id(receiptMainId) .relatedPersonId(otherStorageDTO.getSupplierId()) .productId(otherStorageDTO.getTableData().get(0).getProductId()) .receiptNumber(otherStorageDTO.getReceiptNumber()) - .type("入库") + .type("其他入库") .initReceiptNumber(otherStorageDTO.getReceiptNumber()) .receiptDate(TimeUtil.parse(otherStorageDTO.getReceiptDate())) .totalAmount(totalAmount) diff --git a/web/src/api/warehouse/model/shipmentsModel.ts b/web/src/api/warehouse/model/shipmentsModel.ts new file mode 100644 index 00000000..a4e0eb51 --- /dev/null +++ b/web/src/api/warehouse/model/shipmentsModel.ts @@ -0,0 +1,64 @@ +import {FileData} from "@/api/financial/model/advanceModel"; + +export interface OtherShipmentsData { + id: number | string; + customerId: number | string; + warehouseName: string; + barCode: string; + productId: number | string; + productName: string; + productModel: string; + productUnit: string; + productStandard: string; + stock: number; + productNumber: number; + unitPrice: number; + amount: number; + remark: string; +} + +export interface AddOrUpdateOtherShipmentsReq { + id: number | undefined; + customerId: number; + receiptNumber: string; + receiptDate: string; + remark: string; + status: number; + files: FileData[]; + tableData: OtherShipmentsData[]; +} + +export interface QueryOtherShipmentsReq { + receiptNumber: string; + productInfo: string; + customerId: number; + warehouseId: number; + operatorId: number; + otherReceipt: string; + status: number; + remark: string; +} + +export interface OtherShipmentsResp { + id: string | undefined; + customerName: string; + receiptNumber: string; + productInfo: string; + receiptDate: string; + operator: string; + productNumber: number; + totalAmount: number; + status: number; +} + +export interface OtherShipmentsDetailResp { + id: string | undefined; + customerId: string; + customerName: string; + receiptNumber: string; + receiptDate: string; + remark: string; + status: number; + files: FileData[]; + tableData: OtherShipmentsData[]; +} \ No newline at end of file diff --git a/web/src/api/warehouse/shipments.ts b/web/src/api/warehouse/shipments.ts new file mode 100644 index 00000000..95825341 --- /dev/null +++ b/web/src/api/warehouse/shipments.ts @@ -0,0 +1,63 @@ +import {defHttp} from '/@/utils/http/axios'; +import { ErrorMessageMode } from '/#/axios'; +import {BaseDataResp, BaseResp} from "@/api/model/baseModel"; +import { + AddOrUpdateOtherShipmentsReq, + QueryOtherShipmentsReq, + OtherShipmentsResp, + OtherShipmentsDetailResp, +} from "@/api/warehouse/model/shipmentsModel"; + +enum API { + PageList = '/warehouse/otherShipments/pageList', + AddOrUpdateAccount = '/warehouse/otherShipments/addOrUpdate', + DeleteBatch = '/warehouse/otherShipments/deleteByIds', + UpdateStatus = '/warehouse/otherShipments/updateStatusByIds', + GetDetail = '/warehouse/otherShipments/getDetailById', +} + +export function getOtherShipmentsPageList(params: QueryOtherShipmentsReq, mode: ErrorMessageMode = 'notice') { + return defHttp.post>( + { + url: API.PageList, + params, + }, + { + errorMessageMode: mode, + successMessageMode: mode, + }, + ); +} + +export function addOrUpdateOtherShipments(params: AddOrUpdateOtherShipmentsReq) { + return defHttp.post( + { + url: API.AddOrUpdateAccount, + params, + }, + ); +} + +export function updateOtherShipmentsStatus(ids: number[], status: number) { + return defHttp.put( + { + url: `${API.UpdateStatus}?ids=${ids}&status=${status}` + }, + ); +} + +export function deleteBatchOtherShipments(ids: number[]) { + return defHttp.put( + { + url: `${API.DeleteBatch}?ids=${ids}` + }, + ); +} + +export function getOtherShipmentsDetailById(id: number) { + return defHttp.get>( + { + url: `${API.GetDetail}/${id}` + }, + ); +} \ No newline at end of file diff --git a/web/src/views/warehouse/storage/addEditOtherStorage.data.ts b/web/src/views/warehouse/addEditStorageShipment.data.ts similarity index 91% rename from web/src/views/warehouse/storage/addEditOtherStorage.data.ts rename to web/src/views/warehouse/addEditStorageShipment.data.ts index 33cec846..35a3e32f 100644 --- a/web/src/views/warehouse/storage/addEditOtherStorage.data.ts +++ b/web/src/views/warehouse/addEditStorageShipment.data.ts @@ -29,6 +29,15 @@ interface OtherStorageFormState { remark: string; } +interface OtherShipmentFormState { + id: number | string | undefined; + warehouseId: number | string; + customerId: number | string | undefined; + receiptDate: string | undefined | Dayjs; + receiptNumber: string |undefined; + remark: string; +} + const xGrid = ref>() const tableData = ref([]) const gridOptions = reactive>({ @@ -165,10 +174,20 @@ const otherStorageFormState = reactive({ remark: '', }); +const otherShipmentFormState = reactive({ + id: undefined, + warehouseId: '', + customerId: '', + receiptDate: '', + receiptNumber: '', + remark: '', +}); + export { xGrid, sumNum, tableData, gridOptions, otherStorageFormState, + otherShipmentFormState } \ No newline at end of file diff --git a/web/src/views/warehouse/shipments/components/AddEditOtherShipmentsModal.vue b/web/src/views/warehouse/shipments/components/AddEditOtherShipmentsModal.vue new file mode 100644 index 00000000..3e833084 --- /dev/null +++ b/web/src/views/warehouse/shipments/components/AddEditOtherShipmentsModal.vue @@ -0,0 +1,637 @@ + + + + + \ No newline at end of file diff --git a/web/src/views/warehouse/shipments/components/ViewOtherShipmentsModal.vue b/web/src/views/warehouse/shipments/components/ViewOtherShipmentsModal.vue new file mode 100644 index 00000000..4115911a --- /dev/null +++ b/web/src/views/warehouse/shipments/components/ViewOtherShipmentsModal.vue @@ -0,0 +1,128 @@ + + + diff --git a/web/src/views/warehouse/shipments/index.vue b/web/src/views/warehouse/shipments/index.vue new file mode 100644 index 00000000..21d18a4c --- /dev/null +++ b/web/src/views/warehouse/shipments/index.vue @@ -0,0 +1,201 @@ + +
+
+ + \ No newline at end of file diff --git a/web/src/views/warehouse/shipments/otherShipments.data.ts b/web/src/views/warehouse/shipments/otherShipments.data.ts new file mode 100644 index 00000000..66f333f7 --- /dev/null +++ b/web/src/views/warehouse/shipments/otherShipments.data.ts @@ -0,0 +1,186 @@ +import {FormSchema} from "@/components/Form"; +import {BasicColumn} from "@/components/Table"; +import {getCustomerList} from "@/api/basic/customer"; +import {getUserOperatorList} from "@/api/sys/user"; + +export const columns: BasicColumn[] = [ + { + title: '客户', + dataIndex: 'customerName', + width: 170, + }, + { + title: '单据编号', + dataIndex: 'receiptNumber', + width: 130, + }, + { + title: '商品信息', + dataIndex: 'productInfo', + width: 150, + }, + { + title: '单据日期', + dataIndex: 'receiptDate', + width: 130, + }, + { + title: '数量', + dataIndex: 'productNumber', + width: 100, + }, + { + title: '金额合计', + dataIndex: 'totalAmount', + width: 70, + }, + { + title: '操作员', + dataIndex: 'operator', + width: 70, + }, + { + title: '状态', + dataIndex: 'status', + width: 70, + }, +] + +export const searchFormSchema: FormSchema[] = [ + { + label: '单据编号', + field: 'receiptNumber', + component: 'Input', + colProps: { + xl: 8, + xxl: 8, + }, + }, + { + field: '[startDate, endDate]', + label: '单据日期', + component: 'RangePicker', + componentProps: { + format: 'YYYY/MM/DD', + placeholder: ['开始日期', '结束日期'], + }, + colProps: { span: 7 }, + }, + { + label: '客户', + field: 'customerId', + component: 'ApiSelect', + componentProps: { + api: getCustomerList, + resultField: 'data', + labelField: 'customerName', + valueField: 'id', + }, + colProps: { + xl: 8, + xxl: 8, + }, + }, + { + label: '操作员', + field: 'operatorId', + component: 'ApiSelect', + componentProps: { + api: getUserOperatorList, + resultField: 'data', + labelField: 'name', + valueField: 'id', + }, + colProps: { + xl: 8, + xxl: 8, + }, + }, + { + label: '单据状态', + field: 'status', + component: 'Select', + colProps: { + xl: 8, + xxl: 8, + }, + componentProps: { + options: [ + { label: '未审核', value: 0, key: 0 }, + { label: '已审核', value: 1, key: 1 }, + ], + }, + }, + { + label: '单据备注', + field: 'remark', + component: 'Input', + colProps: { + xl: 8, + xxl: 8, + }, + } +] + +export const otherShipmentTableColumns: BasicColumn[] = [ + { + title: '仓库', + dataIndex: 'warehouseName', + width: 100, + }, + { + title: '条码', + dataIndex: 'barCode', + width: 120, + }, + { + title: '商品名称', + dataIndex: 'productName', + width: 150, + }, + { + title: '单位', + dataIndex: 'productUnit', + width: 70, + }, + { + title: '商品规格', + dataIndex: 'productStandard', + width: 130, + }, + { + title: '商品型号', + dataIndex: 'productModel', + width: 130, + }, + { + title: '扩展信息', + dataIndex: 'productExtendInfo', + width: 150, + }, + { + title: '库存', + dataIndex: 'stock', + width: 70, + }, + { + title: '数量', + dataIndex: 'productNumber', + width: 70, + }, + { + title: '单价', + dataIndex: 'unitPrice', + width: 70, + }, + { + title: '金额', + dataIndex: 'amount', + width: 70, + }, + { + title: '备注', + dataIndex: 'remark', + width: 130, + }, +] \ No newline at end of file diff --git a/web/src/views/warehouse/storage/components/AddEditOtherStorageModal.vue b/web/src/views/warehouse/storage/components/AddEditOtherStorageModal.vue index 9449473a..fdbf4479 100644 --- a/web/src/views/warehouse/storage/components/AddEditOtherStorageModal.vue +++ b/web/src/views/warehouse/storage/components/AddEditOtherStorageModal.vue @@ -154,7 +154,7 @@ import { xGrid, tableData, gridOptions, -} from '/@/views/warehouse/storage/addEditOtherStorage.data'; +} from '/src/views/warehouse/addEditStorageShipment.data'; import {useModal} from "@/components/Modal"; import {generateId, uploadOss} from "@/api/basic/common"; import {VXETable, VxeGrid, VxeInput, VxeButton, VxeSelect, VxeOption} from 'vxe-table' diff --git a/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue b/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue index a69f2c77..3bc55c09 100644 --- a/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue +++ b/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue @@ -2,7 +2,7 @@