123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?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.tld.mapper.ReceiveGoodsMapper">
- <!-- 查询收货单 -->
- <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- select
- a.id,
- a.order_code,
- b.name as materialName,
- c.name as supplierName,
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.arrival_time,
- c.code as wllbCode
- from tld_receive_goods a
- left join tld_material b on a.material_id = b.tld_id
- left join tld_customer c on a.supplier_id = c.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <!-- <if test="materialId != null and materialId != ''">-->
- <!-- and a.material_id = #{materialId}-->
- <!-- </if>-->
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="startTime != null and startTime != ''">
- and a.arrival_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.arrival_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="orderCode != null and orderCode != ''">
- and a.order_code = #{orderCode}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询超时采购单 -->
- <select id="getPastReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- select
- a.id,
- a.order_code,
- b.name as materialName,
- c.name as supplierName,
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.arrival_time
- from tld_receive_goods a
- left join tld_material b on a.material_id = b.tld_id
- left join tld_customer c on a.supplier_id = c.code
- where a.type = "0" and a.arrival_time <![CDATA[<]]> CURDATE()
- <if test="orderCode != null and orderCode != ''">
- and a.order_code = #{orderCode}
- </if>
- order by a.id desc
- </select>
- <!-- 查询采购父表是否有次采购单的数据 -->
- <select id="getReceiveGoodsf" resultType="int">
- select count(*) from tld_receive_goods_f where order_code = #{orderCode}
- </select>
- <!-- 新增采购单信息 -->
- <insert id="addReceiveGoods">
- insert into tld_receive_goods(order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num)
- values(#{orderCode},#{materialId},#{purchaseNum},#{arrivalNum},#{type},#{qualifiedNum},#{disqualificationNum},#{wbs},#{arrivalTime},#{measurementId},#{supplierId},#{entryNumber},'0');
- </insert>
- <!-- 新增采购单信息 -->
- <insert id="addReceiveGoodsf">
- insert into tld_receive_goods_f(order_number,order_code,company_number,supplier_id,arrival_time,order_type,source_type,move_type)
- values(#{orderNumber},#{orderCode},#{companyNumber},#{supplierId},#{arrivalTime},#{orderType},#{sourceType},#{moveType})
- </insert>
- <!-- 修改采购单信息 -->
- <update id="updateReceiveGoods">
- update tld_receive_goods
- <set>
- <trim suffixOverrides=",">
- <if test="arrivalNum != null and arrivalNum != ''">
- arrival_num = #{arrivalNum},
- </if>
- <if test="qualifiedNum != null and qualifiedNum != ''">
- qualified_num = #{qualifiedNum},
- </if>
- <if test="disqualificationNum != null and disqualificationNum != ''">
- disqualification_num = #{disqualificationNum},
- </if>
- <if test="arrivalTime != null and arrivalTime != ''">
- arrival_time = #{arrivalTime},
- </if>
- <if test="type != null and type != ''">
- type = #{type},
- </if>
- </trim>
- </set>
- where order_code = #{orderCode};
- update tld_receive_goods_f
- <set>
- <trim suffixOverrides=",">
- <if test="supplierId != null and supplierId != ''">
- supplier_id = #{supplierId},
- </if>
- <if test="arrivalTime != null and arrivalTime != ''">
- arrival_time = #{arrivalTime},
- </if>
- <if test="orderType != null and orderType != ''">
- order_type = #{orderType},
- </if>
- <if test="sourceType != null and sourceType != ''">
- source_type = #{sourceType},
- </if>
- <if test="moveType != null and moveType != ''">
- move_type = #{moveType},
- </if>
- </trim>
- </set>
- where order_code = #{orderCode};
- </update>
- <!-- 采购单日志 -->
- <insert id="addReceiveGoodsLog" keyProperty="id" useGeneratedKeys="true">
- insert into tld_receive_goods_log(order_number, order_code, company_number, supplier_id, arrival_time, order_type, source_type, move_type, material_id, purchase_num, arrival_num, qualified_num, disqualification_num, wbs, measurement_id)
- values (#{orderNumber}, #{orderCode}, #{companyNumber}, #{supplierId}, #{arrivalTime}, #{orderType}, #{sourceType}, #{moveType}, #{materialId}, #{purchaseNum}, #{arrivalNum}, #{qualifiedNum}, #{disqualificationNum}, #{wbs}, #{measurementId})
- </insert>
- <!-- 新增采购到料大屏信息 -->
- <insert id="addPurchase">
- insert into tld_purchase(supplier_id,order_code,material_id,purchase_num,arrival_num,arrival_time,type)
- values
- <foreach collection="jsonData" index="index" item="item" separator=",">
- (#{item.supplierId},#{item.orderCode},#{item.materialId},#{item.purchaseNum},#{item.arrivalNum},#{item.arrivalTime},'0')
- </foreach>
- </insert>
- <!-- 修改采购到料状态 -->
- <update id="updatePurchaseType">
- update tld_purchase set type = '1' where order_code = #{orderCode}
- </update>
- <!-- 查询采购单 -->
- <select id="getPurchase" resultType="com.tld.model.ReceiveGoods">
- select
- a.id,
- a.supplier_id,
- a.order_code,
- a.material_id,
- a.purchase_num,
- a.arrival_num,
- a.arrival_time,
- a.type,
- b.name as materialName,
- b.code as wllbCode,
- c.name as supplierName
- from tld_purchase a
- left join tld_material b on a.material_id = b.tld_id
- left join tld_customer c on a.supplier_id = c.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="orderCode != null and orderCode != ''">
- and a.order_code = #{orderCode}
- </if>
- <if test="startTime != null and startTime != ''">
- and a.arrival_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.arrival_time <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- </select>
- <!-- 查询超时采购单 -->
- <select id="timeoutPurchase" resultType="com.tld.model.ReceiveGoods">
- select
- a.id,
- a.supplier_id,
- a.order_code,
- a.material_id,
- a.purchase_num,
- a.arrival_num,
- a.arrival_time,
- a.type,
- b.name as materialName,
- b.code as wllbCode,
- c.name as supplierName
- from tld_purchase a
- left join tld_material b on a.material_id = b.tld_id
- left join tld_customer c on a.supplier_id = c.tld_id
- where
- a.arrival_time <![CDATA[<]]> CURDATE() and type = '0'
- <if test="orderCode != null and orderCode != ''">
- and a.order_code = #{orderCode}
- </if>
- <if test="startTime != null and startTime != ''">
- and a.arrival_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.arrival_time <![CDATA[<=]]> #{endTime}
- </if>
- </select>
- </mapper>
|