sum(CASE WHEN t.month = MONTH(CURRENT_DATE()) THEN t.number ELSE 0 END) AS number,
org_info.org_name,
(SELECT `org_id` FROM `pub_org` WHERE ( `org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_id,
org_info.org_code,
(SELECT `org_code` FROM `pub_org` WHERE ( `org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_code,
org_info.d_name
(SELECT `org_name` FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_name,
(SELECT `d_name` FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS d_name
FROM (
FROM (
-- 设备统计子查询
SELECT
SELECT
vecs.`year`,
COALESCE(SUM(vecs.use_count), 0) AS use_count,
vecs.`month`,
COALESCE(SUM(vecs.fix_count), 0) AS fix_count
SUM(vecs.use_count) AS use_count,
SUM(vecs.fix_count) AS fix_count,
SUM(vecs.broken_count) AS broken_count,
sum(vecs.number) as number
FROM vie_equipment_count_summary vecs
FROM vie_equipment_count_summary vecs
left join pub_org po on vecs.org_id_int=po.org_id
LEFT JOIN pub_org po ON vecs.org_id_int = po.org_id
where vecs.`year`= #{year} and po.del_flag=1 AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
WHERE
po.del_flag=1 AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
AND (
AND (
`po`.`level_flag` > (
`po`.`level_flag` > (
...
@@ -240,9 +186,6 @@
...
@@ -240,9 +186,6 @@
#{item}
#{item}
</foreach>
</foreach>
</if>
</if>
<iftest="typeParentId != null and typeParentId !=''">
and vecs.type_parent_id=#{typeParentId}
</if>
<iftest="sizeNameList!=null and sizeNameList.size() > 0">
<iftest="sizeNameList!=null and sizeNameList.size() > 0">
t.org_id_int,t.property,t.org_name,t.org_code,t.type_id,t.type_name,t.size_id,t.size_name,t.location_type,t.location_id,max(t.location_name) as location_name,sum(t.number) as number,t.unit_price,sum(t.price)as price,sum(t.stock_number)as stock_number,sum(t.outbound_number)as outbound_number,
sum(t.destruction_number)as destruction_number,sum(t.expire_number)as expire_number,sum(t.broken_number)as broken_number,sum(t.fix_number)as fix_number,sum(t.use_number)as use_number FROM (
SELECT
bi.org_id_int as org_id_int,
COALESCE(bi.property, 0) as property,
po.org_name as org_name,
po.org_code as org_code,
bi.type_id as type_id,
t.name as type_name,
bi.size_id as size_id,
s.name as size_name,
COALESCE(bcb.cabinet_id, bw.id) as location_id,
COALESCE(MAX(bc.name), MAX(bw.name)) as location_name,
bi.location_type as location_type,
SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) + SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END)+sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end) as number,
bi.price as unit_price,
(SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) + SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END)+sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end))*bi.price as price,
SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) AS stock_number,
SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END) AS outbound_number,
sum(case when bi.state = "destory" then 1 else 0 end) as destruction_number,
sum(case when bi.warranty_period = 0 then 0 when DATE_ADD(bi.production_date, INTERVAL bi.warranty_period MONTH) < NOW() and bi.state!="broken" then 1 else 0 end) as expire_number,
sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end) as broken_number,
sum(case when bi.state = "repair" and bi.location_state = "out" then 1 else 0 end) as fix_number,
sum(case when bi.bussiness_state = "use" and bi.location_state = "out" then 1 else 0 end) as use_number
FROM base_inventory bi
LEFT JOIN base_cabinet_box bcb ON bi.location_id = bcb.id and bi.location_type=1
LEFT JOIN base_cabinet bc ON bcb.cabinet_id = bc.id
LEFT JOIN base_warehouse bw ON bi.location_id = bw.id AND bi.location_type = 0
JOIN base_equipment_type t ON t.id = bi.type_id
JOIN base_equipment_size s ON s.id = bi.size_id
JOIN pub_org po ON bi.org_id_int = po.org_id
and po.org_id=#{orgId}
where bi.location_id=#{locationId}
GROUP BY bi.org_id_int, location_id, type_id, size_id, bi.price, bi.location_type,bi.property
ORDER BY org_id_int, location_id) as t
GROUP BY t.org_id_int,t.location_id,t.type_id,t.size_id,t.location_type,t.unit_price,t.property
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t1
) AS t1
JOIN (
CROSS JOIN (
SELECT
SELECT
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
...
@@ -84,7 +67,7 @@
...
@@ -84,7 +67,7 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
JOIN pub_org po ON vpss.org_id_int = po.org_id AND po.del_flag = 1
JOIN pub_org po ON vpss.org_id_int = po.org_id
WHERE
WHERE
vpss.year = #{year}
vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
...
@@ -92,6 +75,7 @@
...
@@ -92,6 +75,7 @@
FROM vie_price_sum_summary
FROM vie_price_sum_summary
WHERE year = 2025 AND month IS NOT NULL
WHERE year = 2025 AND month IS NOT NULL
)
)
AND po.del_flag = 1
AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
<iftest="typeIdsList!=null and typeIdsList.size() > 0">
<iftest="typeIdsList!=null and typeIdsList.size() > 0">
and vpss.type_id in
and vpss.type_id in
...
@@ -109,7 +93,7 @@
...
@@ -109,7 +93,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -118,140 +102,14 @@
...
@@ -118,140 +102,14 @@
FROM
FROM
pub_org
pub_org
WHERE
WHERE
(org_id = #{orgId} OR org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
org_id = #{orgId}
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT( '%', #{orgId}, '%' ))-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- select COALESCE(t2.start_num,0) as start_num,COALESCE(t2.start_price,0) as start_price,COALESCE(t1.end_num,0) as end_num,-->
<!-- COALESCE(t1.end_price,0) as end_price,t1.destory_num,t1.destory_price,t1.type_name,t1.type_id,t1.size_name,t1.size_id,-->
<!-- COALESCE(end_num,0)-COALESCE(start_num,0) as add_num,COALESCE(end_price,0)-COALESCE(start_price,0) as add_price-->
<!-- FROM(-->
<!-- SELECT-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.end_num, 0 ) ELSE 0 END ) AS end_num,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.end_price, 0 ) ELSE 0 END ) AS end_price,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.destory_num, 0 ) ELSE 0 END ) AS destory_num,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.destory_price, 0 ) ELSE 0 END ) AS destory_price,vpss.type_name,vpss.type_id,vpss.size_name,vpss.size_id-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE `po`.`del_flag` = 1 and po.org_id =#{orgId}-->
<!-- GROUP BY vpss.type_id,vpss.type_name,vpss.size_name,vpss.size_id-->
<!-- ORDER BY vpss.type_id-->
<!-- ) as t1-->
<!-- left join(-->
<!-- SELECT-->
<!-- SUM(COALESCE ( start_num, 0 )) AS start_num,-->
<!-- SUM(COALESCE ( start_price, 0 )) AS start_price, vpss.type_name,vpss.type_id,vpss.size_name,vpss.size_id-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = 3-->
<!-- and `po`.`del_flag` = 1 and po.org_id =#{orgId}-->
<!-- GROUP BY vpss.type_id,vpss.type_name,vpss.size_name,vpss.size_id-->
<!-- ORDER BY vpss.type_id-->
<!-- ) as t2 on t1.type_id =t2.type_id and t1.type_name=t2.type_name and t1.size_id =t2.size_id and t1.size_name=t2.size_name-->
<!-- <if test="column != null and column != '' and order != null and order != '' ">-->
<!-- order by ${column} ${order}-->
<!-- </if>-->
<!-- <if test="column==null and order == null">-->
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN (
left JOIN pub_org po ON vpss.org_id_int = po.org_id
SELECT org_id
WHERE del_flag = 1 and (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
FROM pub_org
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
WHERE del_flag = 1
AND org_id != #{orgId}
AND org_parent_ids LIKE CONCAT('%', #{orgId}, '%')
AND (case when #{levelFlag} >=3 then 1=1 else SUBSTRING(org_code, 5, 2) = '00' end )
AND (
AND (
level_flag > (SELECT level_flag FROM pub_org WHERE org_id = #{orgId}) + 1
`po`.`level_flag` > (
OR level_flag = (SELECT level_flag FROM pub_org WHERE org_id = #{orgId})
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
)
) + 1
) po ON vpss.org_id_int = po.org_id
OR (`po`.`level_flag` = (
WHERE
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
vpss.year = #{year}
))))
and vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MIN(month)
SELECT MIN(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -317,19 +172,17 @@
...
@@ -317,19 +172,17 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN (
left JOIN pub_org po ON vpss.org_id_int = po.org_id
SELECT org_id
WHERE del_flag = 1 and (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
FROM pub_org
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
WHERE del_flag = 1
AND org_id != #{orgId}
AND org_parent_ids LIKE CONCAT('%', #{orgId}, '%')
AND (case when #{levelFlag} >=3 then 1=1 else SUBSTRING(org_code, 5, 2) = '00' end )
AND (
AND (
level_flag > (SELECT level_flag FROM pub_org WHERE org_id = #{orgId}) + 1
`po`.`level_flag` > (
OR level_flag = (SELECT level_flag FROM pub_org WHERE org_id = #{orgId})
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
)) po ON vpss.org_id_int = po.org_id
) + 1
WHERE
OR (`po`.`level_flag` = (
vpss.year = #{year}
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
))))
AND vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MAX(month)
SELECT MAX(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -352,7 +205,7 @@
...
@@ -352,7 +205,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -361,104 +214,9 @@
...
@@ -361,104 +214,9 @@
FROM
FROM
pub_org
pub_org
WHERE
WHERE
(org_id = #{orgId} OR org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
org_id = #{orgId} and level_flag is not null ORDER BY `level_flag` LIMIT 1
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')-->
<!-- AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))-->
<!-- AND (-->
<!-- `po`.`level_flag` > (-->
<!-- SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}-->
<!-- ) + 1-->
<!-- OR (`po`.`level_flag` = (-->
<!-- SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}-->
<!-- ))))-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- <if test="typeName!=null and typeName!=''">-->
<!-- and type_name like CONCAT('%', #{typeName}, '%')-->
<!-- </if>-->
<!-- ) AS t2-->
<!-- join (-->
<!-- SELECT `org_id`,`org_code`,org_name,d_name FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1-->
<!-- ) as t3;-->
</select>
</select>
...
@@ -485,11 +243,11 @@
...
@@ -485,11 +243,11 @@
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN pub_org po ON vpss.org_id_int = po.org_id
left JOIN pub_org po ON vpss.org_id_int = po.org_id
AND po.del_flag = 1
AND po.org_id = #{orgId}
WHERE
WHERE
vpss.year = #{year}
po.org_id = #{orgId}
and vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MIN(month)
SELECT MIN(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -512,7 +270,7 @@
...
@@ -512,7 +270,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t1
) AS t1
JOIN (
CROSS JOIN (
SELECT
SELECT
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
...
@@ -520,11 +278,10 @@
...
@@ -520,11 +278,10 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN pub_org po ON vpss.org_id_int = po.org_id
left JOIN pub_org po ON vpss.org_id_int = po.org_id
AND po.del_flag = 1
AND po.org_id = #{orgId}
WHERE
WHERE
vpss.year = #{year}
po.org_id = #{orgId}
AND vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MAX(month)
SELECT MAX(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -547,7 +304,7 @@
...
@@ -547,7 +304,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -557,196 +314,10 @@
...
@@ -557,196 +314,10 @@
pub_org
pub_org
WHERE
WHERE
org_id = #{orgId}
org_id = #{orgId}
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND org_id_int = #{orgId}-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- <if test="typeName!=null and typeName!=''">-->
<!-- and type_name like CONCAT('%', #{typeName}, '%')-->
<!-- </if>-->
<!-- ) AS t2-->
<!-- join (-->
<!-- SELECT `org_id`,`org_code`,org_name,d_name FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1-->
<iftest="req.typeName != null and req.typeName != ''">
AND vw.type_name like concat('%',#{req.typeName},'%')
</if>
</where>
GROUP BY
vw.id,
vw.size_id,
vw.type_id,
vw.warranty_type,
vw.location_id,
vw.org_id,
vw.location_type,
vw.price,
vw.property) as a
inner join base_inventory_summary as ins on a.org_id=ins.org_id_int and a.location_id=ins.location_id and a.type_id=ins.type_id and a.size_id=ins.size_id and a.price=ins.unit_price and a.property=ins.property
sum(CASE WHEN t.month = MONTH(CURRENT_DATE()) THEN t.number ELSE 0 END) AS number,
org_info.org_name,
(SELECT `org_id` FROM `pub_org` WHERE ( `org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_id,
org_info.org_code,
(SELECT `org_code` FROM `pub_org` WHERE ( `org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_code,
org_info.d_name
(SELECT `org_name` FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS org_name,
(SELECT `d_name` FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%'))and level_flag is not null ORDER BY `level_flag` LIMIT 1) AS d_name
FROM (
FROM (
-- 设备统计子查询
SELECT
SELECT
vecs.`year`,
COALESCE(SUM(vecs.use_count), 0) AS use_count,
vecs.`month`,
COALESCE(SUM(vecs.fix_count), 0) AS fix_count
SUM(vecs.use_count) AS use_count,
SUM(vecs.fix_count) AS fix_count,
SUM(vecs.broken_count) AS broken_count,
sum(vecs.number) as number
FROM vie_equipment_count_summary vecs
FROM vie_equipment_count_summary vecs
left join pub_org po on vecs.org_id_int=po.org_id
LEFT JOIN pub_org po ON vecs.org_id_int = po.org_id
where vecs.`year`= #{year} and po.del_flag=1 AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
WHERE
po.del_flag=1 AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
AND (
AND (
`po`.`level_flag` > (
`po`.`level_flag` > (
...
@@ -240,9 +186,6 @@
...
@@ -240,9 +186,6 @@
#{item}
#{item}
</foreach>
</foreach>
</if>
</if>
<iftest="typeParentId != null and typeParentId !=''">
and vecs.type_parent_id=#{typeParentId}
</if>
<iftest="sizeNameList!=null and sizeNameList.size() > 0">
<iftest="sizeNameList!=null and sizeNameList.size() > 0">
t.org_id_int,t.property,t.org_name,t.org_code,t.type_id,t.type_name,t.size_id,t.size_name,t.location_type,t.location_id,max(t.location_name) as location_name,sum(t.number) as number,t.unit_price,sum(t.price)as price,sum(t.stock_number)as stock_number,sum(t.outbound_number)as outbound_number,
sum(t.destruction_number)as destruction_number,sum(t.expire_number)as expire_number,sum(t.broken_number)as broken_number,sum(t.fix_number)as fix_number,sum(t.use_number)as use_number FROM (
SELECT
bi.org_id_int as org_id_int,
COALESCE(bi.property, 0) as property,
po.org_name as org_name,
po.org_code as org_code,
bi.type_id as type_id,
t.name as type_name,
bi.size_id as size_id,
s.name as size_name,
COALESCE(bcb.cabinet_id, bw.id) as location_id,
COALESCE(MAX(bc.name), MAX(bw.name)) as location_name,
bi.location_type as location_type,
SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) + SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END)+sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end) as number,
bi.price as unit_price,
(SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) + SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END)+sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end))*bi.price as price,
SUM(CASE WHEN bi.location_type=0 and location_state = "in" and bi.state !="broken" THEN 1
when bi.location_type=1 and location_state="in" then 1 ELSE 0 END) AS stock_number,
SUM(CASE WHEN location_state = "out" and bi.state != "destory" THEN 1 ELSE 0 END) AS outbound_number,
sum(case when bi.state = "destory" then 1 else 0 end) as destruction_number,
sum(case when bi.warranty_period = 0 then 0 when DATE_ADD(bi.production_date, INTERVAL bi.warranty_period MONTH) < NOW() and bi.state!="broken" then 1 else 0 end) as expire_number,
sum(case when bi.location_type=0 and bi.state = "broken" and bi.location_state = "in" then 1 else 0 end) as broken_number,
sum(case when bi.state = "repair" and bi.location_state = "out" then 1 else 0 end) as fix_number,
sum(case when bi.bussiness_state = "use" and bi.location_state = "out" then 1 else 0 end) as use_number
FROM base_inventory bi
LEFT JOIN base_cabinet_box bcb ON bi.location_id = bcb.id and bi.location_type=1
LEFT JOIN base_cabinet bc ON bcb.cabinet_id = bc.id
LEFT JOIN base_warehouse bw ON bi.location_id = bw.id AND bi.location_type = 0
JOIN base_equipment_type t ON t.id = bi.type_id
JOIN base_equipment_size s ON s.id = bi.size_id
JOIN pub_org po ON bi.org_id_int = po.org_id
and po.org_id=#{orgId}
where bi.location_id=#{locationId}
GROUP BY bi.org_id_int, location_id, type_id, size_id, bi.price, bi.location_type,bi.property
ORDER BY org_id_int, location_id) as t
GROUP BY t.org_id_int,t.location_id,t.type_id,t.size_id,t.location_type,t.unit_price,t.property
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t1
) AS t1
JOIN (
CROSS JOIN (
SELECT
SELECT
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
...
@@ -84,7 +67,7 @@
...
@@ -84,7 +67,7 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
JOIN pub_org po ON vpss.org_id_int = po.org_id AND po.del_flag = 1
JOIN pub_org po ON vpss.org_id_int = po.org_id
WHERE
WHERE
vpss.year = #{year}
vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
...
@@ -92,6 +75,7 @@
...
@@ -92,6 +75,7 @@
FROM vie_price_sum_summary
FROM vie_price_sum_summary
WHERE year = 2025 AND month IS NOT NULL
WHERE year = 2025 AND month IS NOT NULL
)
)
AND po.del_flag = 1
AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
<iftest="typeIdsList!=null and typeIdsList.size() > 0">
<iftest="typeIdsList!=null and typeIdsList.size() > 0">
and vpss.type_id in
and vpss.type_id in
...
@@ -109,7 +93,7 @@
...
@@ -109,7 +93,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -118,140 +102,14 @@
...
@@ -118,140 +102,14 @@
FROM
FROM
pub_org
pub_org
WHERE
WHERE
(org_id = #{orgId} OR org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
org_id = #{orgId}
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND (po.org_id = #{orgId} OR po.org_parent_ids LIKE CONCAT( '%', #{orgId}, '%' ))-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- select COALESCE(t2.start_num,0) as start_num,COALESCE(t2.start_price,0) as start_price,COALESCE(t1.end_num,0) as end_num,-->
<!-- COALESCE(t1.end_price,0) as end_price,t1.destory_num,t1.destory_price,t1.type_name,t1.type_id,t1.size_name,t1.size_id,-->
<!-- COALESCE(end_num,0)-COALESCE(start_num,0) as add_num,COALESCE(end_price,0)-COALESCE(start_price,0) as add_price-->
<!-- FROM(-->
<!-- SELECT-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.end_num, 0 ) ELSE 0 END ) AS end_num,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.end_price, 0 ) ELSE 0 END ) AS end_price,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.destory_num, 0 ) ELSE 0 END ) AS destory_num,-->
<!-- sum( CASE WHEN vpss.MONTH = MONTH ( CURRENT_DATE ()) THEN COALESCE ( vpss.destory_price, 0 ) ELSE 0 END ) AS destory_price,vpss.type_name,vpss.type_id,vpss.size_name,vpss.size_id-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE `po`.`del_flag` = 1 and po.org_id =#{orgId}-->
<!-- GROUP BY vpss.type_id,vpss.type_name,vpss.size_name,vpss.size_id-->
<!-- ORDER BY vpss.type_id-->
<!-- ) as t1-->
<!-- left join(-->
<!-- SELECT-->
<!-- SUM(COALESCE ( start_num, 0 )) AS start_num,-->
<!-- SUM(COALESCE ( start_price, 0 )) AS start_price, vpss.type_name,vpss.type_id,vpss.size_name,vpss.size_id-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = 3-->
<!-- and `po`.`del_flag` = 1 and po.org_id =#{orgId}-->
<!-- GROUP BY vpss.type_id,vpss.type_name,vpss.size_name,vpss.size_id-->
<!-- ORDER BY vpss.type_id-->
<!-- ) as t2 on t1.type_id =t2.type_id and t1.type_name=t2.type_name and t1.size_id =t2.size_id and t1.size_name=t2.size_name-->
<!-- <if test="column != null and column != '' and order != null and order != '' ">-->
<!-- order by ${column} ${order}-->
<!-- </if>-->
<!-- <if test="column==null and order == null">-->
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN (
left JOIN pub_org po ON vpss.org_id_int = po.org_id
SELECT org_id
WHERE del_flag = 1 and (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
FROM pub_org
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
WHERE del_flag = 1
AND org_id != #{orgId}
AND org_parent_ids LIKE CONCAT('%', #{orgId}, '%')
AND (case when #{levelFlag} >=3 then 1=1 else SUBSTRING(org_code, 5, 2) = '00' end )
AND (
AND (
level_flag > (SELECT level_flag FROM pub_org WHERE org_id = #{orgId}) + 1
`po`.`level_flag` > (
OR level_flag = (SELECT level_flag FROM pub_org WHERE org_id = #{orgId})
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
)
) + 1
) po ON vpss.org_id_int = po.org_id
OR (`po`.`level_flag` = (
WHERE
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
vpss.year = #{year}
))))
and vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MIN(month)
SELECT MIN(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -317,19 +172,17 @@
...
@@ -317,19 +172,17 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN (
left JOIN pub_org po ON vpss.org_id_int = po.org_id
SELECT org_id
WHERE del_flag = 1 and (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
FROM pub_org
AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))
WHERE del_flag = 1
AND org_id != #{orgId}
AND org_parent_ids LIKE CONCAT('%', #{orgId}, '%')
AND (case when #{levelFlag} >=3 then 1=1 else SUBSTRING(org_code, 5, 2) = '00' end )
AND (
AND (
level_flag > (SELECT level_flag FROM pub_org WHERE org_id = #{orgId}) + 1
`po`.`level_flag` > (
OR level_flag = (SELECT level_flag FROM pub_org WHERE org_id = #{orgId})
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
)) po ON vpss.org_id_int = po.org_id
) + 1
WHERE
OR (`po`.`level_flag` = (
vpss.year = #{year}
SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}
))))
AND vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MAX(month)
SELECT MAX(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -352,7 +205,7 @@
...
@@ -352,7 +205,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -361,104 +214,9 @@
...
@@ -361,104 +214,9 @@
FROM
FROM
pub_org
pub_org
WHERE
WHERE
(org_id = #{orgId} OR org_parent_ids LIKE CONCAT('%', #{orgId}, '%'))
org_id = #{orgId} and level_flag is not null ORDER BY `level_flag` LIMIT 1
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND (po.org_id != #{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')-->
<!-- AND(case when #{levelFlag} >=3 then 1=1 else SUBSTRING(`po`.`org_code`, 5, 2) = '00' end ))-->
<!-- AND (-->
<!-- `po`.`level_flag` > (-->
<!-- SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}-->
<!-- ) + 1-->
<!-- OR (`po`.`level_flag` = (-->
<!-- SELECT `level_flag` FROM `pub_org` WHERE `org_id` = #{orgId}-->
<!-- ))))-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- <if test="typeName!=null and typeName!=''">-->
<!-- and type_name like CONCAT('%', #{typeName}, '%')-->
<!-- </if>-->
<!-- ) AS t2-->
<!-- join (-->
<!-- SELECT `org_id`,`org_code`,org_name,d_name FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1-->
<!-- ) as t3;-->
</select>
</select>
...
@@ -485,11 +243,11 @@
...
@@ -485,11 +243,11 @@
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
COALESCE(SUM(COALESCE(start_price, 0)), 0) AS start_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN pub_org po ON vpss.org_id_int = po.org_id
left JOIN pub_org po ON vpss.org_id_int = po.org_id
AND po.del_flag = 1
AND po.org_id = #{orgId}
WHERE
WHERE
vpss.year = #{year}
po.org_id = #{orgId}
and vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MIN(month)
SELECT MIN(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -512,7 +270,7 @@
...
@@ -512,7 +270,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t1
) AS t1
JOIN (
CROSS JOIN (
SELECT
SELECT
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_num, 0)), 0) AS end_num,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
COALESCE(SUM(COALESCE(end_price, 0)), 0) AS end_price,
...
@@ -520,11 +278,10 @@
...
@@ -520,11 +278,10 @@
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
COALESCE(SUM(COALESCE(destory_price, 0)), 0) AS destory_price
FROM
FROM
vie_price_sum_summary vpss
vie_price_sum_summary vpss
INNER JOIN pub_org po ON vpss.org_id_int = po.org_id
left JOIN pub_org po ON vpss.org_id_int = po.org_id
AND po.del_flag = 1
AND po.org_id = #{orgId}
WHERE
WHERE
vpss.year = #{year}
po.org_id = #{orgId}
AND vpss.year = #{year}
AND vpss.month = (
AND vpss.month = (
SELECT MAX(month)
SELECT MAX(month)
FROM vie_price_sum_summary
FROM vie_price_sum_summary
...
@@ -547,7 +304,7 @@
...
@@ -547,7 +304,7 @@
and vpss.type_name like CONCAT('%', #{typeName}, '%')
and vpss.type_name like CONCAT('%', #{typeName}, '%')
</if>
</if>
) AS t2
) AS t2
JOIN (
CROSS JOIN (
SELECT
SELECT
org_id,
org_id,
org_code,
org_code,
...
@@ -557,196 +314,10 @@
...
@@ -557,196 +314,10 @@
pub_org
pub_org
WHERE
WHERE
org_id = #{orgId}
org_id = #{orgId}
AND level_flag IS NOT NULL
ORDER BY
level_flag
LIMIT 1
) AS t3;
) AS t3;
<!-- SELECT-->
<!-- t1.start_num,t1.start_price,t2.end_num,t2.end_price,t2.end_num - t1.start_num AS add_num,-->
<!-- t2.end_price - t1.start_price AS add_price, t2.destory_num,t2.destory_price,t3.org_id,t3.org_code,t3.org_name,t3.d_name-->
<!-- FROM-->
<!-- (-->
<!-- SELECT-->
<!-- COALESCE (SUM(COALESCE ( start_num, 0 )),0) AS start_num,-->
<!-- COALESCE (SUM(COALESCE ( start_price, 0 )),0) AS start_price-->
<!-- FROM-->
<!-- vie_price_sum_summary vpss-->
<!-- LEFT JOIN pub_org po ON vpss.org_id_int = po.org_id-->
<!-- WHERE-->
<!-- vpss.MONTH = (select `month` FROM vie_price_sum_summary where year=#{year} and month is not null ORDER BY month asc limit 1) and vpss.year=#{year}-->
<!-- AND po.del_flag = 1-->
<!-- AND org_id_int = #{orgId}-->
<!-- <if test="typeIdsList!=null and typeIdsList.size() > 0">-->
<!-- <if test="typeName!=null and typeName!=''">-->
<!-- and type_name like CONCAT('%', #{typeName}, '%')-->
<!-- </if>-->
<!-- ) AS t2-->
<!-- join (-->
<!-- SELECT `org_id`,`org_code`,org_name,d_name FROM `pub_org` WHERE (`org_id` = #{orgId} OR `org_parent_ids` LIKE CONCAT('%', #{orgId}, '%')) and level_flag is not null ORDER BY `level_flag` LIMIT 1-->
<iftest="req.typeName != null and req.typeName != ''">
AND vw.type_name like concat('%',#{req.typeName},'%')
</if>
</where>
GROUP BY
vw.id,
vw.size_id,
vw.type_id,
vw.warranty_type,
vw.location_id,
vw.org_id,
vw.location_type,
vw.price,
vw.property) as a
inner join base_inventory_summary as ins on a.org_id=ins.org_id_int and a.location_id=ins.location_id and a.type_id=ins.type_id and a.size_id=ins.size_id and a.price=ins.unit_price and a.property=ins.property