CREATE PROCEDURE `getCatalogAssets` ( IN repertoryIds VARCHAR(1024), IN catalogId BIGINT )
BEGIN
SELECT
count( id ) AS count,
GROUP_CONCAT( id SEPARATOR ',' ) AS ids,
SUM( CASE WHEN stockStatus = '在库' THEN 1 ELSE 0 END ) AS IN_STOCK,
SUM( CASE WHEN stockStatus != '在库' THEN 1 ELSE 0 END ) AS OUT_STOCK,
SUM( CASE WHEN valueStatus = '正常' THEN 1 ELSE 0 END ) AS NORMAL,
SUM( CASE WHEN valueStatus = '维修' THEN 1 ELSE 0 END ) AS REPAIR,
SUM( CASE WHEN valueStatus = '报废' THEN 1 ELSE 0 END ) AS SCRAP
FROM
db_pop_asset AS a
WHERE
FIND_IN_SET(repertoryId,repertoryIds)
AND FIND_IN_SET( a.classificationId, getCatalogChildIds ( catalogId ) );
END