diff --git a/cw/WebRoot/cw/GroupByBookNum.jsp b/cw/WebRoot/cw/GroupByBookNum.jsp
new file mode 100644
index 0000000..c4a62b8
--- /dev/null
+++ b/cw/WebRoot/cw/GroupByBookNum.jsp
@@ -0,0 +1,292 @@
+<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
+<%
+ String path = request.getContextPath();
+ String basePath = request.getScheme() + "://"
+ + request.getServerName() + ":" + request.getServerPort()
+ + path + "/";
+%>
+
+
+
+
+${title }--书号分类统计
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 账单平台 |
+ 书号 |
+ 书名 |
+ 作者 |
+ 语种 |
+ 销售册数 |
+
+ 回款人民币 |
+ 回款美元 |
+
+
+
+
+
+
+
+
+
+
diff --git a/cw/WebRoot/cw/_header.jsp b/cw/WebRoot/cw/_header.jsp
index b99861e..5d9b793 100644
--- a/cw/WebRoot/cw/_header.jsp
+++ b/cw/WebRoot/cw/_header.jsp
@@ -48,6 +48,7 @@
电子书销售详情
diff --git a/cw/WebRoot/temp/groupByBookNumTemp.xlsx b/cw/WebRoot/temp/groupByBookNumTemp.xlsx
new file mode 100644
index 0000000..2c9d401
Binary files /dev/null and b/cw/WebRoot/temp/groupByBookNumTemp.xlsx differ
diff --git a/cw/src/com/wuzhou/controller/BookIncomingController.java b/cw/src/com/wuzhou/controller/BookIncomingController.java
index 915c84d..7bed9f3 100644
--- a/cw/src/com/wuzhou/controller/BookIncomingController.java
+++ b/cw/src/com/wuzhou/controller/BookIncomingController.java
@@ -1,5 +1,7 @@
package com.wuzhou.controller;
+import java.util.Calendar;
+import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -192,4 +194,36 @@ public void getIncomingPicByYear() {
renderText(out);
}
+ final static String [] month = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
+ public void groupByBookNumPage() {
+ render("/cw/GroupByBookNum.jsp");
+ }
+
+
+ public void groupByBookNum() {
+ String startTime = getPara("startTime", "");
+ String endTime = getPara("endTime", "");
+ String platform = getPara("platform", "");
+ int page = getParaToInt("page", 1);
+ try {
+ renderJson(service.groupByBookNum(startTime, endTime, platform, page));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ renderJson("");
+ }
+ }
+
+ public void exportGroupByBookNum() {
+ String startTime = getPara("startTime", "");
+ String endTime = getPara("endTime", "");
+ String platform = getPara("platform", "");
+ try {
+ String fileName = service.createXsltGroupByBookNum(startTime, endTime, platform);
+ renderText(fileName);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ renderText("");
+ }
+ }
+
}
diff --git a/cw/src/com/wuzhou/service/BookIncomingService.java b/cw/src/com/wuzhou/service/BookIncomingService.java
index 6254a6d..1ee125a 100644
--- a/cw/src/com/wuzhou/service/BookIncomingService.java
+++ b/cw/src/com/wuzhou/service/BookIncomingService.java
@@ -23,6 +23,7 @@
import org.jsoup.select.Elements;
import com.jfinal.kit.PathKit;
+import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.wuzhou.model.BookSaleModel;
@@ -213,4 +214,71 @@ public String incomingPic(String year, String bookNum, String platform){
System.out.println("========");
return out;
}
+
+
+
+
+
+ public Page groupByBookNum (String startTime, String endTime, String platform, int pageNumber) {
+ startTime = startTime.replace("-", "");
+ endTime = endTime.replace("-", "");
+ String select = "SELECT platform, book_num, book_name, book_author, book_lan, SUM(sale_count) AS sale, discount, SUM(sale_rmb) AS rmb, SUM(sale_dollar) AS dollar";
+ String sqlExceptSelect = " FROM cw_sale WHERE 1 = 1";
+ if(StrKit.notBlank(startTime, endTime)) {
+ sqlExceptSelect += " AND sale_time BETWEEN '" + startTime +"' AND '" + endTime + "' ";
+ }
+ if(StrKit.notBlank(platform) && !"0".equals(platform)) {
+ sqlExceptSelect += " AND platform = '"+platform+"'";
+ }
+ sqlExceptSelect += " GROUP BY book_num ORDER BY id DESC";
+ System.out.println(sqlExceptSelect);
+ return CwSaleModel.dao.paginate(pageNumber, 15, select, sqlExceptSelect);
+ }
+
+ public String createXsltGroupByBookNum(String startTime, String endTime, String platform) {
+ String sql = "SELECT platform, book_num, book_name, book_author, book_lan, SUM(sale_count) AS sale, discount, SUM(sale_rmb) AS rmb, SUM(sale_dollar) AS dollar FROM cw_sale WHERE 1 = 1";
+ startTime = startTime.replace("-", "");
+ endTime = endTime.replace("-", "");
+ if(StrKit.notBlank(startTime, endTime)) {
+ sql += " AND sale_time BETWEEN '" + startTime +"' AND '" + endTime + "' ";
+ }
+ if(StrKit.notBlank(platform) && !"0".equals(platform)) {
+ sql += " AND platform = '"+platform+"'";
+ }
+ sql += " GROUP BY book_num ORDER BY id DESC";
+ List list = CwSaleModel.dao.find(sql);
+ if(list==null||list.isEmpty()){
+ return "";
+ } else {
+ try {
+ Workbook wb = POITools.getWorkbook(PathKit.getWebRootPath()+File.separator+"temp"+File.separator+"groupByBookNumTemp.xlsx");
+ Sheet sheet = POITools.getSheet(0, wb);
+ for(int i = 0; i < list.size(); i++) {
+ CwSaleModel model = list.get(i);
+ Row row = POITools.createRow(sheet, (short)(i+1));
+ POITools.setCellValue(row.createCell(0), model.getStr("platform"), null);
+ POITools.setCellValue(row.createCell(1), model.getStr("book_num"), null);
+ POITools.setCellValue(row.createCell(2), model.getStr("book_name"), null);
+ POITools.setCellValue(row.createCell(3), model.getStr("book_author"), null);
+ POITools.setCellValue(row.createCell(4), model.getStr("book_lan"), null);
+ POITools.setCellValue(row.createCell(5), model.getBigDecimal("sale").toBigInteger(), null);
+ POITools.setCellValue(row.createCell(6), model.getBigDecimal("rmb"), null);
+ POITools.setCellValue(row.createCell(7), model.getBigDecimal("dollar"), null);
+ }
+ String fileName = new Date().getTime()+".xlsx";
+ POITools.saveAsWorkbook(wb, PathKit.getWebRootPath()+File.separator+"out"+File.separator+fileName);
+ return fileName;
+ } catch (EncryptedDocumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvalidFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return "";
+ }
}
diff --git a/cw/src/com/wuzhou/service/ExcelImportService.java b/cw/src/com/wuzhou/service/ExcelImportService.java
index 42c20eb..4262f37 100644
--- a/cw/src/com/wuzhou/service/ExcelImportService.java
+++ b/cw/src/com/wuzhou/service/ExcelImportService.java
@@ -121,7 +121,7 @@ public List parserIncomingExcelToList(String excelPath) thro
bie.setBookName(POITools.getCellValue(row.getCell(3)));
bie.setBookAuthor(POITools.getCellValue(row.getCell(4)));
bie.setBookLan(POITools.getCellValue(row.getCell(5)));
- bie.setSaleCount(Integer.parseInt(POITools.getCellValue(row.getCell(6))));
+ bie.setSaleCount(Integer.parseInt(POITools.getCellValue(row.getCell(6)).replace(".00", "")));
bie.setBookPrice(Float.parseFloat(POITools.getCellValue(row.getCell(7))));
bie.setZkl(Float.parseFloat(POITools.getCellValue(row.getCell(8))));
bie.setBookRmb(Float.parseFloat(POITools.getCellValue(row.getCell(9))));