修改查询sql
This commit is contained in:
@ -895,54 +895,23 @@
|
||||
<select id="getSupplierPage" parameterType="map"
|
||||
resultType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.vo.SupplierPageVo">
|
||||
|
||||
SELECT
|
||||
|
||||
t.id,
|
||||
t.name,
|
||||
t.supplierType,
|
||||
t.socialCreditCode ,
|
||||
t.dept_id deptId,
|
||||
t.admissionTime ,
|
||||
t.accessWorkId ,
|
||||
t.categoryName ,
|
||||
t.evaluationTime ,
|
||||
t.levelName
|
||||
FROM (
|
||||
SELECT
|
||||
select
|
||||
csb.id,
|
||||
csb.name,
|
||||
csb.supplier_type AS supplierType,
|
||||
csb.social_credit_code AS socialCreditCode,
|
||||
cas.dept_id,
|
||||
caw.update_time AS admissionTime,
|
||||
caw.id AS accessWorkId,
|
||||
c.categoryName as categoryName,
|
||||
ets.update_time AS evaluationTime ,
|
||||
ets.level_name as levelName,
|
||||
ROW_NUMBER() OVER (PARTITION BY csb.id ORDER BY caw.update_time DESC) AS rn
|
||||
FROM cosco_access_supplier cas
|
||||
JOIN cosco_supplier_base csb ON csb.id = cas.supplier_id
|
||||
JOIN cosco_access_work caw ON cas.access_work_id = caw.id
|
||||
-- 品类拼接
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
cac.access_work_id,
|
||||
GROUP_CONCAT(cc.id SEPARATOR ', ') AS categoryId,
|
||||
GROUP_CONCAT(caw.dept_id) as dept_id,
|
||||
max(caw.update_time) AS admissionTime,
|
||||
max(ets.update_time) AS evaluationTime ,
|
||||
max(ets.level_name) as levelName,
|
||||
GROUP_CONCAT(DISTINCT cc.category_name SEPARATOR ', ') AS categoryName
|
||||
FROM cosco_access_category cac
|
||||
LEFT JOIN cosco_category cc ON cac.category_id = cc.id
|
||||
-- 添加当前搜索部门上下所有id
|
||||
<if test="vo.deptList != null and vo.deptList.size > 0">
|
||||
AND cac.dept_id IN
|
||||
<foreach item="dept" collection="vo.deptList" open="(" separator="," close=")">
|
||||
#{dept}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
GROUP BY cac.access_work_id
|
||||
) AS c ON c.access_work_id = caw.id
|
||||
|
||||
-- 获取每个供应商最新的已审批通过的评价记录
|
||||
from
|
||||
cosco_access_supplier_category as casc
|
||||
join cosco_supplier_base as csb on casc.supplier_id = csb.id -- 供应商已准入品类
|
||||
left join cosco_access_supplier as cas on cas.supplier_id = csb.id
|
||||
left join cosco_access_work as caw on caw.id = cas.access_work_id and caw.apply_type=1 and caw.approve_status=1
|
||||
left join cosco_category as cc on casc.category_id = cc.id
|
||||
LEFT JOIN (
|
||||
SELECT ts1.*
|
||||
FROM cosco_evaluate_task_supplier ts1
|
||||
@ -960,6 +929,7 @@
|
||||
AND tsk2.del_flag = 'normal'
|
||||
)
|
||||
) ets ON ets.supplier_id = csb.id
|
||||
|
||||
-- 黑名单排除
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
@ -976,7 +946,6 @@
|
||||
</foreach>
|
||||
</if>
|
||||
)
|
||||
and cas.access_status=1
|
||||
<if test="vo.name!=null and vo.name!=''">
|
||||
and csb.name like concat('%',#{vo.name},'%')
|
||||
</if>
|
||||
@ -984,26 +953,25 @@
|
||||
and cas.dept_id = #{vo.deptId}
|
||||
</if>
|
||||
<if test="vo.categoryId!=null and vo.categoryId!=''">
|
||||
and c.categoryId like concat('%',#{vo.categoryId},'%')
|
||||
and cc.categoryId like concat('%',#{vo.categoryId},'%')
|
||||
</if>
|
||||
<if test="vo.levelName!=null and vo.levelName!=''">
|
||||
and ets.level_name = #{vo.levelName}
|
||||
</if>
|
||||
<if test="vo.librarySupplierIdList!=null and vo.librarySupplierIdList.size>0">
|
||||
and t.id IN
|
||||
and csb.id IN
|
||||
<foreach item="id" collection="vo.librarySupplierIdList" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="vo.deptList != null and vo.deptList.size > 0">
|
||||
AND t.dept_id IN
|
||||
AND casc.dept_id IN
|
||||
<foreach item="dept" collection="vo.deptList" open="(" separator="," close=")">
|
||||
#{dept}
|
||||
</foreach>
|
||||
</if>
|
||||
) t
|
||||
WHERE t.rn = 1
|
||||
|
||||
group by csb.id
|
||||
</select>
|
||||
<select id="selectSupplierByIds" parameterType="list"
|
||||
resultType="com.chinaunicom.zyhy.ebtp.supplier.coscoBlack.vo.BlackSupplierVo">
|
||||
|
Reference in New Issue
Block a user