查询逻辑 联查name和code
This commit is contained in:
@@ -36,16 +36,25 @@ public class WmsStockVo {
|
|||||||
* 物品类型(raw_material/product)
|
* 物品类型(raw_material/product)
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "物品类型", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "物品类型", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(readConverterExp = "r=aw_material/product")
|
@ExcelDictFormat(readConverterExp = "raw_material/product")
|
||||||
private String itemType;
|
private String itemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物品ID(指向原材料或产品主键)
|
* 物品ID(指向原材料或产品主键)
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "物品ID", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "物品ID", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(readConverterExp = "指=向原材料或产品主键")
|
@ExcelDictFormat(readConverterExp = "指向原材料或产品主键")
|
||||||
private Long itemId;
|
private Long itemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物品名称(动态:产品或原材料)
|
||||||
|
*/
|
||||||
|
private String itemName;
|
||||||
|
/**
|
||||||
|
* 物品编码(动态:产品或原材料)
|
||||||
|
*/
|
||||||
|
private String itemCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 库存数量
|
* 库存数量
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import com.klp.domain.WmsStock;
|
|||||||
import com.klp.domain.vo.WmsStockVo;
|
import com.klp.domain.vo.WmsStockVo;
|
||||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,4 +19,9 @@ import java.math.BigDecimal;
|
|||||||
public interface WmsStockMapper extends BaseMapperPlus<WmsStockMapper, WmsStock, WmsStockVo> {
|
public interface WmsStockMapper extends BaseMapperPlus<WmsStockMapper, WmsStock, WmsStockVo> {
|
||||||
|
|
||||||
BigDecimal getStockByItemId(Long rawMaterialId);
|
BigDecimal getStockByItemId(Long rawMaterialId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页联查物品名称和编码,支持Wrapper动态条件,返回Page<WmsStockVo>
|
||||||
|
*/
|
||||||
|
Page<WmsStockVo> selectVoPagePlus(Page<?> page, @Param("ew") Wrapper<WmsStock> wrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class WmsStockServiceImpl implements IWmsStockService {
|
|||||||
@Override
|
@Override
|
||||||
public TableDataInfo<WmsStockVo> queryPageList(WmsStockBo bo, PageQuery pageQuery) {
|
public TableDataInfo<WmsStockVo> queryPageList(WmsStockBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<WmsStock> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<WmsStock> lqw = buildQueryWrapper(bo);
|
||||||
Page<WmsStockVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<WmsStockVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,5 +25,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where item_id = #{rawMaterialId} and item_type = 'raw_material' and del_flag = 0
|
where item_id = #{rawMaterialId} and item_type = 'raw_material' and del_flag = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 分页联查物品名称和编码,支持Wrapper动态条件,返回Page<WmsStockVo> -->
|
||||||
|
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockVo">
|
||||||
|
SELECT
|
||||||
|
s.*,
|
||||||
|
CASE
|
||||||
|
WHEN s.item_type = 'product' THEN p.product_name
|
||||||
|
WHEN s.item_type = 'raw_material' THEN r.raw_material_name
|
||||||
|
ELSE NULL
|
||||||
|
END AS itemName,
|
||||||
|
CASE
|
||||||
|
WHEN s.item_type = 'product' THEN p.product_code
|
||||||
|
WHEN s.item_type = 'raw_material' THEN r.raw_material_code
|
||||||
|
ELSE NULL
|
||||||
|
END AS itemCode
|
||||||
|
FROM wms_stock s
|
||||||
|
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_id
|
||||||
|
LEFT JOIN wms_raw_material r ON s.item_type = 'raw_material' AND s.item_id = r.raw_material_id
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user