<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
~
|
~ Copyright (c) 2018-2025, ztt All rights reserved.
|
~
|
~ Redistribution and use in source and binary forms, with or without
|
~ modification, are permitted provided that the following conditions are met:
|
~
|
~ Redistributions of source code must retain the above copyright notice,
|
~ this list of conditions and the following disclaimer.
|
~ Redistributions in binary form must reproduce the above copyright
|
~ notice, this list of conditions and the following disclaimer in the
|
~ documentation and/or other materials provided with the distribution.
|
~ Neither the name of the pig4cloud.com developer nor the names of its
|
~ contributors may be used to endorse or promote products derived from
|
~ this software without specific prior written permission.
|
~ Author: ztt
|
~
|
-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chinaztt.mes.technology.mapper.DocumentMapper">
|
|
<resultMap id="documentMap" type="com.chinaztt.mes.technology.entity.Document">
|
<id property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="number" column="number"/>
|
<result property="projectNo" column="project_no"/>
|
<result property="country" column="country"/>
|
<result property="remark" column="remark"/>
|
<result property="state" column="state"/>
|
<result property="version" column="version"/>
|
<result property="oaWorkflowId" column="oa_workflow_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="createUser" column="create_user"/>
|
<result property="jgt" column="jgt"/>
|
<result property="lct" column="lct"/>
|
<result property="lctRemark" column="lct_remark"/>
|
<result property="lctJson" column="lct_json"/>
|
<result property="lctBase64" column="lct_base64"/>
|
<result property="projectType" column="project_type"/>
|
<result property="partId" column="part_id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="insulationColor" column="insulation_color"/>
|
<result property="sheathColor" column="sheath_color"/>
|
<result property="testStandard" column="test_standard"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="updateRealTime" column="update_real_time"/>
|
<result property="updateRealUser" column="update_real_user"/>
|
</resultMap>
|
|
<resultMap id="documentMaterialCostMap" type="com.chinaztt.mes.technology.dto.DocumentMaterialCostDTO">
|
<id property="documentId" column="document_id"/>
|
<result property="bomId" column="bom_id"/>
|
<result property="partId" column="part_id"/>
|
<result property="quantity" column="quantity"/>
|
<result property="unit" column="unit"/>
|
<result property="finishedProduct" column="finished_product"/>
|
<result property="bomNumber" column="bom_number"/>
|
<result property="partName" column="part_name"/>
|
</resultMap>
|
|
<resultMap id="bomRoutingMap" type="com.chinaztt.mes.technology.dto.JoinDocumentBomRoutingDTO">
|
<result property="documentId" column="document_id"/>
|
<result property="bomId" column="bom_id"/>
|
<result property="routingId" column="routing_id"/>
|
<result property="bomNumber" column="bom_number"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="routingNo" column="routing_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="routingVersion" column="routing_version"/>
|
<result property="routingAlternativeNo" column="routing_alternative_no"/>
|
<result property="routingAlternativeDesc" column="routing_alternative_desc"/>
|
</resultMap>
|
|
<sql id="routingJoinBomSql">
|
SELECT
|
A.*,
|
b."number" bom_number,
|
b.version bom_version,
|
b.alternative_no bom_alternative_no,
|
b.alternative_desc bom_alternative_desc,
|
r.routing_no,
|
r.version routing_version,
|
r.alternative_no routing_alternative_no,
|
r.alternative_desc routing_alternative_desc,
|
P.part_name,
|
P.part_no
|
FROM
|
technology_join_document_bom_routing A
|
LEFT JOIN technology_bom b ON b.ID = A.bom_id
|
LEFT JOIN technology_routing r ON r.ID = A.routing_id
|
LEFT JOIN basic_part P ON a.part_id = P.ID
|
</sql>
|
|
<select id="getBomRoutingDtoByDocId" resultMap="bomRoutingMap">
|
select * from (<include refid="routingJoinBomSql"/>) aa
|
WHERE
|
aa.document_id = #{documentId}
|
and aa.routing_id is not null
|
</select>
|
|
<select id="getRootBomRoutingDtoPartByDocId" resultMap="bomRoutingMap">
|
select * from (<include refid="routingJoinBomSql"/>) aa
|
WHERE
|
aa.document_id = #{documentId} and aa.parent_id Is NULL
|
</select>
|
|
|
<select id="getBomRoutingDtoPartByDocId" resultMap="bomRoutingMap">
|
select * from (<include refid="routingJoinBomSql"/>) aa
|
WHERE
|
aa.document_id = #{documentId}
|
ORDER BY aa.ID ASC
|
</select>
|
|
<select id="exportList" resultType="com.chinaztt.mes.technology.excel.MaterialCostData">
|
SELECT
|
A.*,
|
b.part_no "partNo",
|
b.part_name "partName",
|
b.specs,
|
b.description
|
FROM
|
technology_document_material_cost A,
|
basic_part b
|
WHERE
|
A.bom_id = #{bomId}
|
and A.document_id = #{documentId}
|
AND A.part_id = b.ID
|
</select>
|
|
<select id="getMaterialCostByDocId" resultMap="documentMaterialCostMap">
|
SELECT
|
A.*,
|
p1.part_name finished_product,
|
p2.part_name,
|
p2.unit,
|
b."number" bom_number,
|
opt.name operation_name
|
FROM
|
technology_document_material_cost A
|
LEFT JOIN technology_bom b ON A.bom_id = b.ID
|
LEFT JOIN basic_part p1 ON b.part_id = p1.ID
|
LEFT JOIN basic_part p2 ON A.part_id = p2.ID
|
LEFT JOIN technology_operation opt ON A.operation_id = opt.ID
|
WHERE
|
A.document_id = #{documentId}
|
ORDER BY A.INDEX,p2.part_name
|
</select>
|
|
|
</mapper>
|