|
@@ -4,15 +4,26 @@ import com.bjlt.spider.entity.OaAccount;
|
|
|
import com.bjlt.spider.table.service.OaAccountService;
|
|
|
import com.bjlt.spider.util.RespEntity;
|
|
|
import com.bjlt.spider.utils.LayuiTableRespEntity;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.sun.tools.internal.ws.processor.model.Model;
|
|
|
+import jxl.Sheet;
|
|
|
+import jxl.Workbook;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.junit.platform.commons.logging.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.logging.Logger;
|
|
|
|
|
|
@RequestMapping(value = "/oaAccount")
|
|
|
@Slf4j
|
|
@@ -60,4 +71,52 @@ public class OaAccountController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ /*@RequestMapping("/greeting")
|
|
|
+ public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ return "greeting";
|
|
|
+ }*/
|
|
|
+ private static final Logger logger = (Logger) LoggerFactory.getLogger(OaAccountController.class);
|
|
|
+ //文件上传相关代码
|
|
|
+ @RequestMapping(value = "upload")
|
|
|
+ @ResponseBody
|
|
|
+ public String upload(@RequestParam("test") MultipartFile file) {
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return "文件为空";
|
|
|
+ }
|
|
|
+ // 获取文件名
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ logger.info("上传的文件名为:" + fileName);
|
|
|
+ // 获取文件的后缀名
|
|
|
+ String suffixName = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+ logger.info("上传的后缀名为:" + suffixName);
|
|
|
+ // 文件上传后的路径
|
|
|
+ String filePath = "D://test//";
|
|
|
+ // 解决中文问题,liunx下中文路径,图片显示问题
|
|
|
+ // fileName = UUID.randomUUID() + suffixName;
|
|
|
+ File dest = new File(filePath + fileName);
|
|
|
+ // 检测是否存在目录
|
|
|
+ if (!dest.getParentFile().exists()) {
|
|
|
+ dest.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ file.transferTo(dest);
|
|
|
+ return "上传成功";
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "上传失败";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|