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