| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945 |
- <?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.zfire.mall.manager.commonmapper.stock.StockCommonMapper">
- <select id="list" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- kdm.id as materialId,
- kdm.number AS materialNumber,
- kdm.`name` AS materialName,
- kdm.old_number AS materialOldNumber,
- kdm.specification,
- kdm.base_unit_id,
- kdm.category_name,
- kdm.material_group_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- where 1=1
- and scp.stock_id = s.stock_id
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="stockId !=null and stockId != ''">
- and scp.stock_id = #{stockId}
- </if>
- <!-- <if test="categoryId !=null and categoryId != ''">
- and kdm.category_id = #{categoryId}
- </if>-->
- <if test="categoryId != null and categoryId.size > 0">
- AND kdm.category_id in
- <foreach item="item" index="index" collection="categoryId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="materialOldNumber !=null and materialOldNumber != ''">
- and kdm.old_number like concat('%',#{materialOldNumber},'%')
- </if>
- <if test="materialName !=null and materialName != ''">
- and kdm.name like concat('%',#{materialName},'%')
- </if>
- <if test="materialNumber !=null and materialNumber != ''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="specification !=null and specification != ''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- group by kdm.id
- order by kdm.create_time desc
- </select>
- <select id="selectInvoiceCount" resultType="Integer">
- SELECT
- ifnull(SUM(iao.refundable_qty),0)
- FROM
- invoice_application_order iao
- LEFT JOIN invoice_application ia ON iao.invoice_id = ia.id
- where ia.examine_status in ('SAVE','WAIT')
- and iao.material_id=#{materialId}
- and type != 2
- <if test="correspondId != null and correspondId != ''">
- and ia.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="countAll" resultType="Integer">
- SELECT
- ifnull(SUM(iao.refundable_qty),0)
- FROM
- sales_order ia
- LEFT JOIN sales_order_item iao ON ia.id = iao.sales_order_no
- where ia.examine_status != 'OK'
- and iao.material_id =#{materialId}
- and ia.type != 2
- <if test="correspondId != null and correspondId != ''">
- and ia.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="countReserved" resultType="Integer">
- SELECT
- ifnull(sum( roi.reserved_num ),0)
- FROM
- reserved_order_item roi
- WHERE
- roi.STATUS = 1
- and roi.material_id = #{materialId}
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <resultMap id="sockPosition" type="com.zfire.mall.manager.bean.k3.StockPositionStock">
- <id column="id" jdbcType="VARCHAR" property="id"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="stock_cordon" jdbcType="DECIMAL" property="stockCordon"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
- <collection property="kingDeeStocks" ofType="com.zfire.mall.manager.plus.entity.KingDeeStock" select="stocks" column="id">
- <id column="id" jdbcType="VARCHAR" property="id"/>
- <result column="number" jdbcType="VARCHAR" property="number"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="useOrgNumber" jdbcType="VARCHAR" property="useOrgName"/>
- <result column="useOrgName" jdbcType="VARCHAR" property="useOrgName"/>
- <result column="syncTime" jdbcType="TIMESTAMP" property="syncTime"/>
- <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="forbid_status" jdbcType="VARCHAR" property="forbidStatus"/>
- <result column="principal_name" jdbcType="VARCHAR" property="principalName"/>
- <result column="stock_property" jdbcType="VARCHAR" property="stockProperty"/>
- <result column="third_stock_type" jdbcType="VARCHAR" property="thirdStockType"/>
- <result column="document_status" jdbcType="VARCHAR" property="documentStatus"/>
- <result column="allow_minus_qty" jdbcType="VARCHAR" property="allowMinusQty"/>
- <result column="open_location" jdbcType="VARCHAR" property="openLocation"/>
- <result column="not_exp_qty" jdbcType="VARCHAR" property="notExpQty"/>
- <result column="available_alert" jdbcType="VARCHAR" property="availableAlert"/>
- <result column="create_org_name" jdbcType="VARCHAR" property="createOrgName"/>
- <result column="supplier_name" jdbcType="VARCHAR" property="supplierName"/>
- <result column="customer_name" jdbcType="VARCHAR" property="customerName"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="tel" jdbcType="VARCHAR" property="tel"/>
- <result column="description" jdbcType="VARCHAR" property="description"/>
- <result column="group_name" jdbcType="VARCHAR" property="groupName"/>
- <result column="gys_stock" jdbcType="VARCHAR" property="gysStock"/>
- <result column="gys_stock_number" jdbcType="VARCHAR" property="gysStockNumber"/>
- <result column="third_stock_no" jdbcType="VARCHAR" property="thirdStockNo"/>
- <result column="stock_status_type" jdbcType="VARCHAR" property="stockStatusType"/>
- <result column="def_stock_status_name" jdbcType="VARCHAR" property="defStockStatusName"/>
- <result column="def_receive_status_name" jdbcType="VARCHAR" property="defReceiveStatusName"/>
- <result column="allow_mrp_plan" jdbcType="VARCHAR" property="allowMrpPlan"/>
- <result column="allow_lock" jdbcType="VARCHAR" property="allowLock"/>
- <result column="available_picking" jdbcType="VARCHAR" property="availablePicking"/>
- <result column="sorting_priority" jdbcType="VARCHAR" property="sortingPriority"/>
- <result column="locList_formatter" jdbcType="VARCHAR" property="loclistFormatter"/>
- <result column="Inquire" jdbcType="TINYINT" property="inquire"/>
- </collection>
- </resultMap>
- <select id="listStock" resultMap="sockPosition">
- SELECT
- sc.*
- FROM
- stock_correspond sc
- LEFT JOIN stock_correspond_position scp ON sc.id = scp.correspond_id
- LEFT JOIN king_dee_stock kds ON scp.stock_id = kds.id
- left join admin_user_stock aus on sc.id = aus.correspond_id
- where 1=1
- <if test="name != null and name != ''">
- and sc.name like CONCAT('%', #{name},'%')
- </if>
- <if test="stockName != null and stockName != ''">
- and kds.name like CONCAT('%', #{stockName},'%')
- </if>
- <if test="adminUserId != null and adminUserId != ''">
- and aus.admin_user_id = #{adminUserId}
- </if>
- <if test="type != null and type != ''">
- and sc.type = #{type}
- </if>
- group by sc.id
- order by sc.create_time desc
- </select>
- <select id="stocks" resultType="com.zfire.mall.manager.plus.entity.KingDeeStock">
- SELECT
- kds.*
- FROM
- stock_correspond sc
- LEFT JOIN stock_correspond_position scp ON sc.id = scp.correspond_id
- LEFT JOIN king_dee_stock kds ON scp.stock_id = kds.id
- where sc.id=#{id}
- </select>
- <select id="resverdNumber" resultType="Integer">
- SELECT
- IFNULL(SUM(roi.reserved_num),0)
- FROM
- reserved_order_item roi
- where roi.material_id = #{materialId}
- and roi.`status` = 1
- <if test="orderId != null and orderId != ''">
- and (roi.order_id != #{orderId} or roi.order_id is null)
- </if>
- and (roi.customer_id != #{customerId})
- <if test="correspondId == null">
- and roi.correspond_id = null
- </if>
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="resverdCustomerNumber" resultType="Integer">
- SELECT
- IFNULL(SUM(roi.reserved_num),0)
- FROM
- reserved_order_item roi
- where roi.material_id = #{materialId}
- and roi.`status` = 1
- <if test="orderId != null and orderId != ''">
- and (roi.order_id != #{orderId} and roi.order_id is not null)
- </if>
- and (roi.customer_id = #{customerId})
- <if test="correspondId == null">
- and roi.correspond_id = null
- </if>
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="resverdCustomerNumberRe" resultType="Integer">
- SELECT
- IFNULL(SUM(roi.reserved_num),0)
- FROM
- reserved_order_item roi
- where roi.material_id = #{materialId}
- and roi.`status` = 1
- <if test="orderId != null and orderId != ''">
- and (roi.order_id = #{orderId})
- </if>
- and (roi.customer_id = #{customerId})
- <if test="correspondId == null">
- and roi.correspond_id = null
- </if>
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="resverdAllStockNumber" resultType="Integer">
- SELECT
- IFNULL(SUM(roi.reserved_num),0)
- FROM
- reserved_order_item roi
- where roi.material_id = #{materialId}
- and roi.`status` = 1
- <if test="correspondId == null || correspondId == ''">
- and roi.correspond_id is null
- </if>
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="resverdAllStockNumberRE" resultType="Integer">
- SELECT
- IFNULL(SUM(roi.reserved_num),0)
- FROM
- reserved_order_item roi
- where roi.material_id = #{materialId}
- and roi.`status` = 1
- <if test="correspondId != null and correspondId != ''">
- and roi.correspond_id =#{correspondId}
- </if>
- </select>
- <select id="sumKingDeeNumber" resultType="Integer">
- SELECT
- IFNULL(SUM(s.stock_qty),0)
- FROM
- stock s
- join stock_correspond_position scp on s.stock_id = scp.stock_id
- join king_dee_stock kds on scp.stock_id = kds.id
- where 1=1
- <if test="correspondId != null and correspondId != ''">
- and scp.correspond_id = #{correspondId}
- </if>
- <if test="correspondId == null or correspondId == ''">
- and kds.not_exp_qty = 0
- </if>
- and s.material_id = #{materialId}
- </select>
- <select id="stockHintUnit" resultType="Integer">
- SELECT
- ifnull(count(pms.id ), 0)
- FROM
- pick_manager_ship pms
- LEFT JOIN pick_manager pm ON pm.id = pms.pick_id
- LEFT JOIN invoice_application_order iao ON pms.invoice_order_id = iao.id
- where pm.correspond_id = #{correspondId}
- and iao.material_id = #{materialId}
- and pm.pick_time BETWEEN #{startOfDay} and #{endOfDay}
- </select>
- <select id="stockHintTower" resultType="Integer">
- SELECT
- ifnull(SUM(iao.refundable_qty), 0)
- FROM
- pick_manager_ship pms
- LEFT JOIN pick_manager pm ON pm.id = pms.pick_id
- LEFT JOIN invoice_application_order iao ON pms.invoice_order_id = iao.id
- where pm.correspond_id = #{correspondId}
- and iao.material_id = #{materialId}
- and pm.pick_time BETWEEN #{startTime} and #{endTime}
- </select>
- <select id="listStockToDay" resultType="com.zfire.mall.manager.bean.stock.StockBeanToDay">
- SELECT
- kdm.`name` as materialName,
- kdm.old_number as materialOldNumber,
- kdm.number as materialNumber,
- kdm.id as materialId,
- kdm.specification,
- s.stock_qty as balanceNumber,
- s.stock_id,
- sc.`name` as correspond_name,
- scp.correspond_id,
- kdm.category_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- left join admin_user_stock aus on scp.correspond_id = aus.correspond_id
- where 1=1
- and scp.stock_id = s.stock_id
- <!-- <if test="correspondId != null and correspondId!=''">
- and scp.correspond_id =#{correspondId}
- </if>-->
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="categoryList != null and categoryList.size > 0">
- AND kdm.category_id in
- <foreach item="item" index="index" collection="categoryList" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="categoryId != null and categoryId.size > 0">
- AND kdm.category_id in
- <foreach item="item" index="index" collection="categoryId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="materialNumber != null and materialNumber!=''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="materialOldNumber != null and materialOldNumber!=''">
- and kdm.old_number like concat('%',#{materialOldNumber},'%')
- </if>
- <if test="materialName != null and materialName!=''">
- and kdm.name like concat('%',#{materialName},'%')
- </if>
- <!-- <if test="categoryId != null and categoryId!=''">
- and kdm.category_id =#{categoryId}
- </if>-->
- <if test="specification != null and specification!=''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- <if test="adminUserId != null and adminUserId!=''">
- and aus.admin_user_id = #{adminUserId}
- </if>
- group by s.id
- </select>
- <select id="sumKingDeeNumberList" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- s.stock_qty,
- s.material_id,
- scp.correspond_id
- FROM
- stock s
- join stock_correspond_position scp on s.stock_id = scp.stock_id
- join king_dee_stock kds on scp.stock_id = kds.id
- where 1=1
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="sumKingDeeNumberAdequateList" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- s.stock_qty as stockAdequate,
- s.material_id,
- scp.correspond_id
- FROM
- stock s
- join stock_correspond_position scp on s.stock_id = scp.stock_id
- join king_dee_stock kds on scp.stock_id = kds.id
- where 1=1
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="correspondId == null ">
- and kds.not_exp_qty = 0
- </if>
- </select>
- <select id="selectInvoiceCountList" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- iao.refundable_qty as temporaryNum,
- iao.material_id,
- ia.correspond_id
- FROM
- invoice_application_order iao
- LEFT JOIN invoice_application ia ON iao.invoice_id = ia.id
- where ia.examine_status in ('SAVE','WAIT')
- and type != 2
- <if test="correspondId != null and correspondId.size > 0">
- AND ia.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="countAllList" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- iao.refundable_qty as num,
- iao.material_id,
- ia.correspond_id
- FROM
- sales_order ia
- LEFT JOIN sales_order_item iao ON ia.id = iao.sales_order_no
- where ia.examine_status != 'OK'
- and ia.type != 2
- <if test="correspondId != null and correspondId.size > 0">
- AND ia.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="countReservedList" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- roi.reserved_num as reservedNum,
- roi.material_id,
- roi.correspond_id
- FROM
- reserved_order_item roi
- WHERE
- roi.STATUS = 1
- <if test="correspondId != null and correspondId.size > 0">
- AND roi.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="listCustomer" resultType="com.zfire.mall.manager.bean.stock.StockCustomerReserved">
- SELECT
- roi.customer_id,
- roi.customer_name,
- roi.customer_number,
- kdm.category_name,
- roi.material_code as materialNumber,
- roi.material_old_number,
- roi.material_id,
- roi.specification,
- roi.material_name,
- roi.unit,
- sum(roi.reserved_num) as reservedNum
- FROM
- reserved_order ro
- JOIN reserved_order_item roi on roi.reserved_id = ro.id
- join king_dee_material kdm on kdm.id = roi.material_id
- where roi.status = 1
- <if test="materialName != null and materialName!=''">
- and roi.material_name like concat('%',#{materialName},'%')
- </if>
- <if test="materialNumber != null and materialNumber!=''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="customerName != null and customerName!=''">
- and ro.customer_name like concat('%',#{customerName},'%')
- </if>
- <if test="customerNumber != null and customerNumber!=''">
- and ro.customer_number like concat('%',#{customerNumber},'%')
- </if>
- <if test="categoryId != null and categoryId!=''">
- and kdm.category_id =#{categoryId}
- </if>
- <if test="specification != null and specification!=''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- GROUP BY roi.customer_id,roi.material_id
- order by roi.create_time
- </select>
- <select id="listPurchaseOrderOut" resultType="com.zfire.mall.manager.bean.stock.KingDeePurchaseStockOutBean">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date,
- kds.`name` as supplierName,
- kdpso.fd_document_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.rm_real_qty as qty,
- kdsc.`name` as stockName
- FROM
- king_dee_purchase_stock_out kdpso
- JOIN king_dee_purchase_stock_out_item kdpsoi on kdpso.id = kdpsoi.f_id
- join king_dee_supplier kds on kdpso.supplier_id = kds.id
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- where 1=1
- <if test="specification != null and specification!=''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- <if test="supplierName != null and supplierName!=''">
- and kds.name like concat('%',#{supplierName},'%')
- </if>
- <if test="materialOldNumber != null and materialOldNumber!=''">
- and kdm.old_number like concat('%',#{materialOldNumber},'%')
- </if>
- <if test="materialName != null and materialName!=''">
- and kdpsoi.material_name like concat('%',#{materialName},'%')
- </if>
- <if test="materialNumber != null and materialNumber!=''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="billNo != null and billNo!=''">
- and kdpso.bill_no like concat('%',#{billNo},'%')
- </if>
- <if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
- and kdpso.f_date between #{startTime} and #{endTime}
- </if>
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- order by kdpso.f_date desc
- </select>
- <select id="listOtherStockOut" resultType="com.zfire.mall.manager.bean.stock.KingDeeOtherStockOutBean">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date,
- kdpso.fd_document_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.qty,
- kdsc.`name` as stockName
- FROM
- king_dee_other_stock_out kdpso
- JOIN king_dee_other_stock_out_item kdpsoi on kdpso.id = kdpsoi.f_id
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- where 1=1
- <if test="specification != null and specification!=''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- <if test="materialOldNumber != null and materialOldNumber!=''">
- and kdm.old_number like concat('%',#{materialOldNumber},'%')
- </if>
- <if test="materialName != null and materialName!=''">
- and kdpsoi.material_name like concat('%',#{materialName},'%')
- </if>
- <if test="billNo != null and billNo!=''">
- and kdpso.bill_no like concat('%',#{billNo},'%')
- </if>
- <if test="materialNumber != null and materialNumber!=''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
- and kdpso.f_date between #{startTime} and #{endTime}
- </if>
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- order by kdpso.f_date desc
- </select>
- <select id="listOtherStockIn" resultType="com.zfire.mall.manager.bean.stock.KingDeeOtherStockInBean">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date,
- kdpso.fd_document_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.qty,
- kdsc.`name` as stockName
- FROM
- king_dee_other_stock_in kdpso
- JOIN king_dee_other_stock_in_item kdpsoi on kdpso.id = kdpsoi.f_id
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- where 1=1
- <if test="specification != null and specification!=''">
- and kdm.specification like concat('%',#{specification},'%')
- </if>
- <if test="materialOldNumber != null and materialOldNumber!=''">
- and kdm.old_number like concat('%',#{materialOldNumber},'%')
- </if>
- <if test="materialName != null and materialName!=''">
- and kdpsoi.material_name like concat('%',#{materialName},'%')
- </if>
- <if test="materialNumber != null and materialNumber!=''">
- and kdm.number like concat('%',#{materialNumber},'%')
- </if>
- <if test="billNo != null and billNo!=''">
- and kdpso.bill_no like concat('%',#{billNo},'%')
- </if>
- <if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
- and kdpso.f_date between #{startTime} and #{endTime}
- </if>
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- order by kdpso.f_date desc
- </select>
- <select id="listStockToDayV2" resultType="com.zfire.mall.manager.bean.stock.StockBeanToDay">
- SELECT
- kdm.`name` as materialName,
- kdm.old_number as materialOldNumber,
- kdm.number as materialNumber,
- kdm.id as materialId,
- kdm.specification,
- kdm.cost_price,
- s.stock_qty as balanceNumber,
- s.stock_id,
- scp.correspond_id,
- sc.name as correspondName,
- kdm.category_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- left join admin_user_stock aus on scp.correspond_id = aus.correspond_id
- ${ex.query}
- and scp.stock_id = s.stock_id
- <if test="adminUserId != null and adminUserId!=''">
- and aus.admin_user_id = #{adminUserId}
- </if>
- group by s.id
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by s.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="listStockToDayCustomerV2"
- resultType="com.zfire.mall.manager.bean.stock.StockBeanCustomerToDay">
- SELECT
- kdm.`name` as materialName,
- kdm.old_number as materialOldNumber,
- kdm.number as materialNumber,
- kdm.id as materialId,
- kdm.specification,
- s.stock_qty as balanceNumber,
- s.stock_id,
- scp.correspond_id,
- sc.name as correspondName,
- kdm.category_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- left join admin_user_stock aus on scp.correspond_id = aus.correspond_id
- ${ex.query}
- and scp.stock_id = s.stock_id
- <if test="adminUserId != null and adminUserId!=''">
- and aus.admin_user_id = #{adminUserId}
- </if>
- <if test="categoryList != null and categoryList.size > 0">
- AND kdm.category_id in
- <foreach item="item" index="index" collection="categoryList" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- group by s.id
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by s.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="listPurchaseOrderOutV2"
- resultType="com.zfire.mall.manager.bean.stock.KingDeePurchaseStockOutVO">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date as fDate,
- kds.`name` as supplierName,
- kdpso.fd_document_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.rm_real_qty as qty,
- kdsc.`name` as stockName
- FROM
- king_dee_purchase_stock_out kdpso
- JOIN king_dee_purchase_stock_out_item kdpsoi on kdpso.id = kdpsoi.bill_no
- join king_dee_supplier kds on kdpso.supplier_id = kds.id
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- ${ex.query}
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by kdpso.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="listOtherStockOutV2" resultType="com.zfire.mall.manager.bean.stock.KingDeeOtherStockOutVO">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date,
- kdpso.stock_direct,
- kdpso.cancel_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.qty,
- kdsc.`name` as stockName
- FROM
- king_dee_other_stock_out kdpso
- JOIN king_dee_other_stock_out_item kdpsoi on kdpso.id = kdpsoi.bill_no
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- ${ex.query}
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by kdpso.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="listOtherStockInV2" resultType="com.zfire.mall.manager.bean.stock.KingDeeOtherStockInVO">
- SELECT
- kdpso.id,
- kdpso.bill_no,
- kdpso.f_date,
- kdpso.stock_direct,
- kdpso.cancel_status,
- kdpso.fd_document_status,
- kdpsoi.material_name,
- kdpsoi.material_number,
- kdm.old_number as materialOldNumber,
- kdm.specification,
- kdm.base_unit_id as unit,
- kdpsoi.qty,
- kdsc.`name` as stockName
- FROM
- king_dee_other_stock_in kdpso
- JOIN king_dee_other_stock_in_item kdpsoi on kdpso.id = kdpsoi.bill_no
- JOIN king_dee_material kdm on kdpsoi.material_id = kdm.id
- join king_dee_stock kdsc on kdsc.id = kdpsoi.stock_id
- join stock_correspond_position scp on kdsc.id = scp.stock_id
- ${ex.query}
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by kdpso.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="listV2" resultType="com.zfire.mall.manager.bean.stock.StockVO">
- SELECT
- kdm.id as materialId,
- kdm.number AS materialNumber,
- kdm.`name` AS materialName,
- kdm.old_number AS materialOldNumber,
- kdm.specification,
- kdm.base_unit_id,
- kdm.category_name,
- kdm.material_group_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- ${ex.query}
- and scp.stock_id = s.stock_id
- group by kdm.id
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by kdm.create_time desc
- </if>
- ${ex.orderBy}
- </select>
- <select id="listCustomerV2" resultType="com.zfire.mall.manager.bean.stock.StockCustomerReserved">
- SELECT
- roi.customer_id,
- roi.customer_name,
- roi.customer_number,
- kdm.category_name,
- roi.material_code as materialNumber,
- roi.material_old_number,
- roi.material_id,
- roi.specification,
- roi.material_name,
- roi.unit,
- sum(roi.reserved_num) as reservedNum
- FROM
- reserved_order ro
- JOIN reserved_order_item roi on roi.reserved_id = ro.id
- join king_dee_material kdm on kdm.id = roi.material_id
- ${ex.query}
- and roi.status = 1
- GROUP BY roi.customer_id,roi.material_id
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by roi.create_time desc
- </if>
- ${ex.orderBy}
- </select>
- <select id="listOne" resultType="com.zfire.mall.manager.bean.stock.StockBean">
- SELECT
- kdm.id as materialId,
- kdm.number AS materialNumber,
- kdm.`name` AS materialName,
- kdm.old_number AS materialOldNumber,
- kdm.specification,
- kdm.base_unit_id,
- kdm.category_name,
- kdm.material_group_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- and scp.stock_id = s.stock_id
- <if test="correspondId != null and correspondId.size > 0">
- AND scp.correspond_id in
- <foreach item="item" index="index" collection="correspondId" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- and kdm.id = #{materialId}
- group by kdm.id
- </select>
- <select id="listStockToCostPriceV2" resultType="com.zfire.mall.manager.bean.stock.StockBeanToCostPrice">
- SELECT
- kdm.`name` as materialName,
- kdm.old_number as materialOldNumber,
- kdm.number as materialNumber,
- kdm.id as materialId,
- kdm.specification,
- kdm.cost_price,
- s.stock_qty as balanceNumber,
- s.stock_id,
- scp.correspond_id,
- sc.name as correspondName,
- kdm.category_name
- FROM
- stock s
- JOIN stock_correspond_position scp on scp.stock_id = s.stock_id
- JOIN king_dee_material kdm ON s.material_id = kdm.id
- JOIN stock_correspond sc on scp.correspond_id = sc.id
- left join admin_user_stock aus on scp.correspond_id = aus.correspond_id
- ${ex.query}
- and scp.stock_id = s.stock_id
- <if test="adminUserId != null and adminUserId!=''">
- and aus.admin_user_id = #{adminUserId}
- </if>
- group by s.id
- <if test="ex.orderBy == null or ex.orderBy ==''">
- order by s.sync_time DESC
- </if>
- ${ex.orderBy}
- </select>
- </mapper>
|