Ver código fonte

处理前端数据问题

anderx 3 anos atrás
pai
commit
06ecabc3c9

+ 108 - 0
src/main/java/com/goafanti/common/dao/DepartmentMapper.java

@@ -0,0 +1,108 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.admin.bo.AdminCustomerBo;
+import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.admin.bo.depCountBo;
+import com.goafanti.common.model.Department;
+import com.goafanti.common.model.OrganizationManagement;
+import com.goafanti.organization.bo.OrganizationListOut;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface DepartmentMapper {
+    int deleteByPrimaryKey(String id);
+
+    int insert(Department record);
+
+    int insertSelective(Department record);
+
+    Department selectByPrimaryKey(String id);
+
+    int updateByPrimaryKeySelective(Department record);
+
+    int updateByPrimaryKey(Department record);
+
+    List<OrganizationListOut> selectSuperId(@Param("sort")int sort);
+    /**
+     * 根据组织名称查组织编号
+     */
+    String selectDepNoByName(String name);
+
+    /**
+     * 根据上级组织查组织编号
+     */
+    String  selectDepNo(String id);
+    /**
+
+
+     /**
+     * 查询相同上级下编号数量
+     */
+    int selectDepNoCount(String superId);
+    /**
+     * 模糊查询负责人名称
+     */
+    List<AdminListBo> selectName(String name);
+
+    OrganizationListOut selectAllById(String id);
+
+    int deleteById(String id);
+
+    String selectAdminNameById(String name);
+
+    String selectIdByDepNo(String depNo);
+    /**
+     * 查询有相同上级组织的信息
+     * @param superId
+     * @return
+     */
+    List<OrganizationListOut> selectIDNBySuperId(String superId);
+
+    int updateByNumber(OrganizationListOut olo);
+
+    int selectCountBySuperId(String superId);
+
+    String selectIdByName(String name);
+
+    String selectNameById(String id);
+
+    String selectDepNoById(String id);
+
+    int selectUserById(String id);
+
+    /**
+     * 查询下级集合
+     * @param superIds
+     * @return
+     */
+    List<OrganizationManagement> selectSubDeps(@Param("superIds")String superIds);
+
+    List<depCountBo> selectBysuperId(String id);
+
+    List<depCountBo> selectBysuperName(String name);
+    /**
+     * 查询当前集合
+     * @param adminId
+     * @return
+     */
+    List<OrganizationManagement> selectCurrentDeps(@Param("aid")String aid);
+
+    /**
+     * 查询所有部门
+     * @return
+     */
+    List<OrganizationManagement> selectAllDeps();
+    /**
+     * 查询最大编号
+     * @param abbreviation
+     * @return
+     */
+    String getMaxAbbreviation(String abbreviation);
+
+    List<AdminCustomerBo> getDepAll(@Param("depId")String depId,
+                                    @Param("adminName")String adminName, @Param("startTime")String startTime, @Param("endTime")String endTime);
+
+
+    List<AdminCustomerBo> AlldepCount(@Param("depIds")List<OrganizationManagement> depIds ,@Param("startTime")String startTime, @Param("endTime")String endTime);
+}

+ 2 - 0
src/main/java/com/goafanti/common/dao/OrganizationManagementMapper.java

@@ -69,6 +69,8 @@ public interface OrganizationManagementMapper {
 	 * @mbg.generated  Thu Nov 30 11:09:29 CST 2017
 	 */
 	int updateByPrimaryKey(OrganizationManagement record);
+
+
 	List<OrganizationListOut> selectSuperId(@Param("sort")int sort);
 	/**
 	 * 根据组织名称查组织编号

+ 521 - 0
src/main/java/com/goafanti/common/mapper/DepartmentMapper.xml

@@ -0,0 +1,521 @@
+<?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" />
+  </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
+  </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" parameterType="com.goafanti.common.model.Department">
+    insert into department (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)
+    values (#{id,jdbcType=VARCHAR}, #{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})
+  </insert>
+  <insert id="insertSelective" parameterType="com.goafanti.common.model.Department">
+    insert into department
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <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>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=VARCHAR},
+      </if>
+      <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>
+    </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>
+    </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}
+    where id = #{id,jdbcType=VARCHAR}
+  </update>
+
+
+  <select id="selectOrganizationList" parameterType="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,
+    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.OrganizationListOut">
+    select
+    id,name,dep_no as depNo
+    from department
+    where
+    status ='0'
+    order by CONVERT (name USING gbk)
+    <if test="sort ==1" >
+      limit 10
+    </if>
+  </select>
+  <insert id="insert1" parameterType="com.goafanti.organization.bo.OrganizationListOut">
+    insert into department(
+      id,create_id,create_time,update_time,deleted_sign,
+      name,type,manager_id,dep_no,super_id,desc,status)
+    values(#{id,jdbcType=VARCHAR},#{createId,jdbcType=VARCHAR},
+           #{createTime,jdbcType=VARCHAR},#{updateTime,jdbcType=VARCHAR},
+           #{deletedSign,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},
+           #{type,jdbcType=VARCHAR},#{managerId,jdbcType=VARCHAR},
+           #{depNo,jdbcType=VARCHAR},#{superId,jdbcType=VARCHAR},
+           #{desc,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR})
+  </insert>
+  <!-- 得到上级 -->
+  <select id="selectDepNo" resultType="String">
+    select
+      dep_no as depNo
+    from department
+    where
+      id=#{superId,jdbcType=VARCHAR}
+  </select>
+
+  <select id="selectDepNoByName" resultType="String">
+    select
+      dep_no as depNo
+    from department
+    where
+      name=#{name,jdbcType=VARCHAR}
+  </select>
+  <select id="selectDepNoCount" parameterType="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='正常'
+      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.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.province, c.name financeName, a.working_hours_type workingHoursType, b.name as managerName
+    from department a
+           left join admin b on a.manager_id = b.id left join admin c on a.finance_id = c.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}
+    </set>
+    where
+    id=#{id,jdbcType=VARCHAR}
+  </update>
+  <select id="selectCountBySuperId" parameterType="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="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" resultMap="BaseResultMap">
+    select id,name,dep_no,super_id from department where manager_id = #{aid,jdbcType=VARCHAR}
+    union all
+    select id,name,dep_no,super_id from department where id = (select department_id from admin where id = #{aid,jdbcType=VARCHAR})
+  </select>
+  <!-- 查询下一层级  -->
+  <select id="selectSubDeps"  parameterType="java.lang.String" resultMap="BaseResultMap">
+    select id,name,dep_no 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" resultMap="BaseResultMap">
+    select id,name,dep_no 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 `user` b on a.uid =b.id
+    where a.clock_in =1
+    <if test="startTime != null and endTime != null">
+      and 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='正常'  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(b.channel=0,1,0))completeCount,
+    sum(if(b.channel=1,1,0))channelCompleteCount from public_release a left join `user` b on a.uid =b.id
+    where a.clock_in =1
+    <if test="startTime != null and endTime != null">
+      and 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='正常'  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>
+
+</mapper>

+ 1 - 0
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -409,6 +409,7 @@
       status = #{status,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
+
 	<select id="selectOrganizationList" parameterType="String" resultType="com.goafanti.organization.bo.OrganizationListOut">
 		select
 			om.id,om.create_id as createId,om.create_time as createTime,

+ 233 - 0
src/main/java/com/goafanti/common/model/Department.java

@@ -0,0 +1,233 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * department
+ * @author 
+ */
+public class Department implements Serializable {
+    /**
+     * 组织ID
+     */
+    private String id;
+
+    /**
+     * 创建人
+     */
+    private String createId;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 删除标识
+     */
+    private Integer deletedSign;
+
+    /**
+     * 组织名称
+     */
+    private String name;
+
+    /**
+     * 组织类型
+     */
+    private String type;
+
+    /**
+     * 组织负责人ID
+     */
+    private String managerId;
+
+    /**
+     * 组织编号
+     */
+    private String depNo;
+
+    /**
+     * 上级组织
+     */
+    private String superId;
+
+    /**
+     * 组织职能说明
+     */
+    private String remarks;
+
+    /**
+     * 组织状态
+     */
+    private String status;
+
+    /**
+     * 缩写
+     */
+    private String abbreviation;
+
+    /**
+     * 财务id(指定跳转的财务)
+     */
+    private String financeId;
+
+    /**
+     * 所在省份
+     */
+    private Integer province;
+
+    /**
+     * 工作时间
+     */
+    private Integer workingHoursType;
+
+    /**
+     * 隐藏 0否 1是
+     */
+    private Integer hideSign;
+
+    private static final long serialVersionUID = 1L;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(String createId) {
+        this.createId = createId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getDeletedSign() {
+        return deletedSign;
+    }
+
+    public void setDeletedSign(Integer deletedSign) {
+        this.deletedSign = deletedSign;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getManagerId() {
+        return managerId;
+    }
+
+    public void setManagerId(String managerId) {
+        this.managerId = managerId;
+    }
+
+    public String getDepNo() {
+        return depNo;
+    }
+
+    public void setDepNo(String depNo) {
+        this.depNo = depNo;
+    }
+
+    public String getSuperId() {
+        return superId;
+    }
+
+    public void setSuperId(String superId) {
+        this.superId = superId;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getAbbreviation() {
+        return abbreviation;
+    }
+
+    public void setAbbreviation(String abbreviation) {
+        this.abbreviation = abbreviation;
+    }
+
+    public String getFinanceId() {
+        return financeId;
+    }
+
+    public void setFinanceId(String financeId) {
+        this.financeId = financeId;
+    }
+
+    public Integer getProvince() {
+        return province;
+    }
+
+    public void setProvince(Integer province) {
+        this.province = province;
+    }
+
+    public Integer getWorkingHoursType() {
+        return workingHoursType;
+    }
+
+    public void setWorkingHoursType(Integer workingHoursType) {
+        this.workingHoursType = workingHoursType;
+    }
+
+    public Integer getHideSign() {
+        return hideSign;
+    }
+
+    public void setHideSign(Integer hideSign) {
+        this.hideSign = hideSign;
+    }
+}

+ 48 - 46
src/main/java/com/goafanti/organization/service/impl/OrganizationServiceImpl.java

@@ -7,6 +7,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import com.goafanti.common.dao.DepartmentMapper;
+import com.goafanti.common.model.Department;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -23,7 +25,7 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
 @Service
 public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManagementMapper> implements OrganizationService {
 	@Autowired
-	private OrganizationManagementMapper organizationManagementMapper;
+	private DepartmentMapper departmentMapper;
 	@Autowired
 	private TOrderMidMapper	tOrderMidMapper;
 
@@ -54,7 +56,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 	}
 	@Override
 	public List<OrganizationListOut> selectSuperId(Integer i) {
-		List<OrganizationListOut> depList=organizationManagementMapper.selectSuperId(i);
+		List<OrganizationListOut> depList=departmentMapper.selectSuperId(i);
 		return depList;
 	}
 	/**
@@ -68,65 +70,65 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 
 		String id = UUID.randomUUID().toString();
 		Date now = new Date();
-		OrganizationManagement om=new OrganizationManagement();
-		om.setId(id);
-		String createId =organizationManagementMapper.selectAdminNameById(TokenManager.getAdminId());
-		om.setCreateId(createId);
-		om.setCreateTime(now);
-		om.setUpdateTime(now);
-		om.setDeletedSign("0");
-		om.setName(name);
-		om.setType(type);
-		om.setManagerId(managerId);
-		om.setDepNo(countDepNo(sdepNo,count));
-	//	superId=organizationManagementMapper.selectIdByName(superId);
-		om.setSuperId(superId);
-		om.setRemarks(remarks);
-		om.setStatus("0");
-		om.setWorkingHoursType(workingHoursType);
-		organizationManagementMapper.insert(om);
+		Department dep=new Department();
+		dep.setId(id);
+		String createId =departmentMapper.selectAdminNameById(TokenManager.getAdminId());
+		dep.setCreateId(createId);
+		dep.setCreateTime(now);
+		dep.setUpdateTime(now);
+		dep.setDeletedSign(0);
+		dep.setName(name);
+		dep.setType(type);
+		dep.setManagerId(managerId);
+		dep.setDepNo(countDepNo(sdepNo,count));
+	//	superId=departmentMapper.selectIdByName(superId);
+		dep.setSuperId(superId);
+		dep.setRemarks(remarks);
+		dep.setStatus("0");
+		dep.setWorkingHoursType(workingHoursType);
+		departmentMapper.insert(dep);
 		return 1;
 	}
 	@Override
 	public List<AdminListBo> selectName(String name) {
-		List<AdminListBo> list=organizationManagementMapper.selectName(name);
+		List<AdminListBo> list=departmentMapper.selectName(name);
 		return list;
 	}
 	@Override
 	public OrganizationListOut selectAllById(String id) {
-		OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
-		olo.setSuperId(organizationManagementMapper.selectNameById(olo.getSuperId()));
+		OrganizationListOut olo=departmentMapper.selectAllById(id);
+		olo.setSuperId(departmentMapper.selectNameById(olo.getSuperId()));
 		return olo;
 	}
 	@Override
 	public int deleteById(String id) {
-		organizationManagementMapper.deleteById(id);
+		departmentMapper.deleteById(id);
 		return 1;
 	}
 	@Override
 	public int updateOrganization(String name, String type, String managerId, String superId, String status,Integer province,
 			String remarks,String id,String sdepNo,Integer count,String abbreviation,String financeId,Integer workingHoursType) {
 
-		String dep = countDepNo(sdepNo,count);
+		String deps = countDepNo(sdepNo,count);
 
 		Date now=new Date();
-		OrganizationManagement om=new OrganizationManagement();
-		om.setName(name);
-		om.setType(type);
-		om.setUpdateTime(now);
-		om.setManagerId(managerId);
-		om.setDepNo(dep);
-		om.setSuperId(superId);
-		om.setStatus(status);
-		om.setRemarks(remarks);
-		om.setId(id);
-		om.setAbbreviation(abbreviation);
-		om.setFinanceId(financeId);
-		om.setProvince(province);
-		om.setWorkingHoursType(workingHoursType);
+		Department dep=new Department();
+		dep.setName(name);
+		dep.setType(type);
+		dep.setUpdateTime(now);
+		dep.setManagerId(managerId);
+		dep.setDepNo(deps);
+		dep.setSuperId(superId);
+		dep.setStatus(status);
+		dep.setRemarks(remarks);
+		dep.setId(id);
+		dep.setAbbreviation(abbreviation);
+		dep.setFinanceId(financeId);
+		dep.setProvince(province);
+		dep.setWorkingHoursType(workingHoursType);
 		tOrderMidMapper.updateFinanceId(id,financeId);
-		int x=organizationManagementMapper.updateByPrimaryKeySelective(om);
-		updateLowerLevelNo(om.getId(),om.getDepNo());
+		int x=departmentMapper.updateByPrimaryKeySelective(dep);
+		updateLowerLevelNo(dep.getId(),dep.getDepNo());
 		return x;
 	}
 
@@ -134,7 +136,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 		String dep=null;
 		if(count<10){
 			dep=sdepNo+"0"+count;
-			String sid=organizationManagementMapper.selectIdByDepNo(dep);
+			String sid=departmentMapper.selectIdByDepNo(dep);
 			while(sid!=null){
 				count=(count+1)%100;
 				if(count>=10){
@@ -142,22 +144,22 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 				}else{
 					dep=sdepNo+"0"+count;
 				}
-				sid=organizationManagementMapper.selectIdByDepNo(dep);
+				sid=departmentMapper.selectIdByDepNo(dep);
 			}
 		}else if(count>=10){
 			dep=sdepNo+count;
-			String sid=organizationManagementMapper.selectIdByDepNo(dep);
+			String sid=departmentMapper.selectIdByDepNo(dep);
 			while(sid!=null){
 				count=(count+1)%100;
 				dep=sdepNo+count;
-				sid=organizationManagementMapper.selectIdByDepNo(dep);
+				sid=departmentMapper.selectIdByDepNo(dep);
 			}
 		}
 		return dep;
 	}
 
 	private void updateLowerLevelNo(String id,String depNo) {
-		List<OrganizationListOut> Nos =organizationManagementMapper.selectIDNBySuperId(id);
+		List<OrganizationListOut> Nos =departmentMapper.selectIDNBySuperId(id);
 		int i=1;
 		for (OrganizationListOut o : Nos) {
 			if(i<10){
@@ -173,7 +175,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 				dep=depNo+i;
 				o.setDepNo(dep);
 			}
-			organizationManagementMapper.updateByNumber(o);
+			departmentMapper.updateByNumber(o);
 			updateLowerLevelNo(o.getId(),o.getDepNo());
 			i++;
 		}