From 1d4df2e294ea4dabc5d588cb28f4940eafa43c15 Mon Sep 17 00:00:00 2001 From: jameszow Date: Sat, 25 Nov 2023 15:43:18 +0800 Subject: [PATCH 1/7] moved: Top level file, as it is a common processing function --- ...data.ts => addEditStorageShipment.data.ts} | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) rename web/src/views/warehouse/{storage/addEditOtherStorage.data.ts => addEditStorageShipment.data.ts} (91%) 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 From 055f1b54faf618e8525c15311817a7cfb2b642c1 Mon Sep 17 00:00:00 2001 From: jameszow Date: Sat, 25 Nov 2023 15:44:03 +0800 Subject: [PATCH 2/7] fix: fix bug page list total data incorrect and update type --- .../impl/OtherStorageServiceImpl.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) 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) From dde3299d4021d0307507910adec6ff18ccff6002 Mon Sep 17 00:00:00 2001 From: jameszow Date: Sat, 25 Nov 2023 15:44:25 +0800 Subject: [PATCH 3/7] fix: fix view object data type and add id --- .../com/wansenai/vo/warehouse/AllotReceiptDetailVO.java | 8 +++++++- .../wansenai/vo/warehouse/AssembleReceiptDetailVO.java | 8 +++++++- .../wansenai/vo/warehouse/DisassembleReceiptDetailVO.java | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) 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; From 5e6f24eb431988142ea1f4d9b3a750627a8bb7ab Mon Sep 17 00:00:00 2001 From: jameszow Date: Sat, 25 Nov 2023 15:44:51 +0800 Subject: [PATCH 4/7] new: add warehouse other shipments api --- .../warehouse/OtherShipmentsController.java | 67 ++++ .../vo/warehouse/OtherShipmentDetailVO.java | 7 +- .../impl/OtherShipmentsServiceImpl.java | 340 +++++++++++++++++- 3 files changed, 408 insertions(+), 6 deletions(-) create mode 100644 core/api/src/main/java/com/wansenai/api/warehouse/OtherShipmentsController.java 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/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); } } From 2dffcf6ceee36d6dc05bd0a59478c9306def4a8c Mon Sep 17 00:00:00 2001 From: jameszow Date: Sat, 25 Nov 2023 15:45:25 +0800 Subject: [PATCH 5/7] fetch: fix correct modal title --- .../warehouse/storage/components/AddEditOtherStorageModal.vue | 2 +- .../warehouse/storage/components/ViewOtherStorageModal.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 @@