Browse Source

部门接口BUG修复

anderx 3 years ago
parent
commit
0afe1fdfe6

+ 7 - 0
src/main/java/com/goafanti/admin/service/DepartmentService.java

@@ -52,4 +52,11 @@ public interface DepartmentService {
 	 * @return 返回权限部门中的筛选部门
 	 */
 	List<String> comparePermissions(List<String> aDep, String deps);
+
+	/**
+	 * 获取财务管理部门
+	 * @param adminId
+	 * @return
+	 */
+	List<String> getFinanceDep(String aid);
 }

+ 7 - 0
src/main/java/com/goafanti/admin/service/impl/DepartmentServiceImpl.java

@@ -119,6 +119,9 @@ public class DepartmentServiceImpl extends BaseMybatisDao<WorkingHoursMapper> im
 		}
 		return myAll;
 	}
+
+
+
 	public List<String> comparePermissions(List<String> aDep, List<String> input) {
 		List<String> myAll=new ArrayList<>();
 		for (String s : aDep) {
@@ -140,6 +143,10 @@ public class DepartmentServiceImpl extends BaseMybatisDao<WorkingHoursMapper> im
 	}
 
 
+	@Override
+	public List<String> getFinanceDep(String aid) {
 
+		return departmentMapper.getFinanceDep(aid);
+	}
 
 }

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

@@ -115,4 +115,6 @@ public interface DepartmentMapper {
     List<AdminCustomerBo> AlldepCount(@Param("depIds")List<Department> depIds ,@Param("startTime")String startTime, @Param("endTime")String endTime);
 
     Department selectByDepNo(String superId);
+
+    List<String> getFinanceDep(String aid);
 }

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

@@ -548,5 +548,9 @@
     from department where super_id=  #{superId}
     order by dep_no desc limit 1
   </select>
+    <select id="getFinanceDep" resultType="java.lang.String">
+      select id from department
+      where finance_id = #{aid};
+    </select>
 
 </mapper>

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

@@ -574,8 +574,8 @@ where x.id=  #{tid}
 		</if>
 		<if test="deps !=null">
 		and c.order_dep in
-          <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-            #{deps.id}
+          <foreach close=")" collection="deps" item="depId" open="(" separator=",">
+            #{depId}
           </foreach>
 		</if>
 		<if test="aname !=null">
@@ -630,8 +630,8 @@ where x.id=  #{tid}
 		</if>
 		<if test="deps !=null">
 		and c.order_dep in
-          <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-            #{deps.id}
+          <foreach close=")" collection="deps" item="depId" open="(" separator=",">
+            #{depId}
           </foreach>
 		</if>
 		<if test="aname !=null">

+ 41 - 41
src/main/java/com/goafanti/order/controller/OrderBonusStatisticsApiController.java

@@ -60,10 +60,10 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 res.setData(fundManageOrderServiceImpl.updateProofreading(orderNew));
 		 return res;
 	 }
-	 
+
 	 /**
 	  * 营销员奖金统计
-	  * @param orderNewBo
+	  * @param bonusBo
 	  * @return
 	  */
 	 @RequestMapping(value="/saleBonusStatistics", method = RequestMethod.GET)
@@ -72,7 +72,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 res.setData(orderBonusServiceImpl.saleBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	 }
-	 
+
 	 /**
 	  * 财务专员发放营销员奖金
 	  * @param id
@@ -89,7 +89,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			}
 		 return res;
 	 }
-	 
+
 	 /**
 	  * 财务专员查看技术员奖金数据
 	  * @param bonusBo
@@ -103,7 +103,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 res.setData(orderBonusServiceImpl.technicianBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	 }
-	 
+
 	 /**
 	  * 财务专员发放技术员的奖金操作
 	  * @param id
@@ -115,8 +115,8 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 res.setData(orderBonusServiceImpl.updateChangeBonus(id));
 		 return res;
 	 }
-	 
-	 
+
+
 	 /**
 	  * 财务专员导出营销员奖金数据
 	  * @param bonusBo
@@ -138,20 +138,20 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			 cell.setCellValue("没有营销员奖金记录");
 		 }
 		 String fileName = "营销员奖金统计" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));
+		 response.setContentType("application/octet-stream;charset=utf-8");
 		 try {
 			 // 返回数据流
-			 wb.write(out); 
+			 wb.write(out);
 			 out.flush();
 			 out.close();
 		 } finally {
-			 out.flush(); 
-			 out.close(); 
+			 out.flush();
+			 out.close();
 		 }
 		 return res;
 	 }
-	 
+
 	/**
 	 * 导出技术员(咨询师)的奖金数据
 	 * @param bonusBo
@@ -173,20 +173,20 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			 cell.setCellValue("没有技术员奖金记录");
 		 }
 		 String fileName = "技术员奖金统计" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));
+		 response.setContentType("application/octet-stream;charset=utf-8");
 		 try {
 			 // 返回数据流
-			 wb.write(out); 
+			 wb.write(out);
 			 out.flush();
 			 out.close();
 		 } finally {
-			 out.flush(); 
-			 out.close(); 
+			 out.flush();
+			 out.close();
 		 }
 		 return res;
 	 }
-	 
+
 	 /**
 	  * 订单报表统计数据
 	  * @param reportBo
@@ -205,7 +205,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		res.setData(orderReportServiceImpl.getOrderReportData(reportBo, pageNo, pageSize));
 		return res;
 	 }
-	 
+
 	 /**
 	  * 导出订单数据
 	  * @param orderReportBo
@@ -221,7 +221,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			res.getError().add(buildError("", "没有指定订单日期"));
 			return res;
 		 }
-		 String date = orderReportBo.getMonth() == orderReportBo.getMonth1() ? orderReportBo.getMonth().toString() : orderReportBo.getMonth() + "-" + orderReportBo.getMonth1(); 
+		 String date = orderReportBo.getMonth() == orderReportBo.getMonth1() ? orderReportBo.getMonth().toString() : orderReportBo.getMonth() + "-" + orderReportBo.getMonth1();
 		 OutputStream out = response.getOutputStream();
 		 XSSFWorkbook wb = orderReportServiceImpl.exportMonthData(orderReportBo, date);
 		 if(null == wb){
@@ -232,16 +232,16 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			 cell.setCellValue("没有订单统计记录");
 		 }
 		 String fileName = "订单统计" + date + ".xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));
+		 response.setContentType("application/octet-stream;charset=utf-8");
 		 try {
 			 // 返回数据流
-			 wb.write(out); 
+			 wb.write(out);
 			 out.flush();
 			 out.close();
 		 } finally {
-			 out.flush(); 
-			 out.close(); 
+			 out.flush();
+			 out.close();
 		 }
 		 return res;
 	 }
@@ -281,10 +281,10 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 				res.setData(orderReportServiceImpl.saveUploadData(boSet));
 			} catch (IOException e) {
 				e.printStackTrace();
-			}	
+			}
 		return res;
 	}
-	
+
 	/**
 	 * 下载年度订单数据模板
 	 * @param response
@@ -297,20 +297,20 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 OutputStream out = response.getOutputStream();
 		 XSSFWorkbook wb = ExportExcelUtil.downOrderModelExcel();
 		 String fileName = "导入年度销售数据模板.xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));
+		 response.setContentType("application/octet-stream;charset=utf-8");
 		 try {
 			 // 返回数据流
-			 wb.write(out); 
+			 wb.write(out);
 			 out.flush();
 			 out.close();
 		 } finally {
-			 out.flush(); 
-			 out.close(); 
+			 out.flush();
+			 out.close();
 		 }
 		return res;
 	}
-	 
+
 	/**
 	 * 手动更新校对单量
 	 * @param report
@@ -322,7 +322,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		res.setData(orderReportServiceImpl.updateMonthDataById(report));
 		return res;
 	}
-	
+
 	/**
 	 * 营销管理员查看所有营销员奖金
 	 * @param bonusBo
@@ -336,7 +336,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 res.setData(orderBonusServiceImpl.saleBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	}
-	
+
 	/**
 	 * 营销管理员导出所有营销员奖金
 	 * @param bonusBo
@@ -357,16 +357,16 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 			 cell.setCellValue("没有营销员奖金记录");
 		 }
 		 String fileName = "营销员奖金统计" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));
+		 response.setContentType("application/octet-stream;charset=utf-8");
 		 try {
 			 // 返回数据流
-			 wb.write(out); 
+			 wb.write(out);
 			 out.flush();
 			 out.close();
 		 } finally {
-			 out.flush(); 
-			 out.close(); 
+			 out.flush();
+			 out.close();
 		 }
 		 return res;
 	 }

+ 15 - 2
src/main/java/com/goafanti/order/service/impl/OrderBonusServiceImpl.java

@@ -94,8 +94,21 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 		}else if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
 			fids=adminMapper.selectBySuperId(TokenManager.getAdminId());
 		}
-		if (newBo.getDeps()!=null){
-			params.put("deps", departmentService.parseArray(newBo.getDeps()));
+		List<String> depsList = new ArrayList<>();
+		if (TokenManager.hasRole(AFTConstants.SALESMAN_ADMIN)){
+			depsList=departmentService.selectMyDeps();
+		}
+		if (newBo.getDeps()==null){
+			if (depsList.isEmpty()){
+				return new Pagination<>(1,10,0);
+			}
+			params.put("deps", depsList);
+		}else {
+			depsList=departmentService.comparePermissions(depsList, newBo.getDeps());
+			if (depsList.isEmpty()){
+				return new Pagination<>(1,10,0);
+			}
+			params.put("deps", depsList);
 		}
 		params.put("fids", fids);
 		params.put("b", newBo);

+ 4 - 2
src/main/java/com/goafanti/order/service/impl/OrderInvoiceServiceImpl.java

@@ -133,7 +133,7 @@ public class OrderInvoiceServiceImpl extends BaseMybatisDao<TOrderInvoiceMapper>
 		//财务专员查看自己的
 		if (TokenManager.hasRole(AFTConstants.FINANCE)) {
 			params.put("financeId", TokenManager.getAdminId());
-
+			aDep.addAll(departmentService.getFinanceDep(TokenManager.getAdminId()));
 		}
 		//财务经理
 		if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
@@ -145,7 +145,9 @@ public class OrderInvoiceServiceImpl extends BaseMybatisDao<TOrderInvoiceMapper>
 
 		}
 		if(o.getDeps()==null){
-			params.put("deps", aDep);
+			if (!aDep.isEmpty()){
+				params.put("deps", aDep);
+			}
 		}else {
 			aDep=departmentService.comparePermissions(aDep,o.getDeps());
 			if (aDep.isEmpty()){