| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- <?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,
- b.code as wllbCode,
- -- a.wbs,
- g.code as wbs,
- e.company_number as companyNumber,
- e.supplier_id as supplierId,
- p.name as compName
- 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
- left join tld_receive_goods_f e on a.order_code = e.order_code
- left join tld_company p on e.company_number = p.code
- left join tld_wbs g on a.wbs = g.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
- </if>
- <if test="materialCode != null and materialCode != ''">
- and b.code like CONCAT(CONCAT('%',#{materialCode},'%'))
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and e.company_number = #{companyNumber}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
- </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 like CONCAT(CONCAT('%',#{orderCode},'%'))
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
- </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}, 0+CAST(#{qualifiedNum} as char),
- #{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">
- arrival_num = #{arrivalNum},
- </if>
- <if test="qualifiedNum != null">
- qualified_num = #{qualifiedNum},
- </if>
- <if test="disqualificationNum != null">
- disqualification_num = #{disqualificationNum},
- </if>
- <if test="arrivalTime != null">
- arrival_time = #{arrivalTime},
- </if>
- <if test="type != null">
- 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}, 0+CAST(#{qualifiedNum} as char),
- #{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.DateTime},'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.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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>
- order by a.id desc
- </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.code
- where
- a.arrival_time <![CDATA[<]]> CURDATE() and a.type = '0'
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{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>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- order by a.id desc
- </select>
- <!-- 查询 原始记录 -->
- <select id="getDelReceiveGoods" resultType="java.util.Map">
- select *
- from tld_receive_goods
- where id = #{id}
- </select>
- <!--采购单导出-->
- <select id="purchaseExport" resultType="java.util.LinkedHashMap">
- select
- a.supplier_id,
- b.code as wllbCode,
- b.name as materialName,
- c.name as supplierName,
- a.arrival_num,
- a.arrival_time
- 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.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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>
- order by a.id desc
- </select>
- <!--超时采购单导出-->
- <select id="overtimePurchaseExport" resultType="java.util.LinkedHashMap">
- select
- a.supplier_id,
- b.code as wllbCode,
- b.name as materialName,
- c.name as supplierName,
- a.arrival_num,
- a.arrival_time
- 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.code
- where
- a.arrival_time <![CDATA[<]]> CURDATE() and a.type = '0'
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{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>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- order by a.id desc
- </select>
- <!--查询采购单1导出-->
- <select id="purchasesExport" resultType="java.util.LinkedHashMap">
- select
- a.order_code,
- b.name as materialName,
- b.code as wllbCode,
- a.wbs,
- c.name as supplierName,
- a.purchase_num,
- a.arrival_num,
- a.qualified_num,
- a.disqualification_num
- 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
- left join tld_receive_goods_f e on a.order_code = e.order_code
- left join tld_company p on e.company_number = p.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and e.company_number = #{companyNumber}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
- </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 like CONCAT(CONCAT('%',#{orderCode},'%'))
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 删除原始记录 -->
- <delete id="delReceiveGoods">
- delete
- from tld_receive_goods
- where id = #{id}
- </delete>
- <!-- 查询入库单内容 -->
- <select id="getPdaReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- select
- a.id,
- a.order_code,
- b.name as materialName,
- c.name as supplierName,
- a.warehousing_num,
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.arrival_time,
- b.code as wllbCode,
- a.wbs,
- e.company_number as companyNumber,
- e.supplier_id as supplierId,
- p.name as compName
- 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
- left join tld_receive_goods_f e on a.order_code = e.order_code
- left join tld_company p on e.company_number = p.code
- where (warehousing_num + 0) <![CDATA[<]]> (qualified_num + 0)
- <if test="materialId != null and materialId != ''">
- and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and e.company_number = #{companyNumber}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
- </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 like CONCAT(CONCAT('%',#{orderCode},'%'))
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
- </if>
- order by a.id desc
- </select>
- <!-- 查询采购单内容 -->
- <select id="getReceiveGoodsCode" resultType="com.tld.model.ReceiveGoods">
- SELECT a.id,
- a.order_code,
- a.material_id,
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.wbs,
- a.arrival_time,
- a.measurement_id,
- a.supplier_id,
- a.entry_number,
- a.warehousing_num,
- b.company_number,
- b.order_number,
- b.source_type,
- b.move_type,
- f.name as supplierName
- FROM tld_receive_goods a
- LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
- JOIN tld_material c on a.material_id = c.tld_id
- LEFT JOIN tld_customer f on a.supplier_id = f.code
- WHERE a.id = #{receiveGoodsId}
- </select>
- </mapper>
|