You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

539 lines
24 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.spring.modules.request.mapper.RequestManageMapper">
<select id="getRequestMainData" parameterType="com.spring.modules.request.vo.PlmRequestHeaderVo" resultType="com.spring.modules.request.vo.PlmRequestHeaderVo">
SELECT
a.site,
a.bu,
d.bu_desc,
a.classification_no,
a.classification_name,
a.menu_id,
c.name,
a.workflow_id,
b.workflowname,
a.status,
(case when a.status = 'Y' then '启用' else '停用' end) statusDesc,
a.remark,
a.create_by,
a.create_date,
a.update_by,
a.update_date
FROM plm_request_header a
LEFT JOIN [VIEW_Process_management_OA_PLM] b ON a.workflow_id = b.workflowid
LEFT JOIN sys_menu c ON a.menu_id = c.menu_id
LEFT JOIN BU d ON a.site = d.site AND a.bu = d.bu_no
<where>
<if test = "query.site != null and query.site != ''">
AND a.site like #{query.site}
</if>
<if test = "query.name != null and query.name != ''">
AND c.name like #{query.name}
</if>
<if test = "query.status != null and query.status != ''">
AND a.status = #{query.status}
</if>
<if test = "query.workflowId != null and query.workflowId != ''">
AND a.workflow_id like #{query.workflowId}
</if>
<if test = "query.workflowname != null and query.workflowname != ''">
AND b.workflowname like #{query.workflowname}
</if>
<if test = "query.classificationNo != null and query.classificationNo != ''">
AND a.workflow_id like #{query.classificationNo}
</if>
</where>
group by a.site, a.bu, d.bu_desc, a.classification_no, a.classification_name, a.menu_id, c.name, a.workflow_id,
b.workflowname, a.status, a.remark, a.create_by, a.create_date, a.update_by, a.update_date
</select>
<select id="getRequestMainDataByList" parameterType="com.spring.modules.request.vo.PlmRequestHeaderVo" resultType="com.spring.modules.request.vo.PlmRequestHeaderVo">
SELECT
a.site,
a.bu,
d.bu_desc,
a.classification_no,
a.classification_name,
a.menu_id,
c.name,
a.workflow_id,
b.workflowname,
a.status,
(case when a.status = 'Y' then '启用' else '停用' end) statusDesc,
a.remark,
a.create_by,
a.create_date,
a.update_by,
a.update_date
FROM plm_request_header a
LEFT JOIN [VIEW_Process_management_OA_PLM] b ON a.workflow_id = b.workflowid
LEFT JOIN sys_menu c ON a.site = c.site AND a.menu_id = c.menu_id
LEFT JOIN BU d ON a.site = d.site AND a.bu = d.bu_no
<where>
<if test = "query.site != null and query.site != ''">
AND a.site like #{query.site}
</if>
<if test = "query.name != null and query.name != ''">
AND c.name like #{query.name}
</if>
<if test = "query.workflowId != null and query.workflowId != ''">
AND a.workflow_id like #{query.workflowId}
</if>
<if test = "query.classificationNo != null and query.classificationNo != ''">
AND a.classification_no like #{query.classificationNo}
</if>
</where>
group by a.site, a.bu, d.bu_desc, a.classification_no, a.classification_name, a.menu_id, c.name, a.workflow_id,
b.workflowname, a.status, a.remark, a.create_by, a.create_date, a.update_by, a.update_date
</select>
<insert id="saveRequestHeader">
INSERT INTO plm_request_header (site,bu,classification_no,classification_name,workflow_id,menu_id,status,create_date,create_by,remark)
values(#{site},#{bu},#{classificationNo},#{classificationName},#{workflowId},#{menuId},#{status},#{createDate},#{createBy},#{remark})
</insert>
<update id="updateRequestHeader" parameterType="com.spring.modules.request.vo.PlmRequestHeaderVo">
update plm_request_header
set classification_name = #{classificationName},
workflow_id = #{workflowId},
menu_id = #{menuId},
status = #{status},
remark = #{remark},
update_date = GETDATE(),
update_by = #{updateBy}
where classification_no = #{classificationNo}
</update>
<delete id="deleteRequestHeader">
delete from plm_request_header
where site = #{data.site} and classification_no = #{data.classificationNo}
</delete>
<delete id="deleteRequestNode">
delete from plm_request_node
where site = #{data.site} and classification_no = #{data.classificationNo}
</delete>
<delete id="deleteRequestNodeDetail">
delete from plm_request_node_detail
where site = #{data.site} and classification_no = #{data.classificationNo}
</delete>
<delete id="deleteRequestNodeAuthority">
delete from plm_request_node_authority
where site = #{data.site} and classification_no = #{data.classificationNo}
</delete>
<insert id="saveRequestNodeDetail">
INSERT INTO plm_request_node_detail (site, bu, classification_no, node_id, node_name,
create_date, create_by, remark, plm_field, oa_field, field_value,
order_ref1, order_ref2, order_ref3, order_ref4, field_desc, workflow_id, plm_table, field_type, review)
values
<foreach item="data" index="index" collection="list" separator=",">
(#{data.site}, #{data.bu},#{data.classificationNo},#{data.nodeId},#{data.nodeName},
GETDATE(),#{data.createBy},#{data.remark},#{data.plmField},#{data.oaField},#{data.fieldValue}
,#{data.orderRef1},#{data.orderRef2},#{data.orderRef3},#{data.orderRef4},#{data.fieldDesc},#{data.workflowId}, #{data.plmTable}, #{data.fieldType}, #{data.review})
</foreach>
</insert>
<delete id="deleteRequestNodeDetailByLine">
delete from plm_request_node_detail
where site = #{site} and workflow_id = #{workflowId}
and node_id = #{nodeId}
and classification_no = #{classificationNo}
</delete>
<select id="getRequestNodeData" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
SELECT
a.nodeid nodeId,
a.nodename nodeName,
a.nodeorder seqNo
FROM VIEW_Process_management_OA_PLM a
<where>
<if test = "workflowId != null and workflowId != ''">
AND a.workflowid like #{workflowId}
</if>
order by a.nodeorder
</where>
</select>
<insert id="saveRequestNode">
INSERT INTO plm_request_node (site,bu,classification_no,node_id,node_name,node_type,create_date,create_by,remark,workflow_id, seq_no, step_id, is_reject)
values
<foreach item="data" index="index" collection="list" separator=",">
(#{data.site}, #{data.bu},#{data.classificationNo},#{data.nodeId},#{data.nodeName},#{data.nodeType},#{data.createDate}
,#{data.createBy},#{data.remark},#{data.workflowId},#{data.seqNo}, #{data.stepId}, 'Y')
</foreach>
</insert>
<select id="getNodeInfoByWorkflow" parameterType="com.spring.modules.request.vo.PlmRequestDetailVo" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
SELECT
a.site,
a.classification_no,
a.workflow_id,
c.workflowname,
a.node_id,
a.node_name,
a.node_type,
a.seq_no,
a.is_reject,
case when a.is_reject = 'Y' then '是' when a.is_reject = 'N' then '否' else '' end as isRejectDesc,
a.countersignature_item
FROM plm_request_node a
LEFT JOIN plm_request_header b ON a.site = b.site and a.classification_no = b.classification_no and a.workflow_id = b.workflow_id
LEFT JOIN VIEW_Process_management_OA_PLM c ON a.workflow_id = c.workflowid
<where>
<if test = "query.site != null and query.site != ''">
AND a.site like #{query.site}
</if>
<if test = "query.classificationNo != null and query.classificationNo != ''">
AND a.classification_no like #{query.classificationNo}
</if>
<if test = "query.workflowId != null and query.workflowId != ''">
AND a.workflow_id like #{query.workflowId}
</if>
</where>
group by a.site, a.classification_no, a.workflow_id, c.workflowname, a.node_id, a.node_name, a.node_type, a.seq_no, a.is_reject, a.countersignature_item
order by a.seq_no
</select>
<select id="getNodeDetail" parameterType="com.spring.modules.request.vo.PlmRequestDetailVo" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
select
site,
bu,
classification_no,
node_id,
node_name,
create_date,
create_by,
update_date,
update_by,
remark,
plm_field,
oa_field,
field_value,
field_desc,
workflow_id,
order_ref1,
order_ref2,
order_ref3,
order_ref4,
plm_table,
field_type,
review
from
plm_request_node_detail
<where>
<if test = "query.site != null and query.site != ''">
AND site like #{query.site}
</if>
<if test = "query.classificationNo != null and query.classificationNo != ''">
AND classification_no like #{query.classificationNo}
</if>
<if test = "query.workflowId != null and query.workflowId != ''">
AND workflow_id like #{query.workflowId}
</if>
<if test = "query.nodeId != null and query.nodeId != ''">
AND node_id like #{query.nodeId}
</if>
</where>
</select>
<select id="getTableList" parameterType="com.spring.modules.request.vo.TableDataVo" resultType="TableData">
SELECT name as tableId
FROM sys.tables where (name like #{data.tableType} + '%'
<if test = "data.addTable != null and data.addTable.size() > 0">
or name in (
<foreach collection="data.addTable" item="item1" separator=",">
#{item1}
</foreach>
)
</if>
)
<if test = "data.passTable != null and data.passTable.size() > 0">
AND name not in (
<foreach collection="data.passTable" item="item2" separator=",">
#{item2}
</foreach>
)
</if>
</select>
<!-- <select id="getFieldList" parameterType="TableData" resultType="PlmFieldData">-->
<!-- SELECT-->
<!-- CONVERT(varchar(50), c.COLUMN_NAME) as fieldId,-->
<!-- CONVERT(varchar(50), ep.value) as fieldName-->
<!-- FROM INFORMATION_SCHEMA.COLUMNS c-->
<!-- LEFT JOIN sys.extended_properties ep ON ep.major_id = OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME) AND ep.minor_id = c.ORDINAL_POSITION AND ep.name = 'MS_Description'-->
<!-- WHERE c.TABLE_NAME = #{tableId} and CONVERT(varchar(50), ep.value) is not null and CONVERT(varchar(50), ep.value) <![CDATA[<>]]> ''-->
<!-- </select>-->
<select id="getFieldList" parameterType="TableData" resultType="PlmFieldData">
SELECT
col.name AS fieldId,
CONVERT(varchar(50), comm.value) AS fieldName
FROM
sys.columns AS col
INNER JOIN sys.tables AS tbl ON col.object_id = tbl.object_id
INNER JOIN sys.schemas AS scm ON tbl.schema_id = scm.schema_id
INNER JOIN sys.types AS typ ON col.user_type_id = typ.user_type_id
LEFT JOIN sys.extended_properties AS comm ON comm.major_id = col.object_id AND comm.minor_id = col.column_id AND comm.name = N'MS_Description'
WHERE
tbl.name = #{tableId} and CONVERT(varchar(50), comm.value) is not null and CONVERT(varchar(50), comm.value) <![CDATA[<>]]> ''
ORDER BY col.column_id
</select>
<select id="getAuthorityFieldList" parameterType="TableData" resultType="PlmFieldData">
select
a.fieldId,
a.fieldName,
isnull(b.update_flag,'N') updateFlag,
#{tableId} as tableId,
b.required
from (SELECT
col.name AS fieldId,
CONVERT(varchar(50), comm.value) AS fieldName
FROM
sys.columns AS col
INNER JOIN sys.tables AS tbl ON col.object_id = tbl.object_id
INNER JOIN sys.schemas AS scm ON tbl.schema_id = scm.schema_id
INNER JOIN sys.types AS typ ON col.user_type_id = typ.user_type_id
LEFT JOIN sys.extended_properties AS comm ON comm.major_id = col.object_id AND comm.minor_id = col.column_id AND comm.name = N'MS_Description'
WHERE
tbl.name = #{tableId}) as a
left join plm_request_node_authority as b on a.fieldId = b.field_id and b.site = #{site} and b.classification_no = #{classificationNo} and b.node_id = #{nodeId} and b.table_id = #{tableId}
where a.fieldName is not null and a.fieldName <![CDATA[<>]]> ''
</select>
<delete id="deleteNodeAuthority" parameterType="TableData">
delete from plm_request_node_authority
where site = #{site} and bu = #{bu} and classification_no = #{classificationNo} and node_id = #{nodeId} and table_id = #{tableId}
</delete>
<insert id="saveNodeAuthority">
INSERT INTO plm_request_node_authority
(site, bu, classification_no, node_id, node_name, field_id, update_flag, create_date, create_by, table_id, required)
values
<foreach item="data" index="index" collection="list" separator=",">
(#{data.site}, #{data.bu}, #{data.classificationNo}, #{data.nodeId}, #{data.nodeName}, #{data.fieldId}, #{data.updateFlag}, getDate(), #{data.createBy}, #{data.tableId}, #{data.required})
</foreach>
</insert>
<update id="editNodeInfo" parameterType="com.spring.modules.request.vo.PlmRequestDetailVo">
update plm_request_node
set is_reject = #{isReject},
update_date = GETDATE(),
update_by = #{updateBy},
countersignature_item = #{countersignatureItem}
where classification_no = #{classificationNo} and site = #{site} and node_id = #{nodeId}
</update>
<select id="getProcessControlList" resultType="PlmProcessControllBaseData">
select
role_id,
workflow_id,
remark,
#{nodeId} as node_id,
#{site} as site
from plm_process_controll_base
where workflow_id = #{workflowId}
</select>
<select id="getProcessSelect" resultType="PlmProcessControllBaseData">
select
a.site,
a.workflow_id,
a.node_id,
a.role_id,
b.remark
from plm_process_controll_value a
left join plm_process_controll_base b on a.role_id = b.role_id and a.workflow_id = b.workflow_id
where b.remark is not null
and a.site = #{site} and a.workflow_id = #{workflowId} and a.node_id = #{nodeId}
</select>
<delete id="deleteProcessControlList">
delete from plm_process_controll_value where site=#{site} and workflow_id=#{workflowId} and node_id=#{nodeId}
</delete>
<insert id="saveProcessControlList">
insert into plm_process_controll_value(site,workflow_id,node_id,role_id)
values (#{site},#{workflowId},#{nodeId},#{roleId})
</insert>
<update id="updateBMStage">
update plm_technical_specification_sheet set stage='Mass Production' where site=#{site} and code_no=#{orderNo}
</update>
<select id="getBomAndRouteFromBM" resultType="PlmTechnicalSpecificationSheetData">
select
a.site,
a.bom_type,
a.eng_chg_level,
a.bom_alternative_no,
a.routing_type,
a.routing_revision,
a.routing_alternative_no,
b.final_part_no
from plm_technical_specification_sheet a
left join plm_project_part b on a.site = b.site and a.test_part_no = b.test_part_no and a.project_id = b.project_id
where a.site = #{site} and a.code_no = #{codeNo}
</select>
<select id="checkBomOfficialFlag" resultType="com.spring.modules.part.vo.BomDetailVo">
select site from plm_bom_detail where site=#{site} and part_no=#{finalPartNo} and bom_type=#{bomType}
and alternative_no=#{bomAlternativeNo} and eng_chg_level=#{engChgLevel,jdbcType=INTEGER}
</select>
<select id="checkRoutingOfficialFlag" resultType="com.spring.modules.part.vo.RoutingDetailVo">
select site from plm_routing_detail where site=#{site} and part_no=#{finalPartNo} and routing_type=#{routingType}
and alternative_no=#{routingAlternativeNo} and routing_revision=#{routingRevision,jdbcType=INTEGER}
</select>
<select id="getProcessFlowInformation" parameterType="com.spring.modules.change.vo.ProcessFormVo" resultType="com.spring.modules.change.vo.ProcessFormVo">
SELECT
a.site,
a.bu,
a.request_id,
a.workflow_id,
b.workflowname as workflowName,
a.node_id,
b.nodename as nodeName,
a.domain_control_account,
d.username as updateBy,
a.document_no,
dbo.get_display_no(a.site, a.document_no, a.document_type) as displayNo,
a.document_type,
a.seq_no,
a.reject_flag,
a.reject_node_id,
a.node_conclusion,
a.submit_date,
a.submitted_by,
a.create_date,
a.create_by,
a.update_date,
a.id,
a.is_remark,
a.classification_no,
a.step_id,
a.menu_id,
a.reject_opinion,
dbo.get_document_status(a.site, a.document_no, a.document_type) as documentStatus,
dbo.get_revision_no(a.site, a.document_no, a.document_type) as revisionNo
FROM plm_process_form as a
LEFT JOIN [VIEW_Process_management_OA_PLM] as b ON a.workflow_id = b.workflowid AND a.node_id = b.nodeid
LEFT JOIN sys_user as d ON a.domain_control_account = d.domain_control_account
<where>
a.site = #{query.site} and a.is_remark = 0 and isnull(a.process_intervention_flag, ' ') <![CDATA[<>]]> 'Y'
<if test = "query.documentNo != null and query.documentNo != ''">
AND a.document_no like #{query.documentNo}
</if>
<if test = "query.workflowId != null and query.workflowId != ''">
AND a.workflow_id like #{query.workflowId}
</if>
<if test = "query.workflowName != null and query.workflowName != ''">
AND b.workflowname like #{query.workflowName}
</if>
<if test = "query.nodeId != null and query.nodeId != ''">
AND a.node_id like #{query.nodeId}
</if>
<if test = "query.nodeName != null and query.nodeName != ''">
AND b.nodename like #{query.nodeName}
</if>
<if test = "query.createBy != null and query.createBy != ''">
AND a.create_by like #{query.createBy}
</if>
<if test = "query.updateBy != null and query.updateBy != ''">
AND d.username like #{query.updateBy}
</if>
<if test = "query.documentStatus != null and query.documentStatus != ''">
and dbo.get_document_status(a.site, a.document_no, a.document_type) = #{query.documentStatus}
</if>
</where>
</select>
<update id="updateProcessInterventionFlag" parameterType="com.spring.modules.change.vo.ProcessFormVo">
update plm_process_form
set process_intervention_flag = #{processInterventionFlag}
where site = #{site} and document_no = #{documentNo} and request_id = #{requestId} and node_id = #{nodeId} and is_remark = 0
</update>
<update id="updateProcessInterventionFlag2" parameterType="com.spring.modules.change.vo.ProcessFormVo">
update plm_process_form
set process_intervention_flag = #{processInterventionFlag},
is_remark = 1
where site = #{site} and document_no = #{documentNo} and request_id = #{requestId} and node_id = #{nodeId} and is_remark = 0
</update>
<select id="getThePreviousProcessInfo" resultType="com.spring.modules.change.vo.ProcessFormVo">
<!-- 2025-06-17 同一个流程有多个路线 导致不能按照顺序取stepId -->
WITH OrderedData AS (
SELECT site, bu, node_id, id, is_remark, step_id,
ROW_NUMBER() OVER (ORDER BY id DESC) AS rn,
LAG(step_id) OVER (ORDER BY id DESC) AS prev_step_id
FROM plm_process_form
WHERE site = #{site} AND document_no = #{documentNo} and ISNULL(process_intervention_flag ,' ') <![CDATA[<>]]> 'Y'
),
Filtered AS (
SELECT *
FROM OrderedData
WHERE step_id != prev_step_id OR prev_step_id IS NULL
)
SELECT site, bu, node_id, id, is_remark, step_id
FROM Filtered
ORDER BY rn OFFSET 1 ROW FETCH NEXT 1 ROW ONLY
<!-- select-->
<!-- site,-->
<!-- bu,-->
<!-- node_id,-->
<!-- id,-->
<!-- is_remark-->
<!-- from plm_process_form-->
<!-- where site = #{site} and bu = #{bu} and document_no = #{documentNo} and step_id = #{stepId} and ISNULL(process_intervention_flag ,' ') <![CDATA[<>]]> 'Y'-->
</select>
<update id="updateIsRemarkToZero">
update plm_process_form
set is_remark = 0
where id = #{id}
</update>
<select id="getProcessSelect2" resultType="com.spring.modules.base.entity.PlmProcessControllBaseData">
select
a.site,
a.workflow_id,
a.node_id,
a.role_id,
b.remark
from plm_process_controll_value a
left join plm_process_controll_base b on a.role_id = b.role_id and a.workflow_id = b.workflow_id
where b.remark is not null
and a.site = #{site} and a.workflow_id = #{workflowId} and a.node_id = #{nodeId} and a.role_id = #{roleId}
</select>
<select id="getProcessFlowInformation2" resultType="com.spring.modules.change.vo.ProcessFormVo">
EXEC dbo.get_process_form_infor #{site}, #{workflowId}, #{documentNo}, #{workflowName}, #{nodeId}, #{nodeName}, #{createBy}, #{updateBy}, #{documentType}, #{documentStatus}, #{page}, #{limit}
</select>
<update id="updateProcessNodeByIntervention1">
update plm_process_form
set node_conclusion = #{nodeConclusion2}
where site = #{site} and document_no = #{documentNo} and is_remark = #{isRemark} and node_conclusion = #{nodeConclusion1}
</update>
<update id="updateProcessNodeByIntervention2">
update plm_process_form
set node_conclusion = #{nodeConclusion2},
update_date = getDate(),
update_by = #{userName}
where site = #{site} and document_no = #{documentNo} and is_remark = #{isRemark} and (node_conclusion = #{nodeConclusion1} or node_conclusion = '')
</update>
<select id="getStepIdFromProcessForm" resultType="com.spring.modules.change.vo.ProcessFormVo">
select
step_id
from plm_process_form
where site = #{site} and document_no = #{documentNo} and is_remark = #{isRemark}
</select>
</mapper>