|
@@ -1,42 +1,36 @@
|
|
|
package org.jeecg.modules.projectImportList.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
-import org.jeecg.modules.projectImportList.entity.ProjectImportList;
|
|
|
-import org.jeecg.modules.projectImportList.service.IProjectImportListService;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
-import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
-import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
-import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.config.JeecgBaseConfig;
|
|
|
+import org.jeecg.modules.projectChbZyf.entity.ProjectChbZyf;
|
|
|
+import org.jeecg.modules.projectChbZyf.service.IProjectChbZyfService;
|
|
|
+import org.jeecg.modules.projectImportList.entity.ProjectImportList;
|
|
|
+import org.jeecg.modules.projectImportList.service.IProjectImportListService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.StreamUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
|
|
- /**
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+/**
|
|
|
* @Description: 导入并下载
|
|
|
* @Author: jeecg-boot
|
|
|
* @Date: 2023-08-10
|
|
@@ -49,7 +43,93 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
public class ProjectImportListController extends JeecgController<ProjectImportList, IProjectImportListService> {
|
|
|
@Autowired
|
|
|
private IProjectImportListService projectImportListService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IProjectChbZyfService zyfService;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private JeecgBaseConfig jeecgBaseConfig;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@RequiresPermissions("kzks_project_import_list:importExcel")
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ return super.importExcel(request, response, ProjectImportList.class);
|
|
|
+ }
|
|
|
+
|
|
|
+// public InputStream getFileStream(String strUrl) {
|
|
|
+// InputStream inputStream = null;
|
|
|
+// try {
|
|
|
+// URL httpUrl = new URL(strUrl);
|
|
|
+// HttpURLConnection httpURLConnection = (HttpURLConnection) httpUrl.openConnection();
|
|
|
+// httpURLConnection.setConnectTimeout(1000 * 3);
|
|
|
+// httpURLConnection.setReadTimeout(1000 * 20);
|
|
|
+// httpURLConnection.connect();
|
|
|
+// inputStream = httpURLConnection.getInputStream();
|
|
|
+// byte[] in = StreamUtils.copyToByteArray(inputStream);
|
|
|
+// return new ByteArrayInputStream(in);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error(e.getMessage(), e);
|
|
|
+//// throw new ApplicationException(10086, "获取文件内容失败,请重新上传");
|
|
|
+// } finally {
|
|
|
+// if (inputStream != null) {
|
|
|
+// try {
|
|
|
+// inputStream.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// log.error("inputStream.close", e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入其他表的数据
|
|
|
+ *项目预算 1
|
|
|
+ *外协费 2
|
|
|
+ *事务费 3
|
|
|
+ *专用费 4
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="导入并解析数据——专用费4", notes="导入并解析数据——专用费4")
|
|
|
+ @RequestMapping(value = "/importOtherExcel", method = RequestMethod.POST)
|
|
|
+// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)//
|
|
|
+ public Result<?> importOtherExcel(@RequestBody ProjectImportList projectImportList,HttpServletRequest request, HttpServletResponse response) {
|
|
|
+
|
|
|
+ Result<?> result = new Result<>();
|
|
|
+ result.setCode(500);
|
|
|
+ result.setMessage("请选择正确的导入类型!");
|
|
|
+
|
|
|
+ System.out.println(projectImportList.getFileType());
|
|
|
+
|
|
|
+// String url = "D:/opt/upFiles/" +
|
|
|
+
|
|
|
+ String url = jeecgBaseConfig.getPath().getUpload() + "/"+ projectImportList.getFileAddress();
|
|
|
+
|
|
|
+// MultipartFile file = new
|
|
|
+ return zyfService.importExcel1(url, ProjectChbZyf.class);
|
|
|
+
|
|
|
+// if(projectImportList.getFileType().equals("1")){
|
|
|
+// return result;
|
|
|
+// }else if(projectImportList.getFileType().equals("2")){
|
|
|
+// return result;
|
|
|
+// }else if(projectImportList.getFileType().equals("3")){
|
|
|
+// return result;
|
|
|
+// }else if(projectImportList.getFileType().equals("4")){
|
|
|
+// return zyfService.importExcel1(request, response, ProjectChbZyf.class);
|
|
|
+// }else {
|
|
|
+// return result;
|
|
|
+// }
|
|
|
+// return zyfService.importExcel1(request, response, ProjectChbZyf.class);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -71,7 +151,7 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
IPage<ProjectImportList> pageList = projectImportListService.page(page, queryWrapper);
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
@@ -86,7 +166,7 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
projectImportListService.save(projectImportList);
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 编辑
|
|
|
*
|
|
@@ -101,7 +181,7 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
projectImportListService.updateById(projectImportList);
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 通过id删除
|
|
|
*
|
|
@@ -116,7 +196,7 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
projectImportListService.removeById(id);
|
|
|
return Result.OK("删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除
|
|
|
*
|
|
@@ -131,7 +211,7 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
this.projectImportListService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
return Result.OK("批量删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 通过id查询
|
|
|
*
|
|
@@ -161,17 +241,6 @@ public class ProjectImportListController extends JeecgController<ProjectImportLi
|
|
|
return super.exportXls(request, projectImportList, ProjectImportList.class, "导入并下载");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@RequiresPermissions("kzks_project_import_list:importExcel")
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- return super.importExcel(request, response, ProjectImportList.class);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|