| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633 |
- <?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">
- <!--添加errorExcel-->
- <insert id="addErrorExcel">
- insert into tld_error_excel(url,error_info,data_val,scrq,type,transmission_type,order_number,material_code,num,classify)
- values (#{url},#{errorInfo},#{dataVal},#{scrq},#{type},#{transmissionType},#{orderNumber},#{materialCode},#{num},#{classify})
- </insert>
- <!-- 呆滞品查询 -->
- <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,
- h.name as wbsName,
- e.name as ustomerName,
- a.account_sleeve as accountSleeve,
- 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
- left join tld_wbs h on a.wbs = h.tld_id
- 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 h.name 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,
- 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,
- m.name as unitOfMeasurement,
- sum( a.amount ) AS sum,
- a.wbs as wbs,
- h.name as wbsName,
- c.max_num as maxNum,
- DATEDIFF(now(), scrq) as day,
- c.part_type as partType,
- c.wllb_class as wllbClass,
- p.code as companyCode,
- p.name as companyName,
- a.account_sleeve as accountSleeve,
- a.supplier_id as supplierId,
- e.name as supplierName,
- a.storage_location_code as storageLocationCode
- 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
- LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
- left join tld_wbs h on a.wbs = h.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>
- <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 = #{wbs}
- </if>
- <if test="wbsName != null and wbsName != ''">
- and h.name like CONCAT(CONCAT('%', #{wbsName}), '%')
- </if>
- <if test="warehouseId != null and warehouseId != ''">
- and f.tld_id = #{warehouseId}
- </if>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- <if test="wllbClass != null and wllbClass != ''">
- and c.wllb_class = #{wllbClass}
- </if>
- <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
- and c.unit_of_measurement = #{unitOfMeasurement}
- </if>
- </trim>
- GROUP BY
- ${groupBy}
- </select>
- <!-- 查询库位信息 -->
- <select id="getQueryInventory" resultType="java.util.Map">
- SELECT
- a.id,
- a.storage_location_code as storageLocationCode,
- a.material_id as materialId,
- a.amount AS sum,
- a.serial,
- a.produc_batch as producBatch,
- a.produc_date as producDate,
- 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,
- h.name as wbsName
- 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
- LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
- left join tld_wbs h on a.wbs = h.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>
- <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>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- <if test="wllbClass != null and wllbClass != ''">
- and c.wllb_class = #{wllbClass}
- </if>
- <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
- and c.unit_of_measurement = #{unitOfMeasurement}
- </if>
- </trim>
- order by c.code
- </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 = " ", null, a.wbs) as wbs,
- if(h.name = " ", null, h.name) as wbsName,
- 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
- left join tld_wbs h on a.wbs = h.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>
- <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="wbsName != null and wbsName != ''">
- and h.name like CONCAT(CONCAT('%', #{wbsName}), '%')
- </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*/
- ${groupBy}
- </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,
- w.name as wbsName
- 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 and b.company_number = c.account_sleeve
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- left join tld_wbs w on a.wbs = w.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 w.name 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.production_code,
- a.num,
- IFNULL( a.out_num, 0 ) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- if(a.wbs = '' , null , a.wbs ) as wbs,
- if(w.name = '' , null , w.name ) as wbsName,
- b.company_number,
- g.name as companyName
- 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 and b.company_number = c.account_sleeve
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- left join tld_wbs w on a.wbs = w.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 w.name 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,
- w.name as wbsName
- 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 and b.company_number = c.account_sleeve
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- left join tld_wbs w on a.wbs = w.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 w.name 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,
- if(a.wbs = '' , null , a.wbs ) as wbs,
- if(w.name = '' , null , w.name ) as wbsName,
- b.company_number,
- g.name as companyName
- 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 and b.company_number = c.account_sleeve
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- left join tld_wbs w on a.wbs = w.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 w.name 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,
- w.name as wbsName,
- 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,
- b.delivery_code,
- 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
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="deliveryCode != null and deliveryCode != ''">
- and b.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
- </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 w.name 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>
- <if test="status != null and status != ''">
- and a.status like CONCAT(CONCAT('%', #{status}), '%')
- </if>
- <if test="gsDeliveryNum != null and gsDeliveryNum != ''">
- and a.gs_delivery_num = #{gsDeliveryNum}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 导出销售单 -->
- <select id="getDeliveryExcel" resultType="java.util.LinkedHashMap">
- select
- b.delivery_code,
- a.material_id,
- if(a.wbs = '', null, a.wbs) as wbs,
- if(w.name = '' , null , w.name ) as wbsName,
- 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
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="deliveryCode != null and deliveryCode != ''">
- and b.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
- </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 w.name 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,
- h.name as wbsName,
- 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,
- a.account_sleeve as accountSleeve,
- 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
- left join tld_wbs h on a.wbs = h.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 h.name 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,
- if(a.wbs = '', null, a.wbs) as wbs,
- if( h.name = '', null, h.name) as wbsName,
- 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
- join tld_company k on a.account_sleeve = k.code
- left join tld_wbs h on a.wbs = h.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 h.name 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,
- if(a.wbs = '', null,a.wbs) as wbs,
- if(h.name = '', null, h.name) as wbsName,
- 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
- left join tld_wbs h on a.wbs = h.tld_id
- 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 h.name 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>
- <!--查询库存数量-->
- <select id="getAmount" resultType="java.lang.String">
- select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
- </select>
- <!--查询库存数量-->
- <select id="getAmounts" resultType="java.lang.String">
- select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
- </select>
- <!--查询其它入库信息-->
- <select id="getOtherReceivingGoods" resultType="com.tld.model.Notice">
- select
- a.id,
- a.notice_id,
- a.entry_number,
- a.material_id,
- a.wbs,
- g.name as wbsName,
- a.measurement_id,
- a.num,
- a.entry_number,
- a.warehousing_num,
- b.notice_code,
- b.company_number,
- b.notice_time,
- b.source_type,
- b.move_type,
- b.notification_type_number,
- b.notification_type_name,
- c.name as materialName,
- c.code as materialCode,
- c.part_type,
- k.name as companyName,
- g.name as wbsCode
- from tld_notices a
- join tld_notices_f b on a.notice_id = b.notice_id
- join tld_material c on a.material_id = c.tld_id
- join tld_company k on b.company_number = k.code
- left join tld_wbs g on a.wbs = g.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type == '0'.toString() ">
- IFNULL(a.warehousing_num, 0) <![CDATA[<]]> (a.num + 0)
- </if>
- <if test="type == '1'.toString() ">
- IFNULL(a.warehousing_num, 0) <![CDATA[=]]> (a.num + 0)
- </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="noticeCode != null and noticeCode != ''">
- and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
- </if>
- <if test="materialId != null and materialId != ''">
- and c.tld_id like CONCAT(CONCAT('%', #{materialId}), '%')
- </if>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- <if test="startTime != null and startTime != ''">
- and b.notice_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.notice_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="wbs != null and wbs != ''">
- and g.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 移库修改状态 -->
- <update id="updateType">
- update tld_storage set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- update tld_removal set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- update tld_removal_half_product set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- update tld_removal_half set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- update tld_half set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- update tld_half_product set transmission_type = #{type} where storage_code = #{wmsCode}
- <if test="code != null and code != ''">
- and wllb_code = #{code}
- </if>;
- </update>
- <!--查询其它出库信息-->
- <select id="getOtherShipments" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.ask_goods_id,
- a.material_id,
- a.wbs,
- g.name as wbsName,
- a.measurement_id,
- a.num,
- a.out_num,
- a.entry_number,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- p.name as department,
- b.source_type,
- b.move_type,
- b.request_type_number,
- b.request_type_name,
- b.if_commodity,
- b.id as documentPointsId,
- c.name as materialName,
- c.code as materialCode,
- c.part_type,
- k.name as companyName,
- g.name as wbsCode
- from tld_enquiry a
- join tld_enquiry_f b on a.ask_goods_id = b.ask_goods_id
- join tld_material c on a.material_id = c.tld_id
- join tld_company k on b.company_number = k.code
- join tld_department p on b.department = p.code and b.company_number = p.account_sleeve
- left join tld_wbs g on a.wbs = g.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type == '0'.toString() ">
- IFNULL(a.out_num, 0) <![CDATA[<]]> (a.num + 0)
- </if>
- <if test="type == '1'.toString() ">
- IFNULL(a.out_num, 0) <![CDATA[=]]> (a.num + 0)
- </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="askGoodsCode != null and askGoodsCode != ''">
- and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and b.department = #{departmentCode}
- </if>
- <if test="materialId != null and materialId != ''">
- and c.tld_id like CONCAT(CONCAT('%', #{materialId}), '%')
- </if>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </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="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="wbs != null and wbs != ''">
- and g.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!--采购大屏信息-->
- <select id="getProcurementScreen" 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,
- b.wllb_class as wllbClass,
- 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 DATE(a.arrival_time) <![CDATA[=]]> DATE(NOW())
- and a.type = '0'
- </select>
- <!--采购大屏总数量-->
- <select id="getTotalQuantity" resultType="java.lang.Integer">
- select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW())
- </select>
- <!-- 已收货数量-->
- <select id="getQuantityArrived" resultType="java.lang.Integer">
- select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW()) and type = '1'
- </select>
- <!--未收货数量-->
- <select id="getUnarrivedQuantity" resultType="java.lang.Integer">
- select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW()) and type = '0'
- </select>
- <!-- 超时未送达数量 -->
- <select id="getTimeoutQuantity" resultType="java.lang.Integer">
- select sum(arrival_num) from tld_purchase
- where arrival_time <![CDATA[<]]> NOW()
- and type = '0'
- </select>
- <!--查询采购单入库数量-->
- <select id="getPurchaseSum" resultType="java.lang.Integer">
- select IFNULL(sum(warehousing_num),0) as amount from tld_receive_goods a
- left join tld_receive_goods_f b on a.order_code = b.order_code
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.arrival_time, '%Y-%m-%d' ) = #{format}
- </select>
- <!--查询其他入库数量-->
- <select id="getSomeoneSum" resultType="java.lang.Integer">
- select IFNULL(sum(warehousing_num),0) as amount from tld_notices a
- left join tld_notices_f b on a.notice_id = b.notice_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.notice_time, '%Y-%m-%d' ) = #{format}
- </select>
- <!--生成领料出库数量-->
- <select id="getAskGoodsSum" resultType="java.lang.Integer">
- select IFNULL(sum(out_num),0) as amount from tld_ask_goods a
- left join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
- </select>
- <!--非生产领料出库数量-->
- <select id="getInviteSum" resultType="java.lang.Integer">
- select IFNULL(sum(out_num),0) as amount from tld_invite a
- left join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
- </select>
- <!--其他出库数量-->
- <select id="getEnquirySum" resultType="java.lang.Integer">
- select IFNULL(sum(out_num),0) as amount from tld_enquiry a
- left join tld_enquiry_f b on a.ask_goods_id = b.ask_goods_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
- </select>
- <!--报工单入库数量-->
- <select id="getNoticeSum" resultType="java.lang.Integer">
- select IFNULL(sum(warehousing_num),0) as amount from tld_notice a
- left join tld_notice_f b on a.notice_id = b.notice_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.notice_time, '%Y-%m-%d' ) = #{format}
- </select>
- <!--销售单出库数量-->
- <select id="getDeliverySum" resultType="java.lang.Integer">
- select IFNULL(sum(out_num),0) as amount from tld_delivery a
- left join tld_delivery_f b on a.delivery_id = b.delivery_id
- left join tld_material c on a.material_id = c.tld_id
- where c.part_type = #{nameType}
- and DATE_FORMAT( b.bills_time, '%Y-%m-%d' ) = #{format}
- </select>
- <!--查询pda所有任务-->
- <select id="getPdaTask" resultType="java.util.Map">
- SELECT
- a.id,
- a.scrq,
- a.modify_time AS modifyTime,
- b.code,
- b.name,
- b.part_type AS partType,
- c.user_name AS userName,
- c.real_name AS realName,
- d.user_name AS modifyUserName,
- d.real_name AS modifyRealName,
- d.modify_time AS modifyTime
- FROM tld_user_material a
- LEFT JOIN tld_material b ON a.material_id = b.CODE
- LEFT JOIN tld_user c ON a.user_id = c.id
- LEFT JOIN tld_user d ON a.modify_user = d.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="userId != null and userId != ''">
- and a.user_id = #{userId}
- </if>
- </trim>
- ORDER BY a.id DESC
- </select>
- <!-- 查询质检单任务数量 -->
- <select id="getShangjia" resultType="int">
- select count(*) from tld_receive_goods where (warehousing_num + 0) <![CDATA[<]]> (qualified_num + 0)
- </select>
- <!-- 查询生产领料任务数量 -->
- <select id="getJihua" resultType="int">
- SELECT
- count(*)
- FROM
- tld_ask_goods a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE
- ((a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- and b.code in (select material_id from tld_user_material where user_id = #{userId})
- and b.part_type != '半成品' and b.part_type != '产成品'
- </select>
- <!-- 查询非生产领料任务数量 -->
- <select id="getYaoqing" resultType="int">
- SELECT
- count(*)
- FROM
- tld_invite a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE
- ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and b.code in (select material_id from tld_user_material where user_id = #{userId})
- and b.part_type != '半成品' and b.part_type != '产成品'
- </select>
- <!-- 查询半成品入库任务数量 -->
- <select id="getBanChenPin" resultType="int">
- SELECT
- count(*)
- FROM
- tld_notice a
- join tld_material b on a.material_id = b.tld_id
- where b.part_type = "半成品" and a.type = "0" and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询产成品入库任务数量 -->
- <select id="getChanChenPin" resultType="int">
- SELECT
- count(*)
- FROM
- tld_notice a
- JOIN tld_material b on a.material_id = b.tld_id
- where b.part_type = "产成品" and (warehousing_num + 0) <![CDATA[<]]> (
- a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 销售发货任务数量 -->
- <select id="getXiaoShou" resultType="int">
- SELECT
- count(*)
- FROM
- tld_delivery a
- JOIN tld_material b ON a.material_id = b.tld_id
- where ( a.gs_delivery_num - a.gs_cancel_num ) <![CDATA[>]]> a.out_num and b.code in (select material_id from tld_user_material where user_id = #{userId}) and a.status = "0"
- </select>
- <!-- 查询其他入库任务数量 -->
- <select id="getQiTaRu" resultType="int">
- SELECT
- count(*)
- FROM
- tld_notices a
- JOIN tld_material b ON a.material_id = b.tld_id
- where (a.warehousing_num + 0) <![CDATA[<]]> (
- a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询其他出库任务数量 -->
- <select id="getQiTaChu" resultType="int">
- SELECT
- count(*)
- FROM
- tld_enquiry a
- JOIN tld_material b ON a.material_id = b.tld_id
- where (a.out_num + 0) <![CDATA[<]]> (
- a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询移库任务数量 -->
- <select id="getYiKu" resultType="int">
- SELECT
- count(*)
- FROM
- tld_warehouse_transfer a
- JOIN tld_material b ON a.material_id = b.tld_id
- where (a.out_num + 0) <![CDATA[<]]> (
- a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询发货追溯任务数量 -->
- <select id="getZhuiSu" resultType="int">
- SELECT
- count(*)
- FROM
- tld_trace_back
- where (out_num + 0) <![CDATA[<]]> (
- num + 0) and material_code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询半成品出 -->
- <select id="getBanChenPinChu" resultType="int">
- SELECT
- count(*)
- FROM
- tld_ask_goods a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE
- ((a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- and b.code in (select material_id from tld_user_material where user_id = #{userId})
- and b.part_type = '半成品'
- </select>
- <select id="storageLocationNum" resultType="java.util.Map">
- SELECT
- a.id,
- 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,
- m.name as unitOfMeasurement,
- a.amount AS sum,
- a.wbs as wbs,
- c.max_num as maxNum,
- DATEDIFF(now(), scrq) as day,
- c.part_type as partType,
- c.wllb_class as wllbClass,
- p.code as companyCode,
- p.name as companyName,
- a.account_sleeve as accountSleeve,
- a.supplier_id as supplierId,
- e.name as supplierName,
- ifnull(a.storage_location_code, "1") as storageLocationCode
- 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
- LEFT JOIN tld_measurement m on c.unit_of_measurement = m.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>
- <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>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- <if test="wllbClass != null and wllbClass != ''">
- and c.wllb_class = #{wllbClass}
- </if>
- <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
- and c.unit_of_measurement = #{unitOfMeasurement}
- </if>
- and (a.amount + 0) <![CDATA[>]]> (#{amount} + 0)
- </trim>
- </select>
- <select id="getTestTwo" resultType="java.util.Map">
- select DISTINCT ask_goods_id from tld_ask_goods_vitrual where unique_code = "1111" and type = "计划出库"
- </select>
- <!--查询领料日期计划出库-->
- <select id="getPlannedDelivery" resultType="java.lang.String">
- select
- b.sqrq
- from tld_ask_goods a
- join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
- join tld_material e on a.material_id = e.tld_id
- where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- and ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
- group by b.sqrq
- order by b.sqrq desc
- </select>
- <!--查询领料日期邀请出库-->
- <select id="getInviteDelivery" resultType="java.lang.String">
- select
- b.sqrq
- from tld_invite a
- join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
- join tld_material e on a.material_id = e.tld_id
- where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- and ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- and e.part_type != '半成品' and e.part_type != '产成品'
- group by b.sqrq
- order by b.sqrq desc
- </select>
- <!--查询部门-->
- <select id="getPlannedDepartment" resultType="java.util.Map">
- select
- c.name,
- c.code
- from tld_ask_goods a
- join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
- join tld_department c on b.department = c.code and b.company_number = c.account_sleeve
- join tld_material e on a.material_id = e.tld_id
- where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- and ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
- and b.sqrq = #{sqrq}
- group by c.name,c.code
- </select>
- <!--查询部门-->
- <select id="getInviteDepartment" resultType="java.util.Map">
- select
- c.name,
- c.code
- from tld_invite a
- join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
- join tld_department c on b.department = c.code and b.company_number = c.account_sleeve
- join tld_material e on a.material_id = e.tld_id
- where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- and ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- and e.part_type != '半成品' and e.part_type != '产成品'
- and b.sqrq = #{sqrq}
- group by c.name,c.code
- </select>
- <!-- 查询指定参数的要货单 -->
- <select id="getAskGoodsInfo" resultType="com.tld.model.AskGoods">
- SELECT DISTINCT b.ask_goods_id as id,b.ask_goods_code as code
- FROM tld_ask_goods a
- JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
- JOIN tld_material e ON a.material_id = e.tld_id
- WHERE
- b.sqrq = #{sqrq} AND b.department = #{department}
- AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- </select>
- <!-- 查询指定参数的要货单 -->
- <select id="getInviteInfo" resultType="com.tld.model.AskGoods">
- SELECT DISTINCT b.ask_goods_id as id,b.ask_goods_code as code
- FROM tld_invite a
- JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
- JOIN tld_material e ON a.material_id = e.tld_id
- WHERE
- b.sqrq = #{sqrq} AND b.department = #{department}
- AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
- AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- </select>
- <!--查询错误日志添加到Excel表-->
- <select id="getErrorList" resultType="com.tld.model.Error">
- select
- id,
- url,
- error_info,
- data_val,
- scrq,
- type,
- transmission_type
- from tld_error where type = '出库回传' and transmission_type = '1' and error_info = '异常:“是否允许负库存”附近有语法错误。'
- </select>
- <!--207生产领料-->
- <select id="getOrderNumber" resultType="java.lang.String">
- select ask_goods_code from tld_ask_goods_f where ask_goods_id = #{giReqBillID}
- </select>
- <!--Z05非生产领料-->
- <select id="getOrderNumberNot" resultType="java.lang.String">
- select ask_goods_code from tld_invite_f where ask_goods_id = #{giReqBillID}
- </select>
- <!--查询物料code-->
- <select id="getMaterialCode" resultType="java.lang.String">
- select code from tld_material where tld_id = #{material}
- </select>
- </mapper>
|