feat(purchase): 采购订单商品查询增加供应商筛选

- 在采购订单商品查询接口中增加供应商 ID 参数
- 修改相关服务和 mapper 方法,支持按供应商筛选商品- 更新 SQL 查询语句,添加供应商 ID 条件
This commit is contained in:
lijiaqi 2024-11-22 09:21:31 +08:00
parent 09a2b1c762
commit 123ea7101c
6 changed files with 23 additions and 17 deletions

View File

@ -391,19 +391,21 @@ public class PurchaseOrderController extends DefaultBaseController {
@ApiOperation("根据关键字查询可采购商品") @ApiOperation("根据关键字查询可采购商品")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(value = "仓库ID", name = "scId", paramType = "query", required = true), @ApiImplicitParam(value = "仓库ID", name = "scId", paramType = "query", required = true),
@ApiImplicitParam(value = "关键字", name = "condition", paramType = "query", required = true)}) @ApiImplicitParam(value = "关键字", name = "condition", paramType = "query", required = true),
@ApiImplicitParam(value = "供应商ID", name = "supplierId", paramType = "query",required = true)
})
@HasPermission({"purchase:order:add", "purchase:order:modify", "purchase:receive:add", @HasPermission({"purchase:order:add", "purchase:order:modify", "purchase:receive:add",
"purchase:receive:modify", "purchase:return:add", "purchase:return:modify"}) "purchase:receive:modify", "purchase:return:add", "purchase:return:modify"})
@GetMapping("/product/search") @GetMapping("/product/search")
public InvokeResult<List<PurchaseProductBo>> searchPurchaseProducts( public InvokeResult<List<PurchaseProductBo>> searchPurchaseProducts(
@NotBlank(message = "仓库ID不能为空") String scId, String condition) { @NotBlank(message = "仓库ID不能为空") String scId, String condition,@NotBlank(message = "供应商ID不能为空") String supplierId) {
if (StringUtil.isBlank(condition)) { if (StringUtil.isBlank(condition)) {
return InvokeResultBuilder.success(CollectionUtil.emptyList()); return InvokeResultBuilder.success(CollectionUtil.emptyList());
} }
PageResult<PurchaseProductDto> pageResult = purchaseOrderService.queryPurchaseByCondition( PageResult<PurchaseProductDto> pageResult = purchaseOrderService.queryPurchaseByCondition(
getPageIndex(), getPageSize(), condition); getPageIndex(), getPageSize(), condition, supplierId);
List<PurchaseProductBo> results = CollectionUtil.emptyList(); List<PurchaseProductBo> results = CollectionUtil.emptyList();
List<PurchaseProductDto> datas = pageResult.getDatas(); List<PurchaseProductDto> datas = pageResult.getDatas();
if (!CollectionUtil.isEmpty(datas)) { if (!CollectionUtil.isEmpty(datas)) {
@ -421,18 +423,20 @@ public class PurchaseOrderController extends DefaultBaseController {
@ApiOperation("根据SKU查询可采购商品") @ApiOperation("根据SKU查询可采购商品")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(value = "仓库ID", name = "scId", paramType = "query", required = true), @ApiImplicitParam(value = "仓库ID", name = "scId", paramType = "query", required = true),
@ApiImplicitParam(value = "SKU", name = "sku", paramType = "query", required = true)}) @ApiImplicitParam(value = "SKU", name = "sku", paramType = "query", required = true),
@ApiImplicitParam(value = "供应商ID", name = "supplierId", paramType = "query", required = true)
})
@HasPermission({"purchase:order:add", "purchase:order:modify", "purchase:receive:add", @HasPermission({"purchase:order:add", "purchase:order:modify", "purchase:receive:add",
"purchase:receive:modify", "purchase:return:add", "purchase:return:modify"}) "purchase:receive:modify", "purchase:return:add", "purchase:return:modify"})
@GetMapping("/product/sku") @GetMapping("/product/sku")
public InvokeResult<PurchaseProductBo> searchPurchaseProductBySku( public InvokeResult<PurchaseProductBo> searchPurchaseProductBySku(
@NotBlank(message = "仓库ID不能为空") String scId, String sku) { @NotBlank(message = "仓库ID不能为空") String scId, String sku,@NotBlank(message = "供应商ID不能为空") String supplierId) {
if (StringUtil.isBlank(sku)) { if (StringUtil.isBlank(sku)) {
throw new DefaultClientException("SKU不能为空"); throw new DefaultClientException("SKU不能为空");
} }
PurchaseProductDto dto = purchaseOrderService.queryPurchaseBySku(sku); PurchaseProductDto dto = purchaseOrderService.queryPurchaseBySku(sku,supplierId);
if (dto == null) { if (dto == null) {
throw new DefaultClientException("该SKU不存在"); throw new DefaultClientException("该SKU不存在");
} }

View File

@ -575,14 +575,14 @@ public class PurchaseOrderServiceImpl extends BaseMpServiceImpl<PurchaseOrderMap
@Override @Override
public PageResult<PurchaseProductDto> queryPurchaseByCondition(Integer pageIndex, public PageResult<PurchaseProductDto> queryPurchaseByCondition(Integer pageIndex,
Integer pageSize, String condition) { Integer pageSize, String condition,String supplierId) {
Assert.greaterThanZero(pageIndex); Assert.greaterThanZero(pageIndex);
Assert.greaterThanZero(pageSize); Assert.greaterThanZero(pageSize);
PageHelperUtil.startPage(pageIndex, pageSize); PageHelperUtil.startPage(pageIndex, pageSize);
List<PurchaseProductDto> datas = getBaseMapper().queryPurchaseByCondition(condition); List<PurchaseProductDto> datas = getBaseMapper().queryPurchaseByCondition(condition,supplierId);
PageResult<PurchaseProductDto> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); PageResult<PurchaseProductDto> pageResult = PageResultUtil.convert(new PageInfo<>(datas));
return pageResult; return pageResult;
@ -693,8 +693,8 @@ public class PurchaseOrderServiceImpl extends BaseMpServiceImpl<PurchaseOrderMap
} }
@Override @Override
public PurchaseProductDto queryPurchaseBySku(String sku) { public PurchaseProductDto queryPurchaseBySku(String sku,String supplierId) {
return getBaseMapper().queryPurchaseBySku(sku); return getBaseMapper().queryPurchaseBySku(sku,supplierId);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

@ -95,7 +95,7 @@ public interface PurchaseOrderMapper extends BaseMapper<PurchaseOrder> {
@DataPermission(template = "category", alias = "c") @DataPermission(template = "category", alias = "c")
}) })
List<PurchaseProductDto> queryPurchaseByCondition( List<PurchaseProductDto> queryPurchaseByCondition(
@Param("condition") String condition); @Param("condition") String condition,@Param("supplierId")String supplierId);
/** /**
* 查询可采购商品信息 * 查询可采购商品信息
@ -128,5 +128,5 @@ public interface PurchaseOrderMapper extends BaseMapper<PurchaseOrder> {
@DataPermission(template = "brand", alias = "b"), @DataPermission(template = "brand", alias = "b"),
@DataPermission(template = "category", alias = "c") @DataPermission(template = "category", alias = "c")
}) })
PurchaseProductDto queryPurchaseBySku( @Param("sku") String sku); PurchaseProductDto queryPurchaseBySku( @Param("sku") String sku,@Param("supplierId")String supplierId);
} }

View File

@ -158,7 +158,7 @@ public interface PurchaseOrderService extends BaseMpService<PurchaseOrder> {
* @param condition * @param condition
* @return * @return
*/ */
PageResult<PurchaseProductDto> queryPurchaseByCondition(Integer pageIndex, Integer pageSize, String condition); PageResult<PurchaseProductDto> queryPurchaseByCondition(Integer pageIndex, Integer pageSize, String condition,String supplierId);
/** /**
* 查询可采购商品信息 * 查询可采购商品信息
@ -196,5 +196,5 @@ public interface PurchaseOrderService extends BaseMpService<PurchaseOrder> {
* @param sku * @param sku
* @return * @return
*/ */
PurchaseProductDto queryPurchaseBySku(String sku); PurchaseProductDto queryPurchaseBySku(String sku,String supplierId);
} }

View File

@ -263,7 +263,7 @@
o.id, o.sc_id, o.supplier_id, o.purchaser_id, d.id AS detail_id, d.product_id AS detail_product_id, o.id, o.sc_id, o.supplier_id, o.purchaser_id, d.id AS detail_id, d.product_id AS detail_product_id,
d.order_num AS detail_order_num, d.tax_price AS detail_tax_price, d.is_gift AS detail_is_gift, d.order_num AS detail_order_num, d.tax_price AS detail_tax_price, d.is_gift AS detail_is_gift,
d.tax_rate AS detail_tax_rate, d.description AS detail_description, d.order_no AS detail_order_no, d.tax_rate AS detail_tax_rate, d.description AS detail_description, d.order_no AS detail_order_no,
d.receive_num AS detail_receive_num,g.p.supplier_id, s.name AS supplier_name d.receive_num AS detail_receive_num,p.supplier_id, s.name AS supplier_name
FROM tbl_purchase_order AS o FROM tbl_purchase_order AS o
LEFT JOIN tbl_purchase_order_detail AS d ON d.order_id = o.id LEFT JOIN tbl_purchase_order_detail AS d ON d.order_id = o.id
LEFT JOIN base_data_product AS p ON p.id = d.product_id LEFT JOIN base_data_product AS p ON p.id = d.product_id
@ -314,6 +314,7 @@
) )
AND g.product_type = 1 AND g.product_type = 1
AND g.available = TRUE AND g.available = TRUE
AND g.supplier_id = #{supplierId}
</where> </where>
ORDER BY g.code ORDER BY g.code
</select> </select>
@ -354,6 +355,7 @@
AND g.sku_code = #{sku} AND g.sku_code = #{sku}
AND g.product_type = 1 AND g.product_type = 1
AND g.available = TRUE AND g.available = TRUE
AND g.supplier_id = #{supplierId}
</where> </where>
ORDER BY g.code ORDER BY g.code
</select> </select>

View File

@ -252,11 +252,11 @@
s.id, s.sc_id, s.supplier_id, s.purchaser_id, d.id AS detail_id, d.product_id AS detail_product_id, s.id, s.sc_id, s.supplier_id, s.purchaser_id, d.id AS detail_id, d.product_id AS detail_product_id,
d.order_num AS detail_order_num, d.tax_price AS detail_tax_price, d.is_gift AS detail_is_gift, d.order_num AS detail_order_num, d.tax_price AS detail_tax_price, d.is_gift AS detail_is_gift,
d.tax_rate AS detail_tax_rate, d.description AS detail_description, d.order_no AS detail_order_no, d.tax_rate AS detail_tax_rate, d.description AS detail_description, d.order_no AS detail_order_no,
d.return_num AS detail_return_num,p.supplier_id,s.name AS supplier_name d.return_num AS detail_return_num,p.supplier_id,sa.name AS supplier_name
FROM tbl_receive_sheet AS s FROM tbl_receive_sheet AS s
LEFT JOIN tbl_receive_sheet_detail AS d ON d.sheet_id = s.id LEFT JOIN tbl_receive_sheet_detail AS d ON d.sheet_id = s.id
LEFT JOIN base_data_product AS p ON p.id = d.product_id LEFT JOIN base_data_product AS p ON p.id = d.product_id
LEFT JOIN base_data_supplier AS s ON s.id = p.supplier_id LEFT JOIN base_data_supplier AS sa ON sa.id = p.supplier_id
<if test="requireReceive">AND d.order_num > d.return_num</if> <if test="requireReceive">AND d.order_num > d.return_num</if>
WHERE s.id = #{id} WHERE s.id = #{id}
AND s.status = 3 AND s.status = 3