Pārlūkot izejas kodu

校区签到签离记录优化

shenhao 3 gadi atpakaļ
vecāks
revīzija
c8c565ffa5

+ 9 - 9
src/main/java/com/ssj/dao/weixin/library/dao/impl/LibUserHistoryQueryDaoImpl.java

@@ -86,9 +86,9 @@ public class LibUserHistoryQueryDaoImpl implements LibUserHistoryQueryDao{
         List<Object> queryParams = new ArrayList<Object>();
         selSQL.append(" SELECT t.ryke_time,t.leave_time,v.child_name, t.lib_id ,i.league_name ");
         selSQL.append("  FROM tb_lib_subscribe t  ");
-        selSQL.append(" inner JOIN tb_lib_read_vip v ON  t.vip_id = v.id ");
+        selSQL.append(" inner JOIN tb_lib_vip v ON  t.vip_id = v.id ");
         selSQL.append(" LEFT JOIN tb_lib_join  i on t.lib_id = i.id  ");
-        selSQL.append(" WHERE  t.ryke_time is not null ");
+        selSQL.append(" WHERE  t.ryke_time is not null and v.user_id is not null ");
         
         if (searchParams.get("orgCode") != null && !searchParams.get("orgCode").equals("")) {
         	selSQL.append(" and  i.org_code in ( ");
@@ -119,9 +119,9 @@ public class LibUserHistoryQueryDaoImpl implements LibUserHistoryQueryDao{
         selSQL.append(" select a.frequency,a.child_name,a.school,a.grade,a.img_url,a.league_name,concat(ROUND( a.frequency/ daycount * 100,2),'%') as qdl from (\n");
         selSQL.append("select COUNT(1) AS frequency, v.child_name, v.school,v.grade,v.img_url, i.league_name ,DAYOFMONTH(last_day(t.ryke_time)) as daycount \n");
         selSQL.append("  FROM tb_lib_subscribe t  ");
-        selSQL.append(" LEFT JOIN tb_lib_read_vip v ON  t.vip_id = v.id ");
+        selSQL.append(" LEFT JOIN tb_lib_vip v ON  t.vip_id = v.id ");
         selSQL.append(" LEFT JOIN tb_lib_join  i on t.lib_id = i.id  ");
-        selSQL.append(" WHERE  t.ryke_time is not null ");
+        selSQL.append(" WHERE  t.ryke_time is not null and v.user_id is not null ");
         
         if (searchParams.get("orgCode") != null && !searchParams.get("orgCode").equals("")) {
         	selSQL.append(" and  i.org_code in ( ");
@@ -148,11 +148,11 @@ public class LibUserHistoryQueryDaoImpl implements LibUserHistoryQueryDao{
 			Map<String, Object> searchParams) {
 		StringBuilder selSQL = new StringBuilder();
         List<Object> queryParams = new ArrayList<Object>();
-        selSQL.append(" SELECT DATE_FORMAT(t.ryke_time,'%Y-%m-%T')as sb ,DATE_FORMAT(t.leave_time,'%Y-%m-%T')as sx,v.child_name,i.league_name ");
+        selSQL.append(" SELECT DATE_FORMAT(t.ryke_time,'%Y-%m-%d %T')as sb ,DATE_FORMAT(t.leave_time,'%Y-%m-%d %T')as sx,v.child_name,i.league_name ");
         selSQL.append("  FROM tb_lib_subscribe t  ");
-        selSQL.append("  LEFT JOIN tb_lib_read_vip v ON  t.vip_id = v.id  ");
+        selSQL.append("   JOIN tb_lib_vip v ON  t.vip_id = v.id  ");
         selSQL.append("  LEFT JOIN tb_lib_join  i on t.lib_id = i.id  ");
-        selSQL.append(" WHERE t.ryke_time is not null ");
+        selSQL.append(" WHERE t.ryke_time is not null  and v.user_id is not null ");
         if (searchParams.get("orgCode") != null && !searchParams.get("orgCode").equals("")) {
         	selSQL.append(" and  i.org_code in ( ");
         	selSQL.append(searchParams.get("orgCode"));
@@ -193,10 +193,10 @@ public class LibUserHistoryQueryDaoImpl implements LibUserHistoryQueryDao{
         selSQL.append(" select a.user_id,a.frequency,a.child_name, a.league_name ,concat(ROUND( a.frequency/ daycount * 100,2),'%') as qdl from (\n");
         selSQL.append(" SELECT t.user_id, COUNT(1) AS frequency, v.child_name,DAYOFMONTH(last_day(t.ryke_time)) as daycount  , i.league_name  \n");
         selSQL.append("  FROM tb_lib_subscribe t  ");
-        selSQL.append("  LEFT JOIN tb_lib_read_vip v ON  t.vip_id = v.id  ");
+        selSQL.append("   JOIN tb_lib_vip v ON  t.vip_id = v.id  ");
         selSQL.append("  LEFT JOIN tb_lib_join  i on t.lib_id = i.id  ");
         
-        selSQL.append(" WHERE t.ryke_time is not null and ");
+        selSQL.append(" WHERE t.ryke_time is not null and v.user_id is not null and ");
         	selSQL.append(" date_format(t.ryke_time,'%Y-%m') =? ");
         	queryParams.add(searchParams.get("monthDate"));
         	

+ 17 - 2
src/main/java/com/ssj/sys/controller/ReportController.java

@@ -4,11 +4,14 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import com.ssj.bean.sys.fx.domain.Merchant;
+import com.ssj.bean.sys.role.domain.Admin;
 import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
 import com.ssj.framework.basic.common.bean.SplitPage;
 import com.ssj.framework.basic.utils.DateHelper;
 import com.ssj.framework.core.common.controller.BaseController;
 import com.ssj.service.sys.counter.service.CounterService;
+import com.ssj.service.sys.fx.service.MerchantService;
 import com.ssj.service.weixin.library.service.IBookBorrowService;
 import com.ssj.service.weixin.library.service.ILibJoinService;
 import com.ssj.service.weixin.library.service.ILibVipService;
@@ -40,6 +43,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -73,6 +77,9 @@ public class ReportController extends BaseController {
 	
 	@Autowired
 	private IBookBorrowService bookBorrowService;
+
+	@Autowired
+	private MerchantService merchantService;
       
     public HSSFCellStyle getStyle(HSSFWorkbook workbook) {  
         //设置字体;  
@@ -967,7 +974,11 @@ public class ReportController extends BaseController {
     		Map<String, Object> searchParams = new  HashMap<String, Object>();
     		searchParams.put("child_name", request.getParameter("child_name")== null ? "":request.getParameter("child_name"));
     		searchParams.put("ryke_time", request.getParameter("ryke_time")== null ? "":request.getParameter("ryke_time"));
-    		searchParams.put("libId", request.getParameter("libId")== null ? "":request.getParameter("libId"));
+			HttpSession session = request.getSession();
+			Admin admin =(Admin) session.getAttribute("admin");
+			Merchant merchant=merchantService.getMerchantByPosCode(admin.getLoginName());
+			String libId = request.getParameter("libId")==null?merchant.getLibId():request.getParameter("libId");
+			searchParams.put("libId", libId);
     		if(!"admin".equals(loginName())){
     			searchParams.put("orgCode", orgCodeStr());
 			}
@@ -1014,7 +1025,11 @@ public class ReportController extends BaseController {
     		 String date =  DateHelper.format(new Date(), "yyyy-MM");
 			 String  monthDate = request.getParameter("monthDate")== null ? date:request.getParameter("monthDate");
 			 searchParams.put("monthDate", monthDate);
-			 searchParams.put("libId", request.getParameter("libId")== null ? "":request.getParameter("libId"));
+			HttpSession session = request.getSession();
+			Admin admin =(Admin) session.getAttribute("admin");
+			Merchant merchant=merchantService.getMerchantByPosCode(admin.getLoginName());
+			String libId = request.getParameter("libId")==null?merchant.getLibId():request.getParameter("libId");
+			searchParams.put("libId", libId);
 			 if(!"admin".equals(loginName())){
      			searchParams.put("orgCode", orgCodeStr());
  			}

+ 16 - 2
src/main/java/com/ssj/sys/controller/SysLibController.java

@@ -15,8 +15,11 @@ import java.util.Map;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 
+import com.ssj.bean.sys.fx.domain.Merchant;
 import com.ssj.bean.weixin.libmy.domain.*;
+import com.ssj.service.sys.fx.service.MerchantService;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -130,6 +133,9 @@ public class SysLibController extends BaseController {
 
     @Autowired
 	private IReadManagerService readManagerService;
+
+	@Autowired
+	private MerchantService merchantService;
     
 
     
@@ -996,7 +1002,11 @@ public class SysLibController extends BaseController {
 			 Map<String, Object> params = new HashMap<String, Object>();
 			 params.put("child_name", request.getParameter("child_name")== null ? "":request.getParameter("child_name"));
 			 params.put("ryke_time", request.getParameter("ryke_time")== null ? "":request.getParameter("ryke_time"));
-				params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
+			HttpSession session = request.getSession();
+			Admin admin =(Admin) session.getAttribute("admin");
+			Merchant merchant=merchantService.getMerchantByPosCode(admin.getLoginName());
+			 String libId = request.getParameter("libId")==null?merchant.getLibId():request.getParameter("libId");
+				params.put("libId", libId);
 				if(!"admin".equals(loginName())){
 					params.put("orgCode", orgCodeStr());
     			}
@@ -1034,7 +1044,11 @@ public class SysLibController extends BaseController {
 			 String date =  DateHelper.format(new Date(), "yyyy-MM");
 			 String  monthDate = request.getParameter("monthDate")== null ? date:request.getParameter("monthDate");
 			 params.put("monthDate", monthDate);
-			 params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
+			HttpSession session = request.getSession();
+			Admin admin =(Admin) session.getAttribute("admin");
+			Merchant merchant=merchantService.getMerchantByPosCode(admin.getLoginName());
+			String libId = request.getParameter("libId")==null?merchant.getLibId():request.getParameter("libId");
+			params.put("libId", libId);
 			 if(!"admin".equals(loginName())){
 					params.put("orgCode", orgCodeStr());
  			}