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.
 
 
 
 
 
 

287 lines
14 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.ProofingInformationMapper">
<insert id="proofingInformationSave">
INSERT INTO plm_proofing_information
(site,proofing_no,project_id,test_part_no,customer_no,tracker,engineer,priority_level,proofing_number,plan_start_date,required_delivery_date,remark,technical_considerations,is_need_to_send_samples,send_samples_address,consignee,consignee_contact,proofing_result_information,actuality_send_samples_date,send_samples_method,deliver_goods_information,deliver_goods_remark,actuality_reply_date,confirm_results,confirm_by,confirm_information,proofing_status,proofing_result_status,next_to_do,create_date,create_by,update_date,update_by,approver,step_id,reject_flag,reject_step_id,c_project_type_db,project_phase)
VALUES
(#{site},#{proofingNo},#{projectId},#{testPartNo},#{customerNo},#{tracker},#{engineer},#{priorityLevel},#{proofingNumber},#{planStartDate},#{requiredDeliveryDate},#{remark},#{technicalConsiderations},#{isNeedToSendSamples},#{sendSamplesAddress},#{consignee},#{consigneeContact},#{proofingResultInformation},#{actualitySendSamplesDate},#{sendSamplesMethod},#{deliverGoodsInformation},#{deliverGoodsRemark},#{actualityReplyDate},#{confirmResults},#{confirmBy},#{confirmInformation},#{proofingStatus},#{proofingResultStatus},#{nextToDo},getDate(),#{createBy},getDate(),#{updateBy},#{approver},#{stepId},#{rejectFlag},#{rejectStepId},#{cProjectTypeDb},#{projectPhase})
</insert>
<update id="updateProofingInfoById">
UPDATE plm_proofing_information
SET
proofing_number = #{proofingNumber},
plan_start_date = #{planStartDate},
required_delivery_date = #{requiredDeliveryDate},
actuality_delivery_date = #{actualityDeliveryDate},
update_date = getDate(),
update_by = #{updateBy},
c_project_type_db = #{cProjectTypeDb},
project_phase = #{projectPhase}
WHERE id = #{id}
</update>
<update id="updateProofingInfoById1">
UPDATE plm_proofing_information
SET
proofing_number = #{proofingNumber},
plan_start_date = #{planStartDate},
required_delivery_date = #{requiredDeliveryDate},
update_date = getDate(),
update_by = #{updateBy},
c_project_type_db = #{cProjectTypeDb},
project_phase = #{projectPhase}
WHERE id = #{id}
</update>
<update id="updateDocumentListUploadedFlag">
UPDATE plm_document_list_definition
SET uploaded_flag = 'N'
WHERE site = #{site} AND proofing_id = #{proofingId} AND project_id = #{projectId}
</update>
<select id="proofingInformationSearch" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT
a.id,
a.site,
a.proofing_no,
a.project_id,
a.test_part_no,
a.customer_no,
a.tracker,
a.engineer,
a.priority_level,
a.proofing_number,
a.plan_start_date,
a.required_delivery_date,
a.remark,
a.technical_considerations,
a.is_need_to_send_samples,
a.send_samples_address,
a.consignee,
a.consignee_contact,
a.actuality_delivery_date,
a.proofing_result_information,
a.actuality_send_samples_date,
a.send_samples_method,
a.deliver_goods_information,
a.deliver_goods_remark,
a.actuality_reply_date,
a.confirm_results,
a.confirm_by,
a.confirm_information,
a.proofing_status,
a.proofing_result_status,
a.next_to_do,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.approver,
a.step_id,
a.reject_flag,
a.reject_step_id,
a.c_project_type_db,
a.project_phase,
b.project_category,
b.bu_no,
b.project_desc,
c.customer_desc,
d.part_desc
FROM plm_proofing_information as a
LEFT JOIN plm_project_info as b ON a.project_id = b.project_id and a.site = b.site
LEFT JOIN plm_customer_information AS c ON c.customer_no = b.customer_no and c.site = b.site
LEFT JOIN plm_project_part AS d ON d.project_id = b.project_id
<where>
<if test="query.projectId != null and query.projectId != ''">
and a.project_id = #{query.projectId}
</if>
</where>
order by a.create_date desc
</select>
<select id="getProofDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
{call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{testPartNo,mode=IN}, #{proofingNo, mode=IN})}
</select>
<delete id="deleteDocumentType">
DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
</delete>
<delete id="deleteProofingDocument">
DELETE a
FROM
plm_document_list_definition as a
INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
WHERE a.proofing_id = #{proofingNo} and b.project_category = #{cProjectTypeDb}
</delete>
<delete id="deleteProofingDocument1">
DELETE FROM CKT_MES_II_REAL.dbo.sys_oss WHERE id = #{documentId}
</delete>
<delete id="deleteProjectDocument">
DELETE a
FROM
plm_document_list_definition as a
INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
WHERE a.proofing_id = '*' and b.project_category = #{projectCategory} and project_id = #{projectId}
</delete>
<delete id="proofingInformationDelete">
DELETE FROM plm_proofing_information WHERE proofing_no = #{proofingNo} and site = #{site} and project_id = #{projectId}
</delete>
<delete id="deleteDocumentDefinitionById">
DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
</delete>
<select id="selecProofingOne" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT * FROM plm_proofing_information WHERE id = #{id}
</select>
<!-- 查询documentTypeId列表 -->
<select id="getDocumentTypeIds" resultType="string" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT document_type_id
FROM bu_document_list_definition
WHERE site = #{site}
AND bu_no = #{buNo}
AND project_category = #{cProjectTypeDb}
AND project_phase = 'Sample'
</select>
<!-- 查询documentTypeId列表 -->
<select id="getProjectDocumentTypeIds" resultType="string" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT document_type_id
FROM bu_document_list_definition
WHERE site = #{site}
AND bu_no = #{buNo}
AND project_category = #{projectCategory}
AND project_phase = 'Mass production'
</select>
<!-- 检查文档是否存在 -->
<select id="documentExists" resultType="boolean" parameterType="map">
SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
FROM plm_document_list_definition
WHERE site = #{data.site}
AND proofing_id = #{data.proofingNo}
AND project_id = #{data.projectId}
AND document_type_id = #{documentTypeId}
</select>
<!-- 检查文档是否存在 -->
<select id="projectDocumentExists" resultType="boolean" parameterType="map">
SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
FROM plm_document_list_definition
WHERE site = #{data.site}
AND proofing_id = #{data.proofingNo}
AND project_id = #{data.projectId}
AND document_type_id = #{documentTypeId}
</select>
<select id="getExtraDocumentList" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
SELECT
a.document_type_id,
a.document_type,
(SELECT role_desc FROM business_role WHERE role_no = a.responsible_department) AS responsible_department,
a.estimated_completion_days
FROM document_type_definition as a
where
a.site = #{query.site}
AND a.document_type_id NOT IN (
SELECT document_type_id
FROM plm_document_list_definition
WHERE site = #{query.site}
AND proofing_id = #{query.proofingNo}
AND project_id = #{query.projectId}
)
<if test="query.documentTypeId != null and query.documentTypeId != ''">
AND a.document_type_id like '%' + #{query.documentTypeId} + '%'
</if>
<if test="query.documentType != null and query.documentType != ''">
AND a.document_type like '%' + #{query.documentType} + '%'
</if>
<if test="query.responsibleDepartment != null and query.responsibleDepartment != ''">
AND a.responsible_department like '%' + #{query.responsibleDepartment} + '%'
</if>
</select>
<select id="documentExists1" resultType="java.lang.Boolean">
SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
FROM plm_document_list_definition
WHERE site = #{data.site}
AND proofing_id = #{data.proofingNo}
AND project_id = #{data.projectId}
AND document_type_id = #{documentTypeId}
</select>
<select id="selectProjectList" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT a.*,b.project_category FROM plm_document_list_definition as a
left join plm_project_info as b on a.project_id = b.project_id
left join bu_document_list_definition as c on a.document_type_id = c.document_type_id
WHERE a.project_id = #{projectId} and a.proofing_id = '*' and c.project_phase = 'Mass Production'
</select>
<select id="searchProjectAllDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
{call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{testPartNo,mode=IN}, #{proofingNo, mode=IN})}
</select>
<select id="queryProofingNo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT * FROM plm_proofing_information WHERE site = #{site} and project_id = #{projectId} and proofing_no = #{proofingNo}
</select>
<select id="selectProofingDocument" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
SELECT
c.id
FROM
sys_oss AS a
LEFT JOIN plm_document_list_definition AS b ON CAST ( b.id AS VARCHAR ) = a.order_ref3
LEFT JOIN bu_document_list_definition AS c ON b.document_type_id = c.document_type_id
WHERE b.proofing_id = #{proofingNo} and c.project_category = #{cProjectTypeDb} and c.project_phase = 'Sample'
</select>
<select id="checkProductionConfirmationDocument" resultType="boolean">
SELECT
CASE
WHEN EXISTS (
SELECT 1
FROM plm_project_document_confirm_file_list AS a
WHERE Site = #{site} AND document_type = #{documentType} AND Order_Ref1 = #{OrderRef1} AND document_id = #{documentId}
) THEN 1
ELSE 0
END AS exists_flag
</select>
<select id="getPendingUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
SELECT * FROM view_plm_toupload_list_byUser
WHERE status != '草稿' AND uploaded_flag = 'N' AND RelatedPerson = #{userId}
order by project_id
</select>
<select id="getOverdueUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
<![CDATA[
SELECT * FROM view_plm_toupload_list_byUser
WHERE status != '草稿' AND uploaded_flag = 'N' AND Request_date < GETDATE() AND RelatedPerson = #{userId}
order by project_id
]]>
</select>
<select id="getPendingConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
SELECT * FROM view_plm_toproconfirm_list_byUser
WHERE status != '草稿' AND confirm_flag = 'N' AND RelatedPerson = #{userId}
order by project_id
</select>
<select id="getOverdueConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
<![CDATA[
SELECT * FROM view_plm_toproconfirm_list_byUser
WHERE status != '草稿' AND confirm_flag = 'N' AND wanted_confirm_date < GETDATE() AND RelatedPerson = #{userId}
order by project_id
]]>
</select>
<!-- 插入文档 -->
<insert id="insertDocument" parameterType="map">
INSERT INTO plm_document_list_definition
(site, proofing_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
VALUES
(#{data.site}, #{data.proofingNo}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
</insert>
<!-- 插入文档 -->
<insert id="insertProjectDocument" parameterType="map">
INSERT INTO plm_document_list_definition
(site, proofing_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
VALUES
(#{data.site}, #{data.proofingNo}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
</insert>
<insert id="proofingDocumentNEWSave">
INSERT INTO plm_document_list_definition
(site,proofing_id,project_id,document_type_id,created_by,manual_flag,uploaded_flag,create_date)
VALUES
(#{site},#{proofingNo},#{projectId},#{documentTypeId},#{createBy},'Y','N',GETDATE())
</insert>
</mapper>