diff --git a/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_SupplierInfo_controller.java b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_SupplierInfo_controller.java new file mode 100644 index 0000000..b2a6502 --- /dev/null +++ b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Check_SupplierInfo_controller.java @@ -0,0 +1,97 @@ +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.CallK3SupplierServices; +import com.weaver.seconddev.interfaces.k3.SupplierServiceStub; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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-18 + * @Description: K3_Check_SupplierInfo的API调用 + */ + + +@Slf4j +@RestController +@RequestMapping({"/papi/secondev/workflow/controller" }) +public class K3_Check_SupplierInfo_controller { + + @Autowired + private CallK3SupplierServices services; + + @RequestMapping("/K3_Check_SupplierInfo") + public WeaResult run(@RequestParam Map params) { + log.error("K3_Check_SupplierInfo_controller execute start"); + log.error("K3_Check_SupplierInfo_controller execute params : " + params); + try { + String datacenterid = null2String(params.get("datacenterid")); //数据中心 + String supname= null2String(params.get("supname")); //供应商名称 + String supnumber = null2String(params.get("supnumber")); //供应商编号 + String code = "0"; + String message = ""; + String issuccess = ""; + String result = ""; + SupplierServiceStub.SupplierSearchReq req = new SupplierServiceStub.SupplierSearchReq(); + req.setUser("oa"); + req.setPwd("k3cloud_htgd"); + req.setFName(supname); + req.setFNumber(supnumber); + req.setDataCenterID(datacenterid); + SupplierServiceStub.SupplierSearchRes res = services.getSupMsg(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> suppliers = new ArrayList<>(); + + if(code.equals("1")&&!result.equals("0")) { + SupplierServiceStub.ArrayOfSupSample supsample = res.getSupSamples(); + SupplierServiceStub.SupSample[] arrs = supsample.getSupSample(); + if (arrs != null && arrs.length > 0) { + for (int i = 0; i < arrs.length; i++) { + Map item = new HashMap<>(); + item.put("supname", arrs[i].getFSupName()); + item.put("supnumber", arrs[i].getFSupNumber()); + suppliers.add(item); + } + } + } + resultJson.put("suppliers",suppliers); + return WeaResult.success(JSONObject.toJSONString(resultJson)); + }catch (Exception e){ + log.error("K3_Check_SupplierInfo_controller execute error : " ,e); + return WeaResult.fail(500, "K3_Check_SupplierInfo_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; + } +} diff --git a/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Get_SupplierInfo_controller.java b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Get_SupplierInfo_controller.java new file mode 100644 index 0000000..5b44b9d --- /dev/null +++ b/secondev-history-action/src/main/java/com/weaver/seconddev/interfaces/workflow/controller/K3_Get_SupplierInfo_controller.java @@ -0,0 +1,149 @@ +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.CallK3SupplierServices; +import com.weaver.seconddev.interfaces.k3.SupplierServiceStub; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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-18 + * @Description: K3_Get_SupplierInfo的API调用 + */ + +@Slf4j +@RestController +@RequestMapping({"/papi/secondev/workflow/controller" }) +public class K3_Get_SupplierInfo_controller { + + @Autowired + private CallK3SupplierServices services; + @RequestMapping("/K3_Get_SupplierInfo") + public WeaResult run(@RequestParam Map params) { + log.error("K3_Get_SupplierInfo_controller execute start"); + log.error("K3_Get_SupplierInfo_controller execute params : " + params); + try { + String datacenterid = null2String(params.get("datacenterid")); //数据中心 + String supname= null2String(params.get("supname")); //供应商名称 + String supnumber = null2String(params.get("supnumber")); //供应商编号 + String code = "0"; + String message = ""; + String issuccess = ""; + String result = ""; + SupplierServiceStub.SupplierSearchReq req = new SupplierServiceStub.SupplierSearchReq(); + req.setUser("oa"); + req.setPwd("k3cloud_htgd"); + req.setFName(supname); + req.setFNumber(supnumber); + req.setDataCenterID(datacenterid); + + SupplierServiceStub.SupplierReturn res = services.getSupplier(req); + code = res.getCode(); + message = res.getMessage(); + issuccess = res.getIsSuccess(); + result = res.getResult(); + + req.setUser("oa"); + req.setPwd("k3cloud_htgd"); + req.setFName(supname); + req.setFNumber(supnumber); + req.setDataCenterID(datacenterid); + + JSONObject resultJson=new JSONObject(); + resultJson.put("code",code); + resultJson.put("message",message); + resultJson.put("IsSuccess",issuccess); + resultJson.put("result",result); + SupplierServiceStub.Supplier supplier = res.getSupplier(); + Map supJson = new HashMap<>(); + if(supplier!=null){ + supJson.put("FSupName",supplier.getFSupName());//供应商名称 + supJson.put("FSupNumber",supplier.getFSupNumber());//公共上代码 + supJson.put("Fgroup",supplier.getFGroup());//供应商分组 + supJson.put("FGroupName",supplier.getFGroupName());//供应商分组名称 + supJson.put("FSupplierClassify",supplier.getFSupplierClassify());//供应商类别 + supJson.put("FSUPPLYCLASSIFYNAME",supplier.getFSUPPLYCLASSIFYNAME());//供应商类别名称 + supJson.put("SOCIALCRECODE",supplier.getFSOCIALCRECODE());//统一社会信用代码 + supJson.put("FPayCurrencyId",supplier.getFPayCurrencyId());//结算币别 + supJson.put("FPayCondition",supplier.getFPayCondition());//付款条件 + supJson.put("FTaxRateId",supplier.getFTaxRateId());//默认税率 + supJson.put("F_HTGD_RELATEDTYPE",supplier.getF_HTGD_RELATEDTYPE());//关联方属性 + SupplierServiceStub.ArrayOfOrganization org = supplier.getListOrgs(); + String orgcode = ""; + String orgname = ""; + if(org!=null){ + SupplierServiceStub.Organization[] orgArr = org.getOrganization(); + if(orgArr!=null){ + for(int m=0;m contactJson = new HashMap<>(); + if(contact!=null) { + contactJson.put("Fcontact", contact.getFCONTACT()); //联系人 + contactJson.put("FBizAddress", contact.getFBIZADDRESS());//通讯地址 + contactJson.put("FMobile", contact.getFMOBILE());//手机 + contactJson.put("Ftel", contact.getFTEL());//电话 + contactJson.put("FFax", contact.getFFAX());//传真 + contactJson.put("Femail", contact.getFEMAIL());//电子邮箱 + } + supJson.put("contact",contactJson); + SupplierServiceStub.ArrayOfSupplierBank bankinfo = supplier.getBankList(); + + if(bankinfo!=null) { + SupplierServiceStub.SupplierBank[] bankarr = bankinfo.getSupplierBank(); + List> bankJsonarr = new ArrayList<>(); + if(bankarr!=null && bankarr.length>0){ + for (int i=0; i item = new HashMap<>(); + item.put("FBankHolder",bankarr[i].getFBankHolder()); + item.put("FBankCode",bankarr[i].getFBankCode()); + item.put("FOPENBANKNAME",bankarr[i].getFOPENBANKNAME()); + item.put("FCNAPS",bankarr[i].getFCNAPS()); + bankJsonarr.add(item); + } + } + supJson.put("banklist",bankJsonarr); + }else{ + supJson.put("banklist",new ArrayList<>()); + } + } + resultJson.put("supplier",supJson); + return WeaResult.success(JSONObject.toJSONString(resultJson)); + }catch (Exception e){ + log.error("K3_Get_SupplierInfo_controller execute error : " , e); + return WeaResult.fail(500, "K3_Get_SupplierInfo_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; + } +}