Bläddra i källkod

灵明光子新增浙江、杭州账套

wzy 4 månader sedan
förälder
incheckning
84802d78c2

+ 87 - 31
mjava-lingmingguangzi/src/main/java/com/malk/lingmingguangzi/service/LingmingguangziServiceImpl.java

@@ -24,7 +24,6 @@ import com.malk.server.aliwork.YDParam;
 import com.malk.server.common.McR;
 import com.malk.server.dingtalk.DDR_New;
 import com.malk.server.teambition.TBConf;
-import com.malk.server.teambition.TBR;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDService;
 import com.malk.service.dingtalk.DDClient;
@@ -37,11 +36,9 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.HttpClients;
 import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -50,9 +47,7 @@ import org.springframework.stereotype.Service;
 import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URL;
-import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -103,6 +98,30 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
     @Value(value = "${erp_xg.filePath}")
     private String filePathXg;
 
+    @Value(value = "${erp_zj.url}")
+    private String erpUrlZj;
+
+    @Value(value = "${erp_zj.username}")
+    private String userNameZj;
+
+    @Value(value = "${erp_zj.password}")
+    private String passwordZj;
+
+    @Value(value = "${erp_zj.filePath}")
+    private String filePathZj;
+
+    @Value(value = "${erp_hz.url}")
+    private String erpUrlHz;
+
+    @Value(value = "${erp_hz.username}")
+    private String userNameHz;
+
+    @Value(value = "${erp_hz.password}")
+    private String passwordHz;
+
+    @Value(value = "${erp_hz.filePath}")
+    private String filePathHz;
+
     private final Object $lock = new Object[0];
 
     private static final Long EXPIRES_IN = 7200000L;
@@ -281,8 +300,12 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
         String erpUrl = "";
         if ("深圳".equals(type)){
             erpUrl = erpUrlSz;
-        }else {
+        }else if ("香港".equals(type)){
             erpUrl = erpUrlXg;
+        }else if ("浙江".equals(type)){
+            erpUrl = erpUrlZj;
+        }else if ("杭州".equals(type)){
+            erpUrl = erpUrlHz;
         }
         return erpUrl;
     }
@@ -522,6 +545,10 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
         }).collect(Collectors.toList());
         //附件
         List<Map> list2 = (List<Map>) formData.get("tableField_ly8fxusx");
+
+        String[] ERP_FILEPATHS = new String[]{filePathSz,filePathXg,filePathZj,filePathHz};
+        String[] ERP_ENVS = new String[]{"深圳","香港","浙江","杭州"};
+
         if (Objects.nonNull(list2)){
             List<Map> makSoFilesList = list2.stream().map(map1 -> {
                 Map detail = new HashMap();
@@ -535,7 +562,27 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                 String ydDownloadUrl = fileList.get(0).get("downloadUrl").toString();
                 String fileName = fileList.get(0).get("name").toString();
                 fileName = convertChineseToUtf8Hex(fileName);
-                if ("深圳".equals(type)){
+
+                for (int i = 0; i < ERP_ENVS.length; i++) {
+                    if (ERP_ENVS[i].equals(type)){
+                        //将downloadurl下载到本地
+                        try {
+                            downloadFile(ydDownloadUrl, ERP_FILEPATHS[i],fileName);
+                            System.out.println("文件下载成功!");
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                        //上传附件
+                        try {
+                            detail.put("files",postWithFile(getErpUrl(type) + "pws/sys/common/upload", ERP_FILEPATHS[i] + fileName,type));
+                        } catch (UnsupportedEncodingException e) {
+                            throw new RuntimeException(e);
+                        }
+
+                        break;
+                    }
+                }
+                /*if ("深圳".equals(type)){
                     //将downloadurl下载到本地
                     try {
                         downloadFile(ydDownloadUrl, filePathSz,fileName);
@@ -549,7 +596,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                     } catch (UnsupportedEncodingException e) {
                         throw new RuntimeException(e);
                     }
-                }else {
+                }else if ("香港".equals(type)){
                     //将downloadurl下载到本地
                     try {
                         downloadFile(ydDownloadUrl, filePathXg,fileName);
@@ -563,7 +610,21 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                     } catch (UnsupportedEncodingException e) {
                         throw new RuntimeException(e);
                     }
-                }
+                }else if ("浙江".equals(type)){
+                    //将downloadurl下载到本地
+                    try {
+                        downloadFile(ydDownloadUrl, filePathZj,fileName);
+                        System.out.println("文件下载成功!");
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    //上传附件
+                    try {
+                        detail.put("files",postWithFile(getErpUrl(type) + "pws/sys/common/upload", filePathZj + fileName,type));
+                    } catch (UnsupportedEncodingException e) {
+                        throw new RuntimeException(e);
+                    }
+                }*/
 
                 return detail;
             }).collect(Collectors.toList());
@@ -834,8 +895,12 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
         Map<String, Object> map = new HashMap<>();
         if ("深圳".equals(type)){
             map = post(erpUrlSz + "pws/sys/mLogin", null, null,UtilMap.map("username, password", userNameSz, passwordSz));
-        }else {
+        }else if ("香港".equals(type)){
             map = post(erpUrlXg + "pws/sys/mLogin", null, null,UtilMap.map("username, password", userNameXg, passwordXg));
+        }else if ("浙江".equals(type)){
+            map = post(erpUrlZj + "pws/sys/mLogin", null, null,UtilMap.map("username, password", userNameZj, passwordZj));
+        }else if ("杭州".equals(type)){
+            map = post(erpUrlHz + "pws/sys/mLogin", null, null,UtilMap.map("username, password", userNameHz, passwordHz));
         }
 
         if (Objects.nonNull(map.get("result"))){
@@ -1024,7 +1089,8 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
     @Override
     public void updateCurrency() {
         //获取erp币别列表
-        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg};
+        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg,erpUrlZj, erpUrlHz};
+        String[] ERP_ENVS = new String[]{"深圳","香港","浙江","杭州"};
         for (int i = 0; i < ERP_URLS.length; i++) {
             List<Map<String,String>> list = new ArrayList<>();
             int pageNo = 1;
@@ -1034,7 +1100,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                 Map param = new HashMap();
                 param.put("pageNo",pageNo);
                 param.put("pageSize",pageSize);
-                Map<String, Object> res = get(ERP_URLS[i] + "pws/fin/finCurrency/list", param, i == 0 ? getHeader("深圳") : getHeader("香港"));
+                Map<String, Object> res = get(ERP_URLS[i] + "pws/fin/finCurrency/list", param, getHeader(ERP_ENVS[i]));
                 result = (Map) res.get("result");
                 List<Map> records = (List<Map>) result.get("records");
                 int finalI = i;
@@ -1043,11 +1109,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                     map.put("textField_m054h6gw",map1.get("currencyCode").toString());
                     map.put("textField_m054h6gx",map1.get("currencyName").toString());
                     map.put("textField_m054h6gy",map1.get("active_dictText").toString());
-                    if (finalI == 0){
-                        map.put("selectField_m3fgkfz9","深圳");
-                    }else {
-                        map.put("selectField_m3fgkfz9","香港");
-                    }
+                    map.put("selectField_m3fgkfz9",ERP_ENVS[finalI]);
                     map.put("textField_m3fiygvb",map.get("selectField_m3fgkfz9") + map.get("textField_m054h6gw"));//唯一标识
 
                     return map;
@@ -1065,7 +1127,8 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
     @Override
     public void updateTaxRate() {
         //获取erp税率列表
-        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg};
+        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg,erpUrlZj, erpUrlHz};
+        String[] ERP_ENVS = new String[]{"深圳","香港","浙江","杭州"};
         for (int i = 0; i < ERP_URLS.length; i++) {
             List<Map<String,String>> list = new ArrayList<>();
             int pageNo = 1;
@@ -1075,7 +1138,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                 Map param = new HashMap();
                 param.put("pageNo",pageNo);
                 param.put("pageSize",pageSize);
-                Map<String, Object> res = get(ERP_URLS[i] + "pws/fin/finTax/list", param, i == 0 ? getHeader("深圳") : getHeader("香港"));
+                Map<String, Object> res = get(ERP_URLS[i] + "pws/fin/finTax/list", param, getHeader(ERP_ENVS[i]));
                 result = (Map) res.get("result");
                 List<Map> records = (List<Map>) result.get("records");
                 int finalI = i;
@@ -1084,11 +1147,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                     map.put("textField_m0539uy1",map1.get("id").toString());
                     map.put("numberField_m0539uy2",map1.get("taxValue").toString());
                     map.put("textField_m0539uy4",map1.get("taxName").toString());
-                    if (finalI == 0){
-                        map.put("selectField_m3fgkfz9","深圳");
-                    }else {
-                        map.put("selectField_m3fgkfz9","香港");
-                    }
+                    map.put("selectField_m3fgkfz9",ERP_ENVS[finalI]);
                     map.put("textField_m3fiygvb",map.get("selectField_m3fgkfz9") + map.get("textField_m0539uy1"));//唯一标识
                     return map;
                 }).collect(Collectors.toList()));
@@ -1105,7 +1164,8 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
     @Override
     public void updateProcess() {
         //获取erp工序列表
-        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg};
+        String[] ERP_URLS = new String[]{erpUrlSz,erpUrlXg,erpUrlZj, erpUrlHz};
+        String[] ERP_ENVS = new String[]{"深圳","香港","浙江","杭州"};
         for (int i = 0; i < ERP_URLS.length; i++) {
             List<Map<String,String>> list = new ArrayList<>();
             int pageNo = 1;
@@ -1116,7 +1176,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                 Map param = new HashMap();
                 param.put("pageNo",pageNo);
                 param.put("pageSize",pageSize);
-                Map<String, Object> res = get(ERP_URLS[i] + "pws/pdm/pdmStation/list", param, i == 0 ? getHeader("深圳") : getHeader("香港"));
+                Map<String, Object> res = get(ERP_URLS[i] + "pws/pdm/pdmStation/list", param, getHeader(ERP_ENVS[i]));
                 result = (Map) res.get("result");
                 List<Map> records = (List<Map>) result.get("records");
                 int finalI = i;
@@ -1132,11 +1192,7 @@ public class LingmingguangziServiceImpl implements LingmingguangziService {
                     map.put("textField_m04yhw5d",getString(map1.get("stationType_dictText")));//工序类型
                     map.put("textField_m04yhw5e",getString(map1.get("comments")));//备注
                     map.put("textField_m04yhw5f",getString(map1.get("active_dictText")));//审核状态
-                    if (finalI == 0){
-                        map.put("selectField_m3fgkfz9","深圳");
-                    }else {
-                        map.put("selectField_m3fgkfz9","香港");
-                    }
+                    map.put("selectField_m3fgkfz9",ERP_ENVS[finalI]);
                     map.put("textField_m3fiygvb",map.get("selectField_m3fgkfz9") + map.get("textField_m04yhw4p"));//唯一标识
 
                     return map;

+ 13 - 0
mjava-lingmingguangzi/src/main/resources/application-dev.yml

@@ -56,3 +56,16 @@ erp_xg:
   username: 黄君
   password: Hello@1234
   filePath: d:\\
+#浙江/德清
+erp_zj:
+  url: https://zjerp.adapsphotonics.net:28443/
+  username: 黄君
+  password: 123456789aa
+  filePath: d:\\
+#杭州
+erp_hz:
+  url: https://hzerp.adapsphotonics.net:28443/
+  username: 黄君
+  password: 123456789aa
+  filePath: d:\\
+

+ 12 - 5
mjava-lingmingguangzi/src/main/resources/application-prod.yml

@@ -7,7 +7,7 @@ enable:
   scheduling: false
 logging:
   config: classpath:logback-spring.xml
-  path: /home/server/lingmingguangzi/log/
+  path: e:\\crm\\log\\
   level:
     com.malk.*: debug
 
@@ -49,13 +49,20 @@ erp_sz:
   username: 黄君
   password: 123456789aa
   filePath: e:\\crm\\file\\sz\\
-#  filePath: d:\\
-#  filePath: /home/server/lingmingguangzi/file/sz/
 #香港环境
 erp_xg:
   url: http://127.0.0.1:9094/
   username: 黄君
   password: Hello@1234
   filePath: e:\\crm\\file\\xg\\
-#  filePath: d:\\
-#  filePath: /home/server/lingmingguangzi/file/xg/
+erp_zj:
+  url: http://127.0.0.1:9002/
+  username: 黄君
+  password: 123456789aa
+  filePath: e:\\crm\\file\\zj\\
+#杭州
+erp_hz:
+  url: http://127.0.0.1:9001/
+  username: 黄君
+  password: 123456789aa
+  filePath: e:\\crm\\file\\hz\\