|
|
@@ -1,5 +1,7 @@
|
|
|
package com.malk.huagao.service.impl;
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -54,13 +56,29 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
|
|
|
try {
|
|
|
MDC.put("MDC_KEY_PID", "1003");
|
|
|
String formInstId = UtilMap.getString(map, "formInstId");
|
|
|
- String action = UtilMap.getString(map, "action");
|
|
|
+ String action = UtilMap.getString(map, "type");
|
|
|
|
|
|
// 处理特殊操作类型
|
|
|
if ("del".equals(action)) {
|
|
|
String bm = UtilMap.getString(map, "bm");
|
|
|
- //todo 删除逻辑
|
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ Map<String, Object> formParams = new HashMap<>();
|
|
|
+ Map<String, Object> djbh = new HashMap<>();
|
|
|
+ djbh.put("djbh", bm);
|
|
|
+ result.put("data", djbh);
|
|
|
+ String jsonStr = JSON.toJSONString(result);
|
|
|
+ formParams.put("jsons", jsonStr);
|
|
|
+
|
|
|
+ HttpResponse response = HttpRequest.post("http://113.45.187.194:70/xk/dyzn/WsBasedyzn.asmx/hgdjydtbdeletefhtzd")
|
|
|
+ .headerMap(headers, true)
|
|
|
+ .form(formParams)
|
|
|
+ .timeout(30000) // 30秒超时
|
|
|
+ .execute();
|
|
|
+
|
|
|
+ String responseBody = response.body();
|
|
|
+ System.out.println("responseBody===="+responseBody);
|
|
|
// 返回删除操作的格式
|
|
|
result.put("table", "KD_YD_DELIVERY");
|
|
|
result.put("action", "del");
|
|
|
@@ -92,7 +110,15 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
|
|
|
String xslx = UtilMap.getString(formData, "selectField_mgrn6p2d");
|
|
|
String bzfs = UtilMap.getString(formData, "selectField_mf6a0h5y");
|
|
|
String bz = UtilMap.getString(formData, "textareaField_mejnamfb");
|
|
|
- LocalDateTime hhsj = parseTimestamp(UtilMap.getString(formData, "dateField_mf6a0h67"));
|
|
|
+// LocalDateTime hhsj = parseTimestamp(UtilMap.getString(formData, "dateField_mf6a0h67"));
|
|
|
+ LocalDateTime hhsj = Optional.ofNullable(
|
|
|
+ parseTimestamp(UtilMap.getString(formData, "dateField_mf6a0h67"))
|
|
|
+ )
|
|
|
+ .orElseGet(() -> LocalDateTime.now()
|
|
|
+ .withHour(17)
|
|
|
+ .withMinute(0)
|
|
|
+ .withSecond(0)
|
|
|
+ .withNano(0));
|
|
|
String ysfs = UtilMap.getString(formData, "selectField_mf6a0h5z");
|
|
|
String hdfs = UtilMap.getString(formData, "selectField_mf6a0h60");
|
|
|
String kdgs = UtilMap.getString(formData, "selectField_mf6a0h61");
|
|
|
@@ -170,24 +196,53 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
|
|
|
deliveryData.put("fkfs", fkfs);
|
|
|
deliveryData.put("DeliveryList", deliveryList);
|
|
|
|
|
|
- // 设置返回结果
|
|
|
- result.put("table", "KD_YD_DELIVERY");
|
|
|
- result.put("action", action != null ? action : "add");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+
|
|
|
result.put("data", deliveryData);
|
|
|
+// 将result转换为JSON字符串
|
|
|
+ String jsonStr = JSON.toJSONString(result);
|
|
|
+// 构建form参数
|
|
|
+ Map<String, Object> formParams = new HashMap<>();
|
|
|
+ formParams.put("jsons", jsonStr);
|
|
|
+ System.out.println("formParams==="+formParams);
|
|
|
+// 发送请求
|
|
|
+ HttpResponse response = null;
|
|
|
+ if ("add".equals(action)) {
|
|
|
+ response = HttpRequest.post("http://113.45.187.194:70/xk/dyzn/WsBasedyzn.asmx/hgdjydtbcreatefhtzd")
|
|
|
+ .headerMap(headers, true)
|
|
|
+ .form(formParams)
|
|
|
+ .timeout(30000) // 30秒超时
|
|
|
+ .execute();
|
|
|
+ } else {
|
|
|
+ response = HttpRequest.post("http://113.45.187.194:70/xk/dyzn/WsBasedyzn.asmx/")
|
|
|
+ .headerMap(headers, true)
|
|
|
+ .form(formParams)
|
|
|
+ .timeout(30000) // 30秒超时
|
|
|
+ .execute();
|
|
|
+ }
|
|
|
|
|
|
- // 添加日志记录
|
|
|
- log.info("发货通知单同步成功: formInstId={}, djbh={}, kh={}", formInstId, djbh, kh);
|
|
|
+ String responseBody = response.body();
|
|
|
+ System.out.println("responseBody===="+responseBody);
|
|
|
|
|
|
- // 如果需要回写到表单,可以在这里操作
|
|
|
- /*
|
|
|
- ydClient.operateData(
|
|
|
- YDParam.builder()
|
|
|
- .formInstanceId(formInstId)
|
|
|
- .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_mgrqnxmm", "需要回写的值")))
|
|
|
- .useLatestVersion(true).build(),
|
|
|
- YDConf.FORM_OPERATION.update);
|
|
|
- */
|
|
|
+ try {
|
|
|
|
|
|
+ String msg = JSON.parseArray(responseBody)
|
|
|
+ .getJSONObject(0)
|
|
|
+ .getString("msg");
|
|
|
+ String code = JSON.parseArray(responseBody)
|
|
|
+ .getJSONObject(0)
|
|
|
+ .getString("code");
|
|
|
+ ydClient.operateData(
|
|
|
+ YDParam.builder()
|
|
|
+ .formInstanceId(formInstId)
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_ml08nk3y, textareaField_mkz9u4p9", code, msg)))
|
|
|
+ .useLatestVersion(true).build(),
|
|
|
+ YDConf.FORM_OPERATION.update);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("解析JSON失败: " + e.getMessage());
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("发货通知单同步异常", e);
|
|
|
result.put("table", "KD_YD_DELIVERY");
|