<?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.unis.base.server.dao.TyJgjcxxbDao">
    <resultMap id="BaseResultMap" type="com.unis.base.server.entity.TyJgjcxxbDO">
        <id column="JGXXID" jdbcType="VARCHAR" property="jgxxid"/>
        <result column="JCDDM" jdbcType="VARCHAR" property="jcddm"/>
        <result column="JCDMC" jdbcType="VARCHAR" property="jcdmc"/>
        <result column="JCDSSQY" jdbcType="VARCHAR" property="jcdssqy"/>
        <result column="PZBM" jdbcType="VARCHAR" property="pzbm"/>
        <result column="PZMC" jdbcType="VARCHAR" property="pzmc"/>
        <result column="LSBSBM" jdbcType="VARCHAR" property="lsbsbm"/>
        <result column="LSDJBM" jdbcType="VARCHAR" property="lsdjbm"/>
        <result column="LSDJMC" jdbcType="VARCHAR" property="lsdjmc"/>
        <result column="LSXZBM" jdbcType="VARCHAR" property="lsxzbm"/>
        <result column="LSXZMC" jdbcType="VARCHAR" property="lsxzmc"/>
        <result column="SHND" jdbcType="VARCHAR" property="shnd"/>
        <result column="LSGB" jdbcType="VARCHAR" property="lsgb"/>
        <result column="LSCD" jdbcType="VARCHAR" property="lscd"/>
        <result column="PPBM" jdbcType="VARCHAR" property="ppbm"/>
        <result column="PPMC" jdbcType="VARCHAR" property="ppmc"/>
        <result column="GGXH" jdbcType="VARCHAR" property="ggxh"/>
        <result column="JGLXBM" jdbcType="VARCHAR" property="jglxbm"/>
        <result column="JGLXMC" jdbcType="VARCHAR" property="jglxmc"/>
        <result column="SJJG" jdbcType="DECIMAL" property="sjjg"/>
        <result column="SHZT" jdbcType="VARCHAR" property="shzt"/>
        <result column="SBLX" jdbcType="VARCHAR" property="sblx"/>
        <result column="CJRBM" jdbcType="VARCHAR" property="cjrbm"/>
        <result column="CJRMC" jdbcType="VARCHAR" property="cjrmc"/>
        <result column="CJSJ" jdbcType="DATE" property="cjsj"/>
        <result column="SCRBM" jdbcType="VARCHAR" property="scrbm"/>
        <result column="SCRMC" jdbcType="VARCHAR" property="scrmc"/>
        <result column="SCSJ" jdbcType="DATE" property="scsj"/>
        <result column="SHRBM" jdbcType="VARCHAR" property="shrbm"/>
        <result column="SHRMC" jdbcType="VARCHAR" property="shrmc"/>
        <result column="SHSJ" jdbcType="DATE" property="shsj"/>
        <result column="FBRBM" jdbcType="VARCHAR" property="fbrbm"/>
        <result column="FBRMC" jdbcType="VARCHAR" property="fbrmc"/>
        <result column="FBSJ" jdbcType="DATE" property="fbsj"/>
        <result column="BQKSSJ" jdbcType="DATE" property="bqkssj"/>
        <result column="BQJSSJ" jdbcType="DATE" property="bqjssj"/>
    </resultMap>

    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
    JGXXID, JCDDM, JCDMC, JCDSSQY, PZBM, PZMC, LSBSBM, LSDJBM, LSDJMC, LSXZBM, LSXZMC,
    SHND, LSGB, LSCD, PPBM, PPMC, GGXH, JGLXBM, JGLXMC, SJJG, SHZT, SBLX, CJRBM, CJRMC,
    CJSJ, SCRBM, SCRMC, SCSJ, SHRBM, SHRMC, SHSJ, FBRBM, FBRMC, FBSJ, BQKSSJ, BQJSSJ
  </sql>
    <!--查询所有-->
    <select id="getPriceMonitorInfo" resultMap="BaseResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from TY_JGJCXXB where STATUS = 1 and JGXXID=#{jgxxid,jdbcType=VARCHAR}
    </select>
    <!--根据条件查询对应的数据-->
    <select id="getPriceMonitorList" resultMap="BaseResultMap" parameterType="com.unis.base.common.vo.PriceMonitorQueryVo">
        select
        <include refid="Base_Column_List"/>
        from TY_JGJCXXB
        <where>
            <!-- 粮食等级编码 -->
            <if test="lsdjbm != null and lsdjbm != ''" >
                and	 lsdjbm LIKE concat(CONCAT('%',#{lsdjbm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 上报类型 -->
            <if test="sblx != null and sblx != ''" >
                and	  sblx LIKE concat(CONCAT('%',#{sblx,jdbcType=VARCHAR}) ,'%')
            </if>
        </where>
        ORDER BY sblx asc
    </select>
<!--    &lt;!&ndash;根据条件查询对应的数据&ndash;&gt;-->
<!--    <select id="getLevelMonthlyReport" resultType="com.unis.base.common.vo.PriceMonitorQueryVo" parameterType="com.unis.base.common.vo.PriceMonitorQueryVo">-->
<!--        select date_format(SHSJ,'yyyy-mm') as shsj,count(LSDJBM) as lsdjbm-->
<!--        from TY_JGJCXXB where date_format(SHSJ,'yyyy') = #{shsj,jdbcType=VARCHAR}-->
<!--        group by date_format(SHSJ,'yyyy-mm') order by date_format(SHSJ,'yyyy-mm')-->
<!--            select date_format(SHSJ,'yyyy-mm') as shsj from TY_JGJCXXB-->
<!--    </select>-->

    <!--根据条件查询对应的数据-->
    <select id="getLevelMonthlyReport" resultType="com.unis.base.common.vo.PriceMonitorQueryVo" parameterType="com.unis.base.common.vo.PriceMonitorQueryVo">
        select date_format(SHSJ,'%Y') as shsj from TY_JGJCXXB
    </select>

    <!--添加-->
    <insert id="insert" parameterType="com.unis.base.server.entity.TyJgjcxxbDO">
        insert into BASE.TY_JGJCXXB (JGXXID,JCDDM, JCDMC, JCDSSQY,
        PZBM, PZMC, LSBSBM,
        LSDJBM, LSDJMC, LSXZBM,
        LSXZMC, SHND, LSGB,
        LSCD, PPBM, PPMC, GGXH,
        JGLXBM, JGLXMC, SJJG,
        SHZT, SBLX, CJRBM,
        CJRMC, CJSJ, SCRBM, SCRMC,
        SCSJ, SHRBM, SHRMC, SHSJ,
        FBRBM, FBRMC, FBSJ, STATUS,
        CREATOR, CREATOR_CODE, CREATE_DATE,
        REFRESHER, REFRESHER_CODE, REFRESH_TIME,
        REMARK, BQKSSJ, BQJSSJ)
        values (#{jgxxid,jdbcType=VARCHAR},#{jcddm,jdbcType=VARCHAR}, #{jcdmc,jdbcType=VARCHAR}, #{jcdssqy,jdbcType=VARCHAR},
        #{pzbm,jdbcType=VARCHAR}, #{pzmc,jdbcType=VARCHAR}, #{lsbsbm,jdbcType=VARCHAR},
        #{lsdjbm,jdbcType=VARCHAR}, #{lsdjmc,jdbcType=VARCHAR}, #{lsxzbm,jdbcType=VARCHAR},
        #{lsxzmc,jdbcType=VARCHAR}, #{shnd,jdbcType=VARCHAR}, #{lsgb,jdbcType=VARCHAR},
        #{lscd,jdbcType=VARCHAR}, #{ppbm,jdbcType=VARCHAR}, #{ppmc,jdbcType=VARCHAR}, #{ggxh,jdbcType=VARCHAR},
        #{jglxbm,jdbcType=VARCHAR}, #{jglxmc,jdbcType=VARCHAR}, #{sjjg,jdbcType=DECIMAL},
        #{shzt,jdbcType=VARCHAR}, #{sblx,jdbcType=VARCHAR}, #{cjrbm,jdbcType=VARCHAR},
        #{cjrmc,jdbcType=VARCHAR}, #{cjsj,jdbcType=DATE}, #{scrbm,jdbcType=VARCHAR}, #{scrmc,jdbcType=VARCHAR},
        #{scsj,jdbcType=DATE}, #{shrbm,jdbcType=VARCHAR}, #{shrmc,jdbcType=VARCHAR}, #{shsj,jdbcType=DATE},
        #{fbrbm,jdbcType=VARCHAR}, #{fbrmc,jdbcType=VARCHAR}, #{fbsj,jdbcType=DATE}, #{status,jdbcType=DECIMAL},
        #{creator,jdbcType=VARCHAR}, #{creatorCode,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
        #{refresher,jdbcType=VARCHAR}, #{refresherCode,jdbcType=VARCHAR}, #{refreshTime,jdbcType=TIMESTAMP},
        #{remark,jdbcType=VARCHAR}, #{bqkssj,jdbcType=DATE}, #{bqjssj,jdbcType=DATE})
    </insert>
    <!--更新信息-->
    <update id="updateByPrimaryKey" parameterType="com.unis.base.server.entity.TyJgjcxxbDO">
     update TY_JGJCXXB
    set JCDDM = #{jcddm,jdbcType=VARCHAR},
      JCDMC = #{jcdmc,jdbcType=VARCHAR},
      JCDSSQY = #{jcdssqy,jdbcType=VARCHAR},
      PZBM = #{pzbm,jdbcType=VARCHAR},
      PZMC = #{pzmc,jdbcType=VARCHAR},
      LSBSBM = #{lsbsbm,jdbcType=VARCHAR},
      LSDJBM = #{lsdjbm,jdbcType=VARCHAR},
      LSDJMC = #{lsdjmc,jdbcType=VARCHAR},
      LSXZBM = #{lsxzbm,jdbcType=VARCHAR},
      LSXZMC = #{lsxzmc,jdbcType=VARCHAR},
      SHND = #{shnd,jdbcType=VARCHAR},
      LSGB = #{lsgb,jdbcType=VARCHAR},
      LSCD = #{lscd,jdbcType=VARCHAR},
      PPBM = #{ppbm,jdbcType=VARCHAR},
      PPMC = #{ppmc,jdbcType=VARCHAR},
      GGXH = #{ggxh,jdbcType=VARCHAR},
      JGLXBM = #{jglxbm,jdbcType=VARCHAR},
      JGLXMC = #{jglxmc,jdbcType=VARCHAR},
      SJJG = #{sjjg,jdbcType=DECIMAL},
      SHZT = #{shzt,jdbcType=VARCHAR},
      SBLX = #{sblx,jdbcType=VARCHAR},
      CJRBM = #{cjrbm,jdbcType=VARCHAR},
      CJRMC = #{cjrmc,jdbcType=VARCHAR},
      CJSJ = #{cjsj,jdbcType=DATE},
      SCRBM = #{scrbm,jdbcType=VARCHAR},
      SCRMC = #{scrmc,jdbcType=VARCHAR},
      SCSJ = #{scsj,jdbcType=DATE},
      SHRBM = #{shrbm,jdbcType=VARCHAR},
      SHRMC = #{shrmc,jdbcType=VARCHAR},
      SHSJ = #{shsj,jdbcType=DATE},
      FBRBM = #{fbrbm,jdbcType=VARCHAR},
      FBRMC = #{fbrmc,jdbcType=VARCHAR},
      FBSJ = #{fbsj,jdbcType=DATE},
      STATUS = #{status,jdbcType=DECIMAL},
      CREATOR = #{creator,jdbcType=VARCHAR},
      CREATOR_CODE = #{creatorCode,jdbcType=VARCHAR},
      CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      REFRESHER = #{refresher,jdbcType=VARCHAR},
      REFRESHER_CODE = #{refresherCode,jdbcType=VARCHAR},
      REFRESH_TIME = #{refreshTime,jdbcType=TIMESTAMP},
      REMARK = #{remark,jdbcType=VARCHAR},
      BQKSSJ = #{bqkssj,jdbcType=DATE},
      BQJSSJ = #{bqjssj,jdbcType=DATE}
    where JGXXID = #{jgxxid,jdbcType=VARCHAR}
  </update>
    <select id="getMaxCodeById" parameterType="java.lang.String" resultType="java.lang.String">
        SELECT
        	max(yg.jgxxid)
        from
			TY_JGJCXXB yg
			WHERE yg.jgxxid like CONCAT(CONCAT('%',#{lsxzbm,jdbcType=VARCHAR}),'%')
    </select>
</mapper>