<?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.wms_admin.server.mapper.OrderInformationMapper">
|
|
<resultMap id="SelectOutProductPageMap" type="com.wms_admin.server.entity.OrderInformation">
|
<result property="id" column="id"/>
|
<result property="orderNumber" column="order_number"/>
|
<result property="customerOrderNumber" column="customer_order_number"/>
|
<result property="createTime" column="create_time"/>
|
<result property="customerName" column="customer_name"/>
|
<result property="consignor" column="consignor"/>
|
<!--自定义字段-->
|
<result property="productName" jdbcType="VARCHAR" column="productName"/>
|
<result property="productModel" jdbcType="VARCHAR" column="productModel"/>
|
<result property="productUnit" jdbcType="VARCHAR" column="productUnit"/>
|
<result property="outQuantity" jdbcType="INTEGER" column="outQuantity"/>
|
</resultMap>
|
<select id="SelectOutProductPage" resultMap="SelectOutProductPageMap">
|
SELECT i.`id`, i.`order_number`, i.`customer_order_number`, i.`create_time`, i.`customer_name`, i.`consignor`,
|
o.`unit` productUnit, o.`outbound_quantity` outQuantity, n.`product_name` productName, m.`product_model` productModel
|
FROM order_information i, out_product o, product_name n, product_model m
|
WHERE o.`order_information_id` = i.`id`
|
AND o.`product_name_id` = n.`id`
|
AND o.`product_model_id` = m.`id`
|
<if test="startTime != null">
|
AND i.create_time >= #{startTime}
|
</if>
|
<if test="endTime != null">
|
-- 在mybatis中小于号不能使用,需要使用方法转义:<![CDATA[<=]]>
|
AND i.create_time <![CDATA[<=]]> #{endTime}
|
</if>
|
<if test="customerName != null">
|
AND i.`customer_name` = #{customerName}
|
</if>
|
</select>
|
|
<resultMap id="SelectOutProductExcelMap" type="com.wms_admin.excel.ExcelOrderInformation">
|
<result property="id" column="id"/>
|
<result property="orderNumber" column="order_number"/>
|
<result property="customerOrderNumber" column="customer_order_number"/>
|
<result property="createTime" column="create_time"/>
|
<result property="customerName" column="customer_name"/>
|
<result property="consignor" column="consignor"/>
|
<!--自定义字段-->
|
<result property="productName" jdbcType="VARCHAR" column="productName"/>
|
<result property="productModel" jdbcType="VARCHAR" column="productModel"/>
|
<result property="productUnit" jdbcType="VARCHAR" column="productUnit"/>
|
<result property="outQuantity" jdbcType="INTEGER" column="outQuantity"/>
|
</resultMap>
|
<select id="SelectOutProductExcel" resultMap="SelectOutProductExcelMap">
|
SELECT i.*,
|
n.`product_name` productName, m.`product_model` productModel, o.`unit` productUnit, o.`outbound_quantity` outQuantity
|
FROM order_information i, out_product o, product_name n, product_model m
|
WHERE i.`id` = o.`order_information_id`
|
AND o.`product_name_id` = n.`id`
|
AND o.`product_model_id` = m.`id`
|
<if test="startTime != null">
|
AND i.create_time >= #{startTime}
|
</if>
|
<if test="endTime != null">
|
-- 在mybatis中小于号不能使用,需要使用方法转义:<![CDATA[<=]]>
|
AND i.create_time <![CDATA[<=]]> #{endTime}
|
</if>
|
<if test="customerName != null">
|
AND i.`customer_name` = #{customerName}
|
</if>
|
</select>
|
|
<resultMap id="SendingAndStoringManagementMap" type="com.wms_admin.excel.ExcelSendAndStoringUtil">
|
<result property="id" column="id"/>
|
<result property="productCode" column="product_code"/>
|
<result property="productName" column="product_name"/>
|
<result property="productModel" column="product_model"/>
|
<result property="productUnit" column="unit"/>
|
<result property="beginningInventory" column="beginningInventory"/>
|
<result property="currentPeriod" column="currentPeriod"/>
|
<result property="issueInCurrentPeriod" column="issueInCurrentPeriod"/>
|
<result property="closingInventory" column="closingInventory"/>
|
</resultMap>
|
<select id="SendingAndStoringManagement" resultMap="SendingAndStoringManagementMap">
|
SELECT *
|
from product
|
<!-- IFNULL(beginningInventory.sumData, 0) 'beginningInventory', IFNULL(currentPeriod.sumData, 0) 'currentPeriod',-->
|
<!-- IFNULL(issueInCurrentPeriod.sumData, 0) 'issueInCurrentPeriod', IFNULL(closingInventory.sumData, 0) 'closingInventory'-->
|
<!-- FROM (out_product o, product_name n, product_model m)-->
|
<!-- <choose>-->
|
<!-- <when test="startTime != null">-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.incoming_quantity) sumData-->
|
<!-- FROM product p-->
|
<!-- WHERE p.`create_time` <![CDATA[<=]]> #{startTime}-->
|
<!-- GROUP BY p.`product_model_id`-->
|
<!-- ) beginningInventory ON beginningInventory.model_id = o.`product_model_id`-->
|
<!-- </when>-->
|
<!-- <otherwise>-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.incoming_quantity) sumData-->
|
<!-- FROM product p-->
|
<!-- WHERE p.`create_time` <![CDATA[<=]]> (SELECT DATE_SUB(DATE_SUB(DATE_FORMAT(NOW(),'%y-%m-%d'),INTERVAL EXTRACT(DAY FROM NOW())-1 DAY),INTERVAL 0 MONTH) first_day)-->
|
<!-- GROUP BY p.`product_model_id`-->
|
<!-- ) beginningInventory ON beginningInventory.model_id = o.`product_model_id`-->
|
<!-- </otherwise>-->
|
<!-- </choose>-->
|
<!-- <choose>-->
|
<!-- <when test="startTime != null">-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT model_id, SUM(currentPeriod) sumData-->
|
<!-- FROM (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.`incoming_quantity`) currentPeriod-->
|
<!-- FROM product p-->
|
<!-- WHERE p.`create_time` >= #{startTime}-->
|
<!-- AND p.`create_time` <![CDATA[<=]]> #{endTime}-->
|
<!-- GROUP BY p.`product_model_id`-->
|
<!-- UNION-->
|
<!-- SELECT o.`product_model_id` model_id, SUM(o.`outbound_quantity`) currentPeriod-->
|
<!-- FROM out_product o-->
|
<!-- WHERE o.`create_time` >= #{startTime}-->
|
<!-- AND o.`create_time` <![CDATA[<=]]> #{endTime}-->
|
<!-- GROUP BY o.`product_model_id`-->
|
<!-- ) AS temp-->
|
<!-- GROUP BY model_id-->
|
<!-- ) currentPeriod ON currentPeriod.model_id = o.`product_model_id`-->
|
<!-- </when>-->
|
<!-- <otherwise>-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT model_id, SUM(currentPeriod) sumData-->
|
<!-- FROM (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.`incoming_quantity`) currentPeriod-->
|
<!-- FROM product p-->
|
<!-- WHERE DATE_FORMAT(p.`create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')-->
|
<!-- GROUP BY p.`product_model_id`-->
|
<!-- UNION-->
|
<!-- SELECT o.`product_model_id` model_id, SUM(o.`outbound_quantity`) currentPeriod-->
|
<!-- FROM out_product o-->
|
<!-- WHERE DATE_FORMAT(o.`add_Time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')-->
|
<!-- GROUP BY o.`product_model_id`-->
|
<!-- ) AS temp-->
|
<!-- GROUP BY model_id-->
|
<!-- ) currentPeriod ON currentPeriod.model_id = o.`product_model_id`-->
|
<!-- </otherwise>-->
|
<!-- </choose>-->
|
<!-- <choose>-->
|
<!-- <when test="startTime != null">-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT o.`product_model_id` model_id, SUM(o.`outbound_quantity`) sumData-->
|
<!-- FROM out_product o-->
|
<!-- WHERE o.`create_time` >= #{startTime}-->
|
<!-- AND o.`create_time` <![CDATA[<=]]> #{endTime}-->
|
<!-- GROUP BY o.`product_model_id`-->
|
<!-- ) issueInCurrentPeriod ON issueInCurrentPeriod.model_id = o.`product_model_id`-->
|
<!-- </when>-->
|
<!-- <otherwise>-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT o.`product_model_id` model_id, SUM(o.`outbound_quantity`) sumData-->
|
<!-- FROM out_product o-->
|
<!-- WHERE DATE_FORMAT(o.`create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')-->
|
<!-- GROUP BY o.`product_model_id`-->
|
<!-- ) issueInCurrentPeriod ON issueInCurrentPeriod.model_id = o.`product_model_id`-->
|
<!-- </otherwise>-->
|
<!-- </choose>-->
|
<!-- <choose>-->
|
<!-- <when test="endTime != null">-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.`incoming_quantity`) sumData-->
|
<!-- FROM product p-->
|
<!-- WHERE p.`create_time` >= #{endTime}-->
|
<!-- ) closingInventory ON closingInventory.model_id = o.`product_model_id`-->
|
<!-- </when>-->
|
<!-- <otherwise>-->
|
<!-- LEFT JOIN (-->
|
<!-- SELECT p.`product_model_id` model_id, SUM(p.`incoming_quantity`) sumData-->
|
<!-- FROM product p-->
|
<!-- WHERE p.`create_time` >= (-->
|
<!-- SELECT DATE_SUB(DATE_SUB(DATE_FORMAT(NOW(),'%y-%m-%d'),INTERVAL EXTRACT(DAY FROM NOW())-1 DAY),INTERVAL 0 MONTH))-->
|
<!-- AND p.`create_time` <![CDATA[<=]]> NOW()-->
|
<!-- ) closingInventory ON closingInventory.model_id = o.`product_model_id`-->
|
<!-- </otherwise>-->
|
<!-- </choose>-->
|
<!-- WHERE o.`product_name_id` = n.`id`-->
|
<!-- AND o.`product_model_id` = m.`id`-->
|
<!-- GROUP BY o.`product_model_id`-->
|
</select>
|
</mapper>
|