Browse Source

外出面谈统计开发

anderx 4 years ago
parent
commit
d5ad275900

+ 4 - 5
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -376,12 +376,12 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		}else {
 			OrganizationListOut oo=organizationManagementMapper.selectAllById(depId);
 			acb.setName(oo.getName());
-			deps=organizationManagementMapper.selectBysuperName(acb.getName());
+			deps=organizationManagementMapper.selectBysuperId(oo.getId());
 		}
 		//迭代查出所有层级并计算
 		acb.setList(nestingList(deps,startTime,  endTime,aName));
 		//计算顶层
-		acb.setaList(organizationManagementMapper.getDepAll(acb.getName(),null,aName,startTime,  endTime));
+		acb.setaList(organizationManagementMapper.getDepAll(depId,aName,startTime,  endTime));
 		sumCount(acb,0);
 		return acb;
 	}
@@ -391,9 +391,9 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		//循环取出其中
 		for (depCountBo ab : deps) {
 			//找出每一个部门的直部门,并嵌套下去,先获取然后将
-			List<depCountBo >deps2=organizationManagementMapper.selectBysuperName(ab.getName());
+			List<depCountBo >deps2=organizationManagementMapper.selectBysuperId(ab.getId());
 			//查找所有部门的人的信息
-			List<AdminCustomerBo> aList=organizationManagementMapper.getDepAll(ab.getName(),null,name,startTime,  endTime);
+			List<AdminCustomerBo> aList=organizationManagementMapper.getDepAll(ab.getId(),name,startTime,  endTime);
 			ab.setList(nestingList(deps2,startTime,  endTime,name));
 			ab.setaList(aList);
 			//计算总数
@@ -423,7 +423,6 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 				if ( a.getNewCount()!=0) newCount+=a.getNewCount();
 				if ( a.getChannelNewCount()!=0) channelNewCount+=a.getChannelNewCount();
 				if ( a.getChannelCompleteCount()!=0) channelCompleteCount+=a.getChannelCompleteCount();
-				
 			}
 		}
 		if (ab.getaList()!=null&&!ab.getaList().isEmpty()) {

+ 6 - 3
src/main/java/com/goafanti/common/dao/OrganizationManagementMapper.java

@@ -124,7 +124,9 @@ public interface OrganizationManagementMapper {
 	 */
 	List<OrganizationManagement> selectSubDeps(@Param("superIds")String superIds);
 	
-	List<depCountBo> selectBysuperName(@Param("superName")String superName);
+	List<depCountBo> selectBysuperId(String id);
+
+	List<depCountBo> selectBysuperName(String name);
 	/**
 	 * 查询当前集合
 	 * @param adminId
@@ -144,7 +146,8 @@ public interface OrganizationManagementMapper {
 	 */
 	String getMaxAbbreviation(String abbreviation);
 	
-	List<AdminCustomerBo> getDepAll(@Param("depName")String depName,@Param("depId")String depId,
+	List<AdminCustomerBo> getDepAll(@Param("depId")String depId,
 			@Param("adminName")String adminName,@Param("startTime")String startTime, @Param("endTime")String endTime);
-	
+
+
 }

+ 11 - 11
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -1111,12 +1111,12 @@ select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobil
 	left join (select uid,max(time_stamp) as time_stamp from user_follow group by uid) b  on a.id=b.uid
 	left join (select uid,name ,mobile from organization_contact_book where major=1) c on a.id=c.uid
 	<if test="type==5 or type==6">
-	left join (select aid,uid from user_business
-	where follow_situation=5 
-	<if test="startTime != null and endTime != null">
-	and  create_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}  
+	left join (select aid,uid from public_release where clock_in =1
+	and aid= #{aid,jdbcType=VARCHAR}
+    <if test="startTime != null and endTime != null">
+	and  clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
     </if>
-	group by aid,uid)d on a.id=d.uid
+	)d on a.id=d.uid
 	</if>
 	where  a.type=1 
 	<if test="type != 5 and type !=6">
@@ -1166,12 +1166,12 @@ select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobil
 	left join (select uid,max(time_stamp) as time_stamp from user_follow group by uid) b  on a.id=b.uid
 	left join (select uid,name ,mobile from organization_contact_book where major=1) c on a.id=c.uid
 	<if test="type==5 or type==6">
-	left join (select aid,uid from user_business
-	where follow_situation=5 
-	<if test="startTime != null and endTime != null">
-	and  create_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}  
-    </if>
-	group by aid,uid)d on a.id=d.uid
+      left join (select aid,uid from public_release where clock_in =1
+      and aid= #{aid,jdbcType=VARCHAR}
+      <if test="startTime != null and endTime != null">
+        and  clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+      </if>
+      )d on a.id=d.uid
 	</if>
 	where  a.type=1 
 	<if test="type != 5 and type !=6">

+ 31 - 61
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -625,10 +625,15 @@
 		select id,name,dep_no from department where super_id in (#{superIds,jdbcType=VARCHAR})
 	</select>
 	
-		<select id="selectBysuperName"  resultType="com.goafanti.admin.bo.depCountBo">
+		<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 left join department b on a.super_id=b.id where b.name= #{superName,jdbcType=VARCHAR}
+		from department a left join department b on a.super_id=b.id where b.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">
@@ -641,65 +646,29 @@
 	</select>
 	
 	<select id="getDepAll" resultType="com.goafanti.admin.bo.AdminCustomerBo">
-	select a.id as aid,a.name as aName,d.id depId,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(qd.userCount,0) as channelCount,
-	ifnull(c.userCount,0) as signCount,ifnull(d.timeCount,0) as newCount,ifnull(e.timeCount,0) as channelNewCount,
-	ifnull(f.completeCount,0)completeCount,ifnull(g.completeCount,0)channelCompleteCount,ifnull(h.timeCount,0) as receiveCount
-  	from admin a 
-	left join (select aid,count(aid) as userCount from user where aid is not null  
-	and  share_type=0 and source !=0 and type=1 and channel=0
-		<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) b on a.id=b.aid
-	left join (select aid,count(aid) as userCount from user where aid is not null  
-	and  share_type=0 and source !=0 and type=1 and channel=1
-		<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) qd on a.id=qd.aid
-	left join (select aid,count(aid) as userCount from user where aid is not null  
-	and  share_type=2 and source !=0 and type=1
-		<if test="startTime != null and endTime != null"> 
-    and  transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) c on a.id=c.aid
-	left join (select aid,count(aid) as timeCount from `user` where aid is not null  
-	and  share_type=0 and source =1 and type=1 and channel=0
-		<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) d on a.id=d.aid
-	left join (select aid,count(aid) as timeCount from `user` where aid is not null  
-	and  share_type=0 and source =1 and type=1 and channel=1
-		<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) e on a.id=e.aid
-	left join (select x.aid,count(uid) completeCount from (select a.aid,a.uid from user_business a left join `user` b on a.uid=b.id where a.follow_situation=5 and b.channel=0
-	and b.`type`=1  
-	<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid,uid)x group by aid)f on a.id=f.aid 
-	left join (select x.aid,count(uid) completeCount from (select a.aid,a.uid from user_business a left join `user` b on a.uid=b.id where a.follow_situation=5 and b.channel=1
-	and b.`type`=1 
-		<if test="startTime != null and endTime != null"> 
-    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid,uid)x group by aid)g on a.id=g.aid 
-	left join (select aid,count(aid) as timeCount from `user` where aid is not null  
-	and  share_type=0 and source =2 and type=1 and channel=0
-		<if test="startTime != null and endTime != null"> 
-    and  transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-    </if>
-	group by aid) h on a.id=h.aid
-	left join department d on a.department_id=d.id
-	left join user_role e on a.id=e.uid left join `role` f on e.rid=f.id 
-	where f.role_name in ('营销员','营销经理')	
-	and	 a.status='正常' 
-	<if test="depName !=null">
-	and d.name= #{depName}
-	</if>
+	select a.id aid,a.name aName,d.id depId,d.name depName,b.userCount,b.channelCount,b.signCount,b.newCount,b.channelNewCount,b.receiveCount,
+        b.completeCount,b.channelCompleteCount
+        from admin a inner 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=0 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
+        <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 1=1
 	<if test="adminName !=null">
 	and a.name  like concat('%',#{adminName},'%')  
 	</if>
@@ -707,4 +676,5 @@
 	and d.id= #{depId}
 	</if>
 	</select>
+
 </mapper>

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 
 jdbc.driverClassName=com.mysql.jdbc.Driver
-#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.username=root
-#jdbc.password=123456
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc\:mysql://localhost:3306/aft20210820?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
-jdbc.password=aftdev
+jdbc.password=123456
+#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.username=root
+#jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20