diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java index c61a282..cac4e24 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java @@ -59,4 +59,7 @@ public class MaWholeVo { /** 套装所需配件数量 */ @ApiModelProperty(value = "套装所需配件种类数量") private Integer totalNum; + /** 库存数量 */ + @ApiModelProperty(value = "库存数量") + private Integer num; } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml index 0c821c7..0cb1dcc 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml @@ -100,12 +100,24 @@ mt2.type_name AS typeName, mt.type_name AS deviceType, mws.whole_type_name as wholeTypeName, + CASE mt.manage_type + WHEN 0 THEN + IFNULL(subquery0.num, 0) + ELSE + IFNULL(mt.num, 0) + END as num, case when mws.ascription_type = 1 then '主体设备' else '配套设备' end as deviceAscription, mws.ascription_type as ascriptionType, mws.part_num AS deviceNum FROM ma_whole_set mws JOIN ma_type mt ON mws.type_id = mt.type_id + left join (SELECT mt.type_id, + count(mm.ma_id) num + FROM ma_machine mm + LEFT JOIN ma_type mt ON mt.type_id = mm.type_id + WHERE mm.ma_code is not null and mm.ma_status in (15) + GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id JOIN ma_type mt2 ON mt2.type_id = mt.parent_id JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id