增加商品导入的功能

This commit is contained in:
季圣华
2019-01-05 21:33:01 +08:00
parent 8a4d034743
commit 2b7a7bbdeb
11 changed files with 311 additions and 7 deletions

View File

@@ -7,6 +7,8 @@ import com.jsh.erp.service.supplier.SupplierService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.ExcelUtils;
import com.jsh.erp.utils.ExportExecUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
@@ -14,6 +16,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -259,4 +264,67 @@ public class SupplierController {
}
return arr;
}
/**
* 生成excel表格
* @param supplier
* @param type
* @param phonenum
* @param telephone
* @param description
* @param request
* @param response
* @return
*/
@GetMapping(value = "/exportExcel")
public BaseResponseInfo exportExcel(@RequestParam("supplier") String supplier,
@RequestParam("type") String type,
@RequestParam("phonenum") String phonenum,
@RequestParam("telephone") String telephone,
@RequestParam("description") String description,
HttpServletRequest request, HttpServletResponse response) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try {
List<Supplier> dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description);
String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"};
String title = "信息报表";
List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) {
for (Supplier s : dataList) {
String[] objs = new String[17];
objs[0] = s.getSupplier();
objs[1] = s.getType();
objs[2] = s.getContacts();
objs[3] = s.getPhonenum();
objs[4] = s.getEmail();
objs[5] = s.getAdvancein() == null? "" : s.getAdvancein().toString();
objs[6] = s.getBeginneedget() == null? "" : s.getBeginneedget().toString();
objs[7] = s.getBeginneedpay() == null? "" : s.getBeginneedpay().toString();
objs[8] = s.getDescription();
objs[9] = s.getFax();
objs[10] = s.getTelephone();
objs[11] = s.getAddress();
objs[12] = s.getTaxnum();
objs[13] = s.getBankname();
objs[14] = s.getAccountnumber();
objs[15] = s.getTaxrate() == null? "" : s.getTaxrate().toString();
objs[16] = s.getEnabled() ? "启用" : "禁用";
objects.add(objs);
}
}
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
ExportExecUtil.showExec(file, file.getName(), response);
res.code = 200;
} catch (Exception e) {
e.printStackTrace();
message = "导出失败";
res.code = 500;
} finally {
map.put("message", message);
res.data = map;
}
return res;
}
}