diff --git a/core/api/src/main/java/com/wansenai/api/user/SysUserController.java b/core/api/src/main/java/com/wansenai/api/user/SysUserController.java index ab140a67..4ab8b60f 100644 --- a/core/api/src/main/java/com/wansenai/api/user/SysUserController.java +++ b/core/api/src/main/java/com/wansenai/api/user/SysUserController.java @@ -63,6 +63,11 @@ public Response updatePassword(@RequestBody UpdatePasswordDto updatePass return userService.updatePassword(updatePasswordDto); } + @GetMapping(value = "operator") + public Response> operator() { + return userService.operator(); + } + @GetMapping(value = "info") public Response info() { return userService.userInfo(); diff --git a/core/api/src/main/java/com/wansenai/api/warehouse/OtherStorageController.java b/core/api/src/main/java/com/wansenai/api/warehouse/OtherStorageController.java new file mode 100644 index 00000000..222e06f9 --- /dev/null +++ b/core/api/src/main/java/com/wansenai/api/warehouse/OtherStorageController.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.OtherStorageDTO; +import com.wansenai.dto.warehouse.QueryOtherStorageDTO; +import com.wansenai.service.warehouse.OtherStorageService; +import com.wansenai.utils.response.Response; +import com.wansenai.vo.warehouse.OtherStorageDetailVO; +import com.wansenai.vo.warehouse.OtherStorageVO; +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/otherStorage") +public class OtherStorageController { + + private final OtherStorageService otherStorageService; + + public OtherStorageController(OtherStorageService otherStorageService) { + this.otherStorageService = otherStorageService; + } + + @PostMapping("addOrUpdate") + public Response addOrUpdateOtherStorage(@RequestBody OtherStorageDTO otherStorageDTO) { + return otherStorageService.addOrUpdateOtherStorage(otherStorageDTO); + } + + @PostMapping("pageList") + public Response> getOtherStoragePageList(@RequestBody QueryOtherStorageDTO queryOtherStorageDTO) { + return otherStorageService.getOtherStoragePageList(queryOtherStorageDTO); + } + + @GetMapping("getDetailById/{id}") + public Response getOtherStorageDetailById(@PathVariable("id") Long id) { + return otherStorageService.getOtherStorageDetail(id); + } + + @PutMapping("deleteByIds") + public Response deleteOtherStorageByIds(@RequestParam("ids") List ids) { + return otherStorageService.deleteBatchOtherStorage(ids); + } + + @PutMapping("updateStatusByIds") + public Response updateOtherStorageStatusByIds(@RequestParam("ids") List ids, @RequestParam("status") Integer status) { + return otherStorageService.updateOtherStorageStatus(ids, status); + } +} diff --git a/core/api/src/main/java/com/wansenai/api/warehouse/WarehouseController.java b/core/api/src/main/java/com/wansenai/api/warehouse/WarehouseController.java index 907d93ef..82404416 100644 --- a/core/api/src/main/java/com/wansenai/api/warehouse/WarehouseController.java +++ b/core/api/src/main/java/com/wansenai/api/warehouse/WarehouseController.java @@ -57,7 +57,7 @@ public Response addOrUpdateWarehouse(@RequestBody AddOrUpdateWarehouseDT public Response deleteWarehouse(@RequestParam("ids") List ids) { return warehouseService.deleteBatch(ids); } - // + @PostMapping("updateStatus") public Response updateStatus(@RequestParam("ids") List ids, @RequestParam("status") Integer status) { return warehouseService.updateBatchStatus(ids, status); diff --git a/core/domain/src/main/java/com/wansenai/bo/StorageShipmentStockBO.java b/core/domain/src/main/java/com/wansenai/bo/StorageShipmentStockBO.java index 874c2cd4..e31595d3 100644 --- a/core/domain/src/main/java/com/wansenai/bo/StorageShipmentStockBO.java +++ b/core/domain/src/main/java/com/wansenai/bo/StorageShipmentStockBO.java @@ -39,12 +39,14 @@ public class StorageShipmentStockBO { private String productName; - private String productModel; - private String productUnit; private String productStandard; + private String productModel; + + private String productExtendInfo; + private Integer stock; private Integer productNumber; diff --git a/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptMain.java b/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptMain.java index e56edb4b..2a17ca61 100644 --- a/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptMain.java +++ b/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptMain.java @@ -16,6 +16,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.Builder; +import lombok.NoArgsConstructor; +import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -24,6 +27,9 @@ import java.time.LocalDateTime; @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("warehouse_receipt_main") @@ -48,6 +54,11 @@ public class WarehouseReceiptMain { */ private Long relatedPersonId; + /** + * 商品id + */ + private Long productId; + /** * 类型(入库/出库/调拨/组装/拆卸) */ @@ -78,10 +89,6 @@ public class WarehouseReceiptMain { */ private Integer totalProductNumber; - /** - * 商品数量 - */ - private String productInfo; /** * 备注 diff --git a/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptSub.java b/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptSub.java index 1707c2ad..3d96a012 100644 --- a/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptSub.java +++ b/core/domain/src/main/java/com/wansenai/entities/warehouse/WarehouseReceiptSub.java @@ -13,10 +13,12 @@ package com.wansenai.entities.warehouse; import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.OrderBy; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.Builder; +import lombok.NoArgsConstructor; +import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -25,6 +27,9 @@ import java.time.LocalDateTime; @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("warehouse_receipt_sub") diff --git a/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherStorageDetailVO.java b/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherStorageDetailVO.java index dc923d9d..dc571f07 100644 --- a/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherStorageDetailVO.java +++ b/core/domain/src/main/java/com/wansenai/vo/warehouse/OtherStorageDetailVO.java @@ -18,12 +18,16 @@ import lombok.Builder; import lombok.Data; +import java.time.LocalDateTime; import java.util.List; @Data @Builder public class OtherStorageDetailVO { + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + @JsonFormat(shape = JsonFormat.Shape.STRING) private Long supplierId; @@ -31,7 +35,8 @@ public class OtherStorageDetailVO { 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/common/CommonServiceImpl.java b/core/service/src/main/java/com/wansenai/service/common/CommonServiceImpl.java index f43d2fad..f66d5d7a 100644 --- a/core/service/src/main/java/com/wansenai/service/common/CommonServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/common/CommonServiceImpl.java @@ -702,11 +702,16 @@ public Response generateSnowflakeId(String type) { case "报损单" -> "BSD"; case "报溢单" -> "BZD"; case "调价单" -> "DJD"; + case "组装单" -> "ADD"; + case "拆卸单" -> "CXD"; case "零售出库" -> "LSCK"; case "零售退货" -> "LSTH"; case "销售出库" -> "XSCK"; case "销售退货" -> "XSTH"; case "采购入库" -> "CGRK"; + case "其他入库" -> "QTRK"; + case "其他出库" -> "QTCK"; + case "调拨出库" -> "DBCK"; case "采购退货" -> "CGTH"; case "收预付款" -> "ACD"; default -> ""; diff --git a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptPurchaseServiceImpl.java b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptPurchaseServiceImpl.java index 630e0ce7..899a749d 100644 --- a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptPurchaseServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptPurchaseServiceImpl.java @@ -721,9 +721,7 @@ public Response addOrUpdatePurchaseStorage(PurchaseStorageDTO purchaseSt .collect(Collectors.toList()); var updateSubResult = receiptPurchaseSubService.saveBatch(receiptPurchaseStorageList); - purchaseStorageDTO.getTableData().forEach(item -> { - updateProductStock(receiptPurchaseStorageList, 1); - }); + updateProductStock(receiptPurchaseStorageList, 1); var account = accountService.getById(purchaseStorageDTO.getAccountId()); if (account != null) { @@ -1025,9 +1023,8 @@ public Response addOrUpdatePurchaseRefund(PurchaseRefundDTO purchaseRefu .collect(Collectors.toList()); var updateSubResult = receiptPurchaseSubService.saveBatch(receiptPurchaseRefundList); - purchaseRefundDTO.getTableData().forEach(item -> { - updateProductStock(receiptPurchaseRefundList, 2); - }); + updateProductStock(receiptPurchaseRefundList, 2); + var account = accountService.getById(purchaseRefundDTO.getAccountId()); if (account != null) { var accountBalance = account.getCurrentAmount(); diff --git a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptRetailServiceImpl.java b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptRetailServiceImpl.java index 6557961a..601283eb 100644 --- a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptRetailServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptRetailServiceImpl.java @@ -383,9 +383,7 @@ public Response addOrUpdateRetailShipments(RetailShipmentsDTO shipmentsD .build()) .collect(Collectors.toList()); var updateSubResult = receiptRetailSubService.saveBatch(receiptList); - shipmentsDTO.getTableData().forEach(item -> { - updateProductStock(receiptList, 2); - }); + updateProductStock(receiptList, 2); var updateMainResult = lambdaUpdate() .eq(ReceiptRetailMain::getId, shipmentsDTO.getId()) @@ -655,9 +653,7 @@ public Response addOrUpdateRetailRefund(RetailRefundDTO refundDTO) { .collect(Collectors.toList()); var updateSubResult = receiptRetailSubService.saveBatch(receiptList); - refundDTO.getTableData().forEach(item -> { - updateProductStock(receiptList, 1); - }); + updateProductStock(receiptList, 1); // 更新余额 如果之前已经修改过那么就需要加上之前的金额 然后再减去现在的金额 如果之前没有修改过那么就直接加上现在的金额 因为这个是退货 所以是负数 var account = accountService.getById(refundDTO.getAccountId()); @@ -665,11 +661,9 @@ public Response addOrUpdateRetailRefund(RetailRefundDTO refundDTO) { var accountBalance = account.getCurrentAmount(); var changeAmount = refundDTO.getReceiptAmount(); var beforeChangeAmount = beforeReceipt.stream() - .map(item -> item.getTotalAmount()) + .map(ReceiptRetailSub::getTotalAmount) .reduce(BigDecimal.ZERO, BigDecimal::add); - if (beforeChangeAmount != null) { - accountBalance = accountBalance.add(beforeChangeAmount); - } + accountBalance = accountBalance.add(beforeChangeAmount); if (changeAmount != null) { accountBalance = accountBalance.subtract(changeAmount); } diff --git a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptSaleServiceImpl.java b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptSaleServiceImpl.java index db522e3d..e1e42067 100644 --- a/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptSaleServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptSaleServiceImpl.java @@ -722,9 +722,7 @@ public Response addOrUpdateSaleShipments(SaleShipmentsDTO shipmentsDTO) .collect(Collectors.toList()); var updateSubResult = receiptSaleSubService.saveBatch(receiptSaleList); - shipmentsDTO.getTableData().forEach(item -> { - updateProductStock(receiptSaleList, 2); - }); + updateProductStock(receiptSaleList, 2); var account = accountService.getById(shipmentsDTO.getAccountId()); if (account != null) { @@ -1027,20 +1025,16 @@ public Response addOrUpdateSaleRefund(SaleRefundDTO refundDTO) { .collect(Collectors.toList()); var updateSubResult = receiptSaleSubService.saveBatch(receiptSaleList); - refundDTO.getTableData().forEach(item -> { - updateProductStock(receiptSaleList, 1); - }); + updateProductStock(receiptSaleList, 1); var account = accountService.getById(refundDTO.getAccountId()); if (account != null) { var accountBalance = account.getCurrentAmount(); var thisRefundAmount = refundDTO.getThisRefundAmount(); var beforeChangeAmount = beforeReceipt.stream() - .map(item -> item.getTotalAmount()) + .map(ReceiptSaleSub::getTotalAmount) .reduce(BigDecimal.ZERO, BigDecimal::add); - if (beforeChangeAmount != null) { - accountBalance = accountBalance.add(beforeChangeAmount); - } + accountBalance = accountBalance.add(beforeChangeAmount); if (thisRefundAmount != null) { accountBalance = accountBalance.subtract(thisRefundAmount); } diff --git a/core/service/src/main/java/com/wansenai/service/user/ISysUserService.java b/core/service/src/main/java/com/wansenai/service/user/ISysUserService.java index 5cf262b3..03b61a63 100644 --- a/core/service/src/main/java/com/wansenai/service/user/ISysUserService.java +++ b/core/service/src/main/java/com/wansenai/service/user/ISysUserService.java @@ -63,4 +63,6 @@ public interface ISysUserService extends IService { Response deleteUser(List ids); Response resetPassword(Long id); + + Response> operator(); } diff --git a/core/service/src/main/java/com/wansenai/service/user/impl/SysUserServiceImpl.java b/core/service/src/main/java/com/wansenai/service/user/impl/SysUserServiceImpl.java index 0bb76c2d..7cfcb1bc 100644 --- a/core/service/src/main/java/com/wansenai/service/user/impl/SysUserServiceImpl.java +++ b/core/service/src/main/java/com/wansenai/service/user/impl/SysUserServiceImpl.java @@ -728,4 +728,24 @@ public Response resetPassword(Long id) { return Response.responseMsg(UserCodeEnum.USER_RESET_PASSWORD_SUCCESS); } + + @Override + public Response> operator() { + var user = lambdaQuery() + .eq(SysUser::getTenantId, getCurrentTenantId()) + .eq(SysUser::getStatus, UserConstants.USER_STATUS_ENABLE) + .eq(SysUser::getDeleteFlag, CommonConstants.NOT_DELETED) + .list(); + var result = new ArrayList(user.size() + 1); + for (SysUser sysUser : user) { + var userVO = UserInfoVO.builder() + .id(sysUser.getId()) + .name(sysUser.getName()) + .userName(sysUser.getUserName()) + .avatar(sysUser.getAvatar()) + .build(); + result.add(userVO); + } + return Response.responseData(result); + } } diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/AllotShipmentsService.java b/core/service/src/main/java/com/wansenai/service/warehouse/AllotShipmentsService.java index facb1a0a..732b9291 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/AllotShipmentsService.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/AllotShipmentsService.java @@ -13,15 +13,17 @@ package com.wansenai.service.warehouse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.wansenai.dto.warehouse.AllotReceiptDTO; import com.wansenai.dto.warehouse.QueryAllotReceiptDTO; +import com.wansenai.entities.warehouse.WarehouseReceiptMain; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.AllotReceiptDetailVO; import com.wansenai.vo.warehouse.AllotReceiptVO; import java.util.List; -public interface AllotShipmentsService { +public interface AllotShipmentsService extends IService { Response> getAllotReceiptPageList(QueryAllotReceiptDTO queryAllotReceiptDTO); diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/AssembleReceiptService.java b/core/service/src/main/java/com/wansenai/service/warehouse/AssembleReceiptService.java index ab71865a..8d7dae0e 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/AssembleReceiptService.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/AssembleReceiptService.java @@ -13,15 +13,17 @@ package com.wansenai.service.warehouse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.wansenai.dto.warehouse.AssembleReceiptDTO; import com.wansenai.dto.warehouse.QueryAssembleReceiptDTO; +import com.wansenai.entities.warehouse.WarehouseReceiptMain; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.AssembleReceiptDetailVO; import com.wansenai.vo.warehouse.AssembleReceiptVO; import java.util.List; -public interface AssembleReceiptService { +public interface AssembleReceiptService extends IService { Response> getAssembleReceiptPageList(QueryAssembleReceiptDTO queryAssembleReceiptDTO); diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/DisassembleReceiptService.java b/core/service/src/main/java/com/wansenai/service/warehouse/DisassembleReceiptService.java index 53c513da..b1124ccd 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/DisassembleReceiptService.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/DisassembleReceiptService.java @@ -13,15 +13,17 @@ package com.wansenai.service.warehouse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.wansenai.dto.warehouse.DisassembleReceiptDTO; import com.wansenai.dto.warehouse.QueryDisassembleReceiptDTO; +import com.wansenai.entities.warehouse.WarehouseReceiptMain; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.DisassembleReceiptDetailVO; import com.wansenai.vo.warehouse.DisassembleReceiptVO; import java.util.List; -public interface DisassembleReceiptService { +public interface DisassembleReceiptService extends IService { Response> getDisassembleReceiptPageList(QueryDisassembleReceiptDTO queryDisassembleReceiptDTO); diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/OtherShipmentsService.java b/core/service/src/main/java/com/wansenai/service/warehouse/OtherShipmentsService.java index 8e045532..7e4c0222 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/OtherShipmentsService.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/OtherShipmentsService.java @@ -13,15 +13,17 @@ package com.wansenai.service.warehouse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.wansenai.dto.warehouse.OtherShipmentDTO; import com.wansenai.dto.warehouse.QueryOtherShipmentDTO; +import com.wansenai.entities.warehouse.WarehouseReceiptMain; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.OtherShipmentDetailVO; import com.wansenai.vo.warehouse.OtherShipmentVO; import java.util.List; -public interface OtherShipmentsService { +public interface OtherShipmentsService extends IService { Response> getOtherShipmentsPageList(QueryOtherShipmentDTO queryOtherShipmentDTO); diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/OtherStorageService.java b/core/service/src/main/java/com/wansenai/service/warehouse/OtherStorageService.java index a6729c6c..91ad7f28 100644 --- a/core/service/src/main/java/com/wansenai/service/warehouse/OtherStorageService.java +++ b/core/service/src/main/java/com/wansenai/service/warehouse/OtherStorageService.java @@ -13,15 +13,17 @@ package com.wansenai.service.warehouse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.wansenai.dto.warehouse.OtherStorageDTO; import com.wansenai.dto.warehouse.QueryOtherStorageDTO; +import com.wansenai.entities.warehouse.WarehouseReceiptMain; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.OtherStorageDetailVO; import com.wansenai.vo.warehouse.OtherStorageVO; import java.util.List; -public interface OtherStorageService { +public interface OtherStorageService extends IService { Response> getOtherStoragePageList(QueryOtherStorageDTO queryOtherStorageDTO); diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/WarehouseReceiptSubService.java b/core/service/src/main/java/com/wansenai/service/warehouse/WarehouseReceiptSubService.java new file mode 100644 index 00000000..aa458b03 --- /dev/null +++ b/core/service/src/main/java/com/wansenai/service/warehouse/WarehouseReceiptSubService.java @@ -0,0 +1,19 @@ +/* + * 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.service.warehouse; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.wansenai.entities.warehouse.WarehouseReceiptSub; + +public interface WarehouseReceiptSubService extends IService { +} 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 9f7c230c..d1196a8e 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 @@ -12,45 +12,367 @@ */ 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.OtherStorageDTO; import com.wansenai.dto.warehouse.QueryOtherStorageDTO; +import com.wansenai.entities.product.ProductStock; +import com.wansenai.entities.receipt.ReceiptPurchaseSub; +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.OtherStorageService; +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.OtherStorageCodeEnum; import com.wansenai.utils.response.Response; import com.wansenai.vo.warehouse.OtherStorageDetailVO; import com.wansenai.vo.warehouse.OtherStorageVO; 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 OtherStorageServiceImpl extends ServiceImpl implements OtherStorageService { + 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 OtherStorageServiceImpl(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> getOtherStoragePageList(QueryOtherStorageDTO queryOtherStorageDTO) { - return null; - } + var result = new Page(); + var page = new Page(queryOtherStorageDTO.getPage(), queryOtherStorageDTO.getPageSize()); + + var wrapperMainMapper = lambdaQuery() + .eq(queryOtherStorageDTO.getSupplierId() != null, WarehouseReceiptMain::getRelatedPersonId, queryOtherStorageDTO.getSupplierId()) + .eq(queryOtherStorageDTO.getOperatorId() != null, WarehouseReceiptMain::getCreateBy, queryOtherStorageDTO.getOperatorId()) + .eq(queryOtherStorageDTO.getStatus() != null, WarehouseReceiptMain::getStatus, queryOtherStorageDTO.getStatus()) + .eq(StringUtils.hasLength(queryOtherStorageDTO.getReceiptNumber()), WarehouseReceiptMain::getReceiptNumber, queryOtherStorageDTO.getReceiptNumber()) + .eq(StringUtils.hasLength(queryOtherStorageDTO.getOtherReceipt()), WarehouseReceiptMain::getReceiptNumber, queryOtherStorageDTO.getOtherReceipt()) + .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::getDeleteFlag, CommonConstants.NOT_DELETED) + .page(page); + + var otherStorageVOList = 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 otherStorageVO = OtherStorageVO.builder() + .id(item.getId()) + .receiptNumber(item.getReceiptNumber()) + .productInfo(productInfo) + .supplierName(commonService.getSupplierName(item.getRelatedPersonId())) + .receiptDate(item.getReceiptDate()) + .operator(Optional.ofNullable(operator).map(SysUser::getName).orElse("")) + .productNumber(item.getTotalProductNumber()) + .totalAmount(item.getTotalAmount()) + .status(item.getStatus()) + .build(); + + otherStorageVOList.add(otherStorageVO); + }); + result.setRecords(otherStorageVOList); + result.setTotal(wrapperMainMapper.getTotal()); + return Response.responseData(result); + } @Override public Response getOtherStorageDetail(Long id) { - return null; + if (id == null) { + return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL); + } + var receiptMain = getById(id); + if (receiptMain != null) { + var otherStorageDetailVO = OtherStorageDetailVO.builder() + .id(receiptMain.getId()) + .supplierId(receiptMain.getRelatedPersonId()) + .supplierName(commonService.getSupplierName(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); + }); + otherStorageDetailVO.setTableData(tableData); + } + var fileList = commonService.getFileList(receiptMain.getFileId()); + otherStorageDetailVO.setFiles(fileList); + return Response.responseData(otherStorageDetailVO); + } + return Response.responseMsg(BaseCodeEnum.QUERY_DATA_EMPTY); } @Override public Response addOrUpdateOtherStorage(OtherStorageDTO otherStorageDTO) { - return null; + var userId = userService.getCurrentUserId(); + var fid = processFiles(otherStorageDTO.getFiles(), otherStorageDTO.getId()); + var fileIds = StringUtils.collectionToCommaDelimitedString(fid); + var isUpdate = otherStorageDTO.getId() != null; + + if (isUpdate) { + var beforeReceipt = warehouseReceiptSubService.lambdaQuery() + .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, otherStorageDTO.getId()) + .list(); + if (!beforeReceipt.isEmpty()) { + updateProductStock(beforeReceipt, 2); + } + + var warehouseReceiptMain = lambdaUpdate() + .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(StringUtils.hasLength(otherStorageDTO.getReceiptDate()), WarehouseReceiptMain::getReceiptDate, otherStorageDTO.getReceiptDate()) + .set(StringUtils.hasLength(otherStorageDTO.getRemark()), WarehouseReceiptMain::getRemark, otherStorageDTO.getRemark()) + .set(StringUtils.hasLength(fileIds), WarehouseReceiptMain::getFileId, fileIds) + .set(WarehouseReceiptMain::getUpdateBy, userId) + .set(WarehouseReceiptMain::getUpdateTime, LocalDateTime.now()) + .update(); + + warehouseReceiptSubService.lambdaUpdate() + .eq(WarehouseReceiptSub::getWarehouseReceiptMainId, otherStorageDTO.getId()) + .remove(); + + var storageShipmentStockList = otherStorageDTO.getTableData(); + var storageShipmentStock = storageShipmentStockList.stream() + .map(item -> WarehouseReceiptSub.builder() + .id(SnowflakeIdUtil.nextId()) + .warehouseReceiptMainId(otherStorageDTO.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(storageShipmentStock); + updateProductStock(storageShipmentStock, 1); + + if (updateSubResult && warehouseReceiptMain) { + return Response.responseMsg(OtherStorageCodeEnum.UPDATE_OTHER_STORAGE_STOCK_SUCCESS); + } + return Response.responseMsg(OtherStorageCodeEnum.UPDATE_OTHER_STORAGE_STOCK_ERROR); + + } else { + var receiptMainId = SnowflakeIdUtil.nextId(); + var storageShipmentStockList = otherStorageDTO.getTableData(); + var storageShipmentStock = storageShipmentStockList.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(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("入库") + .initReceiptNumber(otherStorageDTO.getReceiptNumber()) + .receiptDate(TimeUtil.parse(otherStorageDTO.getReceiptDate())) + .totalAmount(totalAmount) + .totalProductNumber(totalProductNumber) + .remark(otherStorageDTO.getRemark()) + .fileId(fileIds) + .source(0) + .createBy(userId) + .createTime(LocalDateTime.now()) + .build(); + var saveMainResult = save(warehouseReceiptMain); + updateProductStock(storageShipmentStock, 1); + if (saveSubResult && saveMainResult) { + return Response.responseMsg(OtherStorageCodeEnum.ADD_OTHER_STORAGE_STOCK_SUCCESS); + } + return Response.responseMsg(OtherStorageCodeEnum.ADD_OTHER_STORAGE_STOCK_ERROR); + } } @Override public Response deleteBatchOtherStorage(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(OtherStorageCodeEnum.DELETE_OTHER_STORAGE_STOCK_ERROR); + } + return Response.responseMsg(OtherStorageCodeEnum.DELETE_OTHER_STORAGE_STOCK_SUCCESS); } @Override public Response updateOtherStorageStatus(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(OtherStorageCodeEnum.UPDATE_OTHER_STORAGE_STOCK_ERROR); + } + return Response.responseMsg(OtherStorageCodeEnum.UPDATE_OTHER_STORAGE_STOCK_SUCCESS); } } diff --git a/core/service/src/main/java/com/wansenai/service/warehouse/impl/WarehouseReceiptSubServiceImpl.java b/core/service/src/main/java/com/wansenai/service/warehouse/impl/WarehouseReceiptSubServiceImpl.java new file mode 100644 index 00000000..da4d0e14 --- /dev/null +++ b/core/service/src/main/java/com/wansenai/service/warehouse/impl/WarehouseReceiptSubServiceImpl.java @@ -0,0 +1,23 @@ +/* + * 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.service.warehouse.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wansenai.entities.warehouse.WarehouseReceiptSub; +import com.wansenai.mappers.warehouse.WarehouseReceiptSubMapper; +import com.wansenai.service.warehouse.WarehouseReceiptSubService; +import org.springframework.stereotype.Service; + +@Service +public class WarehouseReceiptSubServiceImpl extends ServiceImpl implements WarehouseReceiptSubService { +} diff --git a/web/src/api/sys/model/userModel.ts b/web/src/api/sys/model/userModel.ts index e5c7167e..b3d7aa1f 100644 --- a/web/src/api/sys/model/userModel.ts +++ b/web/src/api/sys/model/userModel.ts @@ -93,4 +93,6 @@ export interface GetUserInfoModel { status: number; // 用户角色名称 roleName: string; + // 头像 + avatar: string; } diff --git a/web/src/api/sys/user.ts b/web/src/api/sys/user.ts index cdd5ba65..2f442706 100644 --- a/web/src/api/sys/user.ts +++ b/web/src/api/sys/user.ts @@ -29,6 +29,7 @@ enum Api { AddOrUpdateUser = '/user/addOrUpdate', DeleteUser = '/user/delete', ResetPassword = '/user/resetPassword', + GetUserOperatorList = '/user/operator', } /** @@ -182,6 +183,10 @@ export function doLogout() { return defHttp.get({url: Api.Logout}); } +export function getUserOperatorList() { + return defHttp.get>({url: Api.GetUserOperatorList}); +} + export function testRetry() { return defHttp.get( {url: Api.TestRetry}, diff --git a/web/src/api/warehouse/model/storageModel.ts b/web/src/api/warehouse/model/storageModel.ts new file mode 100644 index 00000000..165d43eb --- /dev/null +++ b/web/src/api/warehouse/model/storageModel.ts @@ -0,0 +1,64 @@ +import {FileData} from "@/api/financial/model/advanceModel"; + +export interface OtherStorageData { + id: number | string; + warehouseId: 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 AddOrUpdateOtherStorageReq { + id: number | undefined; + supplierId: number; + receiptNumber: string; + receiptDate: string; + remark: string; + status: number; + files: FileData[]; + tableData: OtherStorageData[]; +} + +export interface QueryOtherStorageReq { + receiptNumber: string; + productInfo: string; + supplierId: number; + warehouseId: number; + operatorId: number; + otherReceipt: string; + status: number; + remark: string; +} + +export interface OtherStorageResp { + id: string | undefined; + supplierName: string; + receiptNumber: string; + productInfo: string; + receiptDate: string; + operator: string; + productNumber: number; + totalAmount: number; + status: number; +} + +export interface OtherStorageDetailResp { + id: string | undefined; + supplierId: string; + supplierName: string; + receiptNumber: string; + receiptDate: string; + remark: string; + status: number; + files: FileData[]; + tableData: OtherStorageData[]; +} \ No newline at end of file diff --git a/web/src/api/warehouse/storage.ts b/web/src/api/warehouse/storage.ts new file mode 100644 index 00000000..8416b7c0 --- /dev/null +++ b/web/src/api/warehouse/storage.ts @@ -0,0 +1,63 @@ +import {defHttp} from '/@/utils/http/axios'; +import { ErrorMessageMode } from '/#/axios'; +import {BaseDataResp, BaseResp} from "@/api/model/baseModel"; +import { + AddOrUpdateOtherStorageReq, + QueryOtherStorageReq, + OtherStorageResp, + OtherStorageDetailResp, +} from "@/api/warehouse/model/storageModel"; + +enum API { + PageList = '/warehouse/otherStorage/pageList', + AddOrUpdateAccount = '/warehouse/otherStorage/addOrUpdate', + DeleteBatch = '/warehouse/otherStorage/deleteByIds', + UpdateStatus = '/warehouse/otherStorage/updateStatusByIds', + GetDetail = '/warehouse/otherStorage/getDetailById', +} + +export function getOtherStoragePageList(params: QueryOtherStorageReq, mode: ErrorMessageMode = 'notice') { + return defHttp.post>( + { + url: API.PageList, + params, + }, + { + errorMessageMode: mode, + successMessageMode: mode, + }, + ); +} + +export function addOrUpdateOtherStorage(params: AddOrUpdateOtherStorageReq) { + return defHttp.post( + { + url: API.AddOrUpdateAccount, + params, + }, + ); +} + +export function updateOtherStorageStatus(ids: number[], status: number) { + return defHttp.put( + { + url: `${API.UpdateStatus}?ids=${ids}&status=${status}` + }, + ); +} + +export function deleteBatchOtherStorage(ids: number[]) { + return defHttp.put( + { + url: `${API.DeleteBatch}?ids=${ids}` + }, + ); +} + +export function getOtherStorageDetailById(id: number) { + return defHttp.get>( + { + url: `${API.GetDetail}/${id}` + }, + ); +} \ No newline at end of file diff --git a/web/src/views/product/info/info.data.ts b/web/src/views/product/info/info.data.ts index 6c39e38d..f73fe48d 100644 --- a/web/src/views/product/info/info.data.ts +++ b/web/src/views/product/info/info.data.ts @@ -6,8 +6,7 @@ import {useMessage} from "@/hooks/web/useMessage"; import {useI18n} from "@/hooks/web/useI18n"; import {updateProductStatus} from "@/api/product/product"; import {getCategoryList} from "@/api/product/productCategory"; -import {MeTable, ProductInfo, Stock} from "@/views/product/info/model/productInfoModel"; -import {AddProductReq} from "@/api/product/model/productModel"; +import {MeTable, ProductInfo} from "@/views/product/info/model/productInfoModel"; import {getWarehouseList} from "@/api/basic/warehouse"; const { t } = useI18n(); @@ -303,7 +302,7 @@ const meTable: MeTable = reactive({ ], }); -const stock: Stock = reactive({ +const stock: any = reactive({ loading: false, dataSource: ref([]), columns: [ @@ -333,7 +332,7 @@ const stock: Stock = reactive({ ], }); -const formState: AddProductReq = reactive({ +const formState: any = reactive({ productId: '', productName: '', productStandard: '', diff --git a/web/src/views/warehouse/storage/addEditOtherStorage.data.ts b/web/src/views/warehouse/storage/addEditOtherStorage.data.ts new file mode 100644 index 00000000..33cec846 --- /dev/null +++ b/web/src/views/warehouse/storage/addEditOtherStorage.data.ts @@ -0,0 +1,174 @@ +import {reactive, ref} from "vue"; +import XEUtils from "xe-utils"; +import {VxeGridInstance, VxeGridProps} from "vxe-table"; +import {Dayjs} from "dayjs"; + +export interface RowVO { + [key: string]: any, + warehouseId: number | string; + warehouseName: string | undefined, + barCode: string | number, + productId: number |string, + productName: string, + productModel: string, + productUnit: string, + productStandard: string, + stock: number, + productNumber: number, + unitPrice: number, + amount: number, + remark: string, +} + +interface OtherStorageFormState { + id: number | string | undefined; + warehouseId: number | string; + supplierId: number | string | undefined; + receiptDate: string | undefined | Dayjs; + receiptNumber: string |undefined; + remark: string; +} + +const xGrid = ref>() +const tableData = ref([]) +const gridOptions = reactive>({ + border: true, + showHeaderOverflow: true, + showOverflow: true, + showFooter: true, + keepSource: true, + id: 'full_edit', + height: 400, + rowConfig: { + keyField: 'id', + isHover: true + }, + columnConfig: { + resizable: true + }, + sortConfig: { + trigger: 'cell', + remote: true + }, + filterConfig: { + remote: true + }, + formConfig: { + titleWidth: 100, + titleAlign: 'right', + items: [ + ] + }, + toolbarConfig: { + slots: { + buttons: 'toolbar_buttons' + }, + export: true, + zoom: true, + custom: true + }, + proxyConfig: { + sort: false, + filter: false, + form: true, + }, + columns: [ + { type: 'checkbox', field:'productId', title: 'ID', width: 80}, + { field: 'warehouseId', + width:120, + title: '仓库名称', + slots: { edit: 'warehouseId_edit',default: 'warehouseId_default' }, + sortable: true, + editRender: {} + }, + { field: 'barCode', + width:160, + title: '条码', + slots: { edit: 'barCode_edit' }, + sortable: true, + titlePrefix: { content: '输入条码商品信息自动带出!' }, + editRender: { name: 'input', attrs: { placeholder: '请输入条码并回车' } } + }, + { + field: 'productName', + title: '名称', + width:140, + }, + { field: 'productStandard', title: '规格', width: 110, }, + { field: 'stock', title: '库存', width: 70}, + { field: 'productUnit', title: '单位', width: 70}, + { field: 'productNumber', title: '数量', width:80, + slots: { edit: 'product_number_edit' }, + editRender: { name: '$input', props: { type: 'number', min: 1, max: 9999 } }, }, + { + field: 'unitPrice', + title: '单价', width:90, + formatter ({ cellValue }) { + return cellValue ? `¥${XEUtils.commafy(XEUtils.toNumber(cellValue), { digits: 2 })}` : '' + }, + slots: { edit: 'price_edit' }, + editRender: { name: '$input', props: { type: 'float', digits: 2, placeholder: '输入单价' } } + }, + { + field: 'amount', + title: '金额', width:90, + formatter ({ cellValue }) { + return cellValue ? `¥${XEUtils.commafy(XEUtils.toNumber(cellValue), { digits: 2 })}` : '' + }, + slots: { edit: 'amount_edit' }, + editRender: { name: '$input', props: { type: 'float', digits: 2, placeholder: '输入金额' } } + }, + { field: 'remark', title: '备注', editRender: { name: 'input', attrs: { placeholder: '请输入备注' } }, width: 150}, + ], + footerMethod ({ columns, data }) { + return [ + columns.map((column, columnIndex) => { + if (columnIndex === 0) { + return '总计' + } + if (['productNumber'].includes(column.field)) { + return sumNum(data, column.field) + } + if (['amount'].includes(column.field)) { + return `¥${XEUtils.commafy(XEUtils.toNumber(sumNum(data, column.field)), { digits: 2 })}` + } + return '' + }) + ] + }, + checkboxConfig: { + labelField: 'id', + reserve: true, + highlight: true, + range: true + }, + editConfig: { + trigger: 'click', + mode: 'row', + showStatus: true + } +}) + +const sumNum = (list: RowVO[], field: string) => { + let count = 0 + list.forEach(item => { + count += Number(item[field]) + }) + return count +} +const otherStorageFormState = reactive({ + id: undefined, + warehouseId: '', + supplierId: '', + receiptDate: '', + receiptNumber: '', + remark: '', +}); + +export { + xGrid, + sumNum, + tableData, + gridOptions, + otherStorageFormState, +} \ 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 new file mode 100644 index 00000000..9449473a --- /dev/null +++ b/web/src/views/warehouse/storage/components/AddEditOtherStorageModal.vue @@ -0,0 +1,637 @@ + + + + + \ No newline at end of file diff --git a/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue b/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue new file mode 100644 index 00000000..a69f2c77 --- /dev/null +++ b/web/src/views/warehouse/storage/components/ViewOtherStorageModal.vue @@ -0,0 +1,128 @@ + + + diff --git a/web/src/views/warehouse/storage/index.vue b/web/src/views/warehouse/storage/index.vue new file mode 100644 index 00000000..ffabdccb --- /dev/null +++ b/web/src/views/warehouse/storage/index.vue @@ -0,0 +1,201 @@ + +
+
+ + \ No newline at end of file diff --git a/web/src/views/warehouse/storage/otherStorage.data.ts b/web/src/views/warehouse/storage/otherStorage.data.ts new file mode 100644 index 00000000..26150c92 --- /dev/null +++ b/web/src/views/warehouse/storage/otherStorage.data.ts @@ -0,0 +1,186 @@ +import {FormSchema} from "@/components/Form"; +import {BasicColumn} from "@/components/Table"; +import {getSupplierList} from "@/api/basic/supplier"; +import {getUserOperatorList} from "@/api/sys/user"; + +export const columns: BasicColumn[] = [ + { + title: '供应商', + dataIndex: 'supplierName', + 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: 'supplierId', + component: 'ApiSelect', + componentProps: { + api: getSupplierList, + resultField: 'data', + labelField: 'supplierName', + 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 otherStorageTableColumns: 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