|
|
@@ -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) {
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|