Sfoglia il codice sorgente

呵呵商城改版part8

Aslee 3 anni fa
parent
commit
0a42a77fd7

+ 1 - 0
src/main/java/com/caimei/modules/archive/service/CmOrderArchiveService.java

@@ -235,6 +235,7 @@ public class CmOrderArchiveService extends CrudService<CmOrderArchiveDao, CmOrde
         return result;
     }
 
+    @Transactional(readOnly = false)
     public String resetArchiveNo() {
         List<CmOrderArchive> orderArchiveList = findList(new CmOrderArchive());
         orderArchiveList.forEach(cmOrderArchive->{

+ 24 - 1
src/main/java/com/caimei/modules/hehe/service/HeHeNewOrderService.java

@@ -363,7 +363,30 @@ public class HeHeNewOrderService extends CrudService<HeHeNewOrderDao, NewOrder>
                         productSheet.addMergedRegion(new CellRangeAddress(startRowNum, productRowNum - 1, i, i));
                     }
                 }
-
+            }
+            // 让列宽随着导出的列长自动适应
+            for (int colNum = 0; colNum< 9; colNum++) {
+                int productColumnWidth = productSheet.getColumnWidth(colNum) / 256;
+                for (int rowNum = 0; rowNum < productSheet.getLastRowNum(); rowNum++) {
+                    HSSFRow currentRow;
+                    // 当前行未被使用过
+                    if (productSheet.getRow(rowNum) == null) {
+                        currentRow = productSheet.createRow(rowNum);
+                    } else {
+                        currentRow = productSheet.getRow(rowNum);
+                    }
+                    if (currentRow.getCell(colNum) != null) {
+                        HSSFCell currentCell = currentRow.getCell(colNum);
+                        if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
+                            int length = currentCell.getStringCellValue()
+                                    .getBytes().length;
+                            if (productColumnWidth < length) {
+                                productColumnWidth = length;
+                            }
+                        }
+                    }
+                }
+                productSheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
             }
             outputStream.flush();
             workbook.write(outputStream);

+ 3 - 6
src/main/java/com/caimei/modules/hehe/web/HeHeNewOrderController.java

@@ -32,6 +32,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -249,14 +250,10 @@ public class HeHeNewOrderController extends BaseController {
 
     @RequestMapping(value = "batchExportOrder")
     @ResponseBody
-    public String batchExportOrder(NewOrder order, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) {
+    public String batchExportOrder(NewOrder order, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
         //获取订单数据
-        String fileName = "呵呵订单.xls";
-        String template = Global.getConfig("export.template");
-        String templateFileName = template + "/hehe_order_export.xls";
-        List<String> listSheetNames = new ArrayList<String>();
+        String fileName = new String("呵呵订单.xls".getBytes("UTF-8"),"iso-8859-1");
         // 表格数据
-        ArrayList<List> objects = new ArrayList<List>();
         if (null != order.getStartTime() && !"".equals(order.getStartTime()) && !order.getStartTime().endsWith("00:00:00")) {
             order.setStartTime(order.getStartTime() + " 00:00:00");
         }

+ 0 - 1
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderList.jsp

@@ -664,7 +664,6 @@
         };
 
         function orderExport() {
-            debugger
             var searchForm = $("#searchForm");
             searchForm.attr('action', '${ctx}/hehe/new/order/batchExportOrder');
             searchForm.submit();