|
@@ -11,6 +11,7 @@ import com.kmall.admin.utils.ShiroUtils;
|
|
|
import com.kmall.common.constant.Dict;
|
|
|
import com.kmall.common.constant.JxlsXmlTemplateName;
|
|
|
import com.kmall.common.utils.*;
|
|
|
+import com.kmall.common.utils.excel.Entry;
|
|
|
import com.kmall.common.utils.excel.ExcelExport;
|
|
|
import com.kmall.common.utils.excel.ExcelUtil;
|
|
|
import com.kmall.common.utils.print.ticket.item.Ticket;
|
|
@@ -1346,8 +1347,10 @@ public class OrderController {
|
|
|
"Brand","EDLP","Current Price","Cost Price",/*"Prime Cost","Goods Number",*/"Deduction Rate","Unit Sold","Sales","Tax amount","Total Sales incl. Tax","Tax Rate",
|
|
|
"GP ¥","GP %","Product Category","Supplier Name","Transaction Type","Sale Return Type","Remark"};
|
|
|
|
|
|
- LinkedHashMap<String, Object> headerMap = initHeaderMap();
|
|
|
- List<Map<String, Object>> list = new LinkedList<>();
|
|
|
+// LinkedHashMap<String, Object> headerMap = initHeaderMap();
|
|
|
+ List<Entry> headerMap = initHeaderMap();
|
|
|
+// List<Map<String, Object>> list = new LinkedList<>();
|
|
|
+ List<List<Entry>> list = new ArrayList<>();
|
|
|
list.add(headerMap);
|
|
|
if (systemFormatList != null && systemFormatList.size() > 0) {
|
|
|
for (SystemFormatDto systemFormat : systemFormatList) {
|
|
@@ -1377,7 +1380,8 @@ public class OrderController {
|
|
|
// }
|
|
|
|
|
|
|
|
|
- LinkedHashMap<String, Object> map = new LinkedHashMap<>(32);
|
|
|
+// LinkedHashMap<String, Object> map = new LinkedHashMap<>(32);
|
|
|
+ List<Entry> entries = new ArrayList<>();
|
|
|
if (Objects.nonNull(systemFormat.getTaxRate()) && Objects.nonNull(systemFormat.getTotalSalesInclTax())){
|
|
|
|
|
|
|
|
@@ -1445,7 +1449,7 @@ public class OrderController {
|
|
|
primeCost = gp.setScale(2,BigDecimal.ROUND_HALF_UP).toString();
|
|
|
systemFormat.setPrimeCost(primeCost);
|
|
|
}
|
|
|
- map.put("ReceiptNo",systemFormat.getReceiptNo());
|
|
|
+ /*map.put("ReceiptNo",systemFormat.getReceiptNo());
|
|
|
map.put("StoreName",systemFormat.getStoreName());
|
|
|
map.put("CashRegisterNo",systemFormat.getCashRegisterNo());
|
|
|
map.put("TimeStampDetails",systemFormat.getTimeStampDetails());
|
|
@@ -1487,100 +1491,107 @@ public class OrderController {
|
|
|
|
|
|
map.put("Remark",systemFormat.getRemark());
|
|
|
|
|
|
- list.add(map);
|
|
|
+ list.add(map);*/
|
|
|
+
|
|
|
+ entries.add(new Entry("ReceiptNo",systemFormat.getReceiptNo()));
|
|
|
+ entries.add(new Entry("StoreName",systemFormat.getStoreName()));
|
|
|
+ entries.add(new Entry("CashRegisterNo",systemFormat.getCashRegisterNo()));
|
|
|
+ entries.add(new Entry("TimeStampDetails",systemFormat.getTimeStampDetails()));
|
|
|
+ entries.add(new Entry("StaffID",systemFormat.getStaffID()));
|
|
|
+ entries.add(new Entry("StaffName",systemFormat.getStaffName()));
|
|
|
+ entries.add(new Entry("PayFlag",systemFormat.getPayFlag()));
|
|
|
+ entries.add(new Entry("OrderStatus",orderStatus));
|
|
|
+ entries.add(new Entry("OrderSnWx",systemFormat.getOrderSnWx()));
|
|
|
+ entries.add(new Entry("OrderSnAli",systemFormat.getOrderSnAli()));
|
|
|
+ entries.add(new Entry("HSCode",systemFormat.getHsCode()));
|
|
|
+ entries.add(new Entry("HSCodeName",systemFormat.getHsCodeName()));
|
|
|
+ entries.add(new Entry("EmatouCode",systemFormat.getEmatouCode()));
|
|
|
+ entries.add(new Entry("PLU",systemFormat.getPlu()));
|
|
|
+ entries.add(new Entry("MychemID",systemFormat.getMychemID()));
|
|
|
+ entries.add(new Entry("ProductNameEN",systemFormat.getProductNameEN()));
|
|
|
+ entries.add(new Entry("ProductNameCN",systemFormat.getProductNameCN()));
|
|
|
+ entries.add(new Entry("Barcode",systemFormat.getBarcode()));
|
|
|
+ entries.add(new Entry("PackSize",systemFormat.getPackSize()));
|
|
|
+ entries.add(new Entry("ProductSpecification",systemFormat.getProductSpecification()));
|
|
|
+ entries.add(new Entry("Brand",systemFormat.getBrand()));
|
|
|
+ entries.add(new Entry("EDLP",systemFormat.getEdlp()));
|
|
|
+ entries.add(new Entry("CurrentPrice",systemFormat.getCurrentPrice()));
|
|
|
+ entries.add(new Entry("CostPrice",systemFormat.getCostPrice()));
|
|
|
+// entries.add(new Entry("PrimeCost",systemFormat.getPrimeCost()));
|
|
|
+// entries.add(new Entry("GoodsNumber",systemFormat.getGoodsNumber()));
|
|
|
+ entries.add(new Entry("DeductionRate",systemFormat.getDeductionRate()));
|
|
|
+ entries.add(new Entry("UnitSold",systemFormat.getUnitSold()));
|
|
|
+ entries.add(new Entry("Sales",systemFormat.getSales()));
|
|
|
+ entries.add(new Entry("TaxAmount",systemFormat.getTaxAmount()));
|
|
|
+ entries.add(new Entry("TotalSalesInclTax",systemFormat.getTotalSalesInclTax()));
|
|
|
+ entries.add(new Entry("TaxRate",systemFormat.getTaxRate()));
|
|
|
+ entries.add(new Entry("GP1",systemFormat.getGp1()));
|
|
|
+ entries.add(new Entry("GP2",systemFormat.getGp2()));
|
|
|
+ entries.add(new Entry("ProductCategory",systemFormat.getProductCategory()));
|
|
|
+ entries.add(new Entry("SupplierName",systemFormat.getSupplierName()));
|
|
|
+ entries.add(new Entry("TransactionType",systemFormat.getTransactionType()));
|
|
|
+ entries.add(new Entry("SaleReturnType",systemFormat.getSaleReturnType()));
|
|
|
+
|
|
|
+
|
|
|
+ entries.add(new Entry("Remark",systemFormat.getRemark()));
|
|
|
+
|
|
|
+ list.add(entries);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// =================================================System Format导出结束=====================================
|
|
|
|
|
|
- List<List<Map<String, Object>>> lists = splitList(list, page(list.size()));
|
|
|
- for (int i = 0; i < lists.size(); i++) {
|
|
|
- ee.addSheetByMap("Daily sales report " + (i + 1), lists.get(i), header);
|
|
|
- }
|
|
|
+ ee.addSheetByList("Daily sales report", list, header);
|
|
|
ee.export(response);
|
|
|
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
- private LinkedHashMap<String, Object> initHeaderMap() {
|
|
|
- LinkedHashMap<String, Object> headerMap = new LinkedHashMap<>();
|
|
|
- headerMap.put("ReceiptNo","销售单号");
|
|
|
- headerMap.put("StoreName","门店名称");
|
|
|
- headerMap.put("CashRegisterNo","收银台");
|
|
|
- headerMap.put("TimeStampDetails","销售时间");
|
|
|
- headerMap.put("StaffID","收银员");
|
|
|
- headerMap.put("StaffName","收银员姓名");
|
|
|
- headerMap.put("PayFlag","支付方式");
|
|
|
- headerMap.put("OrderStatus","支付状态");
|
|
|
- headerMap.put("OrderSnWx","微信流水号");
|
|
|
- headerMap.put("OrderSnAli","支付宝流水号");
|
|
|
- headerMap.put("HSCode","海关商品编码");
|
|
|
- headerMap.put("HSCodeName","品类名称");
|
|
|
- headerMap.put("EmatouCode","料件号");
|
|
|
- headerMap.put("PLU","PLU");
|
|
|
- headerMap.put("MychemID","MychemID");
|
|
|
- headerMap.put("ProductNameEN","商品名称(英文)");
|
|
|
- headerMap.put("ProductNameCN","商品名称(中文)");
|
|
|
- headerMap.put("Barcode","商品主条码");
|
|
|
- headerMap.put("PackSize","规格");
|
|
|
- headerMap.put("ProductSpecification","单位");
|
|
|
- headerMap.put("Brand","品牌");
|
|
|
- headerMap.put("EDLP","日常价");
|
|
|
- headerMap.put("CurrentPrice","实际销售价");
|
|
|
- headerMap.put("CostPrice","进货价");
|
|
|
-// headerMap.put("PrimeCost","成本价");
|
|
|
-// headerMap.put("GoodsNumber","可用库存数");
|
|
|
- headerMap.put("DeductionRate","扣率 (EDLP vs 实际销售价)");
|
|
|
- headerMap.put("UnitSold","销售数量");
|
|
|
- headerMap.put("Sales","销售额");
|
|
|
- headerMap.put("TaxAmount","综合税额");
|
|
|
- headerMap.put("TotalSalesInclTax","总销售额");
|
|
|
- headerMap.put("TaxRate","综合税率");
|
|
|
- headerMap.put("GP1","预估毛利额");
|
|
|
- headerMap.put("GP2","预估毛利率");
|
|
|
- headerMap.put("ProductCategory","商品类型");
|
|
|
- headerMap.put("SupplierName","主供应商名称");
|
|
|
- headerMap.put("TransactionType","销售类型");
|
|
|
- headerMap.put("SaleReturnType","退货类型");
|
|
|
- headerMap.put("Remark","备注");
|
|
|
- return headerMap;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据页数分割集合,分割后的集合一般都会少于3000
|
|
|
- * 如果大于3000了可能会导出失败
|
|
|
- * @param list 需要分割的list
|
|
|
- * @param n 页数
|
|
|
- * @return 分割后的list集合
|
|
|
- */
|
|
|
- public static <T> List<List<T>> splitList(List<T> list, int n){
|
|
|
- List<List<T>> result = new ArrayList<>();
|
|
|
- int remainder =list.size() % n; // 先计算出余数
|
|
|
- int number = list.size() / n; // 然后是商
|
|
|
- int offset = 0; // 偏移量
|
|
|
- for (int i = 0; i < n; i++){
|
|
|
- List<T> value;
|
|
|
- if (remainder > 0){
|
|
|
- value = list.subList(i * number + offset, (i + 1) * number + offset + 1);
|
|
|
- remainder--;
|
|
|
- offset++;
|
|
|
- }else{
|
|
|
- value = list.subList(i * number + offset, (i + 1) * number + offset);
|
|
|
- }
|
|
|
- result.add(value);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据集合大小判断有多少页
|
|
|
- * @param size 集合大小
|
|
|
- * @return 多少页
|
|
|
- */
|
|
|
- private int page(int size) {
|
|
|
- return size % 3000 == 0 ? size / 3000 : (size / 3000) + 1;
|
|
|
+ private ArrayList<Entry> initHeaderMap() {
|
|
|
+// LinkedHashMap<String, Object> headerMap = new LinkedHashMap<>();
|
|
|
+ ArrayList<Entry> entries = new ArrayList<>();
|
|
|
+ entries.add(new Entry("ReceiptNo","销售单号"));
|
|
|
+ entries.add(new Entry("StoreName","门店名称"));
|
|
|
+ entries.add(new Entry("CashRegisterNo","收银台"));
|
|
|
+ entries.add(new Entry("TimeStampDetails","销售时间"));
|
|
|
+ entries.add(new Entry("StaffID","收银员"));
|
|
|
+ entries.add(new Entry("StaffName","收银员姓名"));
|
|
|
+ entries.add(new Entry("PayFlag","支付方式"));
|
|
|
+ entries.add(new Entry("OrderStatus","支付状态"));
|
|
|
+ entries.add(new Entry("OrderSnWx","微信流水号"));
|
|
|
+ entries.add(new Entry("OrderSnAli","支付宝流水号"));
|
|
|
+ entries.add(new Entry("HSCode","海关商品编码"));
|
|
|
+ entries.add(new Entry("HSCodeName","品类名称"));
|
|
|
+ entries.add(new Entry("EmatouCode","料件号"));
|
|
|
+ entries.add(new Entry("PLU","PLU"));
|
|
|
+ entries.add(new Entry("MychemID","MychemID"));
|
|
|
+ entries.add(new Entry("ProductNameEN","商品名称(英文)"));
|
|
|
+ entries.add(new Entry("ProductNameCN","商品名称(中文)"));
|
|
|
+ entries.add(new Entry("Barcode","商品主条码"));
|
|
|
+ entries.add(new Entry("PackSize","规格"));
|
|
|
+ entries.add(new Entry("ProductSpecification","单位"));
|
|
|
+ entries.add(new Entry("Brand","品牌"));
|
|
|
+ entries.add(new Entry("EDLP","日常价"));
|
|
|
+ entries.add(new Entry("CurrentPrice","实际销售价"));
|
|
|
+ entries.add(new Entry("CostPrice","进货价"));
|
|
|
+// entries.add(new Entry("PrimeCost","成本价");
|
|
|
+// entries.add(new Entry("GoodsNumber","可用库存数");
|
|
|
+ entries.add(new Entry("DeductionRate","扣率 (EDLP vs 实际销售价)"));
|
|
|
+ entries.add(new Entry("UnitSold","销售数量"));
|
|
|
+ entries.add(new Entry("Sales","销售额"));
|
|
|
+ entries.add(new Entry("TaxAmount","综合税额"));
|
|
|
+ entries.add(new Entry("TotalSalesInclTax","总销售额"));
|
|
|
+ entries.add(new Entry("TaxRate","综合税率"));
|
|
|
+ entries.add(new Entry("GP1","预估毛利额"));
|
|
|
+ entries.add(new Entry("GP2","预估毛利率"));
|
|
|
+ entries.add(new Entry("ProductCategory","商品类型"));
|
|
|
+ entries.add(new Entry("SupplierName","主供应商名称"));
|
|
|
+ entries.add(new Entry("TransactionType","销售类型"));
|
|
|
+ entries.add(new Entry("SaleReturnType","退货类型"));
|
|
|
+ entries.add(new Entry("Remark","备注"));
|
|
|
+ return entries;
|
|
|
}
|
|
|
|
|
|
}
|