<?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.whyc.mapper.MaterialMapper">
|
|
|
<!--<select id="getMaterialWithoutSub" resultType="com.whyc.pojo.Material">
|
select * from tb_Material b
|
where (select count(1) as num from tb_material_product_history c
|
where b.id= c.material_id and c.sub_name=#{subName} and parent_model=#{parentModel}
|
and c.e_version=#{version}
|
) = 0
|
and b.status=1;
|
</select>-->
|
|
<!--<resultMap id="productBomList" type="Material">
|
<id property="id" column="id"></id>
|
<result property="type" column="type"></result>
|
<result property="category" column="category"></result>
|
<result property="subCode" column="sub_code"></result>
|
<result property="subName" column="sub_name"></result>
|
<result property="subModel" column="sub_model"></result>
|
<result property="unit" column="unit"></result>
|
<result property="quantity" column="quantity"></result>
|
<result property="producer" column="producer"></result>
|
<result property="material" column="material"></result>
|
<result property="thickness" column="thickness"></result>
|
<result property="surfaceDetail" column="surface_detail"></result>
|
<result property="notes" column="notes"></result>
|
<result property="pictureUrl" column="picture_url"></result>
|
<result property="fileUrl" column="file_url"></result>
|
<result property="upUserId" column="up_user_id"></result>
|
<result property="createDate" column="create_date"></result>
|
<result property="updateDate" column="update_date"></result>
|
<result property="dwgUrl" column="dwg_url"></result>
|
<collection property="mproductHistorys" javaType="java.util.ArrayList" ofType="com.whyc.pojo.MaterialProductHistory" column="{id=id}" select="selectMaterialProductHistory">
|
</collection>
|
</resultMap>
|
-->
|
<!--<select id="getAllMaterial" resultMap="productBomList">
|
select distinct * from tb_Material
|
<where>
|
1=1
|
<if test="category!=null&&category!=''">
|
and category like '%${category}%'
|
</if>
|
<if test="subCode!=null&&subCode!=''">
|
and sub_code like '%${subCode}%'
|
</if>
|
<if test="subName!=null&&subName!=''">
|
and sub_name like '%${subName}%'
|
</if>
|
<if test="subModel!=null&&subModel!=''">
|
and sub_name like '%${subModel}%'
|
</if>
|
</where>
|
order by id asc
|
</select>-->
|
<!--<select id="selectMaterialProductHistory" resultType="com.whyc.pojo.MaterialProductHistory">
|
select DISTINCT tb_material_product_history.* FROM tb_product_bom,tb_material_product_history
|
where tb_product_bom.version=tb_material_product_history.e_version
|
and tb_product_bom.parent_model=tb_material_product_history.parent_model and tb_material_product_history.material_id=#{id}
|
</select>-->
|
|
|
<!--<resultMap id="replaceBom" type="productBom">
|
<!– <result property="parentCode" column="parent_code"></result>
|
<result property="parentModel" column="parent_model"></result>
|
<result property="parentName" column="parent_name"></result>
|
<result property="oldSubName" column="old_subName"></result>–>
|
<result property="type" column="type"></result>
|
<result property="category" column="category"></result>
|
<result property="subCode" column="sub_code"></result>
|
<result property="subName" column="sub_name"></result>
|
<result property="subModel" column="sub_model"></result>
|
<result property="unit" column="unit"></result>
|
<result property="quantity" column="quantity"></result>
|
<result property="producer" column="producer"></result>
|
<result property="material" column="material"></result>
|
<result property="thickness" column="thickness"></result>
|
<result property="surfaceDetail" column="surface_detail"></result>
|
<result property="notes" column="notes"></result>
|
<result property="pictureUrl" column="picture_url"></result>
|
<result property="fileUrl" column="file_url"></result>
|
<result property="upUserId" column="up_user_id"></result>
|
<result property="createDate" column="create_date"></result>
|
<!–<result property="updateDate" column="update_date"></result>–>
|
<result property="dwgUrl" column="dwg_url"></result>
|
<result property="version" column="version"></result>
|
<!–<result property="parentVersion" column="parent_version"></result>–>
|
</resultMap>-->
|
<!--<select id="getReplaceMaterial" resultMap="replaceBom">
|
select distinct tb_Material.*,tb_material_product_history.sub_name as old_subName
|
,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
|
,tb_material_product_history.e_version as version
|
from tb_Material,tb_material_product_history,tb_product_bom
|
where tb_Material.id=tb_material_product_history.material_id
|
and tb_material_product_history.parent_model=tb_product_bom.parent_model
|
and tb_product_bom.version=tb_material_product_history.e_version
|
and tb_material_product_history.parent_model=#{parentModel}
|
and tb_material_product_history.link_type=2
|
</select>-->
|
<!-- <resultMap id="replaceHisBom" type="productBomHistory">
|
<!–<result property="parentCode" column="parent_code"></result>
|
<result property="parentModel" column="parent_model"></result>
|
<result property="parentName" column="parent_name"></result>–>
|
<result property="oldSubName" column="old_subName"></result>
|
<result property="type" column="type"></result>
|
<result property="category" column="category"></result>
|
<result property="subCode" column="sub_code"></result>
|
<result property="subName" column="sub_name"></result>
|
<result property="subModel" column="sub_model"></result>
|
<result property="unit" column="unit"></result>
|
<result property="quantity" column="quantity"></result>
|
<result property="producer" column="producer"></result>
|
<result property="material" column="material"></result>
|
<result property="thickness" column="thickness"></result>
|
<result property="surfaceDetail" column="surface_detail"></result>
|
<result property="notes" column="notes"></result>
|
<result property="pictureUrl" column="picture_url"></result>
|
<result property="fileUrl" column="file_url"></result>
|
<result property="upUserId" column="up_user_id"></result>
|
<result property="createDate" column="create_date"></result>
|
<result property="dwgUrl" column="dwg_url"></result>
|
<!– <result property="parentVersion" column="parent_version"></result>–>
|
</resultMap>-->
|
<!--<select id="getReplaceHisMaterial" resultMap="replaceHisBom">
|
select distinct tb_Material.*,tb_material_product_history.sub_name as old_subName
|
,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
|
from tb_Material,tb_material_product_history,tb_product_bom
|
where tb_Material.id=tb_material_product_history.material_id
|
and tb_material_product_history.parent_model=tb_product_bom.parent_model
|
and tb_material_product_history.parent_model=#{parentModel}
|
and tb_material_product_history.link_type=2
|
and tb_material_product_history.s_version<=#{version}
|
and tb_material_product_history.e_version>=#{version}
|
</select>-->
|
<update id="updateDwgUrl">
|
<foreach collection="list" item="item" separator=";">
|
update tb_material set dwg_url = #{item.notes} where sub_model = #{item.subModel}
|
</foreach>
|
</update>
|
<update id="updateDwgUrlAndPicUrl">
|
<foreach collection="list" item="item" separator=";">
|
update tb_material
|
<set>
|
<if test="item.dwgUrl!=null">
|
dwg_url = #{item.dwgUrl},
|
</if>
|
<if test="item.pictureUrl!=null">
|
picture_url = #{item.pictureUrl},
|
</if>
|
</set>
|
where sub_code = #{item.subCode} and sub_model = #{item.subModel}
|
</foreach>
|
</update>
|
<update id="disableStatus">
|
update tb_material set status = 0 where sub_code in
|
<foreach collection="list" item="item" separator="," open="(" close=")">
|
#{item.subCode}
|
</foreach>
|
</update>
|
<resultMap id="materialList" type="Material">
|
<id property="id" column="id"></id>
|
<result property="type" column="type"></result>
|
<!--<result property="category" column="category"></result>-->
|
<result property="subCode" column="sub_code"></result>
|
<result property="subName" column="sub_name"></result>
|
<result property="subModel" column="sub_model"></result>
|
<result property="unit" column="unit"></result>
|
<!--<result property="producer" column="producer"></result>
|
<result property="material" column="material"></result>
|
<result property="thickness" column="thickness"></result>
|
<result property="surfaceDetail" column="surface_detail"></result>
|
<result property="notes" column="notes"></result>-->
|
<result property="pictureUrl" column="picture_url"></result>
|
<result property="fileUrl" column="file_url"></result>
|
<result property="upUserId" column="up_user_id"></result>
|
<result property="createDate" column="create_date"></result>
|
<result property="updateDate" column="update_date"></result>
|
<result property="dwgUrl" column="dwg_url"></result>
|
<collection property="mproductHistorys" javaType="java.util.ArrayList" ofType="com.whyc.pojo.MaterialProductHistory" column="{id=id}" select="selectMaterialProductHistory">
|
</collection>
|
<collection property="products" javaType="java.util.ArrayList" ofType="com.whyc.pojo.Product" column="{id=id}" select="selectMaterialInProduct">
|
</collection>
|
<collection property="attachLocks" javaType="java.util.ArrayList" ofType="com.whyc.pojo.AttachLock" column="{id=id}" select="selectAttachLock">
|
</collection>
|
</resultMap>
|
|
<select id="getMaterialLimit" resultMap="materialList">
|
select * from tb_Material
|
<where>
|
1=1
|
<if test="subCode!=null&&subCode!=''">
|
and sub_code like '%${subCode}%'
|
</if>
|
<if test="subName!=null&&subName!=''">
|
and sub_name like '%${subName}%'
|
</if>
|
<if test="subModel!=null&&subModel!=''">
|
and sub_model like '%${subModel}%'
|
</if>
|
</where>
|
order by id asc
|
</select>
|
<select id="selectMaterialProductHistory" resultType="com.whyc.pojo.MaterialProductHistory">
|
select DISTINCT tb_material_product_history.* FROM tb_material_product_history,tb_product
|
where tb_product.version>=tb_material_product_history.s_version and tb_product.version<=tb_material_product_history.e_version
|
and tb_product.parent_code=tb_material_product_history.parent_code
|
and tb_product.custom_code=tb_material_product_history.custom_code
|
and tb_material_product_history.sub_material_id=#{id}
|
</select>
|
<resultMap id="productIds" type="product">
|
<id property="id" column="id"></id>
|
<result property="parentCode" column="parent_code"></result>
|
<result property="parentName" column="parent_name"></result>
|
<result property="parentModel" column="parent_model"></result>
|
<result property="notes" column="notes"></result>
|
<result property="customCode" column="custom_code"></result>
|
<result property="createTime" column="create_time"></result>
|
<result property="version" column="version"></result>
|
<collection property="materialIds" ofType="java.lang.Integer" >
|
<result property="materialId" column="material_id"></result>
|
</collection>
|
</resultMap>
|
|
<select id="selectMaterialInProduct" resultMap="productIds">
|
select p.*,tb_material_product_history.material_id from (select DISTINCT tb_product.* FROM tb_product, tb_product_bom
|
where tb_product.id=tb_product_bom.product_id and tb_product_bom.material_id=#{id}) as p
|
left outer join tb_material_product_history on
|
tb_material_product_history.parent_code= p.parent_code and tb_material_product_history.custom_code= p.custom_code
|
and p.version>=tb_material_product_history.s_version and p.version<=tb_material_product_history.e_version
|
and tb_material_product_history.sub_material_id=#{id}
|
</select>
|
<select id="selectAttachLock" resultType="com.whyc.pojo.AttachLock">
|
select DISTINCT tb_attach_lock.* FROM tb_attach_lock
|
where material_id=#{id}
|
</select>
|
|
<select id="getListByCodeList" resultType="java.lang.String">
|
SELECT sub_code FROM tb_material where sub_code in
|
<foreach collection="list" item="code" separator="," open="(" close=")">
|
${code}
|
</foreach>
|
</select>
|
<select id="getListByCodeAndModelList" resultType="com.whyc.pojo.Material">
|
<foreach collection="list" item="item" separator=" union ">
|
select sub_code,sub_model from tb_material where sub_code = #{item.subCode} and sub_model = #{item.subModel}
|
</foreach>
|
</select>
|
<select id="getListByCodeAndModelList2" resultType="com.whyc.pojo.Material">
|
<foreach collection="list" item="item" separator=" union ">
|
select id,sub_code,sub_model from tb_material where sub_code = #{item.subCode} and sub_model = #{item.subModel}
|
</foreach>
|
</select>
|
<select id="getListByCodeAndModelList3" resultType="com.whyc.pojo.Material">
|
<foreach collection="list" item="item" separator=" union ">
|
select id,sub_code,sub_model,dwg_url from tb_material where sub_code = #{item.subCode} and sub_model = #{item.subModel} and dwg_url is not null and dwg_url!=""
|
</foreach>
|
</select>
|
<select id="getAttachByMaterialId" resultType="com.whyc.pojo.Material">
|
select * from tb_material WHERE id = #{materialId} limit 1
|
</select>
|
<select id="getMaterialVersion" resultType="material">
|
SELECT distinct *
|
FROM tb_material WHERE sub_model LIKE '${subModel}%'
|
ORDER BY create_date DESC
|
</select>
|
<resultMap id="materialInfo" type="Material">
|
<id property="id" column="id"></id>
|
<result property="type" column="type"></result>
|
<!--<result property="category" column="category"></result>-->
|
<result property="subCode" column="sub_code"></result>
|
<result property="subName" column="sub_name"></result>
|
<result property="subModel" column="sub_model"></result>
|
<result property="unit" column="unit"></result>
|
<!--<result property="producer" column="producer"></result>
|
<result property="material" column="material"></result>
|
<result property="thickness" column="thickness"></result>
|
<result property="surfaceDetail" column="surface_detail"></result>
|
<result property="notes" column="notes"></result>-->
|
<result property="pictureUrl" column="picture_url"></result>
|
<result property="fileUrl" column="file_url"></result>
|
<result property="upUserId" column="up_user_id"></result>
|
<result property="createDate" column="create_date"></result>
|
<result property="updateDate" column="update_date"></result>
|
<result property="dwgUrl" column="dwg_url"></result>
|
<collection property="products" javaType="java.util.ArrayList" ofType="com.whyc.pojo.Product" column="{id=id}" select="selectInProduct">
|
</collection>
|
<collection property="attachLocks" javaType="java.util.ArrayList" ofType="com.whyc.pojo.AttachLock" column="{id=id}" select="selectInAttachLock">
|
</collection>
|
</resultMap>
|
<select id="getMaterialById" resultMap="materialInfo">
|
select * from tb_material WHERE id = #{materialId} limit 1
|
</select>
|
<select id="selectInProduct" resultType="product">
|
select DISTINCT tb_product.* FROM tb_product,tb_product_bom
|
where tb_product.id=tb_product_bom.product_id
|
and tb_product_bom.material_id=#{id}
|
</select>
|
<select id="selectInAttachLock" resultType="attachLock">
|
select DISTINCT tb_attach_lock.* FROM tb_attach_lock
|
where tb_attach_lock.material_id=#{id}
|
</select>
|
|
<select id="getSameSubCodeAndModel" resultType="com.whyc.pojo.Material">
|
select * from tb_material where
|
<foreach collection="list" item="item" separator="or">
|
(sub_code = #{item.subCode} and sub_model = #{item.subModel})
|
</foreach>
|
</select>
|
</mapper>
|