123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?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.yh.saas.plugin.yiliangyiyun.mapper.StockSaleReceiptReportMapper">
- <!-- 获得销售出库统计总数 -->
- <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
- SELECT
- COUNT(id)
- FROM stock_sale_receipt_report
- WHERE
- comp_id = #{compId}
- and delete_flag = '0'
- <if test="searchType != null and searchType != ''">
- <if test="searchType == 2">
- AND amount_ing_receivable-amount_ed_receivable>0
- </if>
- <if test="searchType == 3">
- AND amount_ing_receivable-amount_ed_receivable=0
- </if>
- </if>
- <if test="contractNo != null and contractNo != ''and contractNo != '全部合同'">
- AND contract_no = #{contractNo}
- </if>
- <if test="processNo != null and processNo != ''">
- AND process_no = #{processNo}
- </if>
- <if test="startDate != null">
- AND (DATE_FORMAT(create_date,"%Y%m%d") >=
- DATE_FORMAT(#{startDate},"%Y%m%d"))
- </if>
- <if test="endDate != null">
- AND (DATE_FORMAT(create_date,"%Y%m%d") <=
- DATE_FORMAT(#{endDate},"%Y%m%d"))
- </if>
- </select>
- <!-- 获得销售出库统计列表 -->
- <select id="getListByCondition" parameterType="Map"
- resultType="com.yh.saas.plugin.yiliangyiyun.entity.StockSaleReceiptReport">
- SELECT
- id,
- comp_id as compId,
- contract_no as contractNo,
- car_no as carNo,
- warehouse_record_id as warehouseRecordId,
- delivery_date as deliveryDate,
- process_no as processNo,
- tran_car_no as tranCarNo,
- case_no as caseNo,
- title_no as titleNo,
- bin_number as binNumber,
- box_no as boxNo,
- feedback_person as feedbackPerson,
- create_date as createDate,
- update_date as updateDate,
- net_weight as netWeight,
- feedback_weight as feedbackWeight,
- gross_weight as grossWeight,
- tare as tare,
- settlement_weight AS settlementWeight,
- settlement_price AS settlementPrice,
- ROUND(amount_ing_receivable,2) as amountIngReceivable,
- ROUND(amount_ed_receivable,2) as amountEdReceivable,
- ROUND(amount_not_receivable,2) as amountNotReceivable,
- collection_screenshot as collectionScreenshot,
- collection_date as collectionDate,
- already_invoice as alreadyInvoice,
- warehouse_name as warehouseName,
- status,
- approve_status as approveStatus,
- status_flag as statusFlag,
- approve_status as approveStatus,
- return_date as returnDate,
- return_flag as returnFlag,
- workflow_id as workflowId
- FROM stock_sale_receipt_report
- WHERE
- comp_id = #{compId}
- and delete_flag = '0'
- <if test="contractNo != null and contractNo != ''and contractNo != '全部合同'">
- AND contract_no = #{contractNo}
- </if>
- <if test="processNo != null and processNo != ''">
- AND process_no = #{processNo}
- </if>
- <if test="searchType != null and searchType != ''">
- <if test="searchType == 2">
- AND amount_ing_receivable-amount_ed_receivable>0
- </if>
- <if test="searchType == 3">
- AND amount_ing_receivable-amount_ed_receivable=0
- </if>
- </if>
- <if test="startDate != null">
- AND (DATE_FORMAT(create_date,"%Y%m%d") >=
- DATE_FORMAT(#{startDate},"%Y%m%d"))
- </if>
- <if test="endDate != null">
- AND (DATE_FORMAT(create_date,"%Y%m%d") <=
- DATE_FORMAT(#{endDate},"%Y%m%d"))
- </if>
- ORDER BY delivery_date DESC
- <if test="currentPage != null and currentPage != ''">
- LIMIT ${startRecord}, ${pageSize}
- </if>
- </select>
- <select id="getAmonutIn" parameterType="Map"
- resultType="java.lang.String">
- SELECT
- sum(ei.amount_money) as amount
- FROM
- expense_info ei
- LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = ei.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = ei.warehouse_name
- LEFT JOIN contract_management_info cmi ON cmi.comp_id = ei.comp_id and cmi.delete_flag = 0 and cmi.contract_no = ei.contract_no
- WHERE
- ei.delete_flag = 0
- AND ei.comp_id = #{compId}
- and ei.expenses_type = '1'
- and ei.update_date > #{seachMoth}
- <if test="jointVentureParties != null">
- AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
- </if>
- </select>
- <select id="getAmonutOut" parameterType="Map"
- resultType="java.lang.String">
- SELECT
- IFNULL( sum( ei.amount_money ), 0 ) + IFNULL((
- SELECT
- sum( p.amount_ing_payable )
- FROM
- payment_management p
- LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = p.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = p.warehouse_name
- LEFT JOIN contract_management_info cmi ON cmi.comp_id = p.comp_id and cmi.delete_flag = 0 and cmi.contract_no = p.contract_no
- WHERE
- p.delete_flag = 0
- AND p.comp_id = #{compId}
- AND p.create_date > #{seachMoth}
- <if test="jointVentureParties != null">
- AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
- </if>
- ),
- 0
- ) as aa
- FROM
- expense_info ei
- LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = ei.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = ei.warehouse_name
- LEFT JOIN contract_management_info cmi ON cmi.comp_id = ei.comp_id and cmi.delete_flag = 0 and cmi.contract_no = ei.contract_no
- WHERE
- ei.delete_flag = 0
- AND ei.comp_id = #{compId}
- and ei.expenses_type = '2'
- and ei.update_date > #{seachMoth}
- <if test="jointVentureParties != null">
- AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
- </if>
- </select>
- <select id="getAmonutMao" parameterType="Map"
- resultType="java.lang.String">
- SELECT
- sum(
- a.amount_ing_receivable - IFNULL( IFNULL( a.cost, w.cost ), 0 )* a.net_weight - IFNULL( a.sale_cost, 0 )) AS
- lirun
- FROM
- stock_sale_receipt_report a
- LEFT JOIN warehouse_cost w ON w.comp_id = a.comp_id
- AND w.delete_flag = 0
- AND w.warehouse_name = a.warehouse_name
- AND w.calculate_date = DATE_SUB( a.delivery_date, INTERVAL 1 DAY )
- LEFT JOIN warehouse_in_out_info wioi ON wioi.id = a.warehouse_record_id and wioi.delete_flag = 0
- LEFT JOIN warehouse_base_info wbi ON wbi.id = wioi.base_id and wbi.delete_flag = 0
- WHERE
- 1 = 1
- AND a.delete_flag = 0
- <if test="jointVentureParties != null">
- AND wbi.joint_venture_parties = #{jointVentureParties}
- </if>
- AND a.delivery_date > #{seachMoth}
- </select>
- </mapper>
|