增加供应商的导入功能
This commit is contained in:
@@ -160,7 +160,7 @@
|
|||||||
<!-- 导入excel表格 -->
|
<!-- 导入excel表格 -->
|
||||||
<div id="importExcelDlg" style="padding:10px 20px">
|
<div id="importExcelDlg" style="padding:10px 20px">
|
||||||
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
||||||
action="/supplier/importExcelCustomer.action">
|
action="/supplier/importExcelCustomer">
|
||||||
<div class="fitem" style="padding:5px">
|
<div class="fitem" style="padding:5px">
|
||||||
<label>文件名称 </label>
|
<label>文件名称 </label>
|
||||||
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
||||||
@@ -175,7 +175,6 @@
|
|||||||
<option value="1" selected="selected">否</option>
|
<option value="1" selected="selected">否</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="clientIp" id="clientIp" value="<%=clientIp %>"/>
|
|
||||||
<div id="dlg-buttons5">
|
<div id="dlg-buttons5">
|
||||||
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
||||||
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
<!-- 导入excel表格 -->
|
<!-- 导入excel表格 -->
|
||||||
<div id="importExcelDlg" style="padding:10px 20px">
|
<div id="importExcelDlg" style="padding:10px 20px">
|
||||||
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
||||||
action="/supplier/importExcelMember.action">
|
action="/supplier/importExcelMember">
|
||||||
<div class="fitem" style="padding:5px">
|
<div class="fitem" style="padding:5px">
|
||||||
<label>文件名称 </label>
|
<label>文件名称 </label>
|
||||||
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
||||||
@@ -175,7 +175,6 @@
|
|||||||
<option value="1" selected="selected">否</option>
|
<option value="1" selected="selected">否</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="clientIp" id="clientIp" value="<%=clientIp %>"/>
|
|
||||||
<div id="dlg-buttons5">
|
<div id="dlg-buttons5">
|
||||||
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
||||||
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
<!-- 导入excel表格 -->
|
<!-- 导入excel表格 -->
|
||||||
<div id="importExcelDlg" style="padding:10px 20px">
|
<div id="importExcelDlg" style="padding:10px 20px">
|
||||||
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
<form id="importExcelFM" method="post" enctype="multipart/form-data"
|
||||||
action="/supplier/importExcelVendor.action">
|
action="/supplier/importExcelVendor">
|
||||||
<div class="fitem" style="padding:5px">
|
<div class="fitem" style="padding:5px">
|
||||||
<label>文件名称 </label>
|
<label>文件名称 </label>
|
||||||
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
<input name="supplierFile" id="supplierFile" type="file" style="width: 230px;height: 20px"/>
|
||||||
@@ -175,7 +175,6 @@
|
|||||||
<option value="1" selected="selected">否</option>
|
<option value="1" selected="selected">否</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="clientIp" id="clientIp" value="<%=clientIp %>"/>
|
|
||||||
<div id="dlg-buttons5">
|
<div id="dlg-buttons5">
|
||||||
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
<a href="javascript:void(0)" id="saveimport" class="easyui-linkbutton" iconCls="icon-ok">导入</a>
|
||||||
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
<a href="javascript:void(0)" id="cancelimport" class="easyui-linkbutton" iconCls="icon-cancel"
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.jsh.erp.datasource.entities.Supplier;
|
import com.jsh.erp.datasource.entities.Supplier;
|
||||||
import com.jsh.erp.service.supplier.SupplierService;
|
import com.jsh.erp.service.supplier.SupplierService;
|
||||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
import com.jsh.erp.utils.BaseResponseInfo;
|
import com.jsh.erp.utils.*;
|
||||||
import com.jsh.erp.utils.ErpInfo;
|
import jxl.Sheet;
|
||||||
import com.jsh.erp.utils.ExcelUtils;
|
import jxl.Workbook;
|
||||||
import com.jsh.erp.utils.ExportExecUtil;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -327,4 +327,108 @@ public class SupplierController {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入excel表格-供应商
|
||||||
|
* @param supplierFile
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/importExcelVendor")
|
||||||
|
public void importExcelVendor(MultipartFile supplierFile,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||||
|
importFun(supplierFile);
|
||||||
|
response.sendRedirect("../pages/manage/vendor.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入excel表格-客户
|
||||||
|
* @param supplierFile
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/importExcelCustomer")
|
||||||
|
public void importExcelCustomer(MultipartFile supplierFile,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||||
|
importFun(supplierFile);
|
||||||
|
response.sendRedirect("../pages/manage/customer.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入excel表格-会员
|
||||||
|
* @param supplierFile
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/importExcelMember")
|
||||||
|
public void importExcelMember(MultipartFile supplierFile,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||||
|
importFun(supplierFile);
|
||||||
|
response.sendRedirect("../pages/manage/member.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String importFun(MultipartFile supplierFile){
|
||||||
|
BaseResponseInfo info = new BaseResponseInfo();
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>();
|
||||||
|
String message = "成功";
|
||||||
|
try {
|
||||||
|
Sheet src = null;
|
||||||
|
//文件合法性校验
|
||||||
|
try {
|
||||||
|
Workbook workbook = Workbook.getWorkbook(supplierFile.getInputStream());
|
||||||
|
src = workbook.getSheet(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
message = "导入文件不合法,请检查";
|
||||||
|
data.put("message", message);
|
||||||
|
info.code = 400;
|
||||||
|
info.data = data;
|
||||||
|
}
|
||||||
|
//读取所有的摄像机编码
|
||||||
|
//每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"
|
||||||
|
List<Supplier> sList = new ArrayList<Supplier>();
|
||||||
|
for (int i = 1; i < src.getRows(); i++) {
|
||||||
|
Supplier s = new Supplier();
|
||||||
|
s.setSupplier(ExcelUtils.getContent(src, i, 0));
|
||||||
|
s.setType(ExcelUtils.getContent(src, i, 1));
|
||||||
|
s.setContacts(ExcelUtils.getContent(src, i, 2));
|
||||||
|
s.setPhonenum(ExcelUtils.getContent(src, i, 3));
|
||||||
|
s.setEmail(ExcelUtils.getContent(src, i, 4));
|
||||||
|
s.setAdvancein(parseDoubleEx(ExcelUtils.getContent(src, i, 5)));
|
||||||
|
s.setBeginneedget(parseDoubleEx(ExcelUtils.getContent(src, i, 6)));
|
||||||
|
s.setBeginneedpay(parseDoubleEx(ExcelUtils.getContent(src, i, 7)));
|
||||||
|
s.setDescription(ExcelUtils.getContent(src, i, 8));
|
||||||
|
s.setFax(ExcelUtils.getContent(src, i, 9));
|
||||||
|
s.setTelephone(ExcelUtils.getContent(src, i, 10));
|
||||||
|
s.setAddress(ExcelUtils.getContent(src, i, 11));
|
||||||
|
s.setTaxnum(ExcelUtils.getContent(src, i, 12));
|
||||||
|
s.setBankname(ExcelUtils.getContent(src, i, 13));
|
||||||
|
s.setAccountnumber(ExcelUtils.getContent(src, i, 14));
|
||||||
|
s.setTaxrate(parseDoubleEx(ExcelUtils.getContent(src, i, 15)));
|
||||||
|
String enabled = ExcelUtils.getContent(src, i, 16);
|
||||||
|
s.setIsystem(Byte.parseByte("1"));
|
||||||
|
s.setEnabled(enabled.equals("启用")? true: false);
|
||||||
|
sList.add(s);
|
||||||
|
}
|
||||||
|
info = supplierService.importExcel(sList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
message = "导入失败";
|
||||||
|
info.code = 500;
|
||||||
|
data.put("message", message);
|
||||||
|
info.data = data;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double parseDoubleEx(String str){
|
||||||
|
if(!StringUtil.isEmpty(str)) {
|
||||||
|
return Double.parseDouble(str);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,5 @@ public class MaterialService {
|
|||||||
}
|
}
|
||||||
info.data = data;
|
info.data = data;
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.jsh.erp.datasource.entities.Supplier;
|
import com.jsh.erp.datasource.entities.Supplier;
|
||||||
import com.jsh.erp.datasource.entities.SupplierExample;
|
import com.jsh.erp.datasource.entities.SupplierExample;
|
||||||
import com.jsh.erp.datasource.mappers.SupplierMapper;
|
import com.jsh.erp.datasource.mappers.SupplierMapper;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -11,7 +12,9 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SupplierService {
|
public class SupplierService {
|
||||||
@@ -120,4 +123,22 @@ public class SupplierService {
|
|||||||
public List<Supplier> findByAll(String supplier, String type, String phonenum, String telephone, String description) {
|
public List<Supplier> findByAll(String supplier, String type, String phonenum, String telephone, String description) {
|
||||||
return supplierMapper.findByAll(supplier, type, phonenum, telephone, description);
|
return supplierMapper.findByAll(supplier, type, phonenum, telephone, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseResponseInfo importExcel(List<Supplier> mList) throws Exception {
|
||||||
|
BaseResponseInfo info = new BaseResponseInfo();
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
for(Supplier s: mList) {
|
||||||
|
supplierMapper.insertSelective(s);
|
||||||
|
}
|
||||||
|
info.code = 200;
|
||||||
|
data.put("message", "成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
info.code = 500;
|
||||||
|
data.put("message", e.getMessage());
|
||||||
|
}
|
||||||
|
info.data = data;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user