| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- <?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.goafanti.common.dao.DepartmentMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.Department">
- <id column="id" jdbcType="VARCHAR" property="id" />
- <result column="create_id" jdbcType="VARCHAR" property="createId" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="deleted_sign" jdbcType="INTEGER" property="deletedSign" />
- <result column="name" jdbcType="VARCHAR" property="name" />
- <result column="type" jdbcType="VARCHAR" property="type" />
- <result column="manager_id" jdbcType="VARCHAR" property="managerId" />
- <result column="dep_no" jdbcType="VARCHAR" property="depNo" />
- <result column="super_id" jdbcType="VARCHAR" property="superId" />
- <result column="remarks" jdbcType="VARCHAR" property="remarks" />
- <result column="status" jdbcType="VARCHAR" property="status" />
- <result column="abbreviation" jdbcType="VARCHAR" property="abbreviation" />
- <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
- <result column="province" jdbcType="INTEGER" property="province" />
- <result column="working_hours_type" jdbcType="INTEGER" property="workingHoursType" />
- <result column="hide_sign" jdbcType="INTEGER" property="hideSign" />
- <result column="lvl" jdbcType="INTEGER" property="lvl" />
- <result column="current_amount" jdbcType="DECIMAL" property="currentAmount" />
- <result column="subordinate_amount" jdbcType="DECIMAL" property="subordinateAmount" />
- <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="retrial_finance_id" jdbcType="VARCHAR" property="retrialFinanceId" />
- <result column="approval" jdbcType="INTEGER" property="approval" />
- <result column="approval_aid" jdbcType="VARCHAR" property="approvalAid" />
- <result column="expense_finance_id" jdbcType="VARCHAR" property="expenseFinanceId" />
- <result column="expense_retrial_finance_id" jdbcType="VARCHAR" property="expenseRetrialFinanceId" />
- </resultMap>
- <sql id="Base_Column_List">
- id, create_id, create_time, update_time, deleted_sign, `name`, `type`, manager_id,
- dep_no, super_id, remarks, `status`, abbreviation, finance_id, province, working_hours_type,
- hide_sign, lvl, current_amount, subordinate_amount, total_amount, retrial_finance_id,
- approval, approval_aid, expense_finance_id, expense_retrial_finance_id
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from department
- where id = #{id,jdbcType=VARCHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
- delete from department
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.Department" useGeneratedKeys="true">
- insert into department (create_id, create_time, update_time,
- deleted_sign, `name`, `type`,
- manager_id, dep_no, super_id,
- remarks, `status`, abbreviation,
- finance_id, province, working_hours_type,
- hide_sign, lvl, current_amount,
- subordinate_amount, total_amount, retrial_finance_id,
- approval, approval_aid, expense_finance_id,
- expense_retrial_finance_id)
- values (#{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
- #{deletedSign,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
- #{managerId,jdbcType=VARCHAR}, #{depNo,jdbcType=VARCHAR}, #{superId,jdbcType=VARCHAR},
- #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{abbreviation,jdbcType=VARCHAR},
- #{financeId,jdbcType=VARCHAR}, #{province,jdbcType=INTEGER}, #{workingHoursType,jdbcType=INTEGER},
- #{hideSign,jdbcType=INTEGER}, #{lvl,jdbcType=INTEGER}, #{currentAmount,jdbcType=DECIMAL},
- #{subordinateAmount,jdbcType=DECIMAL}, #{totalAmount,jdbcType=DECIMAL}, #{retrialFinanceId,jdbcType=VARCHAR},
- #{approval,jdbcType=INTEGER}, #{approvalAid,jdbcType=VARCHAR}, #{expenseFinanceId,jdbcType=VARCHAR},
- #{expenseRetrialFinanceId,jdbcType=VARCHAR})
- </insert>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.Department" useGeneratedKeys="true">
- insert into department
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="createId != null">
- create_id,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="updateTime != null">
- update_time,
- </if>
- <if test="deletedSign != null">
- deleted_sign,
- </if>
- <if test="name != null">
- `name`,
- </if>
- <if test="type != null">
- `type`,
- </if>
- <if test="managerId != null">
- manager_id,
- </if>
- <if test="depNo != null">
- dep_no,
- </if>
- <if test="superId != null">
- super_id,
- </if>
- <if test="remarks != null">
- remarks,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="abbreviation != null">
- abbreviation,
- </if>
- <if test="financeId != null">
- finance_id,
- </if>
- <if test="province != null">
- province,
- </if>
- <if test="workingHoursType != null">
- working_hours_type,
- </if>
- <if test="hideSign != null">
- hide_sign,
- </if>
- <if test="lvl != null">
- lvl,
- </if>
- <if test="currentAmount != null">
- current_amount,
- </if>
- <if test="subordinateAmount != null">
- subordinate_amount,
- </if>
- <if test="totalAmount != null">
- total_amount,
- </if>
- <if test="retrialFinanceId != null">
- retrial_finance_id,
- </if>
- <if test="approval != null">
- approval,
- </if>
- <if test="approvalAid != null">
- approval_aid,
- </if>
- <if test="expenseFinanceId != null">
- expense_finance_id,
- </if>
- <if test="expenseRetrialFinanceId != null">
- expense_retrial_finance_id,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="createId != null">
- #{createId,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateTime != null">
- #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deletedSign != null">
- #{deletedSign,jdbcType=INTEGER},
- </if>
- <if test="name != null">
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- #{type,jdbcType=VARCHAR},
- </if>
- <if test="managerId != null">
- #{managerId,jdbcType=VARCHAR},
- </if>
- <if test="depNo != null">
- #{depNo,jdbcType=VARCHAR},
- </if>
- <if test="superId != null">
- #{superId,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=VARCHAR},
- </if>
- <if test="abbreviation != null">
- #{abbreviation,jdbcType=VARCHAR},
- </if>
- <if test="financeId != null">
- #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="province != null">
- #{province,jdbcType=INTEGER},
- </if>
- <if test="workingHoursType != null">
- #{workingHoursType,jdbcType=INTEGER},
- </if>
- <if test="hideSign != null">
- #{hideSign,jdbcType=INTEGER},
- </if>
- <if test="lvl != null">
- #{lvl,jdbcType=INTEGER},
- </if>
- <if test="currentAmount != null">
- #{currentAmount,jdbcType=DECIMAL},
- </if>
- <if test="subordinateAmount != null">
- #{subordinateAmount,jdbcType=DECIMAL},
- </if>
- <if test="totalAmount != null">
- #{totalAmount,jdbcType=DECIMAL},
- </if>
- <if test="retrialFinanceId != null">
- #{retrialFinanceId,jdbcType=VARCHAR},
- </if>
- <if test="approval != null">
- #{approval,jdbcType=INTEGER},
- </if>
- <if test="approvalAid != null">
- #{approvalAid,jdbcType=VARCHAR},
- </if>
- <if test="expenseFinanceId != null">
- #{expenseFinanceId,jdbcType=VARCHAR},
- </if>
- <if test="expenseRetrialFinanceId != null">
- #{expenseRetrialFinanceId,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Department">
- update department
- <set>
- <if test="createId != null">
- create_id = #{createId,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deletedSign != null">
- deleted_sign = #{deletedSign,jdbcType=INTEGER},
- </if>
- <if test="name != null">
- `name` = #{name,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- `type` = #{type,jdbcType=VARCHAR},
- </if>
- <if test="managerId != null">
- manager_id = #{managerId,jdbcType=VARCHAR},
- </if>
- <if test="depNo != null">
- dep_no = #{depNo,jdbcType=VARCHAR},
- </if>
- <if test="superId != null">
- super_id = #{superId,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- remarks = #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=VARCHAR},
- </if>
- <if test="abbreviation != null">
- abbreviation = #{abbreviation,jdbcType=VARCHAR},
- </if>
- <if test="financeId != null">
- finance_id = #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="province != null">
- province = #{province,jdbcType=INTEGER},
- </if>
- <if test="workingHoursType != null">
- working_hours_type = #{workingHoursType,jdbcType=INTEGER},
- </if>
- <if test="hideSign != null">
- hide_sign = #{hideSign,jdbcType=INTEGER},
- </if>
- <if test="lvl != null">
- lvl = #{lvl,jdbcType=INTEGER},
- </if>
- <if test="currentAmount != null">
- current_amount = #{currentAmount,jdbcType=DECIMAL},
- </if>
- <if test="subordinateAmount != null">
- subordinate_amount = #{subordinateAmount,jdbcType=DECIMAL},
- </if>
- <if test="totalAmount != null">
- total_amount = #{totalAmount,jdbcType=DECIMAL},
- </if>
- <if test="retrialFinanceId != null">
- retrial_finance_id = #{retrialFinanceId,jdbcType=VARCHAR},
- </if>
- <if test="approval != null">
- approval = #{approval,jdbcType=INTEGER},
- </if>
- <if test="approvalAid != null">
- approval_aid = #{approvalAid,jdbcType=VARCHAR},
- </if>
- <if test="expenseFinanceId != null">
- expense_finance_id = #{expenseFinanceId,jdbcType=VARCHAR},
- </if>
- <if test="expenseRetrialFinanceId != null">
- expense_retrial_finance_id = #{expenseRetrialFinanceId,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Department">
- update department
- set create_id = #{createId,jdbcType=VARCHAR},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- deleted_sign = #{deletedSign,jdbcType=INTEGER},
- `name` = #{name,jdbcType=VARCHAR},
- `type` = #{type,jdbcType=VARCHAR},
- manager_id = #{managerId,jdbcType=VARCHAR},
- dep_no = #{depNo,jdbcType=VARCHAR},
- super_id = #{superId,jdbcType=VARCHAR},
- remarks = #{remarks,jdbcType=VARCHAR},
- `status` = #{status,jdbcType=VARCHAR},
- abbreviation = #{abbreviation,jdbcType=VARCHAR},
- finance_id = #{financeId,jdbcType=VARCHAR},
- province = #{province,jdbcType=INTEGER},
- working_hours_type = #{workingHoursType,jdbcType=INTEGER},
- hide_sign = #{hideSign,jdbcType=INTEGER},
- lvl = #{lvl,jdbcType=INTEGER},
- current_amount = #{currentAmount,jdbcType=DECIMAL},
- subordinate_amount = #{subordinateAmount,jdbcType=DECIMAL},
- total_amount = #{totalAmount,jdbcType=DECIMAL},
- retrial_finance_id = #{retrialFinanceId,jdbcType=VARCHAR},
- approval = #{approval,jdbcType=INTEGER},
- approval_aid = #{approvalAid,jdbcType=VARCHAR},
- expense_finance_id = #{expenseFinanceId,jdbcType=VARCHAR},
- expense_retrial_finance_id = #{expenseRetrialFinanceId,jdbcType=VARCHAR}
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <select id="selectOrganizationList" parameterType="java.lang.String" resultType="com.goafanti.organization.bo.OrganizationListOut">
- select
- om.id,om.create_id as createId,om.create_time as createTime,
- om.update_time as updateTime,om.deleted_sign as deletedSign,
- om.name,om.type,
- om.dep_no as depNo,
- om.remarks,
- om.status,
- om.hide_sign hideSign ,
- om.approval,
- om.approval_aid approvalAid,
- dm.name as superName,
- wh.name as workingHoursName,
- x.name as managerName
- from department om
- left join department dm on om.super_id = dm.id
- left join admin x on om.manager_id = x.id
- left join working_hours wh on om.working_hours_type =wh.`type`
- where om.deleted_sign = 0
- <if test="name !=null">
- AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="superId !=null">
- AND om.super_id=#{superId,jdbcType=VARCHAR}
- </if>
- <if test="type !=null">
- AND om.type=#{type,jdbcType=VARCHAR}
- </if>
- <if test="depNo !=null">
- AND om.dep_no=#{depNo,jdbcType=VARCHAR}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectOrganizationCount" resultType="java.lang.Integer">
- select
- count(0)
- from department om
- left join department dm on om.super_id = dm.id
- left join admin x on om.manager_id = x.id
- where om.deleted_sign = 0
- <if test="name !=null">
- AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="superId !=null">
- AND om.super_id=#{superId,jdbcType=VARCHAR}
- </if>
- <if test="type !=null">
- AND om.type=#{type,jdbcType=VARCHAR}
- </if>
- <if test="depNo !=null">
- AND om.dep_no=#{depNo,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="selectSuperId" resultType="com.goafanti.organization.bo.DepOut">
- select
- id,name,dep_no as depNo,lvl,super_id superId
- from department
- where status ='0'
- <if test="lvl != null ">
- and lvl= #{lvl}
- </if>
- <if test="hideSign != null ">
- and hide_sign= #{hideSign}
- </if>
- <if test="id != null ">
- and super_id= #{id}
- </if>
- order by depNo
- </select>
- <!-- 得到上级 -->
- <select id="selectDepNo" resultType="java.lang.String">
- select
- dep_no as depNo
- from department
- where
- id=#{superId,jdbcType=VARCHAR}
- </select>
- <select id="selectDepNoByName" resultType="java.lang.String">
- select
- dep_no as depNo
- from department
- where
- name=#{name,jdbcType=VARCHAR}
- </select>
- <select id="selectDepNoCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select
- count(0)
- from department
- where
- <!-- dep_no like concat(#{depNo,jdbcType=VARCHAR},'%') -->
- super_id=#{superId,jdbcType=VARCHAR}
- </select>
- <select id="selectName" resultType="com.goafanti.admin.bo.AdminListBo">
- select
- name,id
- from admin
- where status= 0
- and name like concat('%',#{name,jdbcType=VARCHAR},'%')
- </select>
- <select id="selectAllById" resultType="com.goafanti.organization.bo.OrganizationListOut">
- select a.id, a.create_id as createId, a.create_time as createTime, a.update_time as updateTime,a.retrial_finance_id retrialFinanceId,
- d.name retrialFinanceName, a.deleted_sign as deletedSign, a.name, a.type, a.manager_id as managerId, a.dep_no as depNo,
- a.super_id as superId, a.remarks, a.status, a.abbreviation, a.finance_id financeId,a.hide_sign hideSign,
- a.expense_finance_id expenseFinanceId,f.name expenseFinanceName,a.expense_retrial_finance_id expenseRetrialFinanceId,
- g.name expenseRetrialFinanceName, a.province, c.name financeName, a.working_hours_type workingHoursType, b.name as managerName,
- a.retrial_finance_id retrialFinanceId, d.name retrialFinanceName,a.approval,a.approval_aid approvalAid,e.name approvalName
- from department a left join admin b on a.manager_id = b.id left join admin c on a.finance_id = c.id
- left join admin d on a.retrial_finance_id=d.id left join admin e on a.approval_aid =e.id
- left join admin f on a.expense_finance_id=f.id left join admin g on a.expense_retrial_finance_id=g.id
- where a.id=#{id,jdbcType=VARCHAR}
- </select>
- <delete id="deleteById" parameterType="java.lang.String">
- delete from department
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <select id="selectAdminNameById" parameterType="java.lang.String" resultType="java.lang.String">
- select
- name
- from admin
- where
- id=#{id,jdbcType=VARCHAR}
- </select>
- <select id="selectIdByDepNo" parameterType="java.lang.String" resultType="java.lang.String">
- select
- id
- from department
- where
- dep_no=#{depNo,jdbcType=VARCHAR}
- </select>
- <select id="selectIDNBySuperId" parameterType="java.lang.String" resultType="com.goafanti.organization.bo.OrganizationListOut">
- select
- id,create_id as createId,create_time as createTime,
- update_time as updateTime,deleted_sign as deletedSign,
- name,type,manager_id as managerId,
- dep_no as depNo,
- super_id as superId,
- remarks,status
- from department
- where
- super_id=#{id,jdbcType=VARCHAR}
- order by dep_no
- </select>
- <update id="updateByNumber" parameterType="com.goafanti.organization.bo.OrganizationListOut">
- update department
- <set>
- dep_no = #{depNo,jdbcType=VARCHAR},
- lvl= #{lvl}
- </set>
- where
- id=#{id,jdbcType=VARCHAR}
- </update>
- <select id="selectCountBySuperId" parameterType="java.lang.String" resultType="java.lang.Integer">
- select
- count(0)
- from department
- where
- super_id=#{superId,jdbcType=VARCHAR}
- </select>
- <select id="selectIdByName" parameterType="java.lang.String" resultType="java.lang.String">
- select
- id
- from department
- where
- name=#{name,jdbcType=VARCHAR}
- </select>
- <select id="selectNameById" parameterType="java.lang.String" resultType="java.lang.String">
- select
- name
- from department
- where
- id=#{id,jdbcType=VARCHAR}
- </select>
- <select id="selectDepNoById" resultType="java.lang.String">
- select
- dep_no as depNo
- from department
- where
- id=#{id,jdbcType=VARCHAR}
- </select>
- <select id="selectUserById" parameterType="java.lang.String" resultType="java.lang.Integer">
- select
- count(0)
- from admin
- where
- department_id=#{id,jdbcType=VARCHAR}
- </select>
- <!-- 查询当前层级 -->
- <select id="selectCurrentDeps" parameterType="java.lang.String" resultType="string">
- select id from department where manager_id = #{aid,jdbcType=VARCHAR}
- union
- select id from department where id = (select department_id from admin where id = #{aid,jdbcType=VARCHAR})
- </select>
- <!-- 查询下一层级 -->
- <select id="selectSubDeps" parameterType="java.lang.String" resultType="string">
- select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
- </select>
- <!-- 查询下一层级 -->
- <select id="selectSubDepsList" parameterType="java.lang.String" resultType="com.goafanti.common.model.Department">
- select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
- </select>
- <select id="selectBysuperId" resultType="com.goafanti.admin.bo.DepCountBo">
- select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
- from department a where a.super_id= #{id}
- </select>
- <select id="selectBysuperName" resultType="com.goafanti.admin.bo.DepCountBo">
- select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
- from department a left join department b on a.super_id=b.id where b.name= #{name}
- </select>
- <!-- 查询所有 -->
- <select id="selectAllDeps" resultType="com.goafanti.common.model.Department">
- select id ,super_id superId
- from department
- </select>
- <select id="getMaxAbbreviation" parameterType="java.lang.String" resultType="java.lang.String">
- select max(contract_no) as maxNo from t_order_new
- where create_time > '2019-5-31'
- and contract_no like concat(#{abbreviation,jdbcType=VARCHAR},'%')
- </select>
- <select id="getDepAll" resultType="com.goafanti.admin.bo.AdminCustomerBo">
- select a.id aid,a.name aName,d.id depId,d.name depName,ifnull(b.userCount,0)userCount,ifnull(b.channelCount,0)channelCount,
- ifnull(b.signCount,0)signCount,ifnull(b.newCount,0)newCount,ifnull(b.channelNewCount,0)channelNewCount,ifnull( b.receiveCount,0)receiveCount,
- ifnull( b.completeCount,0)completeCount,ifnull(b.channelCompleteCount,0)channelCompleteCount
- from admin a left join (select x.aid,x.userCount,x.channelCount,signCount,x.newCount,x.channelNewCount,x.receiveCount,
- ifnull(y.completeCount,0)completeCount,ifnull(y.channelCompleteCount,0)channelCompleteCount
- from (select aid,sum(if( share_type=0 and channel=0,1,0))userCount,
- sum(if(share_type=3 and channel=1,1,0))channelCount,
- sum(if( share_type=2 ,1,0))signCount,
- sum(if(share_type=0 and source =1 and channel=0,1,0))newCount,
- sum(if(share_type=0 and source =1 and channel=1,1,0))channelNewCount,
- sum(if(share_type=0 and source =2 and channel=0,1,0))receiveCount
- from `user` where `type` =1 and new_channel=0
- <if test="startTime != null and endTime != null">
- and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- group by aid)x left join (select a.aid,sum(if(b.channel=0,1,0))completeCount,
- sum(if(b.channel=1,1,0))channelCompleteCount from public_release a left join public_release_details prd on a.id=prd.id
- left join `user` b on prd.uid =b.id
- where prd.clock_in =1
- <if test="startTime != null and endTime != null">
- and prd.clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- group by a.aid ) y on x.aid=y.aid)b on a.id=b.aid
- left join department d on a.department_id=d.id
- where a.status= 0 and a.type=1
- <if test="adminName !=null">
- and a.name like concat('%',#{adminName},'%')
- </if>
- <if test="depId !=null">
- and d.id= #{depId}
- </if>
- </select>
- <select id="AlldepCount" resultType="com.goafanti.admin.bo.AdminCustomerBo">
- select a.id aid,a.name aName ,a.department_id depId,c.name depName,ifnull(userCount,0)userCount,
- ifnull(channelCount,0)channelCount,ifnull(signCount,0)signCount,ifnull(newCount,0)newCount,
- ifnull(channelNewCount,0)channelNewCount,ifnull(receiveCount,0)receiveCount,ifnull(completeCount,0)completeCount,
- ifnull(channelCompleteCount,0)channelCompleteCount
- from admin a left join (select aid,sum(if( share_type=0 and channel=0,1,0))userCount,
- sum(if(share_type=3 and channel=1,1,0))channelCount,
- sum(if( share_type=2 ,1,0))signCount,
- sum(if(share_type=0 and source =1 and channel=0,1,0))newCount,
- sum(if(share_type=0 and source =1 and channel=1,1,0))channelNewCount,
- sum(if(share_type=0 and source =2 and channel=0,1,0))receiveCount
- from `user` where `type` =1 and new_channel=0
- <if test="startTime != null and endTime != null">
- and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- group by aid)b on a.id=b.aid
- left join (select a.aid,sum(if(c.channel=0,1,0))completeCount,
- sum(if(c.channel=1,1,0))channelCompleteCount
- from public_release a left join public_release_details b on a.id=b.prid left join `user` c on b.uid=c.id
- where b.clock_in =1
- <if test="startTime != null and endTime != null">
- and b.clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- group by a.aid ) y on a.id=y.aid
- left join department c on a.department_id =c.id
- where a.status= 0 and a.type=1
- <if test="depIds!= null">
- and a.department_id in
- <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
- #{deps.id}
- </foreach>
- </if>
- </select>
- <select id="selectByDepNo" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from department where super_id= #{superId}
- order by dep_no desc limit 1
- </select>
- <update id="updateDepFinance">
- update department
- set finance_id= #{transferId}
- where finance_id= #{aid}
- </update>
- </mapper>
|