123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941 |
- <?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.QueryListMapper">
- <!-- 呆滞品查询 -->
- <select id="dullGoods" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.material_id as materialId,
- a.amount as amount,
- a.scrq as scrq,
- a.storage_location_code as storageLocationCode,
- b.name as materialName,
- c.storage_location_name as storageLocationName,
- b.code as wllbCode,
- a.wbs as wbs,
- e.name as ustomerName,
- f.name as companyName
- FROM tld_inventory a
- JOIN tld_material b ON a.material_id = b.tld_id
- LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
- LEFT JOIN tld_customer e ON a.supplier_id = e.code
- LEFT JOIN tld_company f ON a.account_sleeve = f.code
- WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </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="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="ustomerCode != null and ustomerCode != ''">
- and a.supplier_id = #{ustomerCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.account_sleeve = #{companyCode}
- </if>
- </select>
- <!-- 查询所有物料 -->
- <select id="getMaterial" resultType="java.util.Map">
- select
- tld_id as tldId,
- ifnull(min_num, 0) as minNum,
- ifnull(max_num, 0) as maxNum,
- name as name,
- code as code
- from tld_material
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- </trim>
- </select>
- <!-- 物料储量预警查询 -->
- <select id="reserveWarning" resultType="java.util.Map" parameterType="java.util.Map">
- SELECT ifnull(sum(a.amount), "0") as amount,
- ${tldId} as materialId,
- ${minNum} as minNum,
- ${maxNum} as maxNum
- FROM tld_inventory a
- LEFT JOIN tld_material b ON a.material_id = b.tld_id
- WHERE material_id = #{tldId}
- </select>
- <!-- 查询库位信息 -->
- <select id="storageLocation" resultType="java.util.Map">
- SELECT
- a.id,
- a.storage_location_code as storageLocationCode,
- a.material_id as materialId,
- sum( a.amount ) AS sum,
- a.serial,
- a.wbs as wbs,
- a.produc_batch as producBatch,
- a.supplier_id as supplierId,
- b.storage_location_name as storageLocationName ,
- b.warehouse_where as warehouseWhere,
- b.storage_location_type as storageLocationType,
- b.storage_location_capacity as storageLocationCapacity,
- b.is_not_disable as isNotDisable,
- b.create_time as createTime,
- b.is_product as isProduct,
- c.name as name,
- c.code as code,
- e.name as supplierName,
- f.name as warehouseName,
- p.name as companyName,
- a.account_sleeve as accountSleeve
- FROM
- tld_inventory a
- LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- LEFT JOIN tld_material c ON a.material_id = c.tld_id
- LEFT JOIN tld_customer e ON a.supplier_id = e.code
- LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
- LEFT JOIN tld_company p on a.account_sleeve = p.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="companyName != null and companyName != ''">
- and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and p.code = #{companyCode}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="warehouseId != null and warehouseId != ''">
- and f.tld_id = #{warehouseId}
- </if>
- </trim>
- GROUP BY
- a.storage_location_code,
- a.material_id,
- a.wbs,
- a.account_sleeve
- </select>
- <!-- 查询库位信息 -->
- <select id="getQueryInventory" resultType="java.util.Map">
- SELECT
- a.storage_location_code as storageLocationCode,
- a.material_id as materialId,
- a.amount AS sum,
- a.serial,
- a.produc_batch as producBatch,
- a.supplier_id as supplierId,
- b.storage_location_name as storageLocationName ,
- b.warehouse_where as warehouseWhere,
- b.storage_location_type as storageLocationType,
- b.storage_location_capacity as storageLocationCapacity,
- b.is_not_disable as isNotDisable,
- b.create_time as createTime,
- b.is_product as isProduct,
- c.name as name,
- c.code as code,
- e.name as supplierName,
- a.wbs,
- a.account_sleeve
- FROM tld_inventory a
- LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- LEFT JOIN tld_material c ON a.material_id = c.tld_id
- LEFT JOIN tld_customer e ON a.supplier_id = e.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- </trim>
- </select>
- <!--导出-->
- <select id="getStorageLocation" resultType="java.util.LinkedHashMap">
- SELECT
- YEAR(CURDATE()) AS year,
- MONTH(CURDATE()) AS month,
- f.code as warehouseCode,
- f.name as warehouseName,
- b.storage_location_name as storageLocationName,
- c.code as code,
- c.name as name,
- ifnull(c.unit_of_measurement, "暂无单位") as unit_of_measurement,
- sum( a.amount ) AS sum,
- if(a.wbs = "", " ", a.wbs) as wbs,
- ifnull(c.max_num, 0) as max_num,
- DATEDIFF(now(),scrq) as day,
- ifnull(c.part_type, "暂无分类") as part_type,
- ifnull(c.wllb_class, "暂无分类") as wllb_class,
- p.code as companyCode,
- p.name as companyName
- FROM tld_inventory a
- LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- LEFT JOIN tld_material c ON a.material_id = c.tld_id
- LEFT JOIN tld_customer e ON a.supplier_id = e.code
- LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
- LEFT JOIN tld_company p on a.account_sleeve = p.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="companyName != null and companyName != ''">
- and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="warehouseId != null and warehouseId != ''">
- and f.tld_id = #{warehouseId}
- </if>
- </trim>
- GROUP BY
- a.storage_location_code,
- a.material_id,
- a.wbs,
- a.account_sleeve
- </select>
- <!-- 查询接入信息 -->
- <select id="getAccess" resultType="com.tld.model.Access">
- select id,type,data,scrq,access_type from tld_access
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and type = #{type}
- </if>
- <if test="accessType != null and accessType != ''">
- and access_type = #{accessType}
- </if>
- <if test="data != null and data != ''">
- and data like CONCAT(CONCAT('%', #{data}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and scrq <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- order by id desc
- </select>
- <!-- 查询生产领料要货 -->
- <select id="getAskGoods" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.ask_goods_id,
- a.material_id,
- IFNULL( a.out_num, 0 ) AS out_num,
- a.num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- c.name as departmentName,
- g.name as companyName,
- b.source_type,
- b.move_type,
- a.entry_number,
- a.production_code,
- a.wbs
- FROM
- tld_ask_goods a
- JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- /* WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialCode != null and materialCode != ''">
- and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and b.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and b.company_number = #{companyCode}
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询生产领料要货 -->
- <select id="getAskGoodsExcel" resultType="java.util.LinkedHashMap">
- SELECT
- a.ask_goods_id,
- a.material_id,
- a.num,
- IFNULL( a.out_num, 0 ) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number
- FROM
- tld_ask_goods a
- JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialCode != null and materialCode != ''">
- and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and b.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and b.company_number = #{companyCode}
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询非生产领料单 -->
- <select id="getInvite" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.ask_goods_id,
- a.material_id,
- IFNULL( a.out_num, 0 ) AS out_num,
- a.num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- c.name as departmentName,
- g.name as companyName,
- b.source_type ,
- b.move_type ,
- a.entry_number,
- a.production_code,
- a.wbs
- FROM
- tld_invite a
- JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- /*WHERE*/
- /*e.part_type != '半成品' and e.part_type != '产成品'*/
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialCode != null and materialCode != ''">
- and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and b.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and b.company_number = #{companyCode}
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 导出生产领料要货 -->
- <select id="getInviteExcel" resultType="java.util.LinkedHashMap">
- SELECT
- a.ask_goods_id,
- a.material_id,
- a.num,
- IFNULL( a.out_num, 0 ) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number
- FROM
- tld_invite a
- JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialCode != null and materialCode != ''">
- and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and b.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and b.company_number = #{companyCode}
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询销售单 -->
- <select id="getDelivery" resultType="com.tld.model.Delivery">
- select
- a.id,
- a.delivery_id,
- a.material_id,
- a.wbs,
- a.gs_delivery_num,
- a.gs_cancel_num,
- ifnull(a.out_num, 0) as out_num,
- b.company_number,
- b.bills_time,
- c.name as materialName,
- c.code as materialCode,
- g.name as customerName,
- b.delivery_code as deliveryCode,
- v.name as companyName,
- b.delivery_type,
- b.source_type,
- b.move_type,
- a.entry_number
- from tld_delivery a
- join tld_delivery_f b on a.delivery_id = b.delivery_id
- join tld_material c on a.material_id = c.tld_id
- left join tld_customer g on b.customer_code = g.code
- left join tld_company v on b.company_number = v.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.bills_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.bills_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and b.customer_code = #{customerCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="deliveryType != null and deliveryType != ''">
- and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 导出销售单 -->
- <select id="getDeliveryExcel" resultType="java.util.LinkedHashMap">
- select
- a.delivery_id,
- a.material_id,
- a.wbs,
- a.gs_delivery_num,
- a.gs_cancel_num,
- a.out_num,
- v.name as companyName,
- b.bills_time,
- c.name as materialName,
- c.code as materialCode,
- g.name as customerName,
- b.source_type,
- b.move_type,
- b.delivery_type,
- a.entry_number
- from tld_delivery a
- join tld_delivery_f b on a.delivery_id = b.delivery_id
- join tld_material c on a.material_id = c.tld_id
- left join tld_customer g on b.customer_code = g.code
- left join tld_company v on b.company_number = v.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.bills_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.bills_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and b.customer_code = #{customerCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="deliveryType != null and deliveryType != ''">
- and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- </trim>
- </select>
- <!-- 查询移库单 -->
- <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
- select
- a.id,
- a.warehouse_transfer_id,
- a.entry_number,
- a.supply_warehouse_id,
- a.material_id,
- a.wbs,
- a.num,
- a.out_num,
- a.type,
- b.warehouse_transfer_code,
- b.ask_goods_warehouse_id,
- b.document_time,
- b.warehouse_transfer_type,
- c.name as materialName,
- c.code as materialCode,
- f.name as askGoodsWarehouseName,
- e.name as supplyWarehouseName,
- k.name as companyName
- from tld_warehouse_transfer a
- join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
- join tld_material c on a.material_id = c.tld_id
- join tld_warehouse e on a.supply_warehouse_id = e.tld_id
- join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
- join tld_company k on a.account_sleeve = k.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
- and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.document_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.document_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
- and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
- </if>
- <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
- and a.supply_warehouse_id = #{supplyWarehouseId}
- </if>
- <if test="warehouseTransferType != null and warehouseTransferType != ''">
- and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.account_sleeve = #{companyCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 移库单导出 -->
- <select id="getWarehouseTransferExcel" resultType="java.util.LinkedHashMap">
- select
- a.warehouse_transfer_id,
- b.warehouse_transfer_code,
- c.name as materialName,
- c.code as materialCode,
- a.wbs,
- a.num,
- a.out_num,
- f.name as askGoodsWarehouseaName,
- e.name as supplyWarehouseName,
- b.document_time
- from tld_warehouse_transfer a
- join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
- join tld_material c on a.material_id = c.tld_id
- join tld_warehouse e on a.supply_warehouse_id = e.tld_id
- join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
- and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.document_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.document_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
- and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
- </if>
- <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
- and a.supply_warehouse_id = #{supplyWarehouseId}
- </if>
- <if test="warehouseTransferType != null and warehouseTransferType != ''">
- and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.account_sleeve = #{companyCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询日志信息 -->
- <select id="getLogData" resultType="com.tld.model.LogData">
- SELECT
- a.id,
- a.user_id,
- a.scrq,
- a.DATA,
- a.type,
- a.document_type,
- b.user_name
- FROM
- tld_log_data a
- LEFT JOIN tld_user b ON a.user_id = b.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="documentType != null and documentType != ''">
- and a.document_type = #{documentType}
- </if>
- <if test="data != null and data != ''">
- and a.data like CONCAT(CONCAT('%', #{data}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="userName != null and userName != ''">
- and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- </trim>
- ORDER BY a.scrq DESC
- </select>
- <!--呆滞品导出-->
- <select id="dullGoodsExport" resultType="java.util.LinkedHashMap">
- SELECT
- b.code as wllbCode,
- b.name as materialName,
- c.storage_location_name as storageLocationName,
- f.name as companyName,
- e.name as ustomerName,
- a.wbs as wbs,
- a.amount as amount,
- a.scrq as scrq
- FROM tld_inventory a
- JOIN tld_material b ON a.material_id = b.tld_id
- LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
- LEFT JOIN tld_customer e ON a.supplier_id = e.code
- LEFT JOIN tld_company f ON a.account_sleeve = f.code
- WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </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="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="ustomerCode != null and ustomerCode != ''">
- and a.supplier_id = #{ustomerCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.account_sleeve = #{companyCode}
- </if>
- </select>
- <!--查询物料储量预警查询-->
- <select id="reserveWarnings" resultType="java.util.Map">
- SELECT
- a.NAME as materialName,
- a.CODE as wllbCode,
- ifnull(b.sum,0) AS amount,
- ifnull(a.max_num,'0') AS maxNum,
- ifnull(a.min_num,'0') AS minNum
- FROM
- tld_material a
- LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
- b.material_id
- WHERE
- (
- IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
- OR
- IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
- )
- <if test="materialName != null and materialName != ''">
- and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- </select>
- <!--查询物料储量预警查询导出-->
- <select id="reserveWarningsExport" resultType="java.util.LinkedHashMap">
- SELECT
- a.CODE as wllbCode,
- a.NAME as materialName,
- ifnull(b.sum,0) AS amount,
- ifnull(a.max_num,'0') AS maxNum,
- ifnull(a.min_num,'0') AS minNum
- FROM
- tld_material a
- LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
- b.material_id
- WHERE
- (
- IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
- OR
- IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
- )
- <if test="materialName != null and materialName != ''">
- and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- </select>
- <!--接入接出/接口信息导出-->
- <select id="onOffExcel" resultType="java.util.LinkedHashMap">
- select type,data,
- case access_type
- when '0' then '接入'
- when '1' then '接出'
- end as access_type,
- scrq
- from tld_access
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and type = #{type}
- </if>
- <if test="accessType != null and accessType != ''">
- and access_type = #{accessType}
- </if>
- <if test="data != null and data != ''">
- and data like CONCAT(CONCAT('%', #{data}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and scrq <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- order by id desc
- </select>
- <!--查询删除/修改日志信息导出-->
- <select id="getLogDataExcel" resultType="java.util.LinkedHashMap">
- SELECT
- b.user_name,
- a.document_type,
- a.DATA,
- a.scrq
- FROM
- tld_log_data a
- LEFT JOIN tld_user b ON a.user_id = b.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="documentType != null and documentType != ''">
- and a.document_type = #{documentType}
- </if>
- <if test="data != null and data != ''">
- and a.data like CONCAT(CONCAT('%', #{data}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="userName != null and userName != ''">
- and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- </trim>
- ORDER BY a.scrq DESC
- </select>
- </mapper>
|