|
@@ -1,20 +1,31 @@
|
|
|
package com.jpsoft.employment.modules.base.controller;
|
|
package com.jpsoft.employment.modules.base.controller;
|
|
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
+import com.jpsoft.employment.config.OSSConfig;
|
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.OSSUtil;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.POIUtils;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
import com.jpsoft.employment.modules.base.entity.EnterpriseInfo;
|
|
import com.jpsoft.employment.modules.base.entity.EnterpriseInfo;
|
|
|
import com.jpsoft.employment.modules.base.service.EnterpriseInfoService;
|
|
import com.jpsoft.employment.modules.base.service.EnterpriseInfoService;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.ibatis.mapping.ResultMap;
|
|
import org.apache.ibatis.mapping.ResultMap;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
@@ -25,11 +36,14 @@ public class EnterpriseInfoController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EnterpriseInfoService enterpriseInfoService;
|
|
private EnterpriseInfoService enterpriseInfoService;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @ApiOperation(value="创建空记录")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
|
- public MessageResult<EnterpriseInfo> create(){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> create() {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
|
|
EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
|
|
@@ -40,14 +54,14 @@ public class EnterpriseInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="添加信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
@PostMapping("add")
|
|
@PostMapping("add")
|
|
|
- public MessageResult<EnterpriseInfo> add(@RequestBody EnterpriseInfo enterpriseInfo,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> add(@RequestBody EnterpriseInfo enterpriseInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
enterpriseInfo.setId(UUID.randomUUID().toString());
|
|
enterpriseInfo.setId(UUID.randomUUID().toString());
|
|
|
- enterpriseInfo.setDelFlag(false);
|
|
|
|
|
|
|
+ enterpriseInfo.setDelFlag(false);
|
|
|
enterpriseInfo.setCreateBy(subject);
|
|
enterpriseInfo.setCreateBy(subject);
|
|
|
enterpriseInfo.setCreateTime(new Date());
|
|
enterpriseInfo.setCreateTime(new Date());
|
|
|
enterpriseInfo.setStatus("0");
|
|
enterpriseInfo.setStatus("0");
|
|
@@ -61,9 +75,8 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库添加失败");
|
|
msgResult.setMessage("数据库添加失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -72,9 +85,9 @@ public class EnterpriseInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="获取信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
@GetMapping("edit/{id}")
|
|
|
- public MessageResult<EnterpriseInfo> edit(@PathVariable("id") String id){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> edit(@PathVariable("id") String id) {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -87,9 +100,8 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -98,15 +110,15 @@ public class EnterpriseInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="更新用户")
|
|
|
|
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
|
- public MessageResult<EnterpriseInfo> update(@RequestBody EnterpriseInfo enterpriseInfo,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> update(@RequestBody EnterpriseInfo enterpriseInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- enterpriseInfo.setUpdateBy(subject);
|
|
|
|
|
|
|
+ enterpriseInfo.setUpdateBy(subject);
|
|
|
enterpriseInfo.setUpdateTime(new Date());
|
|
enterpriseInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int affectCount = enterpriseInfoService.update(enterpriseInfo);
|
|
int affectCount = enterpriseInfoService.update(enterpriseInfo);
|
|
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
@@ -116,9 +128,8 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库更新失败");
|
|
msgResult.setMessage("数据库更新失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -127,19 +138,19 @@ public class EnterpriseInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
|
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
@PostMapping("delete/{id}")
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<EnterpriseInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
-
|
|
|
|
|
- EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(id);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(id);
|
|
|
enterpriseInfo.setDelFlag(true);
|
|
enterpriseInfo.setDelFlag(true);
|
|
|
enterpriseInfo.setUpdateBy(subject);
|
|
enterpriseInfo.setUpdateBy(subject);
|
|
|
enterpriseInfo.setUpdateTime(new Date());
|
|
enterpriseInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
|
|
- int affectCount = enterpriseInfoService.update(enterpriseInfo);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = enterpriseInfoService.update(enterpriseInfo);
|
|
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
@@ -147,9 +158,8 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库删除失败");
|
|
msgResult.setMessage("数据库删除失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -159,9 +169,9 @@ public class EnterpriseInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="批量删除")
|
|
|
|
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -183,9 +193,8 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
msgResult.setMessage("删除失败");
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -194,31 +203,31 @@ public class EnterpriseInfoController {
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
|
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
public MessageResult<Map> pageList(
|
|
|
String name,
|
|
String name,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
|
- HttpServletRequest request){
|
|
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
|
|
+ HttpServletRequest request) {
|
|
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
|
|
//当前用户ID
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
System.out.println(subject);
|
|
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
|
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
|
- searchParams.put("name","%" + name + "%");
|
|
|
|
|
|
|
+ searchParams.put("name", "%" + name + "%");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- Page<EnterpriseInfo> page = enterpriseInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
|
+ Page<EnterpriseInfo> page = enterpriseInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
|
|
|
|
|
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
@@ -228,12 +237,11 @@ public class EnterpriseInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
|
|
- @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
|
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
|
|
+ @RequestMapping(value = "list", method = RequestMethod.POST)
|
|
|
public MessageResult<List<EnterpriseInfo>> list(
|
|
public MessageResult<List<EnterpriseInfo>> list(
|
|
|
- HttpServletRequest request){
|
|
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
|
+ HttpServletRequest request) {
|
|
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
|
|
//当前用户ID
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
System.out.println(subject);
|
|
@@ -249,9 +257,9 @@ public class EnterpriseInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="审核信息")
|
|
|
|
|
|
|
+ @ApiOperation(value = "审核信息")
|
|
|
@PostMapping("check/{id}")
|
|
@PostMapping("check/{id}")
|
|
|
- public MessageResult<EnterpriseInfo> check(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
|
|
|
+ public MessageResult<EnterpriseInfo> check(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
MessageResult<EnterpriseInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -269,9 +277,91 @@ public class EnterpriseInfoController {
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库认证失败");
|
|
msgResult.setMessage("数据库认证失败");
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
}
|
|
}
|
|
|
- catch(Exception ex){
|
|
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "导入企业")
|
|
|
|
|
+ @PostMapping("importXls")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "uploadFile", value = "上传文件", required = true, paramType = "form", dataType = "__file")
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult<String> importXls(MultipartFile uploadFile, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
|
|
|
|
|
+ int sheetIndex = 0;
|
|
|
|
|
+ Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = 0;
|
|
|
|
|
+ int failCount = 0;
|
|
|
|
|
+ int validateColIndex = 4;
|
|
|
|
|
+
|
|
|
|
|
+ int count = sheet1.getLastRowNum();
|
|
|
|
|
+
|
|
|
|
|
+ for (int rowIndex = 1; rowIndex <= count; rowIndex++) {
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ String name = poiUtils.getCellValue(sheetIndex, rowIndex, 0).toString().replace(" ", "");
|
|
|
|
|
+ String address = poiUtils.getCellValue(sheetIndex, rowIndex, 1).toString().replace(" ", "");
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isEmpty(name)) {
|
|
|
|
|
+ sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未填写企业名称!");
|
|
|
|
|
+ failCount++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //企业
|
|
|
|
|
+ EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
|
|
|
|
|
+ enterpriseInfo.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ enterpriseInfo.setName(name);
|
|
|
|
|
+ enterpriseInfo.setAddress(address);
|
|
|
|
|
+ enterpriseInfo.setStatus("0");
|
|
|
|
|
+ enterpriseInfo.setCreateBy(subject);
|
|
|
|
|
+ enterpriseInfo.setCreateTime(new Date());
|
|
|
|
|
+ enterpriseInfo.setDelFlag(false);
|
|
|
|
|
+
|
|
|
|
|
+ //保存新企业
|
|
|
|
|
+ enterpriseInfoService.insert(enterpriseInfo);
|
|
|
|
|
+ affectCount++;
|
|
|
|
|
+ } catch (Exception innerEx) {
|
|
|
|
|
+ logger.error(innerEx.getMessage(), innerEx);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (failCount > 0) {
|
|
|
|
|
+ //有导入失败的记录
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
|
|
|
|
|
+
|
|
|
|
|
+ //todo 只保留错误数据的sheet
|
|
|
|
|
+ Workbook wb = poiUtils.exportErrorXls(sheetIndex, validateColIndex, 1 + affectCount + failCount);
|
|
|
|
|
+
|
|
|
|
|
+ //todo 将wb保存到oss
|
|
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
|
+ wb.write(output);
|
|
|
|
|
+
|
|
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
|
+
|
|
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
|
|
|
|
|
+
|
|
|
|
|
+ //todo 返回导入失败报表下载链接
|
|
|
|
|
+ msgResult.setData(downloadUrl);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setMessage("数据成功导入" + affectCount + "条");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|