123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <?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.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper">
- <resultMap id="BaseResultMap" type="com.platform.dao.entity.sqarepartmanage.SparePartInfo">
- <id column="id" jdbcType="VARCHAR" property="id"/>
- <result column="unite_no" jdbcType="VARCHAR" property="uniteNo"/>
- <result column="no" jdbcType="VARCHAR" property="no"/>
- <result column="init_no" jdbcType="VARCHAR" property="initNo"/>
- <result column="name_no" jdbcType="VARCHAR" property="nameNo"/>
- <result column="gg_no" jdbcType="VARCHAR" property="ggNo"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="type_id" jdbcType="VARCHAR" property="typeId"/>
- <result column="parent_type_id" jdbcType="VARCHAR" property="parentTypeId"/>
- <result column="middle_type_id" jdbcType="VARCHAR" property="middleTypeId"/>
- <result column="child_type_id" jdbcType="VARCHAR" property="childTypeId"/>
- <result column="parent_no" jdbcType="VARCHAR" property="parentNo"/>
- <result column="middle_no" jdbcType="VARCHAR" property="middleNo"/>
- <result column="child_no" jdbcType="VARCHAR" property="childNo"/>
- <result column="image" jdbcType="VARCHAR" property="image"/>
- <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
- <result column="level" jdbcType="SMALLINT" property="level"/>
- <result column="is_special" jdbcType="SMALLINT" property="isSpecial"/>
- <result column="initial_value" jdbcType="DOUBLE" property="initialValue"/>
- <result column="producer_id" jdbcType="VARCHAR" property="producerId"/>
- <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/>
- <result column="unit" jdbcType="VARCHAR" property="unit"/>
- <result column="warn_status" jdbcType="SMALLINT" property="warnStatus"/>
- <result column="forecast_status" jdbcType="SMALLINT" property="forecastStatus"/>
- <result column="unit_bz" jdbcType="SMALLINT" property="unitBz"/>
- <result column="unit_rate" jdbcType="DOUBLE" property="unitRate"/>
- <result column="max_stock" jdbcType="DOUBLE" property="maxStock"/>
- <result column="min_stock" jdbcType="DOUBLE" property="minStock"/>
- <result column="init_stock" jdbcType="DOUBLE" property="initStock"/>
- <result column="zbh" jdbcType="VARCHAR" property="zbh"/>
- <result column="ggxh" jdbcType="VARCHAR" property="ggxh"/>
- <result column="english_name" jdbcType="VARCHAR" property="englishName"/>
- <result column="zjm" jdbcType="VARCHAR" property="zjm"/>
- <result column="cd" jdbcType="INTEGER" property="cd"/>
- <result column="yt" jdbcType="INTEGER" property="yt"/>
- <result column="purchase_period" jdbcType="DECIMAL" property="purchasePeriod"/>
- <result column="age_period" jdbcType="DECIMAL" property="agePeriod"/>
- <result column="use_period" jdbcType="DECIMAL" property="usePeriod"/>
- <result column="params" jdbcType="VARCHAR" property="params"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="created_user_id" jdbcType="VARCHAR" property="createdUserId"/>
- <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId"/>
- <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <association column="type_id" javaType="string" property="typeName"
- select="com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper.selectNameById"/>
- <association column="producer_id" javaType="string" property="producerName"
- select="com.platform.dao.mapper.firm.FirmProducerMapper.selectNameById"/>
- <association column="supplier_id" javaType="string" property="supplierName"
- select="com.platform.dao.mapper.purchase.SupplierMapper.selectNameById"/>
- </resultMap>
- <sql id="Base_Column_List">
- id, no, unite_no, gg_no, name_no, name, type_id, level, initial_value, producer_id,
- unit,
- is_special,
- purchase_period,
- use_period,age_period,
- unit_bz,
- warn_status,forecast_status,
- unit_rate,
- image,
- qr_code,
- max_stock, min_stock,init_stock,supplier_id,
- remark, created_user_id, update_user_id, created_time, update_time,
- zbh,init_no,
- parent_type_id,
- child_type_id,
- middle_type_id,
- child_no,
- parent_no,
- middle_no,
- ggxh,
- english_name,
- zjm,
- cd,
- yt,
- brand
- </sql>
- <select id="selectPageList" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
- resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
- select info.*, SUM(spareStore.num) currentStock
- from t_spare_part_info info
- LEFT JOIN t_spare_store spareStore on spareStore.spare_id = info.id
- <if test="producerName != null and producerName != ''">
- LEFT JOIN t_firm_producer producer on producer.id = info.producer_id
- </if>
- <if test="supplierName != null and supplierName != ''">
- LEFT JOIN t_supplier supplier on supplier.id = info.supplier_id
- </if>
- <where>
- <if test="spareIdList != null and spareIdList.size > 0">
- and sparestore.spare_id in
- <foreach item="item" index="index" collection="spareIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="warnStatusList != null and warnStatusList.size > 0">
- AND info.warn_status in
- <foreach item="item" index="index" collection="warnStatusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="forecastStatusList != null and forecastStatusList.size > 0">
- AND info.forecast_status in
- <foreach item="item" index="index" collection="forecastStatusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="typeId != null and typeId != ''">
- and info.type_id = #{typeId}
- </if>
- <if test="isSpecial != null and isSpecial != ''">
- and info.is_special = #{isSpecial}
- </if>
- <if test="producerName != null and producerName != ''">
- AND producer.name like concat('%',#{producerName},'%')
- </if>
- <if test="supplierName != null and supplierName != ''">
- AND supplier.name like concat('%',#{supplierName},'%')
- </if>
- <if test="keyword != null and keyword != ''">
- AND ( info.name like concat('%',#{keyword},'%') or
- info.no like concat('%',#{keyword},'%'))
- </if>
- <if test="name != null and name != ''">
- AND info.name = #{name}
- </if>
- <if test="warnStatus != null and warnStatus != ''">
- AND info.warn_status = #{warnStatus}
- </if>
- <if test="forecastStatus != null and forecastStatus != ''">
- AND info.forecast_status = #{forecastStatus}
- </if>
- <if test="ggxh != null and ggxh != ''">
- AND info.ggxh like concat('%',#{ggxh},'%')
- </if>
- <if test="initNo != null and initNo != ''">
- AND info.init_no like concat('%',#{initNo},'%')
- </if>
- <if test="yt != null">
- AND info.yt=#{yt}
- </if>
- <if test="storeId != null and storeId != ''">
- AND spare.store_id=#{storeId}
- </if>
- <if test="level != null and level != ''">
- AND info.level=#{level}
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- AND info.type_id in
- <foreach item="item" index="index" collection="typeIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="producerId != null and producerId != ''">
- AND info.producer_id=#{producerId}
- </if>
- <if test="supplierId != null and producerId != ''">
- AND info.supplier_id=#{supplierId}
- </if>
- <if test="parentTypeId != null and parentTypeId != ''">
- AND info.parent_type_id=#{parentTypeId}
- </if>
- <!-- <if test="typeId != null and typeId != ''">
- AND info.type_id=#{typeId}
- </if>-->
- <if test="parentNo != null and parentNo != ''">
- AND info.parent_no=#{parentNo}
- </if>
- <if test="childNo != null and childNo != ''">
- AND info.child_no=#{childNo}
- </if>
- <if test="searchMinStockWarn">
- AND info.min_stock is not null
- </if>
- <if test="searchMinStockWarn">
- AND info.warn_status = 0
- </if>
- <if test="searchType">
- AND info.type_id not in (select id from t_spare_type)
- </if>
- <if test="brand!=null">
- and info.brand like concat('%',#{brand},'%')
- </if>
- </where>
- group by info.id
- <if test="searchMinStockWarn">
- HAVING info.min_stock > SUM( spareStore.num )
- </if>
- </select>
- <select id="selectMaxNo" parameterType="java.lang.Object" resultType="java.lang.String">
- select max(no) from t_spare_part_info
- where type_id = #{value}
- </select>
- <select id="selectById" parameterType="java.lang.Object" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from t_spare_part_info
- where id = #{value}
- </select>
- <select id="selectNameById" parameterType="java.lang.Object" resultType="java.lang.String">
- select name
- from t_spare_part_info
- where id = #{value}
- </select>
- <select id="selectSpareInfoList" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
- select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
- spare.initial_value, spare.producer_id,
- spare.unit,
- spare.unit_bz,spare.warn_status, spare.forecast_status,
- spare.unit_rate,
- spare.image,
- spare.qr_code,
- spare.zbh,spare.init_no,
- spare.gg_no, spare.name_no,
- spare.ggxh,
- spare.english_name,
- spare.zjm,
- spare.cd,
- spare.yt,
- tcpsr.id as id,
- tcpsr.period,
- tcpsr.period_type as periodType,
- tcpsr.sb_id as sbId, tcpsr.num as num,
- part.name as sbPartName
- from t_spare_part_info spare
- left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
- LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
- where tcpsr.sb_id = #{id}
- </select>
- <select id="selectSpareInfoListBySbId" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
- select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
- spare.initial_value, spare.producer_id,
- spare.unit,
- spare.unit_bz,spare.warn_status, spare.forecast_status,
- spare.unit_rate,
- spare.image,
- spare.qr_code,
- spare.zbh,spare.init_no,
- spare.gg_no, spare.name_no,
- spare.ggxh,
- spare.english_name,
- spare.zjm,
- spare.cd,
- spare.yt,
- tcpsr.id as id,
- tcpsr.period,
- tcpsr.period_type as periodType,
- tcpsr.model_id as modelId,
- tcpsr.sb_id as sbId,
- part.name as sbPartName
- from t_spare_part_info spare
- left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
- LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
- where tcpsr.sb_id = #{id}
- </select>
- <update id="updateBatch" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">
- update t_spare_part_info
- <set>
- <if test="item.parentTypeId != null">
- parent_type_id = #{item.parentTypeId},
- </if>
- <if test="item.childTypeId != null">
- child_type_id = #{item.childTypeId},
- </if>
- <if test="item.middleTypeId != null">
- middle_type_id = #{item.middleTypeId},
- </if>
- <if test="item.parentTypeId == null">
- parent_type_id = null,
- </if>
- <if test="item.childTypeId == null">
- child_type_id = null,
- </if>
- <if test="item.middleTypeId == null">
- middle_type_id = null,
- </if>
- <if test="item.parentNo != null">
- parent_no = #{item.parentNo},
- </if>
- <if test="item.middleNo != null">
- middle_no = #{item.middleNo},
- </if>
- <if test="item.warnStatus != null">
- warn_status = #{item.warnStatus},
- </if>
- <if test="item.forecastStatus != null">
- forecast_status = #{item.forecastStatus},
- </if>
- <if test="item.isSpecial != null">
- is_special = #{item.isSpecial},
- </if>
- <if test="item.unit != null">
- child_no = #{item.childNo},
- </if>
- <if test="item.typeId != null">
- type_id = #{item.typeId},
- </if>
- <if test="item.ggxh != null">
- ggxh = #{item.ggxh},
- </if>
- <if test="item.name != null">
- name = #{item.name},
- </if>
- <if test="item.unit != null">
- unit = #{item.unit},
- </if>
- <if test="item.initNo != null">
- init_no = #{item.initNo},
- </if>
- <if test="item.initialValue != null">
- initial_value = #{item.initialValue}
- </if>
- </set>
- where id = #{item.id}
- </foreach>
- </update>
- <!-- 维修和保养获取备件信息List -->
- <select id="getSpareListBySbInfo" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
- resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
- select spi.* from t_sb_model_spare_bom sm left join t_spare_part_info spi on sm.spare_id = spi.id
- <where>
- <if test="sbId != null">
- and sm.sb_id = #{sbId}
- </if>
- <if test="name != null and name != ''">
- and spi.name like concat('%',#{name},'%')
- </if>
- <if test="isSpecial != null">
- and spi.is_special = #{isSpecial}
- </if>
- </where>
- </select>
- <select id="getInOrOut" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
- resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
- select info.*, SUM(spareStore.num) currentStock,store.name as storeName,spareStore.id as spareStoreId
- from t_spare_part_info info
- LEFT JOIN t_spare_store spareStore on spareStore.spare_id = info.id
- left join t_store store on spareStore.store_id = store.id
- <if test="producerName != null and producerName != ''">
- LEFT JOIN t_firm_producer producer on producer.id = info.producer_id
- </if>
- <if test="supplierName != null and supplierName != ''">
- LEFT JOIN t_supplier supplier on supplier.id = info.supplier_id
- </if>
- <where>
- <if test="spareIdList != null and spareIdList.size > 0">
- and sparestore.spare_id in
- <foreach item="item" index="index" collection="spareIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="warnStatusList != null and warnStatusList.size > 0">
- AND info.warn_status in
- <foreach item="item" index="index" collection="warnStatusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="forecastStatusList != null and forecastStatusList.size > 0">
- AND info.forecast_status in
- <foreach item="item" index="index" collection="forecastStatusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="typeId != null and typeId != ''">
- and info.type_id = #{typeId}
- </if>
- <if test="isSpecial != null and isSpecial != ''">
- and info.is_special = #{isSpecial}
- </if>
- <if test="producerName != null and producerName != ''">
- AND producer.name like concat('%',#{producerName},'%')
- </if>
- <if test="supplierName != null and supplierName != ''">
- AND supplier.name like concat('%',#{supplierName},'%')
- </if>
- <if test="keyword != null and keyword != ''">
- AND ( info.name like concat('%',#{keyword},'%') or
- info.no like concat('%',#{keyword},'%'))
- </if>
- <if test="name != null and name != ''">
- AND info.name = #{name}
- </if>
- <if test="warnStatus != null and warnStatus != ''">
- AND info.warn_status = #{warnStatus}
- </if>
- <if test="forecastStatus != null and forecastStatus != ''">
- AND info.forecast_status = #{forecastStatus}
- </if>
- <if test="ggxh != null and ggxh != ''">
- AND info.ggxh like concat('%',#{ggxh},'%')
- </if>
- <if test="initNo != null and initNo != ''">
- AND info.init_no like concat('%',#{initNo},'%')
- </if>
- <if test="yt != null">
- AND info.yt=#{yt}
- </if>
- <if test="storeId != null and storeId != ''">
- AND spare.store_id=#{storeId}
- </if>
- <if test="level != null and level != ''">
- AND info.level=#{level}
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- AND info.type_id in
- <foreach item="item" index="index" collection="typeIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="producerId != null and producerId != ''">
- AND info.producer_id=#{producerId}
- </if>
- <if test="supplierId != null and producerId != ''">
- AND info.supplier_id=#{supplierId}
- </if>
- <if test="parentTypeId != null and parentTypeId != ''">
- AND info.parent_type_id=#{parentTypeId}
- </if>
- <!-- <if test="typeId != null and typeId != ''">
- AND info.type_id=#{typeId}
- </if>-->
- <if test="parentNo != null and parentNo != ''">
- AND info.parent_no=#{parentNo}
- </if>
- <if test="childNo != null and childNo != ''">
- AND info.child_no=#{childNo}
- </if>
- <if test="searchMinStockWarn">
- AND info.min_stock is not null
- </if>
- <if test="searchMinStockWarn">
- AND info.warn_status = 0
- </if>
- <if test="searchType">
- AND info.type_id not in (select id from t_spare_type)
- </if>
- <if test="brand!=null">
- and info.brand like concat('%',#{brand},'%')
- </if>
- </where>
- group by info.id
- <if test="searchMinStockWarn">
- HAVING info.min_stock > SUM( spareStore.num )
- </if>
- </select>
- </mapper>
|