| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262 |
- <?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.AskGoodsMapper">
- <!-- 查询要货单id+物料id是否存在 -->
- <select id="getAskGoods" resultType="int">
- select count(*)
- from tld_ask_goods
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- </select>
- <!-- 修改要料申请单数量 -->
- <update id="updateAskGoodsNum">
- update tld_ask_goods
- set num =#{num}
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- </update>
- <!-- 新增要料申请单 -->
- <insert id="addAskGoods">
- insert into tld_ask_goods(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id, num,
- type, out_num)
- values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
- #{type}, '0')
- </insert>
- <!-- 新增要料日志 -->
- <insert id="addAskGoodsLog">
- insert into tld_ask_goods_log(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id,
- num, out_num, ask_goods_code, company_number, sqrq, department_id, source_type,
- move_type, ask_goods_type,request_type_number,request_type_name,if_commodity)
- values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
- #{outNum}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},
- #{askGoodsType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
- </insert>
- <!-- 查询次要货单是否存在 -->
- <select id="getAskGoodsf" resultType="int">
- select count(*)
- from tld_ask_goods_f
- where ask_goods_id = #{askGoodsId}
- and ask_goods_code = #{askGoodsCode}
- </select>
- <!-- 新增要料申请单父级 -->
- <insert id="addAskGoodsf">
- insert into tld_ask_goods_f(ask_goods_id, ask_goods_code, company_number, sqrq, department, source_type,
- move_type,request_type_number,request_type_name,if_commodity)
- values (#{askGoodsId}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
- </insert>
- <!-- 查询生产领料单 -->
- <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
- SELECT a.ask_goods_id,
- a.material_id,
- IFNULL(a.out_num, 0) AS num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number,
- 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 (a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0)
- and e.part_type != '半成品' and e.part_type != '产成品'
- </select>
- <!-- 查询指定生产单的物料 -->
- <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
- 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,
- c.name,
- c.code,
- c.id AS departmentId,
- 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
- WHERE (a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0)
- and e.part_type != '半成品' and e.part_type != '产成品'
- </select>
- <!-- 物料库位选择 -->
- <select id="getMaterialCk" resultType="com.tld.model.Inventory">
- select a.storage_location_code,
- a.wllb_class,
- a.library_type,
- a.material_id,
- (a.amount - ifnull(a.amount_lock, 0)) as amount,
- a.total,
- a.totime,
- a.hold,
- a.amount_lock,
- a.account_sleeve,
- a.wbs,
- a.supplier_id,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- b.storage_location_name as storageLocationName
- from tld_inventory a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- join tld_warehouse c on b.warehouse_where = c.tld_id
- where a.material_id = #{materialId}
- and a.account_sleeve = #{companyNumber}
- and a.hold = '0'
- and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
- order by a.produc_date
- </select>
- <!-- 新增出库虚拟表 -->
- <insert id="addAskGoodsVitrual">
- insert into tld_ask_goods_vitrual(unique_code, supplier_id, serial, wllb_code, produc_date, ask_goods_id, type,
- storage_location_code, num, user_id, department, attribute, account_sleeve,
- storage_location_code_rk, wbs)
- values (#{uniqueCode}, #{supplierId}, #{serial}, #{wllbCode}, #{producDate}, #{askGoodsId}, #{type},
- #{storageLocationCode}, #{num}, #{userId}, #{department}, #{attribute}, #{companyNumber},
- #{storageLocationCodeRk}, #{wbs})
- </insert>
- <!-- 查询指定库存内容 -->
- <select id="getInventory" resultType="com.tld.model.Inventory">
- select id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq
- from tld_inventory
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and account_sleeve = #{companyNumber}
- <if test="wbs != null">
- and wbs = #{wbs}
- </if>
- </select>
- <!-- 查询指定库存内容 -->
- <select id="getInventoryWarehousing" resultType="com.tld.model.Inventory">
- select id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and wllb_code = #{wllbCode}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- </select>
- <!-- 查询库存是否充足 -->
- <select id="getAsk" resultType="com.tld.model.AskGoods">
- SELECT ifnull(sum(a.num), 0) as num
- FROM tld_ask_goods_vitrual a
- join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
- where a.storage_location_code = #{storageLocationCode}
- and a.serial = #{serial}
- </select>
- <!-- 查询是否扫描 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select (select ifnull(amount, 0)
- from tld_inventory
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}) as inventoryNum,
- (select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and type = #{type}) as virtualNum
- from dual
- </select>
- <!-- 查询指定送货单信息 -->
- <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
- SELECT a.id,
- a.ask_goods_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- ifnull(a.out_num, 0) as out_num
- FROM tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- where a.ask_goods_id = #{askGoodsId}
- and b.code = #{wllbCode}
- </select>
- <!-- 查询指定移庫單 -->
- <select id="getWareInfo" resultType="com.tld.model.AskGoods">
- SELECT a.id,
- a.warehouse_transfer_id as askGoodsId,
- a.entry_number,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- ifnull(a.out_num, 0) as out_num
- FROM tld_warehouse_transfer a
- join tld_material b on a.material_id = b.tld_id
- where a.warehouse_transfer_id = #{askGoodsId}
- and b.code = #{wllbCode}
- </select>
- <!-- 查询已扫描总数 -->
- <select id="getAskInfoNumVitrual" resultType="int">
- select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where wllb_code = #{wllbCode}
- and ask_goods_id = #{askGoodsId}
- and type = #{type}
- </select>
- <!-- 查询此库存在虚拟表里占用的数量 -->
- <select id="getInventoryAlready" resultType="int">
- select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and type = #{type}
- </select>
- <!-- 查询虚拟表指定pda跟状态的的数据 -->
- <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
- select id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department,
- account_sleeve,
- wbs,
- storage_location_code_rk
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and type = #{type}
- and ask_goods_id = #{askGoodsId}
- </select>
- <!-- 删除库存 -->
- <delete id="deleteInventory">
- delete
- from tld_inventory
- where id = #{id}
- </delete>
- <!-- 修改库存数量 -->
- <update id="updateInventory">
- UPDATE tld_inventory
- SET amount = amount - #{amount}
- WHERE id = #{id}
- </update>
- <!-- 删除虚拟表出库记录 -->
- <delete id="deleteVirtual">
- delete
- from tld_ask_goods_vitrual
- where id = #{id}
- </delete>
- <!-- 插入出库流水 -->
- <insert id="addRemoval">
- insert into tld_removal(wllb_code, supplier_id, serial, num, type, user_id, storage_location_code, scrq,
- process, ask_goods_id, produc_date, department, storage_code, wbs, account_sleeve,transmission_type)
- values (#{wllbCode}, #{supplierId}, #{serial}, #{num}, #{type}, #{userId}, #{storageLocationCode}, now(),
- #{process}, #{askGoodsId}, #{producDate}, #{department}, #{storageCode}, #{wbs}, #{companyNumber},'0')
- </insert>
- <!-- 查询指定物料类型的id -->
- <select id="getMaterialId" resultType="String">
- select tld_id
- from tld_material
- where code = #{wllbCode}
- </select>
- <!-- 查询要料申请单内容 -->
- <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
- select id,
- ask_goods_id,
- entry_number,
- production_code,
- material_id,
- wbs,
- measurement_id,
- num,
- out_num
- from tld_ask_goods
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- </select>
- <!-- 新增返回gs数据字表信息 -->
- <insert id="addReturnGsRemoval">
- insert into tld_return_gs_removal_z(material_id, wbs, num, entry_number, document_id, document_points_id,
- storage_location_code)
- values (#{materialId}, #{wbs}, #{num}, #{entryNumber}, #{documentId}, #{documentPointsId},
- #{storageLocationCode})
- </insert>
- <!-- 查询要货单父级信息 -->
- <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
- select id,
- ask_goods_id,
- ask_goods_code,
- company_number,
- sqrq,
- department,
- source_type,
- move_type
- from tld_ask_goods_f
- where ask_goods_id = #{askGoodsId}
- </select>
- <!-- 新增返回gs数据父表信息 -->
- <insert id="addReturnGsRemovalF">
- insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type)
- values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType})
- </insert>
- <!-- 添加 tld_access 记录-->
- <insert id="addAccess">
- insert into tld_access (type, data, scrq, access_type)
- values (#{names}, #{returnGsRemoval}, now(), #{accessType})
- </insert>
- <!-- 查询当天出库数量 -->
- <select id="getReturnRemovalCount" resultType="int">
- select count(*)
- from tld_return_gs_removal
- where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
- </select>
- <!-- 查询回传数据 -->
- <select id="plugOutRemoval" resultType="java.util.Map">
- select id,
- document_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType,
- scrq
- from tld_return_gs_removal
- where document_id = #{removalCode}
- </select>
- <!-- 查询字表回传数据 -->
- <select id="getRemovalz" resultType="java.util.Map">
- SELECT a.material_id AS materialId,
- a.wbs,
- a.num,
- a.entry_number AS entryNumber,
- a.document_id AS askGoodsId,
- a.document_points_id AS askId,
- ifnull(a.wbs, '') as wbsId,
- ifnull(c.code, '') as wbsCode,
- ifnull(c.name, '') as wbsName
- FROM tld_return_gs_removal_z a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- left join tld_wbs c on a.wbs = c.tld_id
- WHERE a.document_id = #{askGoodsId}
- and b.warehouse_where = #{warehouseWhere}
- </select>
- <!-- 查询出库流水 -->
- <select id="getRemoval" resultType="com.tld.model.AskGoods">
- select
- a.id,
- b.name as materialName,
- a.wllb_code,
- h.name as supplierName,
- a.serial,
- a.type,
- c.user_name as userName,
- e.name as department,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num,
- a.storage_code,
- a.wbs,
- a.ask_goods_id,
- c.real_name as realName,
- a.account_sleeve,
- f.name as accountName
- from tld_removal a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_department e on a.department = e.code
- left join tld_storage_location g on a.storage_location_code = g.storage_location_code
- left join tld_customer h on a.supplier_id = h.code
- left join tld_company f on a.account_sleeve = f.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <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="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 导出 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- if(h.name = '',null,h.name) as supplierName,
- if(a.serial = '',null,a.serial) as serial,
- a.type,
- c.user_name as userName,
- e.name as department,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num,
- a.ask_goods_id,
- c.real_name,
- a.account_sleeve,
- f.name as accountName
- from tld_removal a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_department e on a.department = e.code
- left join tld_storage_location g on a.storage_location_code = g.storage_location_code
- left join tld_customer h on a.supplier_id = h.code
- left join tld_company f on a.account_sleeve = f.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <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="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询指定pda出库虚拟表 -->
- <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
- select id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department,
- account_sleeve,
- wbs,
- attribute
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and type = #{type}
- </select>
- <!-- 删除指定虚拟表数据 -->
- <delete id="delAskGoodsVitrual">
- delete
- from tld_ask_goods_vitrual
- where id = #{id}
- and type = #{type}
- </delete>
- <!-- 删除出库回传主表信息 -->
- <delete id="delPlugOutRemoval">
- delete
- from tld_return_gs_removal
- where document_id = #{removalCode}
- </delete>
- <!-- 删除出库回传子表信息 -->
- <delete id="delRemovalz">
- delete
- from tld_return_gs_removal_z
- where document_id = #{removalCode}
- </delete>
- <!-- 删除入库回传信息 -->
- <delete id="delPlugOutWarehousing">
- delete
- from tld_return_gs_warehousing
- where order_number = #{orderNumber}
- </delete>
- <!-- 修改出库数量 -->
- <update id="updateOutNum">
- update tld_ask_goods
- set out_num = ifnull(out_num, 0) + #{num}
- where material_id = #{materialId}
- and ask_goods_id = #{askGoodsId}
- </update>
- <!-- 查询指定pda 指定物料扫描总数 -->
- <select id="getScanNum" resultType="String">
- select if(sum(num) is null, 0, num)
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and ask_goods_id = #{askGoodsId}
- and wllb_code = #{wllbCode}
- </select>
- <!-- 查询半成品出库数据 -->
- <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.material_id,
- a.num,
- a.production_code,
- b.name as materialName,
- b.code as materialCode,
- a.out_num,
- a.ask_goods_id,
- c.company_number,
- e.name as department,
- a.type,
- a.wbs,
- a.entry_number,
- g.name as companyName,
- c.source_type,
- c.move_type,
- c.sqrq
- FROM
- tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
- left join tld_department e on c.department = e.code
- left join tld_company g on b.company_number = g.code
- WHERE
- -- (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
- b.part_type = #{partType}
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="startTime != null and startTime != ''">
- and c.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and c.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="materialCode != null and materialCode != ''">
- and b.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and c.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and c.company_number = #{companyCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and c.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and c.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- order by a.id desc
- </select>
- <!-- 查询半成品出库流水 -->
- <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.ask_goods_id,
- c.name as department,
- b.name as materialName,
- e.user_name as userName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- e.real_name as realName,
- a.account_sleeve,
- f.name as accountName
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.code
- left join tld_user e on a.user_id = e.id
- left join tld_company f on a.account_sleeve = f.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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="departmentCode != null and departmentCode != ''">
- and a.department = #{departmentCode}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询半成品出库流水导出 -->
- <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
- select
- if(a.ask_goods_id = '' , null , a.ask_goods_id ) as askGoodsId,
- a.storage_code as storageCode,
- a.wllb_code as wllbCode,
- b.name as materialName,
- a.num,
- e.user_name as userName,
- c.name as department,
- a.wbs,
- a.scrq,
- e.real_name as realName,
- f.name as accountName
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.code
- left join tld_user e on a.user_id = e.id
- left join tld_company f on a.account_sleeve = f.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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="departmentCode != null and departmentCode != ''">
- and a.department = #{departmentCode}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品出库流水 -->
- <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.delivery_id,
- a.company_number,
- a.customer_code,
- b.name as materialName,
- c.user_name as userName,
- e.name as customerName,
- f.name as companyName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- c.real_name as realName
- from tld_removal_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_customer e on a.customer_code = e.code
- left join tld_company f on a.company_number = f.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.company_number = #{companyCode}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and a.customer_code = #{customerCode}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </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>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品导出出库流水 -->
- <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.num,
- c.user_name as userName,
- a.scrq,
- f.name as companyName,
- e.name,
- a.storage_code,
- a.wbs,
- c.real_name as realName
- from tld_removal_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_customer e on a.customer_code = e.code
- left join tld_company f on a.company_number = f.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.company_number = #{companyCode}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and a.customer_code = #{customerCode}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </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>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询指定物料的库存 -->
- <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
- select
- id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq,
- produc_batch,
- attribute
- from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and
- account_sleeve = #{accountSleeve} and amount <![CDATA[>=]]> #{num}
- <if test="wbs != null">
- and wbs = #{wbs}
- </if>
- <if test="storageLocationCode != '' and storageLocationCode != null">
- and storage_location_code = #{storageLocationCode}
- </if>
- <if test="serial != '' and serial != null">
- and serial = #{serial}
- </if>
- <if test="attribute != '' and attribute != null">
- and attribute = #{attribute}
- </if>
- <if test="producDate != '' and producDate != null">
- and produc_batch = #{producDate}
- </if>
- <if test="supplierId != '' and supplierId != null">
- and supplier_id = #{supplierId}
- </if>
- </select>
- <!-- 其他入库查询库存是否存在 -->
- <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
- select
- a.id,
- a.storage_location_code,
- a.wllb_class,
- a.library_type,
- a.material_id,
- a.amount,
- a.total,
- a.totime,
- a.hold,
- a.amount_lock,
- a.account_sleeve,
- a.wbs,
- a.supplier_id,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- a.produc_batch,
- a.attribute,
- b.name as accountName,
- c.storage_location_name as storageLocationName,
- c.warehouse_where as warehouseWhere
- from tld_inventory a
- left join tld_company b on a.account_sleeve = b.code
- left join tld_storage_location c on a.storage_location_code = c.storage_location_code
- where material_id = #{materialId}
- <if test="wbs != '' and wbs != null">
- and a.wbs = #{wbs}
- </if>
- <if test="serial != '' and serial != null">
- and a.serial = #{serial}
- </if>
- <if test="attribute != '' and attribute != null">
- and a.attribute = #{attribute}
- </if>
- <if test="producDate != '' and producDate != null">
- and a.produc_batch = #{producDate}
- </if>
- <if test="supplierId != '' and supplierId != null">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="storageLocationCode != '' and storageLocationCode != null">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="accountSleeve != '' and accountSleeve != null">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </select>
- <!-- 查询仓库 -->
- <select id="getWarehouseWhere" resultType="String">
- SELECT DISTINCT b.warehouse_where
- FROM tld_return_gs_removal_z a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.document_id = #{removalCode}
- </select>
- <!-- 查询半成品原始数据 -->
- <select id="getInventoryNotice" resultType="java.util.Map">
- select *
- from tld_notice
- where id = #{id}
- </select>
- <!-- 删除半成品/产成品入库通知原始信息 -->
- <delete id="delInventoryNotice">
- delete
- from tld_notice
- where id = #{id}
- </delete>
- <!-- 查询要料申请单 -->
- <select id="getDelAskGoods" resultType="java.util.Map">
- select *
- from tld_ask_goods
- where id = #{id}
- </select>
- <!-- 销售发货单接口文档 父表信息 -->
- <select id="getGsRemoval" resultType="java.util.Map">
- select id,
- document_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType,
- scrq
- from tld_return_gs_removal
- where document_id = #{removalCode}
- </select>
- <!--查询移库子表中的供货仓库仓库-->
- <select id="getSupplyWarehouseWhere" resultType="java.lang.String">
- SELECT supply_warehouse_id
- FROM tld_return_warehouse_transfer_z
- WHERE warehouse_transfer_id = #{removalCode}
- GROUP BY supply_warehouse_id
- </select>
- <!--查询移库父表信息-->
- <select id="getReturnWarehouseTransfer" resultType="java.util.Map">
- select id,
- warehouse_transfer_id as warehouseTransferId,
- warehouse_transfer_code as warehouseTransferCode,
- ask_goods_warehouse_id as askGoodsWarehouseId,
- warehouse_transfer_type as warehouseTransferType,
- scrq
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </select>
- <!--查询出父表中的移库id根据code-->
- <select id="getSupplyWarehouseWheres" resultType="java.lang.String">
- select warehouse_transfer_id as warehouseTransferId
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </select>
- <!--查询移库子表信息-->
- <select id="getReturnWarehouseTransferZ" resultType="java.util.Map">
- select a.id,
- a.warehouse_transfer_id as warehouseTransferId,
- a.entry_number as entryNumber,
- a.supply_warehouse_id as supplyWarehouseId,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.out_num as outNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_return_warehouse_transfer_z a
- left join tld_wbs b on a.wbs = b.tld_id
- where a.warehouse_transfer_id = #{warehouseTransferId}
- and a.supply_warehouse_id = #{warehouseWhere}
- </select>
- <!-- 删除生产领料 -->
- <delete id="delAskGoods">
- delete
- from tld_ask_goods
- where id = #{id}
- </delete>
- <!--删除移库父表-->
- <delete id="delReturnWarehouseTransfer">
- delete
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </delete>
- <!--删除移库子表-->
- <delete id="delReturnWarehouseTransferZ">
- delete
- from tld_return_warehouse_transfer_z
- where warehouse_transfer_id = #{warehouseTransferTd}
- </delete>
- <!--删除移库父表-->
- <delete id="delNoticeParent">
- delete
- from tld_notice_f
- where notice_id = #{orderNumber}
- </delete>
- <!--删除移库子表-->
- <delete id="delNoticeSubtabulation">
- delete
- from tld_notice
- where notice_id = #{orderNumber}
- </delete>
- <!--删除其它入库父表信息-->
- <delete id="delNoticesParent">
- delete
- from tld_notices_f
- where notice_id = #{noticeId}
- </delete>
- <!--删除其它入库子表信息-->
- <delete id="delNoticesSubtabulation">
- delete
- from tld_notices
- where notice_id = #{noticeId}
- </delete>
- <!-- 查询名牌物料CODE -->
- <select id="getMing" resultType="String">
- select wllb_code from tld_mingpai where code = #{code}
- </select>
- <!--查询入库单信息-->
- <select id="getReturnGsWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select
- id,
- storage_code,
- gs_ck,
- source_type,
- move_type,
- entry_number,
- wbs,
- material_id,
- warehousing_num,
- receive_goods_id,
- scrq,
- order_number,
- user_name,
- storage_location_code
- from tld_return_gs_warehousing where storage_code = #{removalCode}
- </select>
- <!--根据库位查询仓库-->
- <select id="getStorageLocationWarehouseWhere" resultType="java.lang.String">
- select warehouse_where as warehouseWhere from tld_storage_location where storage_location_code = #{storageLocationCode}
- </select>
- <!--查询父表信息-->
- <select id="getNoticeParent" resultType="java.util.Map">
- select
- id as id,
- notice_id as noticeId,
- notice_code as noticeCode,
- company_number as companyNumber,
- notice_time as noticeTime,
- source_type as sourceType,
- move_type as moveType
- from tld_notice_f where notice_id = #{orderNumber}
- </select>
- <!--查询子表信息-->
- <select id="getNoticeSubtabulation" resultType="java.util.Map">
- select
- a.id as id,
- a.notice_id as noticeId,
- a.entry_number as entryNumber,
- a.production_code as productionCode,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.measurement_id as measurementId,
- a.num as num,
- a.type as type,
- a.warehousing_num as warehousingNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_notice a
- left join tld_wbs b on a.wbs = b.tld_id
- where a.notice_id = #{orderNumber}
- </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="getReturnGsOtherWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select
- distinct
- id,
- storage_code,
- account_sleeve,
- storage_location_code,
- wbs,
- amount,
- material_id,
- notice_id
- from tld_return_gs_other_warehousing where storage_code = #{removalCode}
- group by notice_id
- </select>
- <!--查询其他入库表信息-->
- <select id="getNoticesParent" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.storage_code as storageCde,
- a.account_sleeve as accountSleeve,
- a.storage_location_code as storageLocationCode,
- a.notice_id as noticeId,
- a.notice_code as noticeCode,
- a.amount as amount,
- ifnull(a.wbs, '') as wbsId,
- ifnull(a.wbs_code, '') as wbsCode,
- ifnull(a.wbs_name, '') as wbsName,
- a.notice_time as noticeTime,
- a.source_type as sourceType,
- a.move_type as moveType,
- a.entry_number as entryNumber,
- a.wms_item_id as wmsItemId,
- a.material_id as materialId,
- a.wms_id as wmsId,
- b.warehouse_where as warehouseWhere
- FROM tld_return_gs_other_warehousing a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.storage_code = #{noticeId} and a.storage_location_code = #{storageLocationCode}
- </select>
- <!--查询其他入库子表信息-->
- <select id="getNoticesSubtabulation" resultType="java.util.Map">
- select
- a.id as id,
- a.notice_id as noticeId,
- a.entry_number as entryNumber,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.measurement_id as measurementId,
- a.num as num,
- a.type as type,
- a.warehousing_num as warehousingNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_notices a
- left join tld_wbs b on a.wbs = b.tld_id
- join tld_storage_location c on a.storage_location_code = c.storage_location_code
- where a.notice_id = #{noticeId}
- </select>
- <!--查询仓库信息-->
- <select id="getCreateOtherInStockWarehouseWhere" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.storage_code as storageCde,
- a.account_sleeve as accountSleeve,
- a.storage_location_code as storageLocationCode,
- a.notice_id as noticeId,
- a.notice_code as noticeCode,
- a.amount as amount,
- ifnull(a.wbs, '') as wbsId,
- ifnull(a.wbs_code, '') as wbsCode,
- ifnull(a.wbs_name, '') as wbsName,
- a.notice_time as noticeTime,
- a.source_type as sourceType,
- a.move_type as moveType,
- a.entry_number as entryNumber,
- a.wms_item_id as wmsItemId,
- a.material_id as materialId,
- a.wms_id as wmsId,
- b.warehouse_where as warehouseWhere
- FROM tld_return_gs_other_warehousing a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.storage_code = #{removalCode}
- group by b.warehouse_where
- </select>
- <!-- 修改数据传输状态 -->
- <update id="updateRemoval">
- update tld_removal set transmission_type = "1" where storage_code = #{removalCode}
- </update>
- <!-- 修改数据传输状态 -->
- <update id="updateRemovalHalfProduct">
- update tld_removal_half_product set transmission_type = "1" where storage_code = #{removalCode}
- </update>
- <!-- 修改数据传输状态 -->
- <update id="updateRemovalHalf">
- update tld_removal_half set transmission_type = "1" where storage_code = #{removalCode}
- </update>
- </mapper>
|