|
|
@@ -0,0 +1,121 @@
|
|
|
+package com.goafanti.common.controller;
|
|
|
+
|
|
|
+import com.goafanti.admin.service.AdminService;
|
|
|
+import com.goafanti.admin.service.AttachmentService;
|
|
|
+import com.goafanti.common.bo.Error;
|
|
|
+import com.goafanti.common.bo.OutUser;
|
|
|
+import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.AFTConstants;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.dao.TOrderMidMapper;
|
|
|
+import com.goafanti.common.enums.UserType;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.service.DistrictGlossoryService;
|
|
|
+import com.goafanti.common.service.IndustryCategoryService;
|
|
|
+import com.goafanti.common.utils.*;
|
|
|
+import com.goafanti.common.utils.excel.FileUtils;
|
|
|
+import com.goafanti.common.utils.excel.NewExcelUtil;
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import com.goafanti.core.websocket.SystemWebSocketHandler;
|
|
|
+import com.goafanti.order.service.OrderProjectService;
|
|
|
+import com.goafanti.user.service.UserService;
|
|
|
+import org.apache.commons.collections4.map.HashedMap;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.context.annotation.Scope;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+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 org.springframework.web.socket.TextMessage;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/open")
|
|
|
+public class TestPublicController extends CertifyApiController {
|
|
|
+
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String uploadPath = null;
|
|
|
+
|
|
|
+ private String targePath ="F:/data/public/upload/new_order_file";
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("/pushOrder")
|
|
|
+ public Result pushOrder() {
|
|
|
+ Result res= new Result();
|
|
|
+ // 源文件夹路径(存放图片路径)
|
|
|
+ String url=uploadPath+"/order_file/19e76b19-7db5-41e6-b75d-80c0fe20a35c/20719309158800.jpg";
|
|
|
+ String name=url.substring(url.lastIndexOf("/"),url.length());
|
|
|
+ String targeUrl=targePath+name;
|
|
|
+ //目标文件夹路径(没有会自动创建)
|
|
|
+ File targetFile = new File(targePath);
|
|
|
+ File srcFile = new File(url);
|
|
|
+ File destFile = new File(targeUrl);
|
|
|
+ if (!targetFile.exists()){
|
|
|
+ targetFile.mkdir();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ copyFile(srcFile,destFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static String SUFFIX = null;
|
|
|
+
|
|
|
+ private static void moveFile2(File sourceFile,File targetFile) {
|
|
|
+ //该方法为复制文件,sourceFile源文件夹路径(存放图片路径), targetFile是目标文件夹路径(没有会自动创建)
|
|
|
+ File[] fileArray1 = sourceFile.listFiles();
|
|
|
+ File[] fileArray2 = targetFile.listFiles();
|
|
|
+ for (File file : fileArray1) {
|
|
|
+// SUFFIX用于判断指定图片是否存在,如果存在就不移动并且输出“文件已存在”
|
|
|
+ if (file.getName().contentEquals(SUFFIX)) {
|
|
|
+ targetFile = new File( targetFile + "\\"+file.getName());
|
|
|
+ if (targetFile.exists()) {
|
|
|
+ System.out.println("文件已存在");
|
|
|
+ } else {
|
|
|
+ file.renameTo(targetFile);
|
|
|
+ System.out.println("移动文件成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static void copyFile(File srcFile,File destFile) throws IOException {
|
|
|
+ //该方法为复制文件,srcFile是原文件所在地址,destFile是目标文件所在地址
|
|
|
+
|
|
|
+ File[] fileArray1 = srcFile.listFiles();
|
|
|
+ File[] fileArray2 = destFile.listFiles();
|
|
|
+
|
|
|
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile));
|
|
|
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destFile));
|
|
|
+ byte[] bys = new byte[1024];
|
|
|
+ int len = 0;
|
|
|
+ while ((len = bis.read(bys)) != -1)
|
|
|
+ {
|
|
|
+ bos.write(bys, 0, len);
|
|
|
+ }
|
|
|
+ bos.close();
|
|
|
+ bis.close();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|