郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
src/main/java/com/gk/firework/Mapper/mybatis/HistoryStockMapper.xml
对比新文件
@@ -0,0 +1,202 @@
<?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.gk.firework.Mapper.HistoryStockMapper" >
  <resultMap id="BaseResultMap" type="com.gk.firework.Domain.HistoryStock" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="owner" property="owner" jdbcType="BIGINT" />
    <result column="enterprisename" property="enterprisename" jdbcType="VARCHAR" />
    <result column="enterprisenumber" property="enterprisenumber" jdbcType="VARCHAR" />
    <result column="safetysupervision" property="safetysupervision" jdbcType="VARCHAR" />
    <result column="province" property="province" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="district" property="district" jdbcType="VARCHAR" />
    <result column="stocknum" property="stocknum" jdbcType="DECIMAL" />
    <result column="firecracker" property="firecracker" jdbcType="DECIMAL" />
    <result column="spray" property="spray" jdbcType="DECIMAL" />
    <result column="rotation" property="rotation" jdbcType="DECIMAL" />
    <result column="bead" property="bead" jdbcType="DECIMAL" />
    <result column="toy" property="toy" jdbcType="DECIMAL" />
    <result column="combined" property="combined" jdbcType="DECIMAL" />
    <result column="updateat" property="updateat" jdbcType="TIMESTAMP" />
    <result column="flag" property="flag" jdbcType="TINYINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, owner, enterprisename, enterprisenumber, safetysupervision, province, city, district,
    stocknum, firecracker, spray, rotation, bead, toy, combined, updateat,
    flag
  </sql>
  <insert id="insertDayHistoryStock">
    insert into historystock
    (owner, enterprisename, enterprisenumber, safetysupervision, province, city, district,
    stocknum, firecracker, spray, rotation, bead, toy, combined, updateat,flag)
    select
    owner, enterprisename, enterprisenumber, safetysupervision, province, city, district,
    stocknum, firecracker, spray, rotation, bead, toy, combined, updateat,flag
    from staticstock
  </insert>
    <select id="selectPages" resultType="java.util.Map">
        select
        owner, enterprisename, enterprisenumber, safetysupervision,
        province, city, district,
        stocknum, firecracker, spray, rotation, bead, toy, combined,
        updateat,flag
        from historystock
        <where>
            <if test="params.province != null and params.province != ''">
                and province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
                and city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
                and district = #{params.district}
            </if>
            <if test="params.specificDate != null and params.specificDate != ''">
               and  datediff ( updateat , #{params.specificDate} ) = 0
            </if>
            <if test="params.enterprisename != null and params.enterprisename != ''">
                and  enterprisename like concat("%",#{params.enterprisename},"%")
            </if>
            <if test="params.safetysupervision != null and params.safetysupervision != ''">
                and  safetysupervision = #{params.safetysupervision}
            </if>
        </where>
    </select>
    <select id="selectCityStock" resultType="java.util.Map">
        select
        city,
        sum(stocknum) stocknum,
        sum(firecracker) firecracker,
        sum(spray) spray,
        sum(rotation) rotation,
        sum(bead) bead,
        sum(toy) toy,
        sum(combined) combined,
        updateat
        from staticstock
        <where>
            <if test="params.province != null and params.province != ''">
                and province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
                and city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
                and district = #{params.district}
            </if>
            <if test="params.specificDate != null and params.specificDate != ''">
                and  datediff ( updateat , #{params.specificDate} ) = 0
            </if>
            <if test="params.safetysupervision != null and params.safetysupervision != ''">
                and  safetysupervision = #{params.safetysupervision}
            </if>
            <if test="params.enterprisename != null and params.enterprisename != ''">
                and  enterprisename like concat("%",#{params.enterprisename},"%")
            </if>
        </where>
        group by city
    </select>
    <select id="selectAllCityStock" resultType="java.util.Map">
        select
        "合计" city,
        sum(stocknum) stocknum,
        sum(firecracker) firecracker,
        sum(spray) spray,
        sum(rotation) rotation,
        sum(bead) bead,
        sum(toy) toy,
        sum(combined) combined
        from staticstock
        <where>
            <if test="params.province != null and params.province != ''">
                and province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
                and city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
                and district = #{params.district}
            </if>
            <if test="params.specificDate != null and params.specificDate != ''">
                and  datediff ( updateat , #{params.specificDate} ) = 0
            </if>
            <if test="params.safetysupervision != null and params.safetysupervision != ''">
                and  safetysupervision = #{params.safetysupervision}
            </if>
            <if test="params.enterprisename != null and params.enterprisename != ''">
                and  enterprisename like concat("%",#{params.enterprisename},"%")
            </if>
        </where>
    </select>
    <select id="selectDayHistoryStockTotal" resultType="java.util.Map">
        select
        "合计" enterprisename,
        "合计" city,
        sum(stocknum) stocknum,
        sum(firecracker) firecracker,
        sum(spray) spray,
        sum(rotation) rotation,
        sum(bead) bead,
        sum(toy) toy,
        sum(combined) combined
        from historystock
        <where>
            <if test="params.province != null and params.province != ''">
                and  province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
                and  city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
                and  district = #{params.district}
            </if>
            <if test="params.specificDate != null and params.specificDate != ''">
                and  datediff ( updateat , #{params.specificDate} ) = 0
            </if>
            <if test="params.enterprisename != null and params.enterprisename != ''">
                and  enterprisename like concat("%",#{params.enterprisename},"%")
            </if>
            <if test="params.safetysupervision != null and params.safetysupervision != ''">
                and  safetysupervision = #{params.safetysupervision}
            </if>
        </where>
    </select>
    <select id="selectHistoryCityStock" resultType="java.util.Map">
        select
        city,
        sum(stocknum) stocknum,
        sum(firecracker) firecracker,
        sum(spray) spray,
        sum(rotation) rotation,
        sum(bead) bead,
        sum(toy) toy,
        sum(combined) combined
        from historystock
        <where>
            <if test="params.province != null and params.province != ''">
                and province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
                and city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
                and district = #{params.district}
            </if>
            <if test="params.specificDate != null and params.specificDate != ''">
                and  datediff ( updateat , #{params.specificDate} ) = 0
            </if>
            <if test="params.safetysupervision != null and params.safetysupervision != ''">
                and   safetysupervision = #{params.safetysupervision}
            </if>
            <if test="params.enterprisename != null and params.enterprisename != ''">
                and  enterprisename like concat("%",#{params.enterprisename},"%")
            </if>
        </where>
        group by city
    </select>
</mapper>