代码优化

This commit is contained in:
TL
2025-07-14 13:47:48 +08:00
parent e0f14aa4bf
commit 849bbe998b
18 changed files with 247 additions and 229 deletions

View File

@ -62,7 +62,7 @@
) as c on c.access_work_id = caw.id
WHERE
cas.supplier_id = #{vo.supplierId}
cas.supplier_id = #{vo.supplierId} AND cas.access_status IN (1,2)
<if test="vo.categoryNames != null and vo.categoryNames != ''">
and c.categoryNames like concat('%', #{vo.categoryNames}, '%')
</if>
@ -75,7 +75,6 @@
<if test="vo.endTime!=null and vo.endTime != ''">
and caw.update_time &lt;= #{vo.endTime}
</if>
AND cas.access_status IN (1,2)
ORDER BY caw.update_time desc
</select>

View File

@ -47,9 +47,10 @@
WHEN w.access_type = 'scattered' THEN '零星采购/应急采购/个人供应商'
ELSE w.access_type
END AS access_type_text,
w.access_desc,
w.start_time,
w.end_time,
w.review_status,
w.approve_status,
CASE
WHEN w.review_status = 0 THEN '未开始'
WHEN w.review_status = 1 THEN '进行中'
@ -63,7 +64,6 @@
WHEN w.approve_status = 2 THEN '驳回'
ELSE CAST(w.approve_status AS CHAR)
END AS approve_status_text,
w.approve_status,
w.work_flow_id,
w.create_by,
w.create_time,
@ -76,49 +76,45 @@
<sql id="selectCoscoAccessWorkGroupVo">
<sql id="selectCoscoAccessWorkUserReview">
select
IFNULL(cau.is_leader, 0) AS isLeader,
w.id,
w.access_work_name,
w.dept_id,
w.access_type,
CASE
WHEN w.access_type = 'online' THEN '线上准入'
WHEN w.access_type = 'offline' THEN '线下准入'
WHEN w.access_type = 'scattered' THEN '零星采购/应急采购/个人供应商'
ELSE w.access_type
END AS access_type_text,
w.start_time,
w.end_time,
w.review_status,
w.approve_status,
CASE
WHEN w.review_status = 0 THEN '未开始'
WHEN w.review_status = 1 THEN '进行中'
WHEN w.review_status = 2 THEN '结果汇总中'
WHEN w.review_status = 3 THEN '已完成'
ELSE CAST(w.review_status AS CHAR)
END AS review_status_text,
CASE
WHEN w.approve_status = 0 THEN '审批中'
WHEN w.approve_status = 1 THEN '通过'
WHEN w.approve_status = 2 THEN '驳回'
ELSE CAST(w.approve_status AS CHAR)
END AS approve_status_text,
w.work_flow_id,
w.create_by,
w.create_time,
w.update_by,
w.update_time,
w.last_update_time
cau.is_leader,
w.id,
w.access_work_name,
w.dept_id,
w.access_type,
CASE
WHEN w.access_type = 'online' THEN '线上准入'
WHEN w.access_type = 'offline' THEN '线下准入'
WHEN w.access_type = 'scattered' THEN '零星采购/应急采购/个人供应商'
ELSE w.access_type
END AS access_type_text,
w.start_time,
w.end_time,
w.review_status,
w.approve_status,
CASE
WHEN w.review_status = 0 THEN '未开始'
WHEN w.review_status = 1 THEN '进行中'
WHEN w.review_status = 2 THEN '结果汇总中'
WHEN w.review_status = 3 THEN '已完成'
ELSE CAST(w.review_status AS CHAR)
END AS review_status_text,
CASE
WHEN w.approve_status = 0 THEN '审批中'
WHEN w.approve_status = 1 THEN '通过'
WHEN w.approve_status = 2 THEN '驳回'
ELSE CAST(w.approve_status AS CHAR)
END AS approve_status_text,
w.work_flow_id,
w.create_by,
w.create_time,
w.update_by,
w.update_time,
w.last_update_time
FROM
cosco_access_work w
left join cosco_access_user cau on w.id = cau.access_work_id and cau.is_leader = 1
left join cosco_access_category cac on cac.access_work_id = w.id
<if test="vo.userId != null and vo.userId != ''">
and cau.user_id = #{vo.userId}
</if>
left join cosco_access_user cau on w.id = cau.access_work_id
</sql>
<select id="selectCoscoAccessCategoryList"
@ -129,11 +125,18 @@
where c.access_work_id = #{accessWorkId}
</select>
<select id="selectPageList" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoAccessWork" resultMap="CoscoAccessWorkResult">
<include refid="selectCoscoAccessWorkGroupVo"/>
<include refid="selectCoscoAccessWorkVo"/>
<where>
and w.del_flag = 'normal'
<if test="vo.categoryId != null and vo.categoryId != ''">
and cac.category_id = #{vo.categoryId}
AND EXISTS (
SELECT 1 FROM cosco_access_category
WHERE access_work_id = w.id
AND category_id = #{vo.categoryId}
)
</if>
<if test="vo.createBy != null and vo.createBy != ''">
and w.create_by = #{vo.createBy}
</if>
<if test="vo.accessWorkName != null and vo.accessWorkName != ''">
and w.access_work_name like concat('%', #{vo.accessWorkName}, '%')
@ -169,13 +172,60 @@
order by w.create_time desc
</select>
<select id="selectCoscoAccessWorkUserReviewPage" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoAccessWork" resultMap="CoscoAccessWorkResult">
<include refid="selectCoscoAccessWorkUserReview"/>
<where>
and w.del_flag = 'normal' and cau.user_id = #{vo.userId}
<if test="vo.categoryId != null and vo.categoryId != ''">
AND EXISTS (
SELECT 1 FROM cosco_access_category
WHERE access_work_id = w.id
AND category_id = #{vo.categoryId}
)
</if>
<if test="vo.createBy != null and vo.createBy != ''">
and w.create_by = #{vo.createBy}
</if>
<if test="vo.accessWorkName != null and vo.accessWorkName != ''">
and w.access_work_name like concat('%', #{vo.accessWorkName}, '%')
</if>
<if test="vo.deptId != null and vo.deptId != ''">
and w.dept_id = #{vo.deptId}
</if>
<if test="vo.applyType != null and vo.applyType != ''">
and w.apply_type = #{vo.applyType}
</if>
<if test="vo.accessType != null and vo.accessType != ''">
and w.access_type = #{vo.accessType}
</if>
<if test="vo.startTime != null ">
and w.start_time = #{vo.startTime}
</if>
<if test="vo.endTime != null ">
and w.end_time = #{vo.endTime}
</if>
<if test="vo.reviewStatus != null ">
and w.review_status = #{vo.reviewStatus}
</if>
<if test="vo.approveStatus != null ">
and w.approve_status = #{vo.approveStatus}
</if>
</where>
order by w.create_time desc
</select>
<select id="selectCoscoAccessWorkList" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoAccessWork" resultMap="CoscoAccessWorkResult">
<include refid="selectCoscoAccessWorkGroupVo"/>
<include refid="selectCoscoAccessWorkVo"/>
<where>
and w.del_flag = 'normal'
<if test="vo.categoryId != null and vo.categoryId != ''">
and cac.category_id = #{vo.categoryId}
AND EXISTS (
SELECT 1 FROM cosco_access_category
WHERE access_work_id = w.id
AND category_id = #{vo.categoryId}
)
</if>
<if test="vo.accessWorkName != null and vo.accessWorkName != ''">
and w.access_work_name like concat('%', #{vo.accessWorkName}, '%')
@ -214,11 +264,15 @@
<select id="selectApproveList" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoAccessWork" resultMap="CoscoAccessWorkResult">
<include refid="selectCoscoAccessWorkGroupVo"/>
<include refid="selectCoscoAccessWorkVo"/>
<where>
and w.del_flag = 'normal'
<if test="vo.categoryId != null and vo.categoryId != ''">
and cac.category_id = #{vo.categoryId}
AND EXISTS (
SELECT 1 FROM cosco_access_category
WHERE access_work_id = w.id
AND category_id = #{vo.categoryId}
)
</if>
<if test="vo.accessWorkName != null and vo.accessWorkName != ''">
and w.access_work_name like concat('%', #{vo.accessWorkName}, '%')

View File

@ -160,6 +160,7 @@
cas.access_work_id,
cas.supplier_id,
csb.`name`,
csb.name_en,
caw.update_time,
cas.access_status,
CASE cas.access_status
@ -169,14 +170,14 @@
END AS access_status_cn
FROM
cosco_access_supplier cas
LEFT JOIN cosco_access_work caw ON cas.access_work_id = caw.id
LEFT JOIN cosco_supplier_base csb ON cas.supplier_id = csb.id
LEFT JOIN cosco_access_work caw ON cas.access_work_id = caw.id and caw.del_flag = 'normal'
LEFT JOIN cosco_supplier_base csb ON cas.supplier_id = csb.id and csb.del_flag = 'normal'
left join (
SELECT
cac.access_work_id,
GROUP_CONCAT(cc.category_name SEPARATOR ', ') AS categoryName
FROM cosco_access_category cac
INNER JOIN cosco_category cc ON cac.category_id = cc.id
INNER JOIN cosco_category cc ON cac.category_id = cc.id and cc.del_flag = 'normal'
GROUP BY cac.access_work_id
) as c on c.access_work_id = caw.id
left join dict_project dp on csb.enterprise_type = dp.`code` and dp.parent_code = 'enterprise_type'
@ -191,33 +192,32 @@
WHEN csb.supplier_type = 'pe' THEN id_card
ELSE NULL
END AS unified_code,
CASE
WHEN csb.supplier_type = 'ovs' THEN name_en
ELSE name
END AS name
csb.name,
csb.name_en
FROM
cosco_supplier_base csb
left join (
SELECT
cas.supplier_id
FROM
cosco_access_work caw
LEFT JOIN cosco_access_supplier cas ON caw.id = cas.access_work_id
WHERE
(
caw.approve_status IS NULL
OR caw.approve_status = 0
OR ( caw.approve_status = 1 AND cas.access_status = 1 ))
AND cas.dept_id in
<foreach item="item" collection="vo.deptIdList" open="(" separator="," close=")">
#{item}
</foreach>
SELECT
cas.supplier_id
FROM
cosco_access_work caw
LEFT JOIN cosco_access_supplier cas ON caw.id = cas.access_work_id
WHERE
(
caw.approve_status IS NULL
OR caw.approve_status = 0
OR ( caw.approve_status = 1 AND cas.access_status = 1 )
)
AND cas.dept_id in
<foreach item="item" collection="vo.deptIdList" open="(" separator="," close=")">
#{item}
</foreach>
) b on csb.id = b.supplier_id
</sql>
<select id="selectWzrPageList" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierBase" resultMap="CoscoSupplierBaseResult">
<include refid="selecWzrListVo"/>
where b.supplier_id is null
where b.supplier_id is null and csb.del_flag = 'normal'
<if test="vo.name != null and vo.name != ''">
and csb.name = #{vo.name} or csb.name_en = #{vo.name}
</if>
@ -473,14 +473,6 @@
and csb.last_update_time = #{lastUpdateTime}
</if>
</where>
GROUP BY
cas.id,
cas.access_work_id,
cas.supplier_id,
csb.`name`,
caw.update_time ,
csb.enterprise_type,
dp.dic_name
order by csb.create_time desc
</select>
@ -517,78 +509,9 @@
<if test="nameEn != null and nameEn != ''">
and name_en = #{nameEn}
</if>
<if test="socialCreditCode != null and socialCreditCode != ''">
and social_credit_code = #{socialCreditCode}
</if>
<if test="range != null and range != ''">
and `range` = #{range}
</if>
<if test="regAddress != null and regAddress != ''">
and reg_address = #{regAddress}
</if>
<if test="workAddress != null and workAddress != ''">
and work_address = #{workAddress}
</if>
<if test="parentCompanyInvestor != null and parentCompanyInvestor != ''">
and parent_company_investor = #{parentCompanyInvestor}
</if>
<if test="legalPerson != null and legalPerson != ''">
and legal_person = #{legalPerson}
</if>
<if test="idCard != null and idCard != ''">
and id_card = #{idCard}
</if>
<if test="capital != null ">
and capital = #{capital}
</if>
<if test="contactsName != null and contactsName != ''">
and contacts_name like concat('%', #{contactsName}, '%')
</if>
<if test="contactsPhone != null and contactsPhone != ''">
and contacts_phone = #{contactsPhone}
</if>
<if test="contactsType != null and contactsType != ''">
and contacts_type = #{contactsType}
</if>
<if test="contactsEmail != null and contactsEmail != ''">
and contacts_email = #{contactsEmail}
</if>
<if test="telephone != null and telephone != ''">
and telephone = #{telephone}
</if>
<if test="nation != null and nation != ''">
and nation = #{nation}
</if>
<if test="vat != null and vat != ''">
and vat = #{vat}
</if>
<if test="taxpayerId != null and taxpayerId != ''">
and taxpayer_id = #{taxpayerId}
</if>
<if test="currency != null and currency != ''">
and currency = #{currency}
</if>
<if test="personName != null and personName != ''">
and person_name like concat('%', #{personName}, '%')
</if>
<if test="personPhone != null and personPhone != ''">
and person_phone = #{personPhone}
</if>
<if test="personBank != null and personBank != ''">
and person_bank = #{personBank}
</if>
<if test="personAccount != null and personAccount != ''">
and person_account = #{personAccount}
</if>
<if test="accessStatus != null ">
and access_status = #{accessStatus}
</if>
<if test="blacklistStatus != null ">
and blacklist_status = #{blacklistStatus}
</if>
<if test="greylistStatus != null ">
and greylist_status = #{greylistStatus}
</if>
<if test="fillinStatus != null ">
and fillin_status = #{fillinStatus}
</if>
@ -602,6 +525,7 @@
and last_update_time = #{lastUpdateTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectCoscoSupplierBaseById" parameterType="String"

View File

@ -25,9 +25,11 @@
<result property="title" column="title"/>
<result property="changeDesc" column="change_desc"/>
<result property="enterpriseTypeCn" column="enterprise_type_cn"/>
<collection property="coscoSupplierChangeHistoryList" ofType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierChangeHistory"
resultMap="CoscoSupplierChangeHistoryResult"/>
<collection property="coscoSupplierChangeHistoryList"
column="{supplierChangeApplyId=id}"
ofType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierChangeHistory"
select="selectcoscoSupplierChangeHistoryList"/>
</resultMap>
<resultMap type="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierChangeHistory" id="CoscoSupplierChangeHistoryResult">
@ -45,7 +47,10 @@
SELECT
c.id,
c.supplier_id,
sb.`name` AS supplierName,
CASE
WHEN supplier_type = 'ovs' THEN name_en
ELSE sb.`name`
END AS supplierName,
CASE
WHEN sb.supplier_type = 'dvs' THEN
'境内企业'
@ -72,23 +77,14 @@
c.last_update_time,
c.title,
c.change_desc ,
wo.maxTime as update_time,
wo.deptNames,
csch.table_name,
csch.field_name,
csch.field_annotation,
csch.old_value,
csch.new_value
wo.maxTime as update_time
FROM
cosco_supplier_change_apply c
LEFT JOIN cosco_supplier_base sb ON c.supplier_id = sb.id
left join cosco_supplier_change_history csch on csch.supplier_change_apply_id = c.id
left join (
SELECT
cas.supplier_id,
MAX(w.update_time) AS maxTime,
GROUP_CONCAT(DISTINCT w.dept_id SEPARATOR ',') AS deptNames
MAX(w.update_time) AS maxTime
FROM
cosco_access_work w
LEFT JOIN
@ -100,6 +96,14 @@
) wo on wo.supplier_id = sb.id
</sql>
<select id="selectcoscoSupplierChangeHistoryList"
parameterType="map"
resultMap="CoscoSupplierChangeHistoryResult">
select id, supplier_change_apply_id, table_name, field_name, field_annotation, old_value, new_value, del_flag, create_by, create_time, update_by, update_time, last_update_time
from cosco_supplier_change_history
where supplier_change_apply_id = #{supplierChangeApplyId} and del_flag = 'normal'
</select>
<select id="selectPageList" parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscosupplier.entity.CoscoSupplierChangeApply" resultMap="CoscoSupplierChangeApplyResult">
SELECT
@ -116,7 +120,10 @@
WHEN sb.supplier_type = 'pe' THEN
'个人'
END AS supplier_type,
sb.`name` AS supplierName,
CASE
WHEN supplier_type = 'ovs' THEN name_en
ELSE sb.`name`
END AS supplierName,
sb.enterprise_type,
dp.dic_name as enterprise_type_cn,
c.change_by,
@ -140,17 +147,17 @@
LEFT JOIN cosco_supplier_base sb ON c.supplier_id = sb.id
left join dict_project dp on sb.enterprise_type = dp.`code` and dp.parent_code = 'enterprise_type'
left join (
SELECT
cas.supplier_id,
MAX(w.update_time) AS maxTime
FROM
cosco_access_work w
LEFT JOIN
cosco_access_supplier cas ON w.id = cas.access_work_id
WHERE
w.apply_type = 0
GROUP BY
cas.supplier_id
SELECT
cas.supplier_id,
MAX(w.update_time) AS maxTime
FROM
cosco_access_work w
LEFT JOIN
cosco_access_supplier cas ON w.id = cas.access_work_id
WHERE
w.apply_type = 0
GROUP BY
cas.supplier_id
) wo on wo.supplier_id = sb.id
WHERE
sb.del_flag = 'normal'
@ -194,6 +201,7 @@
and c.last_update_time = #{vo.lastUpdateTime}
</if>
</where>
order by c.create_time desc
</select>
<select id="selectCoscoSupplierChangeApplyById" parameterType="String"

View File

@ -49,6 +49,9 @@
<if test="vo.exitTheme != null and vo.exitTheme != ''">
and exit_theme like concat('%', #{vo.exitTheme}, '%')
</if>
<if test="vo.createBy != null and vo.createBy != ''">
and create_by = #{vo.createBy}
</if>
<if test="vo.exitReason != null and vo.exitReason != ''">
and exit_reason = #{vo.exitReason}
</if>