123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <?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
- 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
- WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code = #{wllbCode}
- </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 = #{wllbCode}
- </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.storage_location_code as storageLocationCode,
- a.material_id as materialId,
- sum( 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,
- f.name as warehouseName
- 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
- <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>
- GROUP BY
- a.storage_location_code,
- a.material_id
- </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
- 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
- c.code as code,
- c.name as name,
- b.storage_location_name as storageLocationName ,
- sum( a.amount ) AS sum
- 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
- <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>
- GROUP BY
- a.storage_location_code,
- a.material_id
- </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>
- </trim>
- </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
- 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="askGoodsId != null and askGoodsId != ''">
- and b.ask_goods_code = #{askGoodsId}
- </if>
- <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>
- </trim>
- </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 != '产成品'
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id = #{askGoodsId}
- </if>
- <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>
- </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
- 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="askGoodsId != null and askGoodsId != ''">
- and b.ask_goods_code = #{askGoodsId}
- </if>
- <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>
- </trim>
- </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 != '产成品'
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id = #{askGoodsId}
- </if>
- <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>
- </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
- 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id = #{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 a.bills_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.bills_time <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- </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,
- b.company_number,
- b.bills_time,
- c.name as materialName,
- c.code as materialCode
- 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id = #{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 a.bills_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.bills_time <![CDATA[<=]]> #{endTime}
- </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
- 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 a.document_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.document_time <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- </select>
- <!-- 移库单导出 -->
- <select id="getWarehouseTransferExcel" resultType="java.util.LinkedHashMap">
- select
- a.warehouse_transfer_id,
- b.warehouse_transfer_code,
- a.material_id,
- c.name as materialName,
- c.code as materialCode,
- a.wbs,
- a.num,
- a.out_num,
- b.ask_goods_warehouse_id,
- a.supply_warehouse_id,
- f.name as askGoodsWarehouseaName,
- e.name as supplyWarehouseName,
- b.document_time,
- case
- when a.type = '0' then
- '未移库'
- when a.type = '1' then
- '已移库'
- end as type
- 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="startTime != null and startTime != ''">
- and a.document_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.document_time <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- </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 document_type = #{documentType}
- </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 a.scrq DESC
- </select>
- </mapper>
|