<?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.fuxi.ws.data.dao.EmployeeMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    <id column="EmployeeID" jdbcType="VARCHAR" property="employeeid" />
    <result column="EmployeeTypeID" jdbcType="VARCHAR" property="employeetypeid" />
    <result column="Code" jdbcType="VARCHAR" property="code" />
    <result column="Name" jdbcType="VARCHAR" property="name" />
    <result column="HelpCode" jdbcType="VARCHAR" property="helpcode" />
    <result column="DepartmentID" jdbcType="VARCHAR" property="departmentid" />
    <result column="Memo" jdbcType="VARCHAR" property="memo" />
    <result column="StopFlag" jdbcType="BIT" property="stopflag" />
    <result column="UseFlag" jdbcType="BIT" property="useflag" />
    <result column="DefaultFlag" jdbcType="BIT" property="defaultflag" />
    <result column="CommisionProfit" jdbcType="DECIMAL" property="commisionprofit" />
    <result column="SharedFlag" jdbcType="BIT" property="sharedflag" />
    <result column="CopyFlag" jdbcType="BIT" property="copyflag" />
    <result column="ModifyDate" jdbcType="TIMESTAMP" property="modifydate" />
    <result column="Editor" jdbcType="VARCHAR" property="editor" />
    <result column="SendFlag" jdbcType="BIT" property="sendflag" />
    <result column="MobilPhone" jdbcType="VARCHAR" property="mobilphone" />
    <result column="EngageDate" jdbcType="TIMESTAMP" property="engagedate" />
    <result column="DimissionDate" jdbcType="TIMESTAMP" property="dimissiondate" />
    <result column="BasePay" jdbcType="DECIMAL" property="basepay" />
    <result column="Addr" jdbcType="VARCHAR" property="addr" />
    <result column="Tel" jdbcType="VARCHAR" property="tel" />
    <result column="Education" jdbcType="VARCHAR" property="education" />
    <result column="IDCard" jdbcType="VARCHAR" property="idcard" />
    <result column="MobilePhone2" jdbcType="VARCHAR" property="mobilephone2" />
    <result column="PayType" jdbcType="VARCHAR" property="paytype" />
    <result column="ZW" jdbcType="VARCHAR" property="zw" />
    <result column="IsGuide" jdbcType="BIT" property="isguide" />
    <result column="IsOfficer" jdbcType="BIT" property="isofficer" />
    <result column="VIPID" jdbcType="VARCHAR" property="vipid" />
    <result column="Specialty" jdbcType="NVARCHAR" property="specialty" />
    <result column="OpenID" jdbcType="VARCHAR" property="openid" />
    <result column="UserID" jdbcType="VARCHAR" property="userid" />
    <result column="PhotoUrl" jdbcType="VARCHAR" property="photourl" />
    <result column="Creator" jdbcType="VARCHAR" property="creator" />
    <result column="MadeDate" jdbcType="TIMESTAMP" property="madedate" />
    <result column="DistrictManagerFlag" jdbcType="BIT" property="districtmanagerflag" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    <result column="Photo" jdbcType="LONGVARBINARY" property="photo" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    <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="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    EmployeeID, EmployeeTypeID, Code, Name, HelpCode, DepartmentID, Memo, StopFlag, UseFlag, 
    DefaultFlag, CommisionProfit, SharedFlag, CopyFlag, ModifyDate, Editor, SendFlag, 
    MobilPhone, EngageDate, DimissionDate, BasePay, Addr, Tel, Education, IDCard, MobilePhone2, 
    PayType, ZW, IsGuide, IsOfficer, VIPID, Specialty, OpenID, UserID, PhotoUrl, Creator, 
    MadeDate, DistrictManagerFlag
  </sql>
  <sql id="Blob_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    Photo
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.fuxi.ws.data.entity.EmployeeExample" resultMap="ResultMapWithBLOBs">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from Employee
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.EmployeeExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from Employee
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from Employee
    where EmployeeID = #{employeeid,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    delete from Employee
    where EmployeeID = #{employeeid,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    insert into Employee (EmployeeID, EmployeeTypeID, Code, 
      Name, HelpCode, DepartmentID, 
      Memo, StopFlag, UseFlag, DefaultFlag, 
      CommisionProfit, SharedFlag, CopyFlag, 
      ModifyDate, Editor, SendFlag, 
      MobilPhone, EngageDate, DimissionDate, 
      BasePay, Addr, Tel, 
      Education, IDCard, MobilePhone2, 
      PayType, ZW, IsGuide, IsOfficer, 
      VIPID, Specialty, OpenID, 
      UserID, PhotoUrl, Creator, 
      MadeDate, DistrictManagerFlag, Photo
      )
    values (#{employeeid,jdbcType=VARCHAR}, #{employeetypeid,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
      #{name,jdbcType=VARCHAR}, #{helpcode,jdbcType=VARCHAR}, #{departmentid,jdbcType=VARCHAR}, 
      #{memo,jdbcType=VARCHAR}, #{stopflag,jdbcType=BIT}, #{useflag,jdbcType=BIT}, #{defaultflag,jdbcType=BIT}, 
      #{commisionprofit,jdbcType=DECIMAL}, #{sharedflag,jdbcType=BIT}, #{copyflag,jdbcType=BIT}, 
      #{modifydate,jdbcType=TIMESTAMP}, #{editor,jdbcType=VARCHAR}, #{sendflag,jdbcType=BIT}, 
      #{mobilphone,jdbcType=VARCHAR}, #{engagedate,jdbcType=TIMESTAMP}, #{dimissiondate,jdbcType=TIMESTAMP}, 
      #{basepay,jdbcType=DECIMAL}, #{addr,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR}, 
      #{education,jdbcType=VARCHAR}, #{idcard,jdbcType=VARCHAR}, #{mobilephone2,jdbcType=VARCHAR}, 
      #{paytype,jdbcType=VARCHAR}, #{zw,jdbcType=VARCHAR}, #{isguide,jdbcType=BIT}, #{isofficer,jdbcType=BIT}, 
      #{vipid,jdbcType=VARCHAR}, #{specialty,jdbcType=NVARCHAR}, #{openid,jdbcType=VARCHAR}, 
      #{userid,jdbcType=VARCHAR}, #{photourl,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, 
      #{madedate,jdbcType=TIMESTAMP}, #{districtmanagerflag,jdbcType=BIT}, #{photo,jdbcType=LONGVARBINARY}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    insert into Employee
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="employeeid != null">
        EmployeeID,
      </if>
      <if test="employeetypeid != null">
        EmployeeTypeID,
      </if>
      <if test="code != null">
        Code,
      </if>
      <if test="name != null">
        Name,
      </if>
      <if test="helpcode != null">
        HelpCode,
      </if>
      <if test="departmentid != null">
        DepartmentID,
      </if>
      <if test="memo != null">
        Memo,
      </if>
      <if test="stopflag != null">
        StopFlag,
      </if>
      <if test="useflag != null">
        UseFlag,
      </if>
      <if test="defaultflag != null">
        DefaultFlag,
      </if>
      <if test="commisionprofit != null">
        CommisionProfit,
      </if>
      <if test="sharedflag != null">
        SharedFlag,
      </if>
      <if test="copyflag != null">
        CopyFlag,
      </if>
      <if test="modifydate != null">
        ModifyDate,
      </if>
      <if test="editor != null">
        Editor,
      </if>
      <if test="sendflag != null">
        SendFlag,
      </if>
      <if test="mobilphone != null">
        MobilPhone,
      </if>
      <if test="engagedate != null">
        EngageDate,
      </if>
      <if test="dimissiondate != null">
        DimissionDate,
      </if>
      <if test="basepay != null">
        BasePay,
      </if>
      <if test="addr != null">
        Addr,
      </if>
      <if test="tel != null">
        Tel,
      </if>
      <if test="education != null">
        Education,
      </if>
      <if test="idcard != null">
        IDCard,
      </if>
      <if test="mobilephone2 != null">
        MobilePhone2,
      </if>
      <if test="paytype != null">
        PayType,
      </if>
      <if test="zw != null">
        ZW,
      </if>
      <if test="isguide != null">
        IsGuide,
      </if>
      <if test="isofficer != null">
        IsOfficer,
      </if>
      <if test="vipid != null">
        VIPID,
      </if>
      <if test="specialty != null">
        Specialty,
      </if>
      <if test="openid != null">
        OpenID,
      </if>
      <if test="userid != null">
        UserID,
      </if>
      <if test="photourl != null">
        PhotoUrl,
      </if>
      <if test="creator != null">
        Creator,
      </if>
      <if test="madedate != null">
        MadeDate,
      </if>
      <if test="districtmanagerflag != null">
        DistrictManagerFlag,
      </if>
      <if test="photo != null">
        Photo,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="employeeid != null">
        #{employeeid,jdbcType=VARCHAR},
      </if>
      <if test="employeetypeid != null">
        #{employeetypeid,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="helpcode != null">
        #{helpcode,jdbcType=VARCHAR},
      </if>
      <if test="departmentid != null">
        #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        #{memo,jdbcType=VARCHAR},
      </if>
      <if test="stopflag != null">
        #{stopflag,jdbcType=BIT},
      </if>
      <if test="useflag != null">
        #{useflag,jdbcType=BIT},
      </if>
      <if test="defaultflag != null">
        #{defaultflag,jdbcType=BIT},
      </if>
      <if test="commisionprofit != null">
        #{commisionprofit,jdbcType=DECIMAL},
      </if>
      <if test="sharedflag != null">
        #{sharedflag,jdbcType=BIT},
      </if>
      <if test="copyflag != null">
        #{copyflag,jdbcType=BIT},
      </if>
      <if test="modifydate != null">
        #{modifydate,jdbcType=TIMESTAMP},
      </if>
      <if test="editor != null">
        #{editor,jdbcType=VARCHAR},
      </if>
      <if test="sendflag != null">
        #{sendflag,jdbcType=BIT},
      </if>
      <if test="mobilphone != null">
        #{mobilphone,jdbcType=VARCHAR},
      </if>
      <if test="engagedate != null">
        #{engagedate,jdbcType=TIMESTAMP},
      </if>
      <if test="dimissiondate != null">
        #{dimissiondate,jdbcType=TIMESTAMP},
      </if>
      <if test="basepay != null">
        #{basepay,jdbcType=DECIMAL},
      </if>
      <if test="addr != null">
        #{addr,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        #{tel,jdbcType=VARCHAR},
      </if>
      <if test="education != null">
        #{education,jdbcType=VARCHAR},
      </if>
      <if test="idcard != null">
        #{idcard,jdbcType=VARCHAR},
      </if>
      <if test="mobilephone2 != null">
        #{mobilephone2,jdbcType=VARCHAR},
      </if>
      <if test="paytype != null">
        #{paytype,jdbcType=VARCHAR},
      </if>
      <if test="zw != null">
        #{zw,jdbcType=VARCHAR},
      </if>
      <if test="isguide != null">
        #{isguide,jdbcType=BIT},
      </if>
      <if test="isofficer != null">
        #{isofficer,jdbcType=BIT},
      </if>
      <if test="vipid != null">
        #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="specialty != null">
        #{specialty,jdbcType=NVARCHAR},
      </if>
      <if test="openid != null">
        #{openid,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=VARCHAR},
      </if>
      <if test="photourl != null">
        #{photourl,jdbcType=VARCHAR},
      </if>
      <if test="creator != null">
        #{creator,jdbcType=VARCHAR},
      </if>
      <if test="madedate != null">
        #{madedate,jdbcType=TIMESTAMP},
      </if>
      <if test="districtmanagerflag != null">
        #{districtmanagerflag,jdbcType=BIT},
      </if>
      <if test="photo != null">
        #{photo,jdbcType=LONGVARBINARY},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.EmployeeExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    select count(*) from Employee
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    update Employee
    <set>
      <if test="employeetypeid != null">
        EmployeeTypeID = #{employeetypeid,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        Code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        Name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="helpcode != null">
        HelpCode = #{helpcode,jdbcType=VARCHAR},
      </if>
      <if test="departmentid != null">
        DepartmentID = #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
        Memo = #{memo,jdbcType=VARCHAR},
      </if>
      <if test="stopflag != null">
        StopFlag = #{stopflag,jdbcType=BIT},
      </if>
      <if test="useflag != null">
        UseFlag = #{useflag,jdbcType=BIT},
      </if>
      <if test="defaultflag != null">
        DefaultFlag = #{defaultflag,jdbcType=BIT},
      </if>
      <if test="commisionprofit != null">
        CommisionProfit = #{commisionprofit,jdbcType=DECIMAL},
      </if>
      <if test="sharedflag != null">
        SharedFlag = #{sharedflag,jdbcType=BIT},
      </if>
      <if test="copyflag != null">
        CopyFlag = #{copyflag,jdbcType=BIT},
      </if>
      <if test="modifydate != null">
        ModifyDate = #{modifydate,jdbcType=TIMESTAMP},
      </if>
      <if test="editor != null">
        Editor = #{editor,jdbcType=VARCHAR},
      </if>
      <if test="sendflag != null">
        SendFlag = #{sendflag,jdbcType=BIT},
      </if>
      <if test="mobilphone != null">
        MobilPhone = #{mobilphone,jdbcType=VARCHAR},
      </if>
      <if test="engagedate != null">
        EngageDate = #{engagedate,jdbcType=TIMESTAMP},
      </if>
      <if test="dimissiondate != null">
        DimissionDate = #{dimissiondate,jdbcType=TIMESTAMP},
      </if>
      <if test="basepay != null">
        BasePay = #{basepay,jdbcType=DECIMAL},
      </if>
      <if test="addr != null">
        Addr = #{addr,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        Tel = #{tel,jdbcType=VARCHAR},
      </if>
      <if test="education != null">
        Education = #{education,jdbcType=VARCHAR},
      </if>
      <if test="idcard != null">
        IDCard = #{idcard,jdbcType=VARCHAR},
      </if>
      <if test="mobilephone2 != null">
        MobilePhone2 = #{mobilephone2,jdbcType=VARCHAR},
      </if>
      <if test="paytype != null">
        PayType = #{paytype,jdbcType=VARCHAR},
      </if>
      <if test="zw != null">
        ZW = #{zw,jdbcType=VARCHAR},
      </if>
      <if test="isguide != null">
        IsGuide = #{isguide,jdbcType=BIT},
      </if>
      <if test="isofficer != null">
        IsOfficer = #{isofficer,jdbcType=BIT},
      </if>
      <if test="vipid != null">
        VIPID = #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="specialty != null">
        Specialty = #{specialty,jdbcType=NVARCHAR},
      </if>
      <if test="openid != null">
        OpenID = #{openid,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        UserID = #{userid,jdbcType=VARCHAR},
      </if>
      <if test="photourl != null">
        PhotoUrl = #{photourl,jdbcType=VARCHAR},
      </if>
      <if test="creator != null">
        Creator = #{creator,jdbcType=VARCHAR},
      </if>
      <if test="madedate != null">
        MadeDate = #{madedate,jdbcType=TIMESTAMP},
      </if>
      <if test="districtmanagerflag != null">
        DistrictManagerFlag = #{districtmanagerflag,jdbcType=BIT},
      </if>
      <if test="photo != null">
        Photo = #{photo,jdbcType=LONGVARBINARY},
      </if>
    </set>
    where EmployeeID = #{employeeid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    update Employee
    set EmployeeTypeID = #{employeetypeid,jdbcType=VARCHAR},
      Code = #{code,jdbcType=VARCHAR},
      Name = #{name,jdbcType=VARCHAR},
      HelpCode = #{helpcode,jdbcType=VARCHAR},
      DepartmentID = #{departmentid,jdbcType=VARCHAR},
      Memo = #{memo,jdbcType=VARCHAR},
      StopFlag = #{stopflag,jdbcType=BIT},
      UseFlag = #{useflag,jdbcType=BIT},
      DefaultFlag = #{defaultflag,jdbcType=BIT},
      CommisionProfit = #{commisionprofit,jdbcType=DECIMAL},
      SharedFlag = #{sharedflag,jdbcType=BIT},
      CopyFlag = #{copyflag,jdbcType=BIT},
      ModifyDate = #{modifydate,jdbcType=TIMESTAMP},
      Editor = #{editor,jdbcType=VARCHAR},
      SendFlag = #{sendflag,jdbcType=BIT},
      MobilPhone = #{mobilphone,jdbcType=VARCHAR},
      EngageDate = #{engagedate,jdbcType=TIMESTAMP},
      DimissionDate = #{dimissiondate,jdbcType=TIMESTAMP},
      BasePay = #{basepay,jdbcType=DECIMAL},
      Addr = #{addr,jdbcType=VARCHAR},
      Tel = #{tel,jdbcType=VARCHAR},
      Education = #{education,jdbcType=VARCHAR},
      IDCard = #{idcard,jdbcType=VARCHAR},
      MobilePhone2 = #{mobilephone2,jdbcType=VARCHAR},
      PayType = #{paytype,jdbcType=VARCHAR},
      ZW = #{zw,jdbcType=VARCHAR},
      IsGuide = #{isguide,jdbcType=BIT},
      IsOfficer = #{isofficer,jdbcType=BIT},
      VIPID = #{vipid,jdbcType=VARCHAR},
      Specialty = #{specialty,jdbcType=NVARCHAR},
      OpenID = #{openid,jdbcType=VARCHAR},
      UserID = #{userid,jdbcType=VARCHAR},
      PhotoUrl = #{photourl,jdbcType=VARCHAR},
      Creator = #{creator,jdbcType=VARCHAR},
      MadeDate = #{madedate,jdbcType=TIMESTAMP},
      DistrictManagerFlag = #{districtmanagerflag,jdbcType=BIT},
      Photo = #{photo,jdbcType=LONGVARBINARY}
    where EmployeeID = #{employeeid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.Employee">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 15:45:01 CST 2019.
    -->
    update Employee
    set EmployeeTypeID = #{employeetypeid,jdbcType=VARCHAR},
      Code = #{code,jdbcType=VARCHAR},
      Name = #{name,jdbcType=VARCHAR},
      HelpCode = #{helpcode,jdbcType=VARCHAR},
      DepartmentID = #{departmentid,jdbcType=VARCHAR},
      Memo = #{memo,jdbcType=VARCHAR},
      StopFlag = #{stopflag,jdbcType=BIT},
      UseFlag = #{useflag,jdbcType=BIT},
      DefaultFlag = #{defaultflag,jdbcType=BIT},
      CommisionProfit = #{commisionprofit,jdbcType=DECIMAL},
      SharedFlag = #{sharedflag,jdbcType=BIT},
      CopyFlag = #{copyflag,jdbcType=BIT},
      ModifyDate = #{modifydate,jdbcType=TIMESTAMP},
      Editor = #{editor,jdbcType=VARCHAR},
      SendFlag = #{sendflag,jdbcType=BIT},
      MobilPhone = #{mobilphone,jdbcType=VARCHAR},
      EngageDate = #{engagedate,jdbcType=TIMESTAMP},
      DimissionDate = #{dimissiondate,jdbcType=TIMESTAMP},
      BasePay = #{basepay,jdbcType=DECIMAL},
      Addr = #{addr,jdbcType=VARCHAR},
      Tel = #{tel,jdbcType=VARCHAR},
      Education = #{education,jdbcType=VARCHAR},
      IDCard = #{idcard,jdbcType=VARCHAR},
      MobilePhone2 = #{mobilephone2,jdbcType=VARCHAR},
      PayType = #{paytype,jdbcType=VARCHAR},
      ZW = #{zw,jdbcType=VARCHAR},
      IsGuide = #{isguide,jdbcType=BIT},
      IsOfficer = #{isofficer,jdbcType=BIT},
      VIPID = #{vipid,jdbcType=VARCHAR},
      Specialty = #{specialty,jdbcType=NVARCHAR},
      OpenID = #{openid,jdbcType=VARCHAR},
      UserID = #{userid,jdbcType=VARCHAR},
      PhotoUrl = #{photourl,jdbcType=VARCHAR},
      Creator = #{creator,jdbcType=VARCHAR},
      MadeDate = #{madedate,jdbcType=TIMESTAMP},
      DistrictManagerFlag = #{districtmanagerflag,jdbcType=BIT}
    where EmployeeID = #{employeeid,jdbcType=VARCHAR}
  </update>

	<resultMap extends="BaseResultMap" id="ResultMapextend" type="com.fuxi.ws.data.entity.Employee">
		<result column="IsDistribute" jdbcType="BIT" property="isdistribute" />
		<result column="Department" jdbcType="VARCHAR" property="department" />
		<result column="Vipcode" jdbcType="VARCHAR" property="vipcode" />
	</resultMap>

	<select id="guidersForDepartment" resultType="java.util.LinkedHashMap">
		select *,(Case when
		t.Comment=0 then 0 else CAST(CAST(t.ComLevel as
		decimal(10,1))/t.Comment as decimal(10,1)) end)a from (
		select
		a.EmployeeID,a.Name
		,c.Department
		,SUM(b.ComLevel)ComLevel,COUNT(b.EmployeeID)
		Comment,d.PhotoUrl
		from
		Employee a
		left join W_GuideComment b on
		a.EmployeeID=b.EmployeeID
		join
		Department c on
		a.DepartmentID=c.DepartmentID
		left join VIP d on
		a.VIPID=d.VIPID
		where
		a.IsGuide='1' and a.DepartmentID=#{departmentid}
		group by
		a.EmployeeID,a.Name,c.Department,d.PhotoUrl)t
		order by t.a desc
	</select>

	<select id="guidersImage" resultType="java.util.LinkedHashMap">
		select EmployeeID,Photo
		from Employee
		where IsGuide='1' and DepartmentID=#{departmentid}
	</select>

	<select id="getAllGuider" resultType="java.util.LinkedHashMap">
		<if test="onlyOneDepartment==0">
			<if test="vipid != null and vipid != ''">
				select *,(Case when t.Comment=0 then 0 else
				CAST(CAST(t.ComLevel as
				decimal(10,1))/t.Comment as decimal(10,1))
				end)a from ( select
				a.EmployeeID,b.Name,c.DepartmentID,c.Department,SUM(e.ComLevel)ComLevel,count(e.EmployeeID)
				Comment,c.location_x,c.location_y,d.PhotoUrl,a.LastChatDate from
				W_Guide a join
				Employee b on a.EmployeeID=b.EmployeeID join
				Department
				c on b.DepartmentID=c.DepartmentID
				left join VIP d on
				b.VIPID=d.VIPID
				left join W_GuideComment e on
				b.EmployeeID=e.EmployeeID where
				a.VIPID=#{vipid} and
				b.IsGuide='1' and
				c.EShopSendFlag='1' and
				c.StopFlag='0' and
				c.DefaultFlag=0 group by
				a.EmployeeID,b.Name,c.Department
				,c.location_x,c.location_y,d.PhotoUrl,c.DepartmentID,a.LastChatDate)t
				order by
				t.LastChatDate desc,t.a desc
			</if>
			<if test="vipid == null or vipid == ''">
				select top 100 *,(Case when t.Comment=0 then 0 else
				CAST(CAST(t.ComLevel as
				decimal(10,1))/t.Comment as decimal(10,1))
				end)a from ( select
				a.EmployeeID,b.Name,c.DepartmentID,c.Department,SUM(e.ComLevel)ComLevel,count(e.EmployeeID)
				Comment,c.location_x,c.location_y,d.PhotoUrl from
				W_Guide a join
				Employee b on a.EmployeeID=b.EmployeeID join
				Department
				c on
				b.DepartmentID=c.DepartmentID
				left join VIP d on
				b.VIPID=d.VIPID
				left
				join W_GuideComment e on
				b.EmployeeID=e.EmployeeID where
				b.IsGuide='1' and
				c.EShopSendFlag='1' and
				c.StopFlag='0' and
				c.DefaultFlag=0 group by
				a.EmployeeID,b.Name,c.Department
				,c.location_x,c.location_y,d.PhotoUrl,c.DepartmentID)t
				order by t.a
				desc
			</if>
		</if>
		<if test="onlyOneDepartment==1">
			<if test="vipid != null and vipid != ''">
				select *,(Case when t.Comment=0 then 0 else
				CAST(CAST(t.ComLevel as
				decimal(10,1))/t.Comment as decimal(10,1))
				end)a from (
				select
				a.EmployeeID,b.Name,c.DepartmentID,c.Department,SUM(e.ComLevel)ComLevel,count(e.EmployeeID)
				Comment,c.location_x,c.location_y,d.PhotoUrl
				from W_Guide a
				join
				Employee b on a.EmployeeID=b.EmployeeID
				join Department
				c on
				b.DepartmentID=c.DepartmentID
				left join VIP d on b.VIPID=d.VIPID
				left
				join W_GuideComment e on b.EmployeeID=e.EmployeeID
				where
				a.VIPID=#{vipid} and
				b.IsGuide='1' and
				c.EShopSendFlag='1' and
				c.StopFlag='0'
				<if test="onlyOneDepartment=='1'">
					and b.Departmentid=#{departmentid}
				</if>
				group by a.EmployeeID,b.Name,c.Department
				,c.location_x,c.location_y,d.PhotoUrl,c.DepartmentID)t order by t.a
				desc
			</if>
			<if test="vipid == null or vipid == ''">
				select top 100 *,(Case when t.Comment=0 then 0 else
				CAST(CAST(t.ComLevel as
				decimal(10,1))/t.Comment as decimal(10,1))
				end)a from (
				select
				a.EmployeeID,a.Name,a.DepartmentID,b.Department,SUM(c.ComLevel)ComLevel,count(c.EmployeeID)
				Comment,b.location_x,b.location_y,a.PhotoUrl
				from Employee a
				join
				Department b on b.DepartmentID=a.DepartmentID
				left join
				W_GuideComment
				c on a.EmployeeID=c.EmployeeID
				where
				a.IsGuide='1'
				and
				b.EShopSendFlag='1' and
				b.StopFlag='0'
				group by
				a.EmployeeID,a.Name,b.Department
				,b.location_x,b.location_y,a.PhotoUrl,a.DepartmentID)t
				order by t.a
				desc
			</if>
		</if>
	</select>

	<select id="getAllGuider2" resultType="java.util.LinkedHashMap">
		select
		a.EmployeeID,a.Name,b.Department,count(c.EmployeeID) Comment
		,b.location_x,b.location_y,d.PhotoUrl
		from Employee a
		join Department b
		on
		a.DepartmentID=b.DepartmentID
		left join W_GuideComment c on
		a.EmployeeID=c.EmployeeID and c.ComLevel='3'
		left join VIP d on
		a.VIPID=d.VIPID
		where b.EShopSendFlag='1'
		and a.IsGuide='1' and
		a.StopFlag='0' and
		b.location_x is not null and
		b.location_y is not null
		group by a.EmployeeID,a.Name,b.Department
		,b.location_x,b.location_y,d.PhotoUrl
	</select>

	<select id="getRecentGuide" resultType="java.util.LinkedHashMap">
		select
		a.EmployeeID,b.Name,c.Department,c.location_x,c.location_y,a.IsDefault
		from
		W_Guide a
		join Employee b on a.EmployeeID=b.EmployeeID
		join
		Department c
		on b.DepartmentID=c.DepartmentID
		where a.VIPID=#{ vipid }
		and
		c.EShopSendFlag='1'
		and b.IsGuide='1' and
		b.StopFlag='0' and
		c.location_x is not null and
		c.location_y is not null order by
		a.IsDefault desc
	</select>

	<select id="getEmployeeByID" resultType="java.lang.String">
		select DepartmentID from
		Employee where
		EmployeeID=#{id}
	</select>

	<select id="guidecomments" resultType="java.util.LinkedHashMap">
		select
		b.PhotoUrl,b.LineNickname,a.Created,a.Context,b.MobilePhone from
		W_GuideComment
		a
		join VIP b on a.VIPID=b.VIPID
		where
		a.EmployeeID=#{employeeid}
	</select>

	<select id="guideaddr" resultType="java.util.LinkedHashMap">
		select
		d.Province,d.City,d.County,d.Addr,d.Department,d.DepartmentID
		from
		Department as d
		inner join Employee as e on
		e.DepartmentID=d.DepartmentID
		where e.EmployeeID=#{employeeid}
	</select>

	<!-- 导购员列表 -->
	<select id="employeelist" resultType="java.util.LinkedHashMap">
		select a.EmployeeID,a.Code,b.EmployeeType,a.Name,a.MobilPhone,
		a.DepartmentID,d.Department,a.ZW,v.Code Vipcode,a.StopFlag,
		isnull(a.GoodPoint,0) GoodPoint, v.IsDistribute
		from (select
		m.EmployeeID,m.Code,m.Name,m.MobilPhone,m.DepartmentID,m.ZW,m.StopFlag,m.EmployeeTypeID,m.vipid,
		convert(decimal(10,1),convert(decimal(10,1),SUM(g.ComLevel))/convert(decimal(10,1),COUNT(*)))
		as GoodPoint
		from Employee m with(nolock) left join
		W_GuideComment g on
		m.EmployeeID=g.EmployeeID
		group by
		m.EmployeeID,m.Code,m.Name,m.MobilPhone,m.DepartmentID,m.ZW,m.StopFlag,m.EmployeeTypeID,m.vipid)
		a left join
		Employeetype b on a.EmployeeTypeID=b.EmployeeTypeID left
		join
		Department d on a.DepartmentID=d.DepartmentID left join
		vip v on
		a.VIPID=v.VIPID
		<if test="conditions != null and conditions != ''"> where ${conditions}
		</if>
		<if test="orderby == 1">
			order by a.GoodPoint desc
		</if>
		<if test="orderby == 2">
			order by a.GoodPoint asc
		</if>
	</select>

	<!-- 关联查询一条记录 -->
	<select id="findEmployeeById" parameterType="java.lang.String" resultMap="ResultMapextend">
		select a.*,b.EmployeeType,d.Department,v.Code Vipcode,case
		when
		c.goodcom is null then 0
		when c.goodcom=0 then 0 else
		convert(decimal(10,1),
		convert(decimal(10,1),goodsum)/convert(decimal(10,1),goodcom)) end as
		goodpoint,
		v.IsDistribute
		from Employee a left join
		Employeetype b on
		a.EmployeeTypeID=b.EmployeeTypeID left join
		Department d on
		a.DepartmentID=d.DepartmentID left join
		vip v on a.VIPID=v.VIPID
		left
		join (select EmployeeID,SUM(ISNULL(ComLevel,0)) as goodsum,COUNT(*)
		as
		goodcom from W_GuideComment (nolock) group by EmployeeID)
		as c on
		c.EmployeeID=a.EmployeeID
		where
		a.EmployeeID=#{employeeid}
	</select>


	<select id="findEmployeePointById" parameterType="java.lang.String" resultType="java.lang.String">
		select case when
		c.goodcom is null then 0
		when c.goodcom=0
		then 0 else convert(decimal(10,1),
		convert(decimal(10,1),goodsum)/convert(decimal(10,1),goodcom)) end as
		goodpoint
		from Employee a left join
		Employeetype b on
		a.EmployeeTypeID=b.EmployeeTypeID left join
		Department d on
		a.DepartmentID=d.DepartmentID left join
		vip v on a.VIPID=v.VIPID
		left
		join (select EmployeeID,SUM(ISNULL(ComLevel,0)) as goodsum,COUNT(*)
		as
		goodcom from W_GuideComment (nolock) group by EmployeeID)
		as c on
		c.EmployeeID=a.EmployeeID
		where
		a.EmployeeID=#{employeeid}
	</select>


	<select id="invitevip" resultType="java.util.LinkedHashMap">
		select
		e.EmployeeID,e.Name,d.DepartmentID,d.Department,e.PhotoUrl
		from
		Employee as e
		inner join Department as d on
		e.DepartmentID=d.DepartmentID
		where e.EmployeeID=#{employeeid}
	</select>

	<select id="selectEmpBycode" resultType="java.util.LinkedHashMap">
		select
		e.EmployeeID,e.EmployeeTypeID,e.Name,e.MobilPhone,e.ZW,d.DepartmentID,d.Department
		from Employee as e
		inner join Department as d on
		e.DepartmentID=d.DepartmentID
		where e.Code=#{code}
	</select>

	<select id="getVipcodeByID" resultType="java.util.LinkedHashMap">
		select
		v.Code,e.VIPID,e.EmployeeID,e.DepartmentID
		from Employee as e
		inner join
		VIP as v on v.VIPID=e.VIPID
		where e.StopFlag=0 and e.IsGuide=1 and
		e.EmployeeID=#{employeeid}
	</select>

	<!-- 导购员中心（业绩数据 — 概况） -->
	<select id="situation" resultType="java.util.LinkedHashMap">
		${paramSQL}
	</select>

	<select id="getForBarcode" resultType="java.util.LinkedHashMap">
		select
		b.EmployeeID,b.Name,c.Department,b.MobilPhone
		from Employee b inner
		join Department c on
		b.DepartmentID=c.DepartmentID
		where b.IsGuide='1'
		and b.StopFlag='0'
	</select>

	<select id="getEmpByDeptId" resultType="java.util.LinkedHashMap">
		select EmployeeID,Name
		from Employee
		where IsGuide='1' and StopFlag='0'
		and
		DepartmentID=#{departmentid,jdbcType=VARCHAR}
		order by Name
	</select>

	<select id="getEmpByVipId" parameterType="java.lang.String" resultType="java.util.LinkedHashMap">
		SELECT a.Name, b.Department,
		a.PhotoUrl,b.SendFlag,b.StopFlag
		FROM Employee AS
		a INNER JOIN
		Department AS b
		ON a.DepartmentID =
		b.DepartmentID
		WHERE
		a.IsGuide = '1'
		and a.StopFlag =
		'0' and
		a.EmployeeID =
		#{vipid,jdbcType=VARCHAR}
	</select>

	<!-- 导购离职处理 -->
	<update id="setTurnover" parameterType="java.lang.String">
		update Employee set
		StopFlag=1,DimissionDate=getdate(),DepartmentID=null
		where
		EmployeeID=#{employeeid,jdbcType=VARCHAR};
		delete
		W_Guide
		where
		EmployeeID=#{employeeid,jdbcType=VARCHAR} and vipid in
		(select vipid
		from W_Guide where
		EmployeeID=#{newemployeeid,jdbcType=VARCHAR});
		update W_Guide set
		EmployeeID=#{newemployeeid,jdbcType=VARCHAR}
		where
		EmployeeID=#{employeeid,jdbcType=VARCHAR}
	</update>
	<!-- 新导购离职处理 -->
	<update id="newsetTurnover" parameterType="java.lang.String">
		update Employee set
		StopFlag=1,DimissionDate=getdate(),DepartmentID=null
		where
		EmployeeID=#{employeeid,jdbcType=VARCHAR}; 
	</update>
	<!-- 导购转店处理 -->
	<update id="changeShop" parameterType="java.lang.String">
		update Employee set
		DepartmentID=#{departmentid,jdbcType=VARCHAR}
		where
		EmployeeID=#{employeeid,jdbcType=VARCHAR};
		<if test="newemployeeid != null and newemployeeid != ''"> delete W_Guide where
			EmployeeID=#{employeeid,jdbcType=VARCHAR} and vipid in (select vipid
			from W_Guide where EmployeeID=#{newemployeeid,jdbcType=VARCHAR});
			update W_Guide set EmployeeID=#{newemployeeid,jdbcType=VARCHAR} where
			EmployeeID=#{employeeid,jdbcType=VARCHAR}
		</if>
	</update>

	<!-- 企业号访客管理关注更新 -->
	<update id="updateVisitor" parameterType="com.fuxi.ws.data.entity.Employee">
		update Employee set
		OpenID = #{openid,jdbcType=VARCHAR},
		UserID =
		#{userid,jdbcType=VARCHAR},
		PhotoUrl = #{photourl,jdbcType=VARCHAR}
		where
		MobilPhone = #{mobilphone,jdbcType=VARCHAR}
	</update>

	<!-- 企业号访客管理部门人员列表 -->
	<select id="selectOfficer" resultType="java.util.LinkedHashMap">
		select e.EmployeeID,e.PhotoUrl,e.Name,e.MobilPhone,d.Department
		from
		Employee as e left join Department as d on e.departmentid =
		d.departmentid
		where IsOfficer = 'True'
		<if test="conditions != null and conditions != ''">
			${conditions}
		</if>

	</select>
	
	

</mapper>