<?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.huaheng.pc.inventory.report.mapper.InventoryTransactionsMapper"> <select id="select" resultType="com.huaheng.pc.inventory.report.domain.InventoryTransactionsRep"> select d.created, d.transactionType, IFNULL(taskQty,0) taskQty FROM (select created,transactionType from ( (SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) created FROM ( SELECT @date := DATE_ADD( #{startTime}, INTERVAL - 1 DAY ) FROM inventory_transaction ) time WHERE to_days( @date ) < to_days( #{endTime} ) - 1 ) a INNER JOIN (select transactionType from transactionType) type ) where 1=1 <if test="transactionType != null"> and transactionType = #{transactionType} </if> ORDER BY created,transactionType) d LEFT JOIN ( SELECT DATE_FORMAT( created, '%Y-%m-%d' ) created, transactionType, sum( taskQty ) taskQty FROM inventory_transaction b GROUP BY DATE_FORMAT( created, '%Y-%m-%d' ), transactionType ) t ON t.created = d.created and t.transactionType = d.transactionType ORDER BY d.created </select> <select id="selectCount" resultType="com.huaheng.pc.inventory.report.domain.InventoryTransactionsRep"> SELECT DATE_FORMAT( created, '%Y-%m-%d' ) created, count( DISTINCT transactionType ) seriesLen FROM inventory_transaction GROUP BY DATE_FORMAT( created, '%Y-%m-%d' ) </select> </mapper>