供应商查询 sql 修改
This commit is contained in:
@ -128,12 +128,6 @@ public class CoscoEvaluateTaskServiceImpl implements ICoscoEvaluateTaskService {
|
||||
vo.setType(userNdTypeVos1.get(0).getType());
|
||||
List<String> indicatorIds = userNdTypeVos1.stream().map(UserNdTypeVo::getNeId).collect(Collectors.toList());
|
||||
vo.setIndicatorIds(indicatorIds);
|
||||
// if (EvaluateTaskConstant.INDICATOR_TYPE_ND_1.equals(vo.getType())) {
|
||||
//
|
||||
// } else {
|
||||
// vo.setIndicatorIds(new ArrayList<>());
|
||||
// }
|
||||
|
||||
vos.add(vo);
|
||||
});
|
||||
List<String> supplierIds = list.stream().map(TaskSupplierVo::getId).collect(Collectors.toList());
|
||||
|
@ -894,94 +894,88 @@
|
||||
|
||||
<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
|
||||
csb.id,
|
||||
csb.supplier_type as supplierType,
|
||||
MAX(csb.name) AS name,
|
||||
MAX(csb.social_credit_code) AS socialCreditCode,
|
||||
MAX(cas.dept_id) AS deptId,
|
||||
MAX(caw.id) AS accessWorkId,
|
||||
MAX(caw.update_time) AS admissionTime,
|
||||
MAX(category_info.categoryName) AS categoryName,
|
||||
MAX(cetss.level_name) AS levelName,
|
||||
MAX(cetss.update_time) AS evaluationTime
|
||||
FROM
|
||||
cosco_access_supplier cas
|
||||
LEFT JOIN cosco_supplier_base csb ON csb.id = cas.supplier_id
|
||||
LEFT JOIN cosco_access_work caw ON cas.access_work_id = caw.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
|
||||
cets.supplier_id,
|
||||
cets.level_name,
|
||||
cet.update_time
|
||||
FROM
|
||||
cosco_evaluate_task cet
|
||||
JOIN cosco_evaluate_task_supplier cets ON cet.id = cets.evaluate_task_id
|
||||
JOIN (
|
||||
SELECT
|
||||
cets_inner.supplier_id,
|
||||
MAX(cet_inner.update_time) AS max_update_time
|
||||
FROM
|
||||
cosco_evaluate_task cet_inner
|
||||
JOIN cosco_evaluate_task_supplier cets_inner ON cet_inner.id = cets_inner.evaluate_task_id
|
||||
WHERE
|
||||
cet_inner.approve_status = 1
|
||||
cac.access_work_id,
|
||||
GROUP_CONCAT(cc.id SEPARATOR ', ') AS categoryId,
|
||||
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 cet_inner.dept_id IN
|
||||
AND cac.dept_id IN
|
||||
<foreach item="dept" collection="vo.deptList" open="(" separator="," close=")">
|
||||
#{dept}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
cets_inner.supplier_id
|
||||
) latest ON latest.supplier_id = cets.supplier_id
|
||||
AND latest.max_update_time = cet.update_time
|
||||
WHERE
|
||||
cet.approve_status = 1
|
||||
) cetss ON cetss.supplier_id = csb.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
casc.supplier_id,
|
||||
GROUP_CONCAT(casc.category_id SEPARATOR ', ') AS categoryId,
|
||||
GROUP_CONCAT(cc.category_name SEPARATOR ', ') AS categoryName
|
||||
FROM
|
||||
cosco_access_supplier_category casc
|
||||
JOIN cosco_category cc ON cc.id = casc.category_id
|
||||
WHERE 1 = 1
|
||||
<if test="vo.deptList != null and vo.deptList.size > 0">
|
||||
AND casc.dept_id IN
|
||||
<foreach item="dept" collection="vo.deptList" open="(" separator="," close=")">
|
||||
#{dept}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
casc.supplier_id
|
||||
) category_info ON category_info.supplier_id = csb.id
|
||||
|
||||
WHERE
|
||||
cas.access_status = 1
|
||||
<if test="vo.name != null and vo.name != ''">
|
||||
and csb.name like concat('%', #{vo.name}, '%')
|
||||
</if>
|
||||
<if test="vo.supplierType != null and vo.supplierType != ''">
|
||||
and csb.supplier_type = #{vo.supplierType}
|
||||
</if>
|
||||
AND csb.del_flag = 'normal'
|
||||
GROUP BY cac.access_work_id
|
||||
) AS c ON c.access_work_id = caw.id
|
||||
|
||||
-- 获取每个供应商最新的已审批通过的评价记录
|
||||
LEFT JOIN (
|
||||
SELECT ts1.*
|
||||
FROM cosco_evaluate_task_supplier ts1
|
||||
JOIN cosco_evaluate_task tsk1 ON ts1.evaluate_task_id = tsk1.id
|
||||
WHERE tsk1.approve_status = 1
|
||||
AND ts1.del_flag = 'normal'
|
||||
AND tsk1.del_flag = 'normal'
|
||||
AND ts1.create_time = (
|
||||
SELECT MAX(ts2.create_time)
|
||||
FROM cosco_evaluate_task_supplier ts2
|
||||
JOIN cosco_evaluate_task tsk2 ON ts2.evaluate_task_id = tsk2.id
|
||||
WHERE ts2.supplier_id = ts1.supplier_id
|
||||
AND tsk2.approve_status = 1
|
||||
AND ts2.del_flag = 'normal'
|
||||
AND tsk2.del_flag = 'normal'
|
||||
-- 添加当前搜索部门上下所有id
|
||||
<if test="vo.deptList != null and vo.deptList.size > 0">
|
||||
AND cas.dept_id IN
|
||||
AND tsk2.dept_id IN
|
||||
<foreach item="dept" collection="vo.deptList" open="(" separator="," close=")">
|
||||
#{dept}
|
||||
</foreach>
|
||||
</if>
|
||||
AND csb.id NOT IN (
|
||||
SELECT
|
||||
cbs.supplier_id
|
||||
FROM
|
||||
cosco_blacklist cb
|
||||
JOIN cosco_blacklist_supplier cbs ON cb.id = cbs.blacklist_id
|
||||
WHERE
|
||||
cb.approve_status = 2
|
||||
AND cb.restore_approve_status != 2
|
||||
)
|
||||
) ets ON ets.supplier_id = csb.id
|
||||
-- 黑名单排除
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM cosco_blacklist_supplier b
|
||||
JOIN cosco_blacklist cb ON cb.id = b.blacklist_id
|
||||
WHERE b.supplier_id = csb.id
|
||||
AND cb.approve_status = 1
|
||||
AND cb.restore_approve_status != 1
|
||||
-- 添加当前部门及上级部门id
|
||||
<if test="vo.blackListDept != null and vo.blackListDept.size > 0">
|
||||
AND cb.dept_id IN
|
||||
<foreach item="dept" collection="vo.blackListDept" open="(" separator="," close=")">
|
||||
@ -996,14 +990,14 @@
|
||||
and cas.dept_id = #{vo.deptId}
|
||||
</if>
|
||||
<if test="vo.categoryId!=null and vo.categoryId!=''">
|
||||
and category_info.categoryId like concat('%',#{vo.categoryId},'%')
|
||||
and c.categoryId like concat('%',#{vo.categoryId},'%')
|
||||
</if>
|
||||
<if test="vo.levelName!=null and vo.levelName!=''">
|
||||
and cetss.level_name = #{vo.levelName}
|
||||
and ets.level_name = #{vo.levelName}
|
||||
</if>
|
||||
|
||||
GROUP BY
|
||||
csb.id
|
||||
) t
|
||||
WHERE t.rn = 1
|
||||
|
||||
</select>
|
||||
<select id="selectSupplierByIds" parameterType="list"
|
||||
|
Reference in New Issue
Block a user