diff --git a/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_CustomerInfo_controller.java b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_CustomerInfo_controller.java new file mode 100644 index 0000000..7b2e007 --- /dev/null +++ b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_CustomerInfo_controller.java @@ -0,0 +1,89 @@ +package com.weaver.seconddev.interfaces.workflow.controller; + +import com.alibaba.fastjson.JSONObject; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.seconddev.interfaces.k3.CallK3CustomerService; +import com.weaver.seconddev.interfaces.k3.CustomerServiceStub; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: calyrex + * @CreateTime: 2025-02-17 + * @Description:K3_Check_CustomerInfo的API调用 + */ + +@Slf4j +@RestController +@RequestMapping({"/papi/secondev/workflow/controller" }) +public class K3_Check_CustomerInfo_controller { + + @RequestMapping("/K3_Check_CustomerInfo") + public WeaResult run(@RequestParam Map params) { + log.error("K3_Check_CustomerInfo_controller execute start"); + log.error("K3_Check_CustomerInfo_controller execute params : " + params); + try { + String datacenterid = null2String(params.get("datacenterid")); //数据中心 + String custname= null2String(params.get("custname")); //客户名称 + String custnumber = null2String(params.get("custnumber")); //客户编号 + String code = "0"; + String message = ""; + String issuccess = ""; + String result = ""; + CustomerServiceStub.CustomerSearchReq req = new CustomerServiceStub.CustomerSearchReq(); + req.setUser("oa"); + req.setPwd("k3cloud_htgd"); + req.setFName(custname); + req.setFNumber(custnumber); + req.setDataCenterID(datacenterid); + CallK3CustomerService services = new CallK3CustomerService(); + CustomerServiceStub.CustomerSearchRes res = services.getCustMsg(req); + code = res.getCode(); + message = res.getMessage(); + issuccess = res.getIsSuccess(); + result = res.getResult(); + JSONObject resultJson = new JSONObject(); + resultJson.put("code",code); + resultJson.put("message",message); + resultJson.put("IsSuccess",issuccess); + resultJson.put("result",result); + List> customers = new ArrayList<>(); + if(!result.equals("0")) { + CustomerServiceStub.ArrayOfCustSample supsample = res.getCustSamples(); + CustomerServiceStub.CustSample[] arrs = supsample.getCustSample(); + if (arrs != null && arrs.length > 0) { + for (int i = 0; i < arrs.length; i++) { + Map item = new HashMap<>(); + item.put("custname", arrs[i].getFCustName()); + item.put("custnumber", arrs[i].getFCustNumber()); + customers.add(item); + } + } + } + resultJson.put("customers",customers); + return WeaResult.success(JSONObject.toJSONString(resultJson)); + }catch (Exception e){ + log.error("K3_Check_CustomerInfo_controller execute error : " , e); + return WeaResult.fail(500, "K3_Check_CustomerInfo_controller execute error", e); + } + } + + public static String null2String(String s){ + return s == null ? "" : s; + } + + public static String null2String(Object o){ + return o == null ? "" : o.toString(); + } + + public static String null2String(String s1,String s2){ + return s1 == null ? (s2 == null ? "" : s2) : s1; + } +}