Browse Source

update 新营销统计开发

Signed-off-by: anderx <312518615@qq.com>
anderx 5 years ago
parent
commit
bc0ef4072e

+ 1 - 8
src/main/java/com/goafanti/admin/bo/AdminCustomerBo.java

@@ -1,6 +1,5 @@
 package com.goafanti.admin.bo;
 
-import java.util.List;
 
 public class AdminCustomerBo {
 	private String aid;
@@ -13,7 +12,6 @@ public class AdminCustomerBo {
 	private Integer completeCount;
 	private Integer interviewCount;
 	
-	private List<AdminCustomerBo > list;
 	
 	public String getAid() {
 		return aid;
@@ -51,12 +49,7 @@ public class AdminCustomerBo {
 	public void setReceiveCount(Integer receiveCount) {
 		this.receiveCount = receiveCount;
 	}
-	public List<AdminCustomerBo > getList() {
-		return list;
-	}
-	public void setList(List<AdminCustomerBo > list) {
-		this.list = list;
-	}
+	
 	public Integer getCompleteCount() {
 		return completeCount;
 	}

+ 74 - 0
src/main/java/com/goafanti/admin/bo/depCountBo.java

@@ -0,0 +1,74 @@
+package com.goafanti.admin.bo;
+
+import java.util.List;
+
+public class depCountBo {
+	
+	private String id;
+	private String name;
+	private Integer userCount;
+	private Integer inputCount;
+	private Integer receiveCount;
+	private Integer completeCount;
+	private Integer interviewCount;
+	private List<depCountBo> list;
+	private List<AdminCustomerBo> aList;
+	
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public Integer getUserCount() {
+		return userCount;
+	}
+	public void setUserCount(Integer userCount) {
+		this.userCount = userCount;
+	}
+	public Integer getInputCount() {
+		return inputCount;
+	}
+	public void setInputCount(Integer inputCount) {
+		this.inputCount = inputCount;
+	}
+	public Integer getReceiveCount() {
+		return receiveCount;
+	}
+	public void setReceiveCount(Integer receiveCount) {
+		this.receiveCount = receiveCount;
+	}
+	public Integer getCompleteCount() {
+		return completeCount;
+	}
+	public void setCompleteCount(Integer completeCount) {
+		this.completeCount = completeCount;
+	}
+	public Integer getInterviewCount() {
+		return interviewCount;
+	}
+	public void setInterviewCount(Integer interviewCount) {
+		this.interviewCount = interviewCount;
+	}
+	public List<depCountBo> getList() {
+		return list;
+	}
+	public void setList(List<depCountBo> list) {
+		this.list = list;
+	}
+	public List<AdminCustomerBo> getaList() {
+		return aList;
+	}
+	public void setaList(List<AdminCustomerBo> aList) {
+		this.aList = aList;
+	}
+	
+	
+
+}

+ 3 - 2
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -7,6 +7,7 @@ import com.goafanti.admin.bo.AdminCustomerBo;
 import com.goafanti.admin.bo.AdminCustomerDetailBo;
 import com.goafanti.admin.bo.AdminDetail;
 import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.admin.bo.depCountBo;
 import com.goafanti.common.model.Admin;
 import com.goafanti.core.mybatis.page.Pagination;
 
@@ -81,11 +82,11 @@ public interface AdminService {
 
 	Pagination<AdminCustomerBo> selectAdminCustomerStatistics(String depId, String startTime, String endTime, Integer pageSize, Integer pageNo);
 
-	Pagination<AdminCustomerDetailBo> selectAdminCustomerList(String aid, String startTime, String endTime,Integer type, Integer pageSize, Integer pageNo);
+	Pagination<AdminCustomerDetailBo> selectAdminCustomerList(String aid, String startTime, String endTime, Integer type, Integer pageSize, Integer pageNo);
 
 	int updatePrivateBusinessTransfer(String inputId, String uid, String pid);
 
-	AdminCustomerBo selectAllUser(String depId, String startTime, String endTime, Integer pageSize, Integer pageNo);
+	depCountBo selectAllUser(String depId, String startTime, String endTime, String aName);
 
 
 	

+ 70 - 21
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -18,6 +18,7 @@ import com.goafanti.admin.bo.AdminCustomerBo;
 import com.goafanti.admin.bo.AdminCustomerDetailBo;
 import com.goafanti.admin.bo.AdminDetail;
 import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.admin.bo.depCountBo;
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminLocationMapper;
@@ -35,6 +36,7 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.bo.BusinessListBo;
+import com.goafanti.organization.bo.OrganizationListOut;
 
 @Service
 public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements AdminService {
@@ -363,36 +365,81 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 	
 	@Override
-	public AdminCustomerBo selectAllUser(String depId, String startTime, String endTime, Integer pageSize, Integer pageNo) {
-		AdminCustomerBo acb=new AdminCustomerBo();
-		List<AdminCustomerBo >deps=new ArrayList<>();
+	public depCountBo selectAllUser(String depId, String startTime, String endTime,String aName) {
+		depCountBo acb=new depCountBo();
+		List<depCountBo >deps=new ArrayList<>();
 		if (depId==null) {
-			acb.setDepName("科德集团");
-			//首先把值全部归零
-			acb.setCompleteCount(0);
-			acb.setInputCount(0);
-			acb.setInterviewCount(0);
-			acb.setReceiveCount(0);
-			acb.setUserCount(0);
-			deps=organizationManagementMapper.getDepAll("科德集团",null,startTime,  endTime);
-			nestingList(deps,startTime,  endTime);
-			acb.setList(deps);
-		}else {
+			acb.setName("科德集团");
+//			organizationManagementMapper.getDepAll("科德集团",null,startTime,  endTime);
+			deps=organizationManagementMapper.selectBysuperName("科德集团");
 			
+		}else {
+			OrganizationListOut oo=organizationManagementMapper.selectAllById(depId);
+			acb.setName(oo.getName());
+			deps=organizationManagementMapper.selectBysuperName(acb.getName());
 		}
+		acb.setCompleteCount(0);
+		acb.setInputCount(0);
+		acb.setInterviewCount(0);
+		acb.setReceiveCount(0);
+		acb.setUserCount(0);
+		acb.setaList(new ArrayList<>());
+		//迭代查出所有层级并计算
+		acb.setList(nestingList(deps,startTime,  endTime,aName));
+		//计算顶层
+		sumCount(acb,0);
 		return acb;
 	}
 
-	private void nestingList(List<AdminCustomerBo >deps,String startTime, String endTime) {
+	private List<depCountBo> nestingList(List<depCountBo>deps,String startTime, String endTime,String name) {
+		List<depCountBo> res=new ArrayList<>();
 		//循环取出其中
-		for (AdminCustomerBo ab : deps) {
+		for (depCountBo ab : deps) {
 			//找出每一个部门的直部门,并嵌套下去,先获取然后将
-			List<AdminCustomerBo >deps2=organizationManagementMapper.getDepAll(null,ab.getDepId(),startTime,  endTime);
-			nestingList(deps2,startTime,  endTime);
-			//待继续开发
+			List<depCountBo >deps2=organizationManagementMapper.selectBysuperName(ab.getName());
+			//查找所有部门的人的信息
+			List<AdminCustomerBo> aList=organizationManagementMapper.getDepAll(ab.getName(),null,name,startTime,  endTime);
+			ab.setList(nestingList(deps2,startTime,  endTime,name));
+			ab.setaList(aList);
+			//计算总数
+			sumCount(ab,1);
+			if (ab.getCompleteCount()!=0||ab.getInputCount()!=0||ab.getInterviewCount()!=0
+					||ab.getReceiveCount()!=0||ab.getUserCount()!=0) {
+				res.add(ab);
+			}
 		}
-		
-		
+		return res;
+	}
+	/**
+	 * 
+	 * @param ab
+	 * @param type 0 部门计算 1人员计算
+	 */
+	private void sumCount(depCountBo ab,int type ) {
+		int completeCount=0,inputCount=0,interviewCount=0,receiveCount=0,userCount=0;
+		if (ab.getList()!=null&&!ab.getList().isEmpty()) {
+			for (depCountBo a : ab.getList()) {
+				if ( a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
+				if ( a.getInputCount()!=0) inputCount+=a.getInputCount();
+				if ( a.getInterviewCount()!=0) interviewCount+=a.getInterviewCount();
+				if ( a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
+				if ( a.getUserCount()!=0) userCount+=a.getUserCount();
+			}
+		}
+		if (ab.getaList()!=null&&!ab.getaList().isEmpty()) {
+			for (AdminCustomerBo a : ab.getaList()) {
+				if ( a.getCompleteCount()!=0) completeCount+=a.getCompleteCount();
+				if ( a.getInputCount()!=0) inputCount+=a.getInputCount();
+				if ( a.getInterviewCount()!=0) interviewCount+=a.getInterviewCount();
+				if ( a.getReceiveCount()!=0) receiveCount+=a.getReceiveCount();
+				if ( a.getUserCount()!=0) userCount+=a.getUserCount();
+			}
+		}
+		ab.setCompleteCount(completeCount);
+		ab.setInputCount(inputCount);
+		ab.setInterviewCount(interviewCount);
+		ab.setReceiveCount(receiveCount);
+		ab.setUserCount(userCount);
 	}
 
 	@SuppressWarnings("unchecked")
@@ -430,6 +477,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		return i;
 	}
 
+
+
 	
 	
 }

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

@@ -5,6 +5,7 @@ import java.util.List;
 import com.goafanti.organization.bo.OrganizationListOut;
 import com.goafanti.admin.bo.AdminCustomerBo;
 import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.admin.bo.depCountBo;
 import com.goafanti.common.model.OrganizationManagement;
 import com.goafanti.common.model.OrganizationManagementExample;
 
@@ -122,6 +123,8 @@ public interface OrganizationManagementMapper {
 	 * @return
 	 */
 	List<OrganizationManagement> selectSubDeps(@Param("superIds")String superIds);
+	
+	List<depCountBo> selectBysuperName(@Param("superName")String superName);
 	/**
 	 * 查询当前集合
 	 * @param adminId
@@ -141,5 +144,7 @@ public interface OrganizationManagementMapper {
 	 */
 	String getMaxAbbreviation(String abbreviation);
 	
-	List<AdminCustomerBo> getDepAll(@Param("name")String name,@Param("depId")String depId, @Param("startTime")String startTime, @Param("endTime")String endTime);
+	List<AdminCustomerBo> getDepAll(@Param("depName")String depName,@Param("depId")String depId,
+			@Param("adminName")String adminName,@Param("startTime")String startTime, @Param("endTime")String endTime);
+	
 }

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

@@ -253,6 +253,6 @@ public interface UserMapper {
 
 	 List<CustomerListOut> privateUnitCustomerList(@Param("params")Map<String, Object> params);
 
-	void pushUserGuidance(@Param("id")String id, @Param("guidance")Integer guidance);
+	int pushUserGuidance(@Param("id")String id, @Param("guidance")Integer guidance);
 	
 }

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

@@ -1094,10 +1094,12 @@
   
    <select id="selectAdminCustomerDetailList"  resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
 select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobile,
-	a.create_time as createTime,b.time_stamp as followTime
+	a.create_time as createTime,b.time_stamp as followTime,ifnull(d.update_time,e.update_time) updateTime
 	from user a 
 	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
+	left join (select uid,update_time from user_business where follow_situation=5)d  on a.id=d.uid
+	left join (select uid,update_time from user_business where follow_situation=6)e  on a.id=e.uid
 	where a.aid is not null and  a.share_type=0 and a.type=1
     <if test="aid != null"> 
 	and a.aid=  #{aid,jdbcType=VARCHAR}
@@ -1117,6 +1119,18 @@ select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobil
 	and  a.transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR} 
     </if>
     </if>
+    <if test="type == 2">
+    and d.follow_situation=5
+	<if test="startTime != null and endTime != null">
+		and  d.update_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}  
+    </if>
+    </if>
+    <if test="type == 3">
+    and d.follow_situation=6
+    <if test="startTime != null and endTime != null">
+	and  e.update_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+	</if>
+    </if>
    <if test="page_sql!=null">
 			${page_sql}
 	</if>
@@ -1124,8 +1138,10 @@ select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobil
   
   <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
   	select count(*) from user a 
+  	left join (select uid,update_time,follow_situation from user_business where follow_situation=5)d  on a.id=d.uid
+	left join (select uid,update_time,follow_situation from user_business where follow_situation=6)e  on a.id=e.uid
 	where a.aid is not null and  a.share_type=0 and a.type=1
-	 <if test="aid != null"> 
+	<if test="aid != null"> 
 	and a.aid=  #{aid,jdbcType=VARCHAR}
     </if>
     <if test="type==null">
@@ -1143,6 +1159,18 @@ select a.id,a.nickname as name,a.source,c.name contacts,c.mobile as contactMobil
 	and  a.transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR} 
     </if>
     </if>
+	<if test="type == 2">
+    and d.follow_situation=5
+	<if test="startTime != null and endTime != null">
+		and  d.update_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}  
+    </if>
+    </if>
+    <if test="type == 3">
+    and e.follow_situation=6
+    <if test="startTime != null and endTime != null">
+	and  e.update_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+	</if>
+    </if>
   </select>
   <select id="listNameByDepAndName" resultType="java.lang.String">
 	select a.id  from admin a left join user_role b on a.id =b.uid

+ 13 - 4
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -618,6 +618,12 @@
 	<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="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= #{superName,jdbcType=VARCHAR}
+	</select>
+	
 	<!-- 查询所有 -->
 	<select id="selectAllDeps" resultMap="BaseResultMap">
 		select id,name,dep_no from department
@@ -628,7 +634,7 @@
 	and contract_no like  concat(#{abbreviation,jdbcType=VARCHAR},'%') 
 	</select>
 	
-	<select id="getDepAllBySuprName" resultType="com.goafanti.admin.bo.AdminCustomerBo">
+	<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(c.timeCount,0) as inputCount,
   	ifnull(d.timeCount,0) as receiveCount, ifnull(e.completeCount,0)completeCount,ifnull(f.interviewCount,0)interviewCount
   	from admin a 
@@ -662,12 +668,15 @@
 	left join `role` f on e.rid=f.id
 	where f.role_name in ('营销员','营销经理')	
 	and	 a.status='正常' 
-	<if test="name !=null">
-	and d.name= #{name}
+	<if test="depName !=null">
+	and d.name= #{depName}
+	</if>
+	
+	<if test="adminName !=null">
+	and a.name  like concat('%',#{adminName},'%')  
 	</if>
 	<if test="depId !=null">
 	and d.id= #{depId}
 	</if>
-	
 	</select>
 </mapper>

+ 16 - 4
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -293,9 +293,21 @@ public class AdminCustomerApiController extends BaseApiController{
 	
 	/** 查看跟进记录 **/
 	@RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
-	public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId){
+	public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
 		Result res = new Result();
-		res.setData(customerService.pushListFollowHistory(pageNo,pageSize,uid,businessProjectId));
+		res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
+		return res;
+	}
+	
+	/** 指导已读 **/
+	@RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
+	public Result pushGuidance(String uid){
+		Result res = new Result();
+		if (StringUtils.isBlank(uid)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
+			return res;
+		}
+		res.setData(customerService.pushGuidance(uid));
 		return res;
 	}
 	
@@ -1198,9 +1210,9 @@ public class AdminCustomerApiController extends BaseApiController{
 	 * @return
 	 */
 	@RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
-	public Result selectAllUser(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
+	public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
 		Result res = new Result();
-		res.data(adminService.selectAllUser( depId,  startTime, endTime,  pageSize,  pageNo));
+		res.data(adminService.selectAllUser( depId,  startTime, endTime, aName));
 		return res;
 	}
 	/**

+ 2 - 1
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -515,6 +515,7 @@ public interface CustomerService {
 	 * @param pageSize
 	 * @return
 	 */
-	Pagination<FollowListBo> pushListFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId);
+	Pagination<FollowListBo> listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId,Integer type);
+	int pushGuidance(String uid);
 	
 }

+ 5 - 5
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -445,7 +445,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<FollowListBo> pushListFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId) {
+	public Pagination<FollowListBo> listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type) {
 		Map<String, Object> params = new HashMap<String, Object>();
 		if(StringUtils.isNotBlank(uid))params.put("uid", uid);
 		if(StringUtils.isNotBlank(businessProjectId)) params.put("businessProjectId", businessProjectId);
@@ -463,7 +463,6 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			
 		}
 		page.setList(list);
-		pushGuidance(uid);
 		return page;
 	}
 
@@ -471,12 +470,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	 * 推动指导已读
 	 * @param uid
 	 */
-	private void pushGuidance(String uid) {
+	@Override
+	public int pushGuidance(String uid) {
 		User u=userMapper.findUserAccountDetail(uid);
 		if (u!=null &&u.getGuidance()!=0) {
-			u.setGuidance(1);
-			userMapper.pushUserGuidance(uid,1);
+		 return userMapper.pushUserGuidance(uid,0);
 		}
+		return 0;
 	}
 
 	@Override