chenkang11 1 месяц назад
Родитель
Сommit
6b79555083

+ 2 - 1
mjava-ts/src/main/java/com/malk/taisen/Timers/Time.java

@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 
 @Slf4j
 @Configuration
@@ -18,7 +19,7 @@ public class Time {
 
 //    @Scheduled(fixedRate = 500)
 //    public void JX() throws Exception {
-//        nonPoServer.NonPoinsetSAP0005("","045e8b98-3e82-4569-b5ea-c22def5170bd");
+//        nonPoServer.NonPoinsetSAP0005("Non-PoToSAP0005","a752cd1d-af0e-4a9b-8ba");
 //
 //    }
 

+ 2 - 0
mjava-ts/src/main/java/com/malk/taisen/controller/NonPoCpntroller.java

@@ -6,6 +6,7 @@ import com.malk.utils.UtilMap;
 import com.malk.utils.UtilServlet;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -21,6 +22,7 @@ public class NonPoCpntroller {
     private NonPoServer NonPoServer;
 
 
+
     @PostMapping("/nonpo")
     McR notice(HttpServletRequest request) {
 

+ 8 - 6
mjava-ts/src/main/java/com/malk/taisen/service/impl/NonPoServerImpl.java

@@ -361,7 +361,7 @@ public class NonPoServerImpl implements NonPoServer {
             // 添加顶级键值对
             sapJson.put("ZDUEDATE", CusutUtil.getFormatDate((Long) dataForm.get("dateField_mejfoonv"))); //Due date / 到期日
             sapJson.put("BKTXT", dataForm.get("textareaField_mejfoonw"));//备注  抬头文本
-            sapJson.put("ZOA_NUMBER", dataForm.get("textField_mi73dy3n")); //钉钉单据号
+            sapJson.put("ZOA_NUMBER", dataForm.get("textField_mi73dy3n")); //钉钉单据号dataForm.get("textField_mi73dy3n")
             if (dataForm.get("selectField_mejfoona").equals("收据支付")) {//☑ 票据支付时 代码ZINVOICE_AMT 默认ZPAY_AMT的值
                 sapJson.put("ZINVOICE_AMT", dataForm.get("numberField_mejfoool_value").equals("") ? "0" : dataForm.get("numberField_mejfoool_value"));//支付金额
             } else {
@@ -503,7 +503,7 @@ public class NonPoServerImpl implements NonPoServer {
                 if (XREFlist != null && !XREFlist.isEmpty()) {
                     if (XREFlist.size() == 1) {
                         Map<String, Object> row = XREFlist.get(0);
-                        XREF1 = row.get("textField_mi5kjmwk") != null ? row.get("textField_mi5kjmwk").toString() : "";
+                        XREF1 = row.get("textField_mi8q495f") != null ? row.get("textField_mi8q495f").toString() : "";
                     } else {
                         // 多于一条,按时间戳降序排序
                         XREFlist.sort((a, b) -> {
@@ -601,7 +601,7 @@ public class NonPoServerImpl implements NonPoServer {
                             /**
                              * 执行勾选发票
                              */
-                            if (dataForm.get("selectField_mejfoona").equals("发票支付")) {
+                            if (dataForm.get("selectField_mejfoona").equals("发票支付") ||dataForm.get("selectField_mejfoona").equals("100%清预付款") ) {
                                 FPGX(InstanceId, voucherNumber, (String) dataForm.get("textField_mi73dy3n"));
                             }
                         } else {
@@ -663,7 +663,7 @@ public class NonPoServerImpl implements NonPoServer {
                     row.put("selectField_mgz2tut4", "不相关");
                     continue;
                 }
-                if ("".equals(row.get("textField_l6ujr47c"))  ||"泰森(江苏)畜禽业发展有限公司".equals(row.get("textField_l6vk7131") )  ) {
+                if ("".equals(row.get("textField_l6ujr47c")) || "泰森(江苏)畜禽业发展有限公司".equals(row.get("textField_l6vk7131"))) {
                     row.put("selectField_mgz2tut4", "不相关");
                     continue;
                 }
@@ -739,7 +739,7 @@ public class NonPoServerImpl implements NonPoServer {
                     Map<String, Object> originalRow = tableFils.get(i);
                     String fpInstanceId = safeGetString(originalRow, "textField_mi1l1tcc");
                     String invoiceNoInTable = safeGetString(originalRow, "textField_l6ujr47c");
-                    String status = !"".equals(originalRow.get("selectField_mgz2tut4")) ? (String) originalRow.get("selectField_mgz2tut4") : "未勾选";
+                    String status = originalRow.containsKey("selectField_mgz2tut4") && !"".equals(originalRow.get("selectField_mgz2tut4")) ? (String) originalRow.get("selectField_mgz2tut4") : "未勾选";
                     String returnMsg = "";
 
                     // 匹配返回的发票结果
@@ -751,7 +751,9 @@ public class NonPoServerImpl implements NonPoServer {
                             break;
                         }
                     }
-
+                    if ("不相关".equals(status)) {
+                        returnMsg = "";
+                    }
                     // 构建更新后的行数据
                     Map<String, Object> updatedRow = new HashMap<>(originalRow);
                     updatedRow.put("selectField_mgz2tut4", status);

+ 147 - 139
mjava-ts/src/test/java/test.java

@@ -10,6 +10,7 @@ import com.malk.server.dingtalk.DDR_New;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDService;
 import com.malk.service.dingtalk.DDClient;
+import com.malk.taisen.service.NonPoServer;
 import com.malk.taisen.util.CusutUtil;
 import com.malk.taisen.util.HttpUtil;
 import com.malk.utils.UtilMap;
@@ -45,151 +46,158 @@ public class test {
      * 测试地址
      */
     String QA_sapUrl = "https://etl-nonprod-tasks.tysondt.com:443/api/1/rest/feed/run/task/TysonNonProd/Ultra_PoC/10-QA-team-fssc/tk_oa_to_sap_p2p?bearer_token=bBiGTA7PS0JJ6wKhQU8Vm0vLsIDNjLaN&interface_id=";
+private NonPoServer nonPoServer;
 
-    @Test
-    public void testService() {
-        System.out.println("sdafasdfas");
-
-
-        ////////////1920000006
-
-        YDParam ydParam = _getYDTokenKPD();
-        ydParam.setFormInstanceId("045e8b98-3e82-4569-b5ea-c22def5170bd");
-        DDR_New ddr = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_id);
-        Map dataForm = ddr.getFormData();
-
-        String voucherNumber = "1920000006";
-        try {
-
-            if (dataForm.get("selectField_mejfoona").equals("发票支付")) {//勾选发票处理
-                String nowDate = CusutUtil.getNowDate();
-                List<Map<String, Object>> requestList = new ArrayList<>();
-                Map<String, Object> request = new LinkedHashMap<>();
-                JSONArray invoices = new JSONArray();
-                ArrayList<String> ids = new ArrayList<>();
-                request.put("voucherNumber", voucherNumber);
-                request.put("voucherstatus", "0");
-                request.put("voucherdate", nowDate);
-                request.put("applytime", nowDate);
-                request.put("bookeepflag", "1");
-                request.put("syssource", "第三方系统规定");
-                List<Map> list = new ArrayList<>();
-
-                List<Map<String, Object>> tableFils = (List<Map<String, Object>>) dataForm.get("tableField_l6ujr47b");
-                if (tableFils != null && tableFils.size() > 0) {
-                    list = (List<Map>) dataForm.get("tableField_l6ujr47b");
-                    for (int n = 0; n < tableFils.size(); n++) {
-
-                        Map<String, Object> row = new HashMap(tableFils.get(n));
-                        Map<Object, Object> invoice = new LinkedHashMap<>();
-//                                String substring = row.getString("associationFormField_l6yglav7_id").replaceAll("\\\\", "").substring(1);
-                        String instanceId = row.get("textField_mi1l1tcc").toString();
-
-                        Map formdata = ydClient.queryData(YDParam.builder()
-                                .appType("APP_N9NPHVTQLPBPO8MR6WFG")
-                                .systemToken("UM6660D1PGF2O34KAVVKG8XZ756E3O06MZX5LW")
-                                .formUuid("FORM-4J7669A1Z1X22RIL61LB7AOXGRX82OHP45U6L51")
-                                .formInstanceId(instanceId)
-                                .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
-                        if (formdata != null) {
-                            ids.add(instanceId);
-                            JSONObject jsonObject = new JSONObject();
-                            invoice.put("taxno", formdata.get("textField_l6u55vdn"));
-                            if (formdata.get("textField_l6u55vd8").toString().contains("全电")) {
-                                invoice.put("invoicecode", "全电发票");
-                            } else {
-                                invoice.put("invoicecode", formdata.get("textField_l6u55vd9"));
-                            }
-                            invoice.put("invoicenumber", formdata.get("textField_l6u55vd3"));
-                            invoice.put("usetax", formdata.get("textField_l6vu65fs").toString());
-                            try {
-                                if (!formdata.containsKey("textField_l6vvuq3f") || formdata.get("textField_l6vvuq3f").equals("")) {
-                                    formdata.remove("textField_l6vvuq3f");
-                                    formdata.put("textField_l6vvuq3f", "0");
-                                }
-                                invoice.put("taxrate", Double.parseDouble(formdata.get("textField_l6vvuq3f").toString().substring(0, formdata.get("textField_l6vvuq3f").toString().lastIndexOf("%"))) / 100);
-                            } catch (Exception ex) {
-                                try {
-                                    invoice.put("taxrate", Double.parseDouble(formdata.get("textField_l6vvuq3f").toString()) / 100);
-                                } catch (Exception ex2) {
-                                    invoice.put("taxrate", 0);
-                                }
-                            }
-                            invoice.put("autodeduct", "1");
-                            invoice.put("oper", "1");
-                            jsonObject.toString();
-                            invoices.put(invoice);
-                            request.put("invoices", invoices);
-                        }
-
-                    }
 
 
-                    requestList.add(request);
-                    String jsonBody = new ObjectMapper().writeValueAsString(requestList);
-                    System.out.println(jsonBody.toString());
-                    RestTemplate restTemplate = new RestTemplate();
-                    String PROXY_URL = "https://28356641.r38.cpolar.top/api/ts/bookkeeping";
-                    HttpHeaders headers = new HttpHeaders();
-                    headers.setContentType(MediaType.APPLICATION_JSON);
-                    ResponseEntity<String> response = restTemplate.postForEntity(
-                            PROXY_URL,
-                            new HttpEntity<>(jsonBody, headers),
-                            String.class
-                    );
 
-                    //   String post_GX = HttpUtil.post("https://28356641.r38.cpolar.top/api/ts/bookkeeping", null, jsonBody.toString(), null);
-                    // if (!"".equals(post_GX)) {
-                    //  System.out.println(CusutUtil.unicodeDecode(post_GX));
-                    //  log.info("post_GX:" + CusutUtil.unicodeDecode(post_GX));
-
-                    String responseBody = response.getBody();
-                    try {
-                        ObjectMapper objectMapper = new ObjectMapper();
-                        JsonNode rootNode = objectMapper.readTree(responseBody);
-                        ArrayList<Map<String, String>> maps_YD = new ArrayList<>();
-                        // 获取 data 数组
-                        JsonNode dataArray = rootNode.get("data");
-                        // 循环遍历 data 数组
-                        if (dataArray.isArray()) {
-
-                            for (int i = 0; i < list.size(); i++) {
-                                Map sss2 = (Map) list.get(i);
-                                String pd = (String) sss2.get("selectField_mgz2tut4");
-                                for (JsonNode dataItem : dataArray) {
-                                    String returnMsg = dataItem.get("returnmsg").asText();
-                                    String invoicenumber = dataItem.get("invoicenumber").asText();
-                                    if (invoicenumber.equals(sss2.get("textField_l6ujr47c")) && !returnMsg.equals("未同步到该发票信息,请先进行同步发票操作!")) {
-                                        pd = "已勾选";
-                                    } else {
-                                        pd = "不相关";
-                                    }
-                                }
-                                sss2.put("selectField_mgz2tut4", pd);
-                                maps_YD.add(sss2);
-                            }
-                            Map map = new HashMap();
-                            map.put("tableField_l6ujr47b", maps_YD);
-                            ydClient.operateData(YDParam.builder()
-                                    .formInstId("045e8b98-3e82-4569-b5ea-c22def5170bd")
-                                    .updateFormDataJson(JSON.toJSONString(map))
-                                    .build(), YDConf.FORM_OPERATION.update);
-
-                        }
-
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-
-
-                }
-
-
-            }
+    @Test
+    public void testService() {
 
-        } catch (Exception ex) {
+       // nonPoServer.NonPoinsetSAP0005("","4c5bbb9e-7a8d-47ab-841f-04172692808a");
 
-        }
+//        System.out.println("sdafasdfas");
+//
+//
+//        ////////////1920000006
+//
+//        YDParam ydParam = _getYDTokenKPD();
+//        ydParam.setFormInstanceId("045e8b98-3e82-4569-b5ea-c22def5170bd");
+//        DDR_New ddr = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_id);
+//        Map dataForm = ddr.getFormData();
+//
+//        String voucherNumber = "1920000006";
+//        try {
+//
+//            if (dataForm.get("selectField_mejfoona").equals("发票支付")) {//勾选发票处理
+//                String nowDate = CusutUtil.getNowDate();
+//                List<Map<String, Object>> requestList = new ArrayList<>();
+//                Map<String, Object> request = new LinkedHashMap<>();
+//                JSONArray invoices = new JSONArray();
+//                ArrayList<String> ids = new ArrayList<>();
+//                request.put("voucherNumber", voucherNumber);
+//                request.put("voucherstatus", "0");
+//                request.put("voucherdate", nowDate);
+//                request.put("applytime", nowDate);
+//                request.put("bookeepflag", "1");
+//                request.put("syssource", "第三方系统规定");
+//                List<Map> list = new ArrayList<>();
+//
+//                List<Map<String, Object>> tableFils = (List<Map<String, Object>>) dataForm.get("tableField_l6ujr47b");
+//                if (tableFils != null && tableFils.size() > 0) {
+//                    list = (List<Map>) dataForm.get("tableField_l6ujr47b");
+//                    for (int n = 0; n < tableFils.size(); n++) {
+//
+//                        Map<String, Object> row = new HashMap(tableFils.get(n));
+//                        Map<Object, Object> invoice = new LinkedHashMap<>();
+////                                String substring = row.getString("associationFormField_l6yglav7_id").replaceAll("\\\\", "").substring(1);
+//                        String instanceId = row.get("textField_mi1l1tcc").toString();
+//
+//                        Map formdata = ydClient.queryData(YDParam.builder()
+//                                .appType("APP_N9NPHVTQLPBPO8MR6WFG")
+//                                .systemToken("UM6660D1PGF2O34KAVVKG8XZ756E3O06MZX5LW")
+//                                .formUuid("FORM-4J7669A1Z1X22RIL61LB7AOXGRX82OHP45U6L51")
+//                                .formInstanceId(instanceId)
+//                                .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
+//                        if (formdata != null) {
+//                            ids.add(instanceId);
+//                            JSONObject jsonObject = new JSONObject();
+//                            invoice.put("taxno", formdata.get("textField_l6u55vdn"));
+//                            if (formdata.get("textField_l6u55vd8").toString().contains("全电")) {
+//                                invoice.put("invoicecode", "全电发票");
+//                            } else {
+//                                invoice.put("invoicecode", formdata.get("textField_l6u55vd9"));
+//                            }
+//                            invoice.put("invoicenumber", formdata.get("textField_l6u55vd3"));
+//                            invoice.put("usetax", formdata.get("textField_l6vu65fs").toString());
+//                            try {
+//                                if (!formdata.containsKey("textField_l6vvuq3f") || formdata.get("textField_l6vvuq3f").equals("")) {
+//                                    formdata.remove("textField_l6vvuq3f");
+//                                    formdata.put("textField_l6vvuq3f", "0");
+//                                }
+//                                invoice.put("taxrate", Double.parseDouble(formdata.get("textField_l6vvuq3f").toString().substring(0, formdata.get("textField_l6vvuq3f").toString().lastIndexOf("%"))) / 100);
+//                            } catch (Exception ex) {
+//                                try {
+//                                    invoice.put("taxrate", Double.parseDouble(formdata.get("textField_l6vvuq3f").toString()) / 100);
+//                                } catch (Exception ex2) {
+//                                    invoice.put("taxrate", 0);
+//                                }
+//                            }
+//                            invoice.put("autodeduct", "1");
+//                            invoice.put("oper", "1");
+//                            jsonObject.toString();
+//                            invoices.put(invoice);
+//                            request.put("invoices", invoices);
+//                        }
+//
+//                    }
+//
+//
+//                    requestList.add(request);
+//                    String jsonBody = new ObjectMapper().writeValueAsString(requestList);
+//                    System.out.println(jsonBody.toString());
+//                    RestTemplate restTemplate = new RestTemplate();
+//                    String PROXY_URL = "https://28356641.r38.cpolar.top/api/ts/bookkeeping";
+//                    HttpHeaders headers = new HttpHeaders();
+//                    headers.setContentType(MediaType.APPLICATION_JSON);
+//                    ResponseEntity<String> response = restTemplate.postForEntity(
+//                            PROXY_URL,
+//                            new HttpEntity<>(jsonBody, headers),
+//                            String.class
+//                    );
+//
+//                    //   String post_GX = HttpUtil.post("https://28356641.r38.cpolar.top/api/ts/bookkeeping", null, jsonBody.toString(), null);
+//                    // if (!"".equals(post_GX)) {
+//                    //  System.out.println(CusutUtil.unicodeDecode(post_GX));
+//                    //  log.info("post_GX:" + CusutUtil.unicodeDecode(post_GX));
+//
+//                    String responseBody = response.getBody();
+//                    try {
+//                        ObjectMapper objectMapper = new ObjectMapper();
+//                        JsonNode rootNode = objectMapper.readTree(responseBody);
+//                        ArrayList<Map<String, String>> maps_YD = new ArrayList<>();
+//                        // 获取 data 数组
+//                        JsonNode dataArray = rootNode.get("data");
+//                        // 循环遍历 data 数组
+//                        if (dataArray.isArray()) {
+//
+//                            for (int i = 0; i < list.size(); i++) {
+//                                Map sss2 = (Map) list.get(i);
+//                                String pd = (String) sss2.get("selectField_mgz2tut4");
+//                                for (JsonNode dataItem : dataArray) {
+//                                    String returnMsg = dataItem.get("returnmsg").asText();
+//                                    String invoicenumber = dataItem.get("invoicenumber").asText();
+//                                    if (invoicenumber.equals(sss2.get("textField_l6ujr47c")) && !returnMsg.equals("未同步到该发票信息,请先进行同步发票操作!")) {
+//                                        pd = "已勾选";
+//                                    } else {
+//                                        pd = "不相关";
+//                                    }
+//                                }
+//                                sss2.put("selectField_mgz2tut4", pd);
+//                                maps_YD.add(sss2);
+//                            }
+//                            Map map = new HashMap();
+//                            map.put("tableField_l6ujr47b", maps_YD);
+//                            ydClient.operateData(YDParam.builder()
+//                                    .formInstId("045e8b98-3e82-4569-b5ea-c22def5170bd")
+//                                    .updateFormDataJson(JSON.toJSONString(map))
+//                                    .build(), YDConf.FORM_OPERATION.update);
+//
+//                        }
+//
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//
+//
+//                }
+//
+//
+//            }
+//
+//        } catch (Exception ex) {
+//
+//        }
 
 
     }