Browse Source

查询BUG修改

anderx 3 years ago
parent
commit
dd5a19ce15

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

@@ -187,9 +187,9 @@ public interface UserMapper {
 
     void updateDimissionTransfer(@Param("aid")String aid, @Param("transferId")String transferId);
 
-    List<userDataListBo> userDataStatistics(@Param("depId")String depId);
+    List<userDataListBo> userDataStatistics(@Param("deps")List<String> deps);
 
-    userDataListBo userDataStatisticsCount(@Param("depId")String depId);
+    userDataListBo userDataStatisticsCount(@Param("deps")List<String> deps);
 
     int UserReceiveCount( @Param("aid")String aid);
 

+ 10 - 4
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1848,8 +1848,11 @@ inner join(
 				left join user y on x1.uid=y.id where x1.type=1
 				and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
 	where a.status='正常'
-	<if test="depId!=null and depId!=''">
-	and a.department_id=	#{depId,jdbcType=VARCHAR}
+	<if test="deps!=null">
+	and a.department_id in
+		<foreach close=")" collection="deps" item="depId" open="(" separator=",">
+			#{depId}
+		</foreach>
 	</if>
 	</select>
 	<select id="userDataStatisticsCount" resultType="com.goafanti.report.bo.userDataListBo">
@@ -1873,8 +1876,11 @@ inner join(
 				left join user y on x1.uid=y.id where x1.type=1
 				and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
 	where a.status='正常'
-	<if test="depId!=null and depId!=''">
-	and a.department_id=	#{depId,jdbcType=VARCHAR}
+	<if test="depId!=null ">
+	and a.department_id in
+		<foreach close=")" collection="deps" item="depId" open="(" separator=",">
+			#{depId}
+		</foreach>
 	</if>
 	)z
 	</select>

+ 14 - 14
src/main/java/com/goafanti/report/controller/ReportApiController.java

@@ -118,7 +118,7 @@ public class ReportApiController extends BaseApiController {
 	@RequestMapping(value = "/sales/marketingStatistics", method = RequestMethod.GET)
 	public Result marketingStatistics(String depId,Integer type) {
 		Result res=new Result();
-		
+
 		if (null==type||type>1) {
 			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
 	            return res;
@@ -138,7 +138,7 @@ public class ReportApiController extends BaseApiController {
 	@RequestMapping(value = "/sales/countMarketingStatistics", method = RequestMethod.GET)
 	public Result countMarketingStatistics(String depId,Integer type) {
 		Result res=new Result();
-		
+
 		if (null==type||type>1) {
 			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "参数错误", "参数"));
 	            return res;
@@ -149,7 +149,7 @@ public class ReportApiController extends BaseApiController {
 			return res.data(reportService.countMarketingDepStatistics(depId));
 		}
 	}
-	
+
 	/**
 	 * 客户营销时段统计表
 	 * @param depId
@@ -199,7 +199,7 @@ public class ReportApiController extends BaseApiController {
 	            return res;
 		}
 	  return res.data(reportService.countSometimeMarketingStatistics(depId,timeType,startTime,endTime));
-		
+
 	}
 	/**
 	 * 派单报表统计
@@ -216,28 +216,28 @@ public class ReportApiController extends BaseApiController {
 	            return res;
 		}
 	   return res.data(reportService.technicalDepStatistics(depId,timeType,startTime,endTime,publishStatus,taskStatus));
-		
+
 	}
-	
+
 	/**
 	 * 客户资料统计报表
 	 */
 	@RequestMapping(value="/userDataStatistics" , method=RequestMethod.GET)
-	public Result userDataStatistics(String depId){
+	public Result userDataStatistics(String deps){
 		Result res=new Result();
-		return res.data(reportService.userDataStatistics(depId));
-		
+		return res.data(reportService.userDataStatistics(deps));
+
 	}
-	
+
 	/**
 	 * 客户资料统计报表总计
 	 */
 	@RequestMapping(value="/userDataStatisticsCount" , method=RequestMethod.GET)
-	public Result userDataStatisticsCount(String depId){
+	public Result userDataStatisticsCount(String deps){
 		Result res=new Result();
-		return res.data(reportService.userDataStatisticsCount(depId));
-		
+		return res.data(reportService.userDataStatisticsCount(deps));
+
 	}
-	
+
 
 }

+ 22 - 15
src/main/java/com/goafanti/report/service/SalesReportServiceImpl.java

@@ -1,13 +1,10 @@
 package com.goafanti.report.service;
 
 import java.math.BigDecimal;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
+
+import com.goafanti.admin.service.DepartmentService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -38,6 +35,8 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 	DailySalesReportMapper dailySalesReportMapper;
 	@Autowired
 	UserMapper userMapper;
+	@Autowired
+	DepartmentService	departmentService;
 
 	public int insertDailyReports(Date startTime, Date endTime) {
 		List<DailySalesReport> list = dailySalesReportMapper.selectAdmins();
@@ -250,12 +249,12 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 		}
 	}
 
-	
+
 	public List<marketingESBo> marketingStatistics(String depId) {
 		ReportDate rd = new ReportDate(new Date());
 		List<marketingESBo> list=dailySalesReportMapper.findmarketingStatisticsList(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
 														rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
-		
+
 			return list;
 	}
 
@@ -264,7 +263,7 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 		ReportDate rd = new ReportDate(new Date());
 		List<marketingESBo> list=dailySalesReportMapper.marketingDepStatisticsList(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
 				rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
-			
+
 		return list;
 	}
 
@@ -279,7 +278,7 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 		ReportDate rd = new ReportDate(new Date());
 		CountMarketingStatisticsBo count=dailySalesReportMapper.privateCustomersDepCount(depId,rd.getStringDailyStart(),rd.getStringDailyEnd(),rd.getStringWeeklyStart(),rd.getStringWeeklyEnd(),
 				rd.getStringMonthStart(),rd.getStringMonthEnd(),rd.getStringYearStart(),rd.getStringYearEnd());
-		
+
 		return count;
 	}
 
@@ -388,13 +387,21 @@ public class SalesReportServiceImpl extends BaseMybatisDao<DailySalesReportMappe
 		return null;
 	}
 
-	public List<userDataListBo> userDataStatistics(String depId) {
-		return userMapper.userDataStatistics(depId);
+	public List<userDataListBo> userDataStatistics(String deps) {
+		List<String> listDep=new ArrayList<>();
+		if (deps!=null){
+			listDep=departmentService.parseArray(deps);
+		}
+		return userMapper.userDataStatistics(listDep);
 	}
 
-	public userDataListBo userDataStatisticsCount(String depId) {
-		return userMapper.userDataStatisticsCount(depId);
+	public userDataListBo userDataStatisticsCount(String deps) {
+		List<String> listDep=new ArrayList<>();
+		if (deps!=null){
+			listDep=departmentService.parseArray(deps);
+		}
+		return userMapper.userDataStatisticsCount(listDep);
 	}
-	
+
 
 }

+ 5 - 1
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -626,7 +626,11 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			in.setType(2);
 		}else if(TokenManager.hasRole(AFTConstants.COMPANY_MANAGER)||TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
 			in.setType(1);
-			map.put("deps", departmentService.selectSubDeps(in.getDeps()));
+			if (in.getDeps()!=null){
+				map.put("deps", departmentService.selectSubDeps(in.getDeps()));
+			}else {
+				map.put("deps",departmentService.selectMyDeps());
+			}
 		}else{
 			in.setType(0);
 			if (in.getAid()==null) map.put("aid",TokenManager.getAdminId());