zss
2023-08-30 af9457d7ce94c7684a9439d46b0025bd6e66d8af
standard-server/src/main/resources/mapper/MaterialMapper.xml
@@ -3,49 +3,42 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yuanchu.mom.mapper.MaterialMapper">
    <resultMap id="BaseResultMap" type="Material">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="version" column="version" jdbcType="INTEGER"/>
    <!--标准MOM 左侧五级树展示-->
    <resultMap id="selectTreeByMaterialMap" type="map">
        <id property="id" column="type"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps1" javaType="List"/>
    </resultMap>
    <resultMap id="materialTreeDto" type="materialTreeDto">
    <resultMap id="selectTreeByMaterialMaps1" type="map">
        <id property="name" column="father"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps2" javaType="List"/>
    </resultMap>
    <resultMap id="selectTreeByMaterialMaps2" type="map">
        <id property="id" column="mid"/>
        <result property="name" column="mname"/>
        <result property="type" column="type"/>
        <association property="children" resultMap="standardDto"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps3" javaType="List"/>
    </resultMap>
    <resultMap id="standardDto" type="standardDto">
    <resultMap id="selectTreeByMaterialMaps3" type="map">
        <id property="id" column="sid"/>
        <result property="name" column="sname"/>
        <association property="children" resultMap="specificationsDto"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps4" javaType="List"/>
    </resultMap>
    <resultMap id="specificationsDto" type="specificationsDto">
    <resultMap id="selectTreeByMaterialMaps4" type="map">
        <id property="id" column="spid"/>
        <result property="name" column="spname"/>
    </resultMap>
    <select id="selectTreeByMaterial" resultMap="materialTreeDto">
        select m.type,
               m.id    mid,
               m.name  mname,
               s.id    sid,
               s.name  sname,
               s2.id   spid,
               s2.name spname,
               p.id    pid,
               p.name  pname
        from (select type, id, name from material where state = 1) m
                 left join (select id, name, material_id from standard where state = 1) s on m.id = s.material_id
                 left join (select id, name, standard_id from specifications where state = 1) s2
                           on s2.standard_id = s.id
                 left join (select id, name, specifications_id from product where state = 1) p
                           on s2.id = p.specifications_id
    <select id="selectTreeByMaterial" resultMap="selectTreeByMaterialMap" >
        select m.type, #一级类型
               father, #二级产品大类(4大类)
               m.id    mid, #三级物料id
               m.name  mname, #三级样品名称
               s.id    sid, #四级标准id
               s.name  sname, #四级标准名
               sp.id   spid, #五级型号id
               sp.name spname #五级型号名
        from (select type, id, name,father from mom_ocean.material where state = 1) m
                 left join (select id, name, material_id from mom_ocean.standard where state = 1) s on m.id = s.material_id
                 left join (select id, name, standard_id from mom_ocean.specifications where state = 1) sp
                           on sp.standard_id = s.id
    </select>
    <select id="selectMcodeId" resultType="com.yuanchu.mom.pojo.Material">