Explorar o código

修改部门统计

anderx %!s(int64=3) %!d(string=hai) anos
pai
achega
8f7bb188ca

+ 8 - 5
src/main/java/com/goafanti/admin/bo/depCountBo.java

@@ -1,9 +1,10 @@
 package com.goafanti.admin.bo;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class depCountBo {
-	
+
 	private String id;
 	private String name;
 	private Integer userCount;
@@ -16,7 +17,7 @@ public class depCountBo {
 	private Integer channelCompleteCount;
 	private List<depCountBo> list;
 	private List<AdminCustomerBo> aList;
-	
+
 	public depCountBo() {
 		userCount = 0;
 		receiveCount = 0;
@@ -26,8 +27,10 @@ public class depCountBo {
 		newCount = 0;
 		channelCompleteCount = 0;
 		channelNewCount = 0;
+		list=new ArrayList<>();
+		aList=new ArrayList<>();
 	}
-	
+
 	public Integer getSignCount() {
 		return signCount;
 	}
@@ -102,7 +105,7 @@ public class depCountBo {
 	public void setaList(List<AdminCustomerBo> aList) {
 		this.aList = aList;
 	}
-	
-	
+
+
 
 }

+ 49 - 43
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -365,8 +365,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 
 	@Override
-	@Cacheable(cacheNames = "selectAllUser#500",key = "'selectAllUser:depId:'+#depId+'startTime:'+#startTime+" +
-			"'endTime:'+#endTime+'aName:'+#aName")
+//	@Cacheable(cacheNames = "selectAllUser#500",key = "'selectAllUser:depId:'+#depId+'startTime:'+#startTime+" +
+//			"'endTime:'+#endTime+'aName:'+#aName")
 	public depCountBo selectAllUser(String depId, String startTime, String endTime,String aName) {
 		depCountBo acb=new depCountBo();
 		if (endTime!=null)endTime=endTime+" 23:59:59";
@@ -379,66 +379,72 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		}else {
 			OrganizationListOut oo=organizationManagementMapper.selectAllById(depId);
 			acb.setName(oo.getName());
+			acb.setId(depId);
 			deps=organizationManagementMapper.selectBysuperId(oo.getId());
 		}
-		//迭代查出所有层级并计算
-		acb.setList(nestingList(deps,startTime,  endTime,aName));
-		//计算顶层
-		acb.setaList(organizationManagementMapper.getDepAll(depId,aName,startTime,  endTime));
-		sumCount(acb,0);
-		//
+		List<AdminCustomerBo> list =organizationManagementMapper.testAlldepCount(startTime,  endTime);
+		for (AdminCustomerBo ad : list) {
+			if (acb.getId().equals(ad.getDepId())){
+				acb.getaList().add(ad);
+			}
+		}
+		for (depCountBo dep : deps) {
+			dep.setList(iterationDeps(dep.getId(),list));
+			for (AdminCustomerBo ad : list) {
+				if (dep.getId().equals(ad.getDepId())){
+					dep.getaList().add(ad);
+				}
+				sumCount(dep);
+			}
+		}
+		acb.setList(deps);
+		sumCount(acb);
 		return acb;
 	}
 
-	private List<depCountBo> nestingList(List<depCountBo>deps,String startTime, String endTime,String name) {
-		List<depCountBo> res=new ArrayList<>();
-		//循环取出其中
-		for (depCountBo ab : deps) {
-			//找出每一个部门的直部门,并嵌套下去,先获取然后将
-			List<depCountBo >deps2=organizationManagementMapper.selectBysuperId(ab.getId());
-			//查找所有部门的人的信息
-			List<AdminCustomerBo> aList=organizationManagementMapper.getDepAll(ab.getId(),name,startTime,  endTime);
-			ab.setList(nestingList(deps2,startTime,  endTime,name));
-			ab.setaList(aList);
-			//计算总数
-			sumCount(ab,1);
-			if (ab.getCompleteCount() != 0 || ab.getReceiveCount() != 0 || ab.getUserCount() != 0
-					|| ab.getSignCount() != 0 || ab.getChannelCount() != 0|| ab.getNewCount() != 0
-					|| ab.getChannelNewCount() != 0|| ab.getChannelCompleteCount() != 0) {
-				res.add(ab);
+	//迭代获取所有部门与部门员工并计算出部门数量
+	private List<depCountBo> iterationDeps(String id,List<AdminCustomerBo> list) {
+		List<depCountBo>  deps =organizationManagementMapper.selectBysuperId(id);
+		for (depCountBo dep : deps) {
+			dep.setList(iterationDeps(dep.getId(),list));
+			for (AdminCustomerBo ad : list) {
+				if (dep.getId().equals(ad.getDepId())){
+					dep.getaList().add(ad);
+				}
 			}
+			sumCount(dep);
 		}
-		return res;
+    	return deps;
 	}
+
 	/**
 	 *
 	 * @param ab
-	 * @param type 0 部门计算 1人员计算
 	 */
-	private void sumCount(depCountBo ab,int type ) {
+	private void sumCount(depCountBo ab) {
 		int completeCount=0,receiveCount=0,userCount=0,signCount=0,channelCount=0,newCount=0,channelNewCount=0,channelCompleteCount=0;
 		if (ab.getList()!=null&&!ab.getList().isEmpty()) {
 			for (depCountBo a : ab.getList()) {
-				if ( a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
-				if ( a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
-				if ( a.getUserCount()!=0) userCount+=a.getUserCount();
-				if ( a.getSignCount()!=0) signCount+=a.getSignCount();
-				if ( a.getChannelCount()!=0) channelCount+=a.getChannelCount();
-				if ( a.getNewCount()!=0) newCount+=a.getNewCount();
-				if ( a.getChannelNewCount()!=0) channelNewCount+=a.getChannelNewCount();
-				if ( a.getChannelCompleteCount()!=0) channelCompleteCount+=a.getChannelCompleteCount();
+				if (a.getCompleteCount()!=null&& a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
+				if (a.getReceiveCount()!=null&& a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
+				if (a.getUserCount()!=null&& a.getUserCount()!=0) userCount+=a.getUserCount();
+				if (a.getSignCount()!=null&& a.getSignCount()!=0) signCount+=a.getSignCount();
+				if (a.getChannelCount()!=null&& a.getChannelCount()!=0) channelCount+=a.getChannelCount();
+				if (a.getNewCount()!=null&& a.getNewCount()!=0) newCount+=a.getNewCount();
+				if (a.getChannelNewCount()!=null&& a.getChannelNewCount()!=0) channelNewCount+=a.getChannelNewCount();
+				if (a.getChannelCompleteCount()!=null&& a.getChannelCompleteCount()!=0) channelCompleteCount+=a.getChannelCompleteCount();
 			}
 		}
 		if (ab.getaList()!=null&&!ab.getaList().isEmpty()) {
 			for (AdminCustomerBo a : ab.getaList()) {
-				if ( a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
-				if ( a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
-				if ( a.getUserCount()!=0) userCount+=a.getUserCount();
-				if ( a.getSignCount()!=0) signCount+=a.getSignCount();
-				if ( a.getChannelCount()!=0) channelCount+=a.getChannelCount();
-				if ( a.getNewCount()!=0) newCount+=a.getNewCount();
-				if ( a.getChannelNewCount()!=0) channelNewCount+=a.getChannelNewCount();
-				if ( a.getChannelCompleteCount()!=0) channelCompleteCount+=a.getChannelCompleteCount();
+				if (a.getCompleteCount()!=null&& a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
+				if (a.getReceiveCount()!=null&& a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
+				if (a.getUserCount()!=null&& a.getUserCount()!=0) userCount+=a.getUserCount();
+				if (a.getSignCount()!=null&& a.getSignCount()!=0) signCount+=a.getSignCount();
+				if (a.getChannelCount()!=null&& a.getChannelCount()!=0) channelCount+=a.getChannelCount();
+				if (a.getNewCount()!=null&& a.getNewCount()!=0) newCount+=a.getNewCount();
+				if (a.getChannelNewCount()!=null&& a.getChannelNewCount()!=0) channelNewCount+=a.getChannelNewCount();
+				if (a.getChannelCompleteCount()!=null&& a.getChannelCompleteCount()!=0) channelCompleteCount+=a.getChannelCompleteCount();
 			}
 		}
 		ab.setCompleteCount(completeCount);

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

@@ -150,4 +150,5 @@ public interface OrganizationManagementMapper {
 			@Param("adminName")String adminName,@Param("startTime")String startTime, @Param("endTime")String endTime);
 
 
+	List<AdminCustomerBo> testAlldepCount(@Param("startTime")String startTime, @Param("endTime")String endTime);
 }

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

@@ -660,5 +660,31 @@
 	and d.id= #{depId}
 	</if>
 	</select>
+    <select id="testAlldepCount" 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
+    </select>
 
 </mapper>

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

@@ -46,7 +46,7 @@ user_remind_days=15
 user_channel_days=90
 
 avatar.host=//static.jishutao.com
-static.host=//static.jishutao.com/1.2.13
+static.host=//static.jishutao.com/1.2.14
 #avatar.host=//172.16.0.255:3000
 #static.host=//172.16.0.255:3000/1.2.05
 #static.host=http://172.16.1.187/prod/1.2.05

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -43,7 +43,7 @@ user_remind_days=15
 #提前提醒天数
 user_channel_days=90
 
-static.host=//static.jishutao.com/1.2.13
+static.host=//static.jishutao.com/1.2.14
 portal.host=//static.jishutao.com/portal/2.0.6
 avatar.host=//static.jishutao.com
 avatar.upload.host=//static.jishutao.com/upload