xlsx导入bug修复,客户新增导出模块
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/ImportExcelUtil.java b/src/main/java/com/supwisdom/dlpay/framework/util/ImportExcelUtil.java
index a5eb64b..1ac4f4b 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/ImportExcelUtil.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/ImportExcelUtil.java
@@ -322,20 +322,22 @@
OPCPackage op = OPCPackage.open(excelFile);
XSSFWorkbook xwb = new XSSFWorkbook(op);
List<Object[][]> oList = new ArrayList<Object[][]>();
- for (int k = 0; k < xwb.getNumberOfSheets(); k++) {
- XSSFSheet sheet = xwb.getSheetAt(k);
- Iterator<Row> rows = sheet.rowIterator();
- int coloumNum = sheet.getRow(0).getPhysicalNumberOfCells();// get number of columns
- Object data[][] = new Object[sheet.getLastRowNum() + 1][coloumNum];
- while (rows.hasNext()) {
- XSSFRow row = (XSSFRow) rows.next();
- Iterator<Cell> cells = row.cellIterator();
- while (cells.hasNext()) {
- XSSFCell cell = (XSSFCell) cells.next();
+ // for (int k = 0; k < xwb.getNumberOfSheets(); k++) {
+ XSSFSheet sheet = xwb.getSheetAt(0);
+ Iterator<Row> rows = sheet.rowIterator();
+ int coloumNum = sheet.getRow(0).getPhysicalNumberOfCells();// get number of columns
+ Object data[][] = new Object[sheet.getLastRowNum() + 1][coloumNum];
+ while (rows.hasNext()) {
+ XSSFRow row = (XSSFRow) rows.next();
+ Iterator<Cell> cells = row.cellIterator();
+ while (cells.hasNext()) {
+ /* XSSFCell cell = (XSSFCell) cells.next();
for (int i = 0; i < 3; i++) {
cell.setCellType(XSSFCell.CELL_TYPE_STRING);
- }
- switch (cell.getCellType()) {
+ }*/
+ XSSFCell cell = (XSSFCell) cells.next();
+ cell.setCellType(XSSFCell.CELL_TYPE_STRING);
+ /*switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
if (100000000 < cell.getNumericCellValue()) {
double d = cell.getNumericCellValue();
@@ -364,11 +366,13 @@
default:
data[row.getRowNum()][cell.getColumnIndex()] = "";
break;
- }
- }
+ }*/
+ data[row.getRowNum()][cell.getColumnIndex()] = cell
+ .getStringCellValue();
}
- oList.add(data);
}
+ oList.add(data);
+ // }
return oList;
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
index 2ed7649..79a05ee 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
@@ -115,5 +115,13 @@
}
+ @RequestMapping("/export")
+ @ResponseBody
+ public JsonResult exportCustomerExcel(
+ HttpServletRequest request, HttpServletResponse response) {
+
+ return customerService.export( request, response);
+ }
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
index d0821d5..2ebc83d 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
@@ -11,6 +11,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface CustomerService {
@@ -28,4 +29,9 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
JsonResult importFile(MultipartFile file, HttpServletRequest request) throws Exception;
+
+
+ JsonResult export( HttpServletRequest request, HttpServletResponse response);
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
index b6360ac..2d1c455 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
@@ -2,10 +2,7 @@
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.framework.service.SystemUtilService;
-import com.supwisdom.dlpay.framework.util.DateUtil;
-import com.supwisdom.dlpay.framework.util.ImportExcelUtil;
-import com.supwisdom.dlpay.framework.util.PageResult;
-import com.supwisdom.dlpay.framework.util.StringUtil;
+import com.supwisdom.dlpay.framework.util.*;
import com.supwisdom.dlpay.restaurant.bean.CustomerSearchBean;
import com.supwisdom.dlpay.restaurant.dao.CardDao;
import com.supwisdom.dlpay.restaurant.dao.CardverDao;
@@ -23,10 +20,9 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
+import java.util.*;
@Service
@@ -181,5 +177,36 @@
return JsonResult.error(String.format(Locale.CHINESE, msg));
}
+ @Override
+ public JsonResult export(HttpServletRequest request, HttpServletResponse response) {
+ String[] titles0 = {"市民卡号", "姓名", "联系电话","银行卡号"
+ }; //表头
+ String fileName0 = "客户名单";// 保存数据
+ String[][] info0 = {{}};
+ List<TCustomer> dtl=customerDao.findAll();
+ Integer cnt=dtl.size();
+ if(cnt>0 ){
+ System.out.println("---init here---");
+ info0=new String[cnt][titles0.length];
+
+ for(int i=0;i<cnt;i++){
+ TCustomer t=dtl.get(i);
+ info0[i][0]=t.getCardno();
+ info0[i][1]=t.getCustname();
+ info0[i][2]=t.getPhone();
+ info0[i][3]=t.getBankcardno();
+
+ }
+ }
+
+ try {
+ ExportExcel.queryexcel(fileName0, titles0,info0,request, response);
+ return JsonResult.ok("操作成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return JsonResult.error("操作失败");
+ }
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
index 72efa0b..a19c528 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
@@ -209,7 +209,8 @@
if (null == excelData || excelData.size() < 1) {
throw new WebCheckException("excel文件解析错误");
}
- }catch (ArrayIndexOutOfBoundsException e){
+ }catch (Exception e){
+ e.printStackTrace();
throw new WebCheckException("模板格式错误,请重新下载模板");
}
diff --git a/src/main/resources/templates/restaurant/customer/index.html b/src/main/resources/templates/restaurant/customer/index.html
index 5f0040b..9ebbf2b 100644
--- a/src/main/resources/templates/restaurant/customer/index.html
+++ b/src/main/resources/templates/restaurant/customer/index.html
@@ -14,7 +14,7 @@
</button>
<button id="customer-btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加人员</button>
<button id="customer-btn-import" class="layui-btn icon-btn" ><i class="layui-icon"></i>批量导入</button>
-
+ <a id="customer-btn-export" href="javascript:void(0);" class="layui-btn layui-btn-primary" >导出</a>
</div>
<table class="layui-table" id="customer-table" lay-filter="customer-table"></table>
</div>
@@ -51,6 +51,15 @@
]
]
});
+ $('#customer-btn-export').click(function () {
+ var url = '[[@{/customer/export}]]';
+ /* $("#form").attr("action",url);
+
+ $("#form").submit();*/
+
+ $("#customer-btn-export").attr("href", url );
+ $("#customer-btn-export")[0].click();
+ });
// 搜索按钮点击事件
$('#customer-btn-search').click(function () {
let key = $('#customer-search-value').val().trim();
diff --git a/src/main/resources/templates/restaurant/devpara/devparabind.html b/src/main/resources/templates/restaurant/devpara/devparabind.html
index 51c8ce7..e2df2dc 100644
--- a/src/main/resources/templates/restaurant/devpara/devparabind.html
+++ b/src/main/resources/templates/restaurant/devpara/devparabind.html
@@ -73,7 +73,7 @@
var data = obj.data;
if('del' == obj.event){
- layer.confirm('确定要删除设备【'+data.devicename+'】绑定的参数组【'+data.groupname+'】吗?', {
+ layer.confirm('确定要删除设备绑定的参数组【'+data.groupname+'】吗?', {
btn: ['确定', '取消']
},function(){
layer.closeAll('dialog');
diff --git a/src/main/resources/templates/restaurant/discountrule/ruledevbind.html b/src/main/resources/templates/restaurant/discountrule/ruledevbind.html
index 10eefab..71cb26f 100644
--- a/src/main/resources/templates/restaurant/discountrule/ruledevbind.html
+++ b/src/main/resources/templates/restaurant/discountrule/ruledevbind.html
@@ -87,7 +87,7 @@
var data = obj.data;
if('del' == obj.event){
- layer.confirm('确定要删除设备【'+data.devicename+'】绑定的餐补规则【'+data.rulename+'】吗?', {
+ layer.confirm('确定要删除设备绑定的餐补规则【'+data.rulename+'】吗?', {
btn: ['确定', '取消']
},function(){
layer.closeAll('dialog');
diff --git a/src/main/resources/templates/restaurant/discountrule/ruleform.html b/src/main/resources/templates/restaurant/discountrule/ruleform.html
index 175f81c..f9e0fc5 100644
--- a/src/main/resources/templates/restaurant/discountrule/ruleform.html
+++ b/src/main/resources/templates/restaurant/discountrule/ruleform.html
@@ -172,8 +172,7 @@
layer.msg("请选择餐补名单", {icon: 2, time: 1500});
return;
}
- console.log(formData);
-
+ layer.load(2);
$.ajax({
type: "POST",
url: '[[@{/discountrule/addrule}]]',