O
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.
 
 
 
 
 
 

653 lines
35 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">
<!-- namespace = 接口的全限定符 -->
<mapper namespace="com.xujie.sys.modules.pms.mapper.EamProjectMapper">
<insert id="saveNeweamProject">
INSERT INTO plm_project_info
(site,bu_no,project_no,ori_project_id,project_category,project_name,project_desc,status,project_source,customer_no,final_customer_id,priority,remark,need_date,c_project_region,project_manager,project_owner,engineer,c_quality_engineer1,c_quality_engineer2,c_quality_engineer3,c_quality_engineer4,c_quality_engineer5,c_quality_engineer6,c_manufacture_engineer,doc_engineer,project_creation_date,create_date,create_by)
VALUES
(#{site},#{buNo},#{projectNo},#{oriProjectId},#{projectCategory},#{projectName},#{projectDesc},#{status},#{projectSource},#{customerNo},#{finalCustomerId},#{priority},#{remark},#{needDate},#{cProjectRegion},#{projectManager},#{projectOwner},#{engineer},#{cQualityEngineer1},#{cQualityEngineer2},#{cQualityEngineer3},#{cQualityEngineer4},#{cQualityEngineer5},#{cQualityEngineer6},#{cManufactureEngineer},#{docEngineer},#{projectCreationDate},GetDATE(),#{createBy})
</insert>
<insert id="saveProductionValidationDocument">
INSERT INTO plm_project_document_confirm_file_list
(site,Order_Ref1,Order_Ref2,Item_No,document_type,document_id,Order_Ref3)
VALUES
(#{site},#{orderRef1},#{orderRef2},#{itemNo},#{documentType},#{documentId},#{orderRef3})
</insert>
<insert id="saveProductionValidationDocumentConfirmator">
INSERT INTO plm_project_document_confirm
(site,Order_Ref1,Order_Ref2,Item_No,document_type,userid,wanted_confirm_date,confirm_flag,confirmed_by,confirmed_date,create_date,create_by)
VALUES
(#{site},#{orderRef1},#{orderRef2},#{itemNo},'产品文档',#{userid},#{wantedConfirmDate},'N',#{confirmedBy},#{confirmedDate},GETDATE(),#{createBy})
</insert>
<update id="eamProjectEdit">
UPDATE plm_project_info
SET project_category = #{projectCategory},project_name = #{projectName},project_desc = #{projectDesc},status = #{status},project_source = #{projectSource},customer_no = #{customerNo},priority = #{priority},remark = #{remark},need_date = #{needDate},c_project_region = #{cProjectRegion},project_manager = #{projectManager},project_owner = #{projectOwner},engineer = #{engineer},c_quality_engineer1 = #{cQualityEngineer1},c_quality_engineer2 = #{cQualityEngineer2},c_quality_engineer3 = #{cQualityEngineer3},c_quality_engineer4 = #{cQualityEngineer4},c_quality_engineer5 = #{cQualityEngineer5},c_quality_engineer6 = #{cQualityEngineer6},c_manufacture_engineer = #{cManufactureEngineer},doc_engineer = #{docEngineer},update_date = GETDATE(),update_by = #{updateBy},project_creation_date = #{projectCreationDate}
,project_close_date =
CASE
WHEN #{projectCloseDate} IS NOT NULL THEN CONVERT(date, #{projectCloseDate})
ELSE project_close_date
END
WHERE site = #{site} and id = #{projectId}
</update>
<update id="saveFormalPartNo">
UPDATE plm_project_part
SET final_part_no = #{finalPartNo} ,remark = #{finalPartDesc}
WHERE site = #{site} and project_id = #{projectId} and id = #{projectPartId}
</update>
<update id="updateProjectDocumentConfirm">
UPDATE plm_project_document_confirm
SET confirm_flag = 'Y',confirmed_by = #{confirmedBy},confirmed_date = #{confirmedDate},remark = #{remark}
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2} and document_type = '产品文档' and Item_No = #{itemNo} and userid = #{userid}
</update>
<delete id="eamProjectDelete">
DELETE FROM plm_project_info
WHERE id = #{projectId}
</delete>
<delete id="eamProjectPartDelete">
DELETE FROM plm_project_part
WHERE site = #{site} and project_id = #{projectId} and test_part_no = #{testPartNo}
</delete>
<delete id="deleteDocumentInformation">
DELETE FROM plm_project_document_confirm_file_list
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
</delete>
<delete id="deleteConfirmationRecord">
DELETE FROM plm_project_document_confirm
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and document_type = '产品文档' and Order_Ref2 = #{orderRef2}
</delete>
<delete id="deleteSysoss">
delete from CKT_MES_II_REAL.dbo.sys_oss
where order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2} and order_ref4 = #{orderRef4} and order_ref5 = #{orderRef5}
</delete>
<delete id="eamProjectPartInfoDelete">
DELETE FROM plm_project_part
WHERE id = #{projectPartId}
</delete>
<delete id="deleteConfirmatory">
DELETE FROM plm_document_toconfirm_user
WHERE site = #{site} and BU = #{buNo} and document_type = '产品文档' and userid = #{userid}
</delete>
<select id="eamProjectSearch" parameterType="com.xujie.sys.modules.pms.data.EamProjectInfoData" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.id as project_id,a.site,a.bu_no,d.bu_desc,a.project_no,a.project_category,a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.final_customer_id, a.priority,a.engineer,
a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
a.c_manufacture_engineer,a.doc_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,c.customer_desc, CKT_MES_II_REAL.dbo.plm_get_customer_desc(a.site,a.final_customer_id) as final_customer_name
FROM plm_project_info as a
LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
left join CKT_MES_II_REAL.dbo.BU as d on a.site = d.site and a.bu_no = d.bu_no
<where>
a.site in (select site from eam_access_site where username = #{query.userName})
and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
<if test="query.projectId != null and query.projectId != ''">
AND (
a.id = #{query.projectId}
OR a.id IN (
SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectId}, ',')
)
)
</if>
<if test="query.projectNo != null and query.projectNo != ''">
AND (
a.project_no = #{query.projectNo}
OR a.project_no IN (
SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
)
)
</if>
<if test="query.projectDesc != null and query.projectDesc != ''">
and a.project_desc like #{query.projectDesc}
</if>
<if test="query.customerNo != null and query.customerNo != ''">
and a.customer_no like #{query.customerNo}
</if>
<if test="query.customerDesc != null and query.customerDesc != ''">
and c.customer_desc like #{query.customerDesc}
</if>
<if test="query.buDesc != null and query.buDesc != ''">
AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
</if>
<if test="query.projectCategory != null and query.projectCategory != ''">
and a.project_category = #{query.projectCategory}
</if>
<if test="query.status != null and query.status != ''">
and a.status = #{query.status}
</if>
<if test="query.projectManager != null and query.projectManager != ''">
and a.project_manager = #{query.projectManager}
</if>
<if test="query.projectOwner != null and query.projectOwner != ''">
and a.project_owner = #{query.projectOwner}
</if>
<if test="query.engineer != null and query.engineer != ''">
and a.engineer = #{query.engineer}
</if>
<if test="query.cProjectRegion != null and query.cProjectRegion != ''">
and a.c_project_region = #{query.cProjectRegion}
</if>
<if test="query.startDate != null ">
AND a.project_creation_date >= #{query.startDate}
</if>
<if test="query.endDate != null ">
AND #{query.endDate} >= a.project_creation_date
</if>
</where>
order by a.id desc
</select>
<select id="queryEamProjectInfo" parameterType="com.xujie.sys.modules.pms.data.EamProjectInfoData" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.id as project_id,a.site,a.bu_no,d.bu_desc,a.project_no,a.project_category,a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.final_customer_id, a.priority,a.engineer,
a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
a.c_manufacture_engineer,a.doc_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,c.customer_desc, CKT_MES_II_REAL.dbo.plm_get_customer_desc(a.site,a.final_customer_id) as final_customer_name
FROM plm_project_info as a
LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
left join CKT_MES_II_REAL.dbo.BU as d on a.site = d.site and a.bu_no = d.bu_no
<where>
a.site in (select site from eam_access_site where username = #{params.userName})
and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
<if test="params.sql != null and params.sql != ''">
${params.sql}
</if>
</where>
order by a.id desc
</select>
<select id="checkeamProject" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.site,a.bu_no,a.id as project_id,a.project_category, a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.priority,
a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
a.c_manufacture_engineer,a.doc_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,b.test_part_no,b.part_desc
FROM plm_project_info as a
LEFT JOIN plm_project_part as b ON a.id = b.project_id
WHERE a.project_no = #{projectNo} and a.site = #{site} and a.bu_no = #{buNo}
</select>
<select id="getCustomerNo" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
customer_no,
customer_desc,
active
FROM
plm_customer_information AS a
where site = #{site} and active = 'Y'
ORDER BY customer_no DESC
</select>
<insert id="saveNewCustomer">
INSERT INTO plm_customer_information
(site,customer_no,customer_desc,create_date,create_by,active)
VALUES
(#{site},#{customerNo},#{customerDesc},GETDATE(),#{createBy},'Y')
</insert>
<select id="checkProjectDelete" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT
a.project_id,
a.id as project_part_id,
a.test_part_no
FROM plm_project_part as a
LEFT JOIN plm_project_info as b ON a.project_id = b.id
WHERE a.project_id = #{projectId}
</select>
<select id="searchConfirmatorList" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.userid,
b.username,
b.user_display
FROM plm_document_toconfirm_user as a
LEFT JOIN CKT_MES_II_REAL.dbo.sys_user as b ON a.userid = b.user_id
WHERE a.BU = #{query.buNo} and a.Site = #{query.site} and a.document_type = '产品文档'
</select>
<select id="searchNotConfirmatorList" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.site,
a.bu_no,
a.username,
s.user_id,
s.user_display
FROM
AccessBu a
LEFT JOIN sys_user s ON a.username = s.username
AND a.site = s.site
LEFT JOIN plm_document_toconfirm_user b ON s.user_id = b.userid
AND b.Site = s.site
AND b.BU = a.bu_no
AND b.document_type = '产品文档'
<where>
a.site = #{query.site}
AND a.bu_no = #{query.buNo}
AND s.user_id IS NOT NULL
AND b.userid IS NULL
<if test="query.username != null and query.username != ''">
AND s.username like #{query.username}
</if>
<if test="query.userDisplay != null and query.userDisplay != ''">
AND s.user_display like #{query.userDisplay}
</if>
</where>
</select>
<select id="checkProductionValidationDocument"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT *
FROM plm_project_document_confirm_file_list
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
</select>
<select id="checkProductionValidationDocumentAll"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT *
FROM plm_project_document_confirm_file_list
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
</select>
<select id="checkProductionValidationDocumentConfirmator"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT *
FROM plm_project_document_confirm
WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2} and document_type = '产品文档' and Item_No = #{itemNo} and userid = #{userid}
</select>
<select id="searchConfirmProgressDocumentList"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT a.Item_No,
a.document_type,
(case when a.order_ref3 = '-2' then c.sop_name ELSE b.file_name END) as file_name,
a.document_id,
a.site,
a.Order_Ref1 AS project_id,
a.order_ref3 AS document_definition_list_id,
b.created_by
FROM
plm_project_document_confirm_file_list AS a
LEFT JOIN sys_oss AS b ON a.document_id = b.id
LEFT JOIN part_sop AS c ON a.document_id = c.id
WHERE a.Site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.Order_Ref2 = #{query.orderRef2}
ORDER BY a.Item_No
</select>
<select id="searchConfirmProgressPusherList"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT a.*,b.user_display,b.username
FROM plm_project_document_confirm as a
LEFT JOIN sys_user as b ON a.userid = b.user_id
WHERE a.site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{query.orderRef2}
</select>
<select id="searchProjectConfirmatorFileList"
resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
SELECT a.*
FROM sys_oss as a
<where>
<if test="query.id != null and query.id != ''">
a.id = CAST(#{query.id} AS INT)
</if>
<if test="query.id == null or query.id == ''">
a.order_ref1 = #{query.orderRef1} and a.order_ref4 = #{query.orderRef4} and a.order_ref2 = #{query.orderRef2} and a.order_ref3 = #{query.orderRef3} and a.order_ref5 = #{query.orderRef5}
<if test="query.createdBy != null and query.createdBy != ''">
and a.created_by = #{query.createdBy}
</if>
<if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
and a.c_additional_info = #{query.cAdditionalInfo}
</if>
<if test="query.fileName != null and query.fileName != ''">
and a.file_name = #{query.fileName}
</if>
</if>
</where>
</select>
<select id="getMaxItemNo2" resultType="java.lang.Integer">
SELECT COALESCE(MAX(Item_No), 0) AS maxItemNo
FROM plm_project_document_confirm_file_list
WHERE site = #{site} AND Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
</select>
<select id="checkConfirmationRecord"
resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT a.*
FROM plm_project_document_confirm as a
WHERE a.site = #{site} and a.Order_Ref1 = #{orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{orderRef2}
</select>
<!-- SELECT-->
<!-- (SELECT TOP 1 proofing_no FROM plm_proofing_information WHERE project_id = ppi.project_id and test_part_id = ppi.id) AS proofing_no,-->
<!-- ppi.id AS project_part_id,-->
<!-- ppi.project_id,-->
<!-- STUFF(-->
<!-- COALESCE(-->
<!-- CASE WHEN pu1.email IS NOT NULL AND pu1.email != '' THEN ';' + pu1.email ELSE '' END +-->
<!-- CASE WHEN pu2.email IS NOT NULL AND pu2.email != '' THEN ';' + pu2.email ELSE '' END +-->
<!-- CASE WHEN pu3.email IS NOT NULL AND pu3.email != '' THEN ';' + pu3.email ELSE '' END +-->
<!-- CASE WHEN pu4.email IS NOT NULL AND pu4.email != '' THEN ';' + pu4.email ELSE '' END +-->
<!-- CASE WHEN pu5.email IS NOT NULL AND pu5.email != '' THEN ';' + pu5.email ELSE '' END +-->
<!-- CASE WHEN pu6.email IS NOT NULL AND pu6.email != '' THEN ';' + pu6.email ELSE '' END,-->
<!-- ''-->
<!-- ),-->
<!-- 1, 1, ''-->
<!-- ) AS email-->
<!-- FROM-->
<!-- plm_project_part ppi-->
<!-- LEFT JOIN sys_user pu1 ON LEFT ( ppi.c_quality_engineer1, CHARINDEX( '-', ppi.c_quality_engineer1 ) - 1 ) = pu1.username-->
<!-- LEFT JOIN sys_user pu2 ON LEFT ( ppi.c_quality_engineer2, CHARINDEX( '-', ppi.c_quality_engineer2 ) - 1 ) = pu2.username-->
<!-- LEFT JOIN sys_user pu3 ON LEFT ( ppi.c_quality_engineer3, CHARINDEX( '-', ppi.c_quality_engineer3 ) - 1 ) = pu3.username-->
<!-- LEFT JOIN sys_user pu7 ON LEFT ( ppi.c_quality_engineer4, CHARINDEX( '-', ppi.c_quality_engineer4 ) - 1 ) = pu7.username-->
<!-- LEFT JOIN sys_user pu4 ON LEFT ( ppi.c_manufacture_engineer, CHARINDEX( '-', ppi.c_manufacture_engineer ) - 1 ) = pu4.username-->
<!-- LEFT JOIN sys_user pu5 ON LEFT ( ppi.engineer, CHARINDEX( '-', ppi.engineer ) - 1 ) = pu5.username-->
<!-- LEFT JOIN sys_user pu6 ON LEFT ( ppi.doc_engineer, CHARINDEX( '-', ppi.doc_engineer ) - 1 ) = pu6.username-->
<!-- WHERE-->
<!-- ppi.id = #{projectPartId}-->
<select id="getSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
{call plm_get_to_email_list_proofing(
#{site, mode=IN, jdbcType=VARCHAR},
#{projectId, mode=IN, jdbcType=INTEGER},
#{projectPartId, mode=IN, jdbcType=INTEGER},
#{proofingId, mode=IN, jdbcType=INTEGER})}
</select>
<select id="getSendMassProductionMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
{call plm_get_to_email_list_MassProd(
#{site, mode=IN, jdbcType=VARCHAR},
#{projectId, mode=IN, jdbcType=INTEGER},
#{projectPartId, mode=IN, jdbcType=INTEGER})}
</select>
<select id="getAutoSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
{call plm_get_to_email_list_AlertMessage(
#{site, mode=IN, jdbcType=VARCHAR})}
</select>
<select id="getRoleDescByNo" resultType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo">
SELECT
role_desc
FROM business_role
WHERE role_no = #{roleNo}
</select>
<select id="getWarnSendMailAddress" parameterType="map" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
ppp.project_id,
ppp.test_part_no,
pu.email
FROM
plm_project_part ppp
LEFT JOIN sys_user pu ON LEFT ( ppp.${type}, CHARINDEX( '-', ppp.${type} ) - 1 ) = pu.username
WHERE
ppp.project_id = #{query.projectId} and ppp.site = #{query.site} and ppp.id = #{query.projectPartId}
</select>
<select id="getConfirmatorSendMailAddress" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT DISTINCT
a.Order_Ref1 as project_id,
a.Order_Ref2 as project_part_id,
STUFF((SELECT DISTINCT '; ' + b.email
FROM plm_project_document_confirm as c
LEFT JOIN sys_user as b ON c.userid = b.user_id
WHERE c.Site = #{site} and c.Order_Ref1 = #{projectId} and c.Order_Ref2 = #{projectPartId}
FOR XML PATH('')), 1, 2, '') as email
FROM plm_project_document_confirm as a
WHERE a.Site = #{site} and a.Order_Ref1 = #{projectId} and a.Order_Ref2 = #{projectPartId}
</select>
<select id="searchProjectAllDocumentTask" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
{call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{projectPartId,mode=IN}, #{proofingId, mode=IN})}
</select>
<select id="queryEmailByCreateUser" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
a.project_id,
a.proofing_no,
a.create_by,
b.email
FROM plm_proofing_information as a
LEFT JOIN sys_user as b ON a.create_by = b.username
WHERE a.site = #{site} and a.project_id = #{projectId} and a.id = #{proofingId} and a.test_part_id = #{projectPartId}
</select>
<select id="checkProjectPartInfo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT
*
from plm_project_part
WHERE project_id = #{projectId}
</select>
<select id="checkeamProjectId" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
a.project_no
FROM plm_project_info as a
WHERE a.id = #{projectId}
</select>
<select id="eamProjectPartSearch" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
a.*,
a.id as projectPartId,
b.project_no,
b.project_desc,
b.bu_no,
b.c_project_region,
c.customer_desc,
d.bu_desc
FROM plm_project_part as a
LEFT JOIN plm_project_info as b ON a.project_id = b.id
LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
left join CKT_MES_II_REAL.dbo.BU as d on b.site = d.site and b.bu_no = d.bu_no
<where>
<if test="query.projectId != null and query.projectId != ''">
AND (
a.project_id = #{query.projectId}
OR a.project_id IN (
SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectId}, ',')
)
)
</if>
<if test="query.projectNo != null and query.projectNo != ''">
AND
(b.project_no = #{query.projectNo} OR b.project_no IN (SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')))
</if>
<if test="query.projectDesc != null and query.projectDesc != ''">
and b.project_desc like #{query.projectDesc}
</if>
<if test="query.projectPartId != null and query.projectPartId != ''">
and a.id = #{query.projectPartId}
</if>
<if test="query.testPartNo != null and query.testPartNo != ''">
AND (
a.test_part_no like #{query.testPartNo}
OR a.test_part_no IN (
SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
)
)
</if>
<if test="query.partDesc != null and query.partDesc != ''">
and a.part_desc like #{query.partDesc}
</if>
<if test="query.customerNo != null and query.customerNo != ''">
and a.customer_no = like #{query.customerNo}
</if>
<if test="query.customerDesc != null and query.customerDesc != ''">
and c.customer_desc = like #{query.customerDesc}
</if>
<if test="query.buDesc != null and query.buDesc != ''">
AND dbo.get_bu_desc ( b.site, b.bu_no ) = #{query.buDesc}
</if>
<if test="query.projectCategory != null and query.projectCategory != ''">
and a.project_category = #{query.projectCategory}
</if>
<if test="query.status != null and query.status != ''">
and a.status = #{query.status}
</if>
<if test="query.projectManager != null and query.projectManager != ''">
and a.project_manager = #{query.projectManager}
</if>
<if test="query.projectOwner != null and query.projectOwner != ''">
and a.project_owner = #{query.projectOwner}
</if>
<if test="query.engineer != null and query.engineer != ''">
and a.engineer = #{query.engineer}
</if>
<if test="query.cProjectRegion != null and query.cProjectRegion != ''">
and b.c_project_region = #{query.cProjectRegion}
</if>
<if test="query.finalPartNo != null and query.finalPartNo != ''">
and a.final_part_no = #{query.finalPartNo}
</if>
<if test="query.startDate != null ">
AND a.build_date >= #{query.startDate}
</if>
<if test="query.endDate != null ">
AND #{query.endDate} >= a.build_date
</if>
<if test="query.massProductionStartDate != null ">
AND a.close_date >= #{query.massProductionStartDate}
</if>
<if test="query.massProductionEndDate != null ">
AND #{query.massProductionEndDate} >= a.close_date
</if>
</where>
order by a.id desc
</select>
<select id="queryEamProjectPart" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
a.*,
a.id as projectPartId,
b.project_no,
b.project_desc,
b.bu_no,
a.customer_no,
b.c_project_region,
c.customer_desc,
d.bu_desc
FROM plm_project_part as a
LEFT JOIN plm_project_info as b ON a.project_id = b.id
LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and b.site = c.site
left join CKT_MES_II_REAL.dbo.BU as d on b.site = d.site and b.bu_no = d.bu_no
<where>
1=1
<if test="params.sql != null and params.sql != ''">
${params.sql}
</if>
</where>
order by a.id desc
</select>
<select id="checkProjectPartNo" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
a.test_part_no
FROM plm_project_part as a
WHERE a.site = #{site} and a.project_id = #{projectId} and a.test_part_no = #{testPartNo} and a.id != (case when #{projectPartId} is null then '' else #{projectPartId} end)
</select>
<select id="checkProjectPartProofing" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT * from plm_proofing_information
WHERE project_id = #{projectId} and test_part_id = #{projectPartId}
</select>
<select id="getFinalPartDesc" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
SELECT
part_no as final_part_no,
part_desc as final_part_desc
FROM part
WHERE site = #{site} and part_no = #{finalPartNo}
</select>
<select id="getEmailAddressByUsername" resultType="string">
SELECT
email
FROM
sys_user
WHERE
username = #{username}
</select>
<select id="checkConfirmatory" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
SELECT
*
FROM plm_document_toconfirm_user as a
WHERE a.BU = #{buNo} and a.Site = #{site} and a.document_type = '产品文档' and a.userid = #{userid}
</select>
<select id="searchSopFileList" resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
SELECT a.sop_name + '.' + SUBSTRING(sop_url, CHARINDEX('.', sop_url) + 1, LEN(sop_url)) as file_name,
a.creation_date as create_date,
a.created_by as created_by,
a.sop_url as url,
a.id,
'-2' as order_ref3,
SUBSTRING(a.sop_url, CHARINDEX('.', a.sop_url) + 1, LEN(a.sop_url)) as file_type
FROM part_sop as a
<where>
<if test="query.id != null and query.id != ''">
a.id = CAST(#{query.id} AS INT)
</if>
<if test="query.id == null or query.id == ''">
a.order_ref1 = #{query.orderRef1} and a.order_ref4 = #{query.orderRef4} and a.order_ref2 = #{query.orderRef2} and a.order_ref3 = #{query.orderRef3} and a.order_ref5 = #{query.orderRef5}
<if test="query.createdBy != null and query.createdBy != ''">
and a.created_by = #{query.createdBy}
</if>
<if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
and a.c_additional_info = #{query.cAdditionalInfo}
</if>
<if test="query.fileName != null and query.fileName != ''">
and a.file_name = #{query.fileName}
</if>
</if>
</where>
</select>
<select id="getEmailsByUsernames" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT email
FROM sys_user
WHERE site = #{site}
AND username IN
<foreach item="username" collection="usernames" open="(" separator="," close=")">
#{username}
</foreach>
</select>
<insert id="saveNewProjectPart" useGeneratedKeys="true" keyProperty="projectPartId">
INSERT INTO plm_project_part (
site,
project_id,
test_part_no,
part_desc,
create_date,
create_by,
final_part_no,
project_manager,
project_owner,
build_date,
c_quality_engineer1,
c_quality_engineer2,
c_quality_engineer3,
c_quality_engineer4,
c_quality_engineer5,
c_quality_engineer6,
c_manufacture_engineer,
doc_engineer,
engineer,
status,
part_type,
priority,
project_category,
need_date,
customer_no
) VALUES (
#{site},
#{projectId},
#{testPartNo},
#{partDesc},
getdate(),
#{createBy},
#{finalPartNo},
#{projectManager},
#{projectOwner},
#{buildDate},
#{cQualityEngineer1},
#{cQualityEngineer2},
#{cQualityEngineer3},
#{cQualityEngineer4},
#{cQualityEngineer5},
#{cQualityEngineer6},
#{cManufactureEngineer},
#{docEngineer},
#{engineer},
#{status},
#{partType},
#{priority},
#{projectCategory},
#{needDate},
#{customerNo}
);
</insert>
<insert id="addConfirmatory">
INSERT INTO plm_document_toconfirm_user
(site,BU,document_type,userid,create_date,create_by)
VALUES
(#{site},#{buNo},'产品文档',#{userid},GETDATE(),#{createBy})
</insert>
<update id="eamProjectPartInfoEdit">
UPDATE plm_project_part
SET test_part_no = #{testPartNo},part_desc = #{partDesc},update_date = GETDATE(),update_by = #{updateBy}, build_date = #{buildDate}, priority = #{priority}, project_category = #{projectCategory}, need_date = #{needDate}, project_manager = #{projectManager}, project_owner = #{projectOwner}, engineer = #{engineer}, c_quality_engineer1 = #{cQualityEngineer1}, c_quality_engineer2 = #{cQualityEngineer2}, c_quality_engineer3 = #{cQualityEngineer3}, c_quality_engineer4 = #{cQualityEngineer4}, c_quality_engineer5 = #{cQualityEngineer5}, c_quality_engineer6 = #{cQualityEngineer6}, c_manufacture_engineer = #{cManufactureEngineer},doc_engineer = #{docEngineer},
status = CASE WHEN #{status} IS NOT NULL THEN #{status} ELSE status END,customer_no = #{customerNo},
part_type = CASE WHEN #{partType} IS NOT NULL THEN #{partType} ELSE part_type END,
close_date = (CASE
WHEN #{closeDate} IS NULL THEN ISNULL(close_date, NULL)
ELSE CONVERT(DATE, #{closeDate})
END)
WHERE id = #{projectPartId}
</update>
</mapper>