feat(purchase): 添加根据采购订单id查询入库产品信息接口
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | @Schema(description = "å建æ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | @Schema(description = "æ´æ°æ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "åå»ºç¨æ·") |
| | |
| | | import com.ruoyi.purchase.dto.PurchaseReturnOrderDto; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.purchase.service.PurchaseReturnOrdersService; |
| | | import com.ruoyi.purchase.vo.PurchaseStockInProductVo; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/getByPurchaseLedgerId") |
| | | @Operation(summary = "éè´éè´§-æ ¹æ®éè´è®¢åidæ¥è¯¢éè´è®¢å对åºçå
¥åºäº§åä¿¡æ¯") |
| | | public AjaxResult getByPurchaseLedgerId(Long purchaseLedgerId) { |
| | | List<PurchaseStockInProductVo> purchaseStockInProductVos = purchaseReturnOrdersService.getByPurchaseLedgerId(purchaseLedgerId); |
| | | return AjaxResult.success(purchaseStockInProductVos); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ruoyi.purchase.pojo.PurchaseReturnOrders; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.purchase.dto.PurchaseReturnOrderHasAllInfoDto; |
| | | import com.ruoyi.purchase.vo.PurchaseStockInProductVo; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | PurchaseReturnOrderHasAllInfoDto getPurchaseReturnOrderHasAllInfoById(@Param("id") @NotNull Long id); |
| | | |
| | | IPage<PurchaseReturnVo> listPageAccountPurchaseReturn(Page page, @Param("req") PurchaseReturnDto purchaseReturnDto); |
| | | |
| | | //æ ¹æ®éè´è®¢åidæ¥è¯¢éè´è®¢å对åºçå
¥åºäº§åä¿¡æ¯ |
| | | List<PurchaseStockInProductVo> getByPurchaseLedgerId(@Param("purchaseLedgerId") Long purchaseLedgerId); |
| | | } |
| | |
| | | package com.ruoyi.purchase.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Schema(description = "éè´§åid") |
| | | private Long purchaseReturnOrderId; |
| | | |
| | | @Schema(description = "éè´äº§åid") |
| | | private Long salesLedgerProductId; |
| | | @Schema(description = "产åè§æ ¼id") |
| | | private Long ProductModelId; |
| | | |
| | | @Schema(description = "éè´§æ°é") |
| | | private BigDecimal returnQuantity; |
| | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | @Schema(description = "å
³èå
¥åºåid") |
| | | private Long stockInRecordId; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.purchase.vo.PurchaseReturnDetailsVo; |
| | | import com.ruoyi.purchase.dto.PurchaseReturnOrderHasAllInfoDto; |
| | | |
| | | import com.ruoyi.purchase.vo.PurchaseStockInProductVo; |
| | | import jakarta.validation.constraints.NotNull; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | PurchaseReturnDetailsVo getPurchaseReturnOrderDtoById(@NotNull Long id); |
| | | |
| | | void deleteById(@NotNull Long id); |
| | | |
| | | List<PurchaseStockInProductVo> getByPurchaseLedgerId(Long purchaseLedgerId); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.purchase.pojo.PurchaseReturnOrders; |
| | | import com.ruoyi.purchase.service.PurchaseReturnOrdersService; |
| | | import com.ruoyi.purchase.vo.PurchaseReturnDetailsVo; |
| | | import com.ruoyi.purchase.vo.PurchaseStockInProductVo; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.purchase.dto.PurchaseReturnOrderHasAllInfoDto; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | |
| | | |
| | | if (!purchaseReturnOrderDto.getPurchaseReturnOrderProductsDtos().isEmpty()) { |
| | | for (PurchaseReturnOrderProductsDto purchaseReturnOrderProductsDto : purchaseReturnOrderDto.getPurchaseReturnOrderProductsDtos()) { |
| | | purchaseReturnOrderProductsDto.setSalesLedgerProductId(purchaseReturnOrderProductsDto.getSalesLedgerProductId()); |
| | | purchaseReturnOrderProductsDto.setProductModelId(purchaseReturnOrderProductsDto.getProductModelId()); |
| | | purchaseReturnOrderProductsDto.setPurchaseReturnOrderId(purchaseReturnOrderDto.getId()); |
| | | purchaseReturnOrderProductsDto.setReturnQuantity(purchaseReturnOrderProductsDto.getReturnQuantity()); |
| | | // è¿é为æ°å¢å æ¤id为null |
| | |
| | | purchaseReturnOrderProductsMapper.insert(purchaseReturnOrderProductsDto); |
| | | //åºåéè¦åºåº(éè´éè´§) |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(purchaseReturnOrderDto.getPurchaseLedgerId()); |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(purchaseReturnOrderProductsDto.getSalesLedgerProductId()); |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(purchaseReturnOrderProductsDto.getProductModelId()); |
| | | stockUtils.substractStock(salesLedgerProduct.getProductModelId(), purchaseReturnOrderProductsDto.getReturnQuantity(), StockOutQualifiedRecordTypeEnum.PURCHASE_RETURN_STOCK_OUT.getCode(), purchaseReturnOrderDto.getId(), purchaseLedger.getPurchaseContractNumber()+"-"+salesLedgerProduct.getId()); |
| | | } |
| | | }else { |
| | |
| | | updateWrapperAccountIncome.eq(AccountIncome::getIncomeType, 4); |
| | | accountIncomeService.remove(updateWrapperAccountIncome); |
| | | } |
| | | |
| | | @Override |
| | | public List<PurchaseStockInProductVo> getByPurchaseLedgerId(Long purchaseLedgerId) { |
| | | return purchaseReturnOrdersMapper.getByPurchaseLedgerId(purchaseLedgerId); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.purchase.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @Schema(name = "PurchaseStockInProductVo", description = "éè´ç®¡ç--éè´è®¢åä¸å
¥åºäº§åå表") |
| | | public class PurchaseStockInProductVo { |
| | | |
| | | @Schema(description = "å
¥åºåid") |
| | | private Long id; |
| | | |
| | | @Schema(description = "产å大类") |
| | | private String productCategory; |
| | | |
| | | @Schema(description = "è§æ ¼åå·") |
| | | private String specificationModel; |
| | | |
| | | @Schema(description = "åä½") |
| | | private String unit; |
| | | |
| | | @Schema(description = "å
¥åºåå·") |
| | | private String inboundBatches; |
| | | |
| | | @Schema(description = "å
¥åºæ°é") |
| | | private BigDecimal stockInNum; |
| | | |
| | | @Schema(description = "æ¹æ¬¡å·") |
| | | private String batchNo; |
| | | |
| | | @Schema(description = "å¯éè´§æ°") |
| | | private BigDecimal unQuantity; |
| | | |
| | | @Schema(description = "éè´§æ»æ°") |
| | | private BigDecimal totalReturnNum; |
| | | |
| | | @Schema(description = "å«ç¨åä»·") |
| | | private BigDecimal taxInclusiveUnitPrice; |
| | | } |
| | |
| | | <result column="status" property="status" /> |
| | | </resultMap> |
| | | <select id="listReturnSaleProductDto" resultType="com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto"> |
| | | SELECT p.product_name as product_name, |
| | | SELECT distinct |
| | | p.product_name as product_name, |
| | | pm.model as model, |
| | | pm.unit as unit, |
| | | rsp.*, |
| | | GREATEST(slp.quantity - COALESCE(rs.total_return_num, 0), 0) AS un_quantity, |
| | | GREATEST(sor.stock_out_num - COALESCE(rsp.num, 0), 0) AS un_quantity, |
| | | COALESCE(rs.total_return_num, 0) AS total_return_num |
| | | FROM return_sale_product rsp |
| | | LEFT JOIN return_management rm ON rm.id = rsp.return_management_id |
| | | LEFT JOIN shipping_info si ON si.id = rm.shipping_id |
| | | LEFT JOIN shipping_product_detail spd ON spd.shipping_info_id = si.id |
| | | LEFT JOIN stock_out_record sor ON sor.record_id = si.id and sor.record_type = '13' |
| | | LEFT JOIN stock_out_record sor ON rsp.stock_out_record_id = sor.id and sor.record_type = '13' |
| | | LEFT JOIN sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | left join product_model pm on slp.product_model_id = pm.id |
| | | LEFT JOIN product p on pm.product_id = p.id |
| | |
| | | </if> |
| | | order by pro.id DESC |
| | | </select> |
| | | <select id="getByPurchaseLedgerId" resultType="com.ruoyi.purchase.vo.PurchaseStockInProductVo"> |
| | | SELECT |
| | | sir.id, |
| | | slp.product_category, |
| | | slp.specification_model, |
| | | slp.unit, |
| | | sir.inbound_batches, |
| | | sir.stock_in_num, |
| | | sir.batch_no, |
| | | slp.tax_inclusive_unit_price, |
| | | GREATEST(sir.stock_in_num - COALESCE(rs.total_return_num, 0), 0) AS un_quantity, |
| | | COALESCE(rs.total_return_num, 0) AS total_return_num |
| | | FROM stock_in_record sir |
| | | LEFT JOIN quality_inspect qi ON sir.record_type = 10 AND sir.record_id = qi.id |
| | | LEFT JOIN purchase_ledger pl |
| | | ON pl.id = IF(sir.record_type = 7, sir.record_id, qi.purchase_ledger_id) |
| | | LEFT JOIN sales_ledger_product slp ON pl.id = slp.product_id |
| | | LEFT JOIN ( |
| | | SELECT |
| | | stock_in_record_id, |
| | | SUM(return_quantity) AS total_return_num |
| | | FROM purchase_return_order_products prop |
| | | left join purchase_return_orders pro on pro.id = prop.purchase_return_order_id |
| | | WHERE 1=1 |
| | | GROUP BY stock_in_record_id |
| | | ) rs ON rs.stock_in_record_id = sir.id |
| | | WHERE sir.approval_status = 1 AND slp.type = 2 |
| | | AND sir.record_type IN ('7','10') |
| | | and pl.id = #{purchaseLedgerId} |
| | | </select> |
| | | </mapper> |
| | |
| | | LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id |
| | | </select> |
| | | <select id="getReturnManagementDtoById" resultType="com.ruoyi.procurementrecord.bean.vo.ShippingProductVo"> |
| | | SELECT |
| | | SELECT distinct |
| | | sor.id, |
| | | slp.product_category, |
| | | slp.specification_model, |