Przeglądaj źródła

阿米巴支付先不开发

anderx 3 lat temu
rodzic
commit
5528bf96af

+ 101 - 41
src/main/java/com/goafanti/common/controller/TestPublicController.java

@@ -20,6 +20,7 @@ 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.fragment.service.FragmentService;
 import com.goafanti.order.service.OrderProjectService;
 import com.goafanti.user.service.UserService;
 import org.apache.commons.collections4.map.HashedMap;
@@ -28,11 +29,14 @@ 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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 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.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -53,21 +57,63 @@ public class TestPublicController extends CertifyApiController {
     @Value(value = "${upload.path}")
     private String		uploadPath			= null;
 
-    private String		targePath			="F:/data/public/upload/";
+    private String		targePath			="F:/data/public/upload/new_order_file/";
 
     @Autowired
     private TOrderNewMapper tOrderNewMapper;
 
 
-    @RequestMapping("/pushOrder")
+    private static final Logger logger	= LoggerFactory.getLogger(TestPublicController.class);
+
+    @RequestMapping("/pushOrderList")
+    @Transactional
     public Result pushOrder() {
       Result res= new Result();
         List<TOrderNew> list = tOrderNewMapper.selectgetAll();
         for (TOrderNew t : list) {
-            TOrderNew neworder=new TOrderNew();
-            neworder.setOrderNo(t.getOrderNo());
+            if (StringUtils.isNotBlank(t.getContractPictureUrl())||
+                    StringUtils.isNotBlank(t.getAgreementUrl())||
+                    StringUtils.isNotBlank(t.getServiceContent())){
+                TOrderNew neworder=new TOrderNew();
+                neworder.setOrderNo(t.getOrderNo());
+                try {
+                    if (StringUtils.isNotBlank(t.getContractPictureUrl())){
+                        String str= null;
+                        str = moveImg(t.getContractPictureUrl(),t.getOrderNo(),0,uploadPath);
+                        neworder.setContractPictureUrl(str);
+                    }
+                    if (StringUtils.isNotBlank(t.getAgreementUrl())){
+                        String str=moveImg(t.getAgreementUrl(),t.getOrderNo(),1,uploadPath);
+                        neworder.setAgreementUrl(str);
+                    }
+                    if (StringUtils.isNotBlank(t.getServiceContent())){
+                        String str=moveImg(t.getServiceContent(),t.getOrderNo(),2,uploadPath);
+                        neworder.setServiceContent(str);
+                    }
+                } catch (IOException e) {
+                    if (t.getOrderNo().equals("706517544638255104")){
+                        logger.debug(t.getContractPictureUrl());
+                        logger.debug("订单编号["+t.getOrderNo()+"]移动异常...\\n"+e.getLocalizedMessage());
+                    }
+
+                    continue;
+                }
+                tOrderNewMapper.updateByPrimaryKeySelective(neworder);
+            }
+        }
+        return res;
+    }
+
+    @RequestMapping(value = "/pushOrder" ,method = RequestMethod.GET)
+    public Result pushOrder(String orderNo) {
+        Result res= new Result();
+        TOrderNew t = tOrderNewMapper.selectByPrimaryKey(orderNo);
+        TOrderNew neworder=new TOrderNew();
+        neworder.setOrderNo(t.getOrderNo());
+        try {
             if (StringUtils.isNotBlank(t.getContractPictureUrl())){
-                String str=moveImg(t.getContractPictureUrl(),t.getOrderNo(),0,uploadPath);
+                String str= null;
+                    str = moveImg(t.getContractPictureUrl(),t.getOrderNo(),0,uploadPath);
                 neworder.setContractPictureUrl(str);
             }
             if (StringUtils.isNotBlank(t.getAgreementUrl())){
@@ -78,8 +124,10 @@ public class TestPublicController extends CertifyApiController {
                 String str=moveImg(t.getServiceContent(),t.getOrderNo(),2,uploadPath);
                 neworder.setServiceContent(str);
             }
-            tOrderNewMapper.updateByPrimaryKeySelective(neworder);
+        } catch (IOException e) {
+            e.printStackTrace();
         }
+        tOrderNewMapper.updateByPrimaryKeySelective(neworder);
         return res;
     }
 
@@ -91,11 +139,17 @@ public class TestPublicController extends CertifyApiController {
      * @param uploadPath
      * @return
      */
-    private static String moveImg(String attURL ,String orderNo,Integer i,String uploadPath) {
+
+    private static String moveImg(String attURL ,String orderNo,Integer i,String uploadPath) throws IOException {
         StringBuffer str =new StringBuffer();
         String[] split = attURL.split(",");
         for (String s : split) {
-            String url=s.substring(s.lastIndexOf("/"));
+            String url="";
+            if (s.contains("/")){
+                url=s.substring(s.lastIndexOf("/"));
+            }else {
+                url=s.substring(s.lastIndexOf("\\"));
+            }
             String newURL="";
             String frontName="/new_order_file/";
             String rearName="";
@@ -107,55 +161,44 @@ public class TestPublicController extends CertifyApiController {
             }else if (i==2){
                 rearName="/content";
             }
-            newURL=frontName+orderNo+rearName+url;
-            str.append(newURL).append(",");
-            moveFile(uploadPath+s, uploadPath+newURL);
+            newURL=frontName+orderNo+rearName;
+            moveFile(s, newURL,uploadPath,url);
+            str.append(newURL+url).append(",");
         }
         return str.substring(0,str.length()-1);
     }
 
+
+
     /**
      *
      * @param useURL 旧地址
      * @param newURL 新地址
      */
-    private static void moveFile(String useURL, String newURL) {
+    private static void moveFile(String useURL, String newURL,String uploadPath,String url) throws IOException {
+        String targePath=uploadPath+newURL;
+        useURL=uploadPath+useURL;
+        String targeUrl=targePath+url;
         //目标文件夹路径(没有会自动创建)
-        File targetFile = new File(useURL);
+        File targetFile = new File(targePath);
         File srcFile = new File(useURL);
-        File destFile = new File(newURL);
-        if (!targetFile.exists()){
-            targetFile.mkdir();
-        }
-        try {
-            copyFile(srcFile,destFile);
-        } catch (IOException e) {
-            throw new BusinessException("");
-        }
-    }
+        File destFile = new File(targeUrl);
+        createFile(targetFile);
+        copyFile(srcFile,destFile);
+        srcFile.delete();
 
+    }
 
-    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 createFile(File file) {
+        if (file.exists()) {
+        } else {
+            if (!file.exists()) {
+                //创建上级目录
+                file.mkdirs();
             }
         }
     }
 
-
     private static void copyFile(File srcFile,File destFile) throws IOException {
         //该方法为复制文件,srcFile是原文件所在地址,destFile是目标文件所在地址
 
@@ -174,5 +217,22 @@ public class TestPublicController extends CertifyApiController {
         bis.close();
     }
 
-
+    public static void main(String[] args) {
+        String uploadPath="F:/data/public/upload";
+        String	targePath="F:/data/public/upload/new_order_file/706517544638255104/contract";
+        // 源文件夹路径(存放图片路径)
+        String url=uploadPath+"\\order_file\\c44a10a3-eae0-40ae-b847-d0c09046e340\\176852558400.png";
+        String name=url.substring(url.lastIndexOf("\\"));
+        String targeUrl=targePath+name;
+        //目标文件夹路径(没有会自动创建)
+        File targetFile = new File(targePath);
+        File srcFile = new File(url);
+        File destFile = new File(targeUrl);
+        createFile(targetFile);
+        try {
+            copyFile(srcFile,destFile);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 9 - 9
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20220318?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.username=root
-#jdbc.password=123456
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
-jdbc.password=aftdev
+jdbc.password=123456
+#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.username=root
+#jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20
@@ -51,10 +51,10 @@ yxjl_max=100
 
 amb.maxLvl=6
 
-avatar.host=//static.jishutao.com
-static.host=//static.jishutao.com/1.2.53
-#avatar.host=//172.16.0.255:3000
-#static.host=//172.16.0.255:3000/1.2.27
+#avatar.host=//static.jishutao.com
+#static.host=//static.jishutao.com/1.2.53
+avatar.host=//172.16.0.255:3000
+static.host=//172.16.0.255:3000/1.2.53
 #static.host=http://172.16.1.187/prod/1.2.25
 
 wx.appId=wxff2f5720ed7d7f63