package com.fzzy.push.gd2020.v2; import com.fzzy.api.data.AuthToken; import com.fzzy.api.entity.Api1102; import com.fzzy.api.entity.Api1103; import com.fzzy.api.entity.ApiConfs; import com.fzzy.push.gd2020.GDResult; import com.fzzy.push.gd2020.GDUtils; import com.fzzy.push.gd2020.InvokeResult; import com.fzzy.push.gd2020.JaxbUtil; import lombok.extern.slf4j.Slf4j; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import javax.xml.namespace.QName; /** * @Desc: 仓房信息-数据接口 * @author: Andy * @update-time: 2022/10/15 */ @Slf4j public class StoreHouseWebService { public static StoreHouseWebService newInstance() { return new StoreHouseWebService(); } public String xml_webservice = "{sskd}{cfmc}{cfbm}{cflx}{cfsjcr}{jfsyrq}{nfszcc}{ywfsfqfczz}{ywfhfbfdss}{ywlqjcss}{ywjxtfss}{nfhlxzsc}{nffddyqtcl}{nfcwcc}{cfzt}{cfccfs}{cfjd}{cfwd}{bgr}{czbz}{zhgxsj}{cfsfwh}{nfgrbw}{dmjg}{cwc}{cwk}{cwyg}{cwdg}{cwtcwj}{cnc}{cnk}{cnyg}{cnzlxg}{cntcnj}{cntj}{cmsl}{qtjg}{fdjg}{fjjg}{cmwz}{cmgd}{cmkd}{grbwcs}"; private String method = "saveStoreHouseRecordDetail";// 填写数据方法名 private String wsdl = "/storeLocationWebService?wsdl";//填写调用库点信息接口服务 private String nameSpace = "http://service.sljt.com";// 填写调用省平台命名空间 public InvokeResult webService(AuthToken authToken,ApiConfs conf, Api1103 data) { InvokeResult invokeResult = new InvokeResult(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); String url = conf.getApiUrl() + "/storeHouseWebService?wsdl"; // 填写调用仓房信息接口服务 String method = "saveStoreHouseRecordDetail"; // 填写数据方法名 String nameSpace = "http://service.sljt.com"; // 填写调用省平台命名空间 Thread.currentThread().setContextClassLoader(cl); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient(url); QName name = new QName(nameSpace, method); Object[] objects; try { String xmlStr = webServiceXml(data);// 获取接口的输入报文,根据需要填写相应的报文 log.debug("------xmlStr--{}", xmlStr); objects = client.invoke(name, new Object[]{authToken.getToken(), xmlStr}); log.debug("-----------返回信息---{}", objects[0].toString()); invokeResult = JaxbUtil.converyToJavaBean(objects[0].toString(), InvokeResult.class); } catch (Exception e) { log.error("----执行异常----{}", e); invokeResult.setCode(GDResult.CODE_500.getCode()); invokeResult.setData("后端服务执行异常:+" + e.getMessage()); return invokeResult; } return invokeResult; } /** * 报文获取-- 替换数据 * * @param data * @return */ private String webServiceXml(Api1103 data) { String xmlStr = xml_webservice; xmlStr = xmlStr.replace("{sskd}", GDUtils.formatStr(data.getKqdm()));//所属库点代码 xmlStr = xmlStr.replace("{cfmc}", GDUtils.formatStr(data.getCfmc()));//仓房名称 xmlStr = xmlStr.replace("{cfbm}", GDUtils.formatStr(data.getCfdm()));//仓房编码 xmlStr = xmlStr.replace("{cflx}", GDUtils.formatStr(data.getCflxdm()));//仓房类型 xmlStr = xmlStr.replace("{cfsjcr}", GDUtils.formatNum(data.getSjcr()));//仓房设计仓容 xmlStr = xmlStr.replace("{jfsyrq}", GDUtils.formatDate(data.getJfsyrq(), "yyyy-MM-dd"));//交付使用日期 xmlStr = xmlStr.replace("{qtjg}", GDUtils.formatStr(data.getQtjg()));//墙体结构 xmlStr = xmlStr.replace("{fdjg}", GDUtils.formatStr(data.getFdjg()));//房顶结构 xmlStr = xmlStr.replace("{fjjg}", GDUtils.formatStr(data.getFjjg()));//房架结构 xmlStr = xmlStr.replace("{dmjg}", GDUtils.formatStr(data.getDmjg()));//地面结构 xmlStr = xmlStr.replace("{cwc}", GDUtils.formatNum(data.getCwc()));//仓外长 xmlStr = xmlStr.replace("{cwk}", GDUtils.formatNum(data.getCwk()));//仓外宽 xmlStr = xmlStr.replace("{cwyg}", GDUtils.formatNum(data.getCwyg()));//仓外檐高 xmlStr = xmlStr.replace("{cwdg}", GDUtils.formatNum(data.getCwdg()));//仓外顶高 xmlStr = xmlStr.replace("{cwtcwj}", GDUtils.formatNum(data.getTcwj()));//筒仓外径 xmlStr = xmlStr.replace("{cnc}", GDUtils.formatNum(data.getCnc()));//仓内长 xmlStr = xmlStr.replace("{cnk}", GDUtils.formatNum(data.getCnk()));//仓内宽 xmlStr = xmlStr.replace("{cnyg}", GDUtils.formatNum(data.getCnyg()));//仓内檐高 xmlStr = xmlStr.replace("{cnzlxg}", GDUtils.formatNum(data.getCnzlxg()));//仓内装粮线高 xmlStr = xmlStr.replace("{cntcnj}", GDUtils.formatNum(data.getTcnj()));//筒仓内径 xmlStr = xmlStr.replace("{cntj}", GDUtils.formatNum(data.getCntj()));//仓内体积 xmlStr = xmlStr.replace("{cmsl}", GDUtils.formatNum(data.getCmsl()));//仓门数量 xmlStr = xmlStr.replace("{cmwz}", GDUtils.formatStr(data.getCmwz()));//仓门位置 xmlStr = xmlStr.replace("{cmgd}", GDUtils.formatNum(data.getCmgd()));//仓门高度 xmlStr = xmlStr.replace("{cmkd}", GDUtils.formatNum(data.getCmkd()));//仓门宽度 xmlStr = xmlStr.replace("{cfsfwh}", GDUtils.formatStr(data.getCfsfwh()));//仓房是否完好 xmlStr = xmlStr.replace("{nfgrbw}", GDUtils.formatStr(data.getNfgrbw()));//能否隔热保温 xmlStr = xmlStr.replace("{grbwcs}", GDUtils.formatStr(data.getGrbwcs()));//隔热保温措施 xmlStr = xmlStr.replace("{nfszcc}", GDUtils.formatStr(data.getNfszcc()));//能否散装储存 xmlStr = xmlStr.replace("{ywfsfqfczz}", GDUtils.formatStr(data.getYwfsfqfczz()));//有无防鼠防雀防虫装置及设施 xmlStr = xmlStr.replace("{ywfhfbfdss}", GDUtils.formatStr(data.getYwfhfbfdss()));//有无防火防爆防盗措施 xmlStr = xmlStr.replace("{ywlqjcss}", "1");//有无粮情检测设施 xmlStr = xmlStr.replace("{ywjxtfss}", GDUtils.formatStr(data.getYwjxtfss()));//有无机械通风设施 xmlStr = xmlStr.replace("{nfhlxzsc}", GDUtils.formatStr(data.getNfhlxzsc()));//能否环流熏蒸杀虫 xmlStr = xmlStr.replace("{nffddyqtcl}", GDUtils.formatStr(data.getNffddyqtcl()));//能否富氮低氧气调储粮 xmlStr = xmlStr.replace("{nfcwcc}", "9");//能否仓外测虫 xmlStr = xmlStr.replace("{cfzt}", GDUtils.formatStr(data.getCfzt()));//仓房状态 xmlStr = xmlStr.replace("{cfccfs}", "0");//仓房存储方式 0:散装 1:包装 xmlStr = xmlStr.replace("{cfjd}", GDUtils.formatNum(data.getJd()));//仓房经度 xmlStr = xmlStr.replace("{cfwd}", GDUtils.formatNum(data.getWd()));//仓房经度 xmlStr = xmlStr.replace("{bgr}", GDUtils.formatStr(data.getBgr()));//保管员 xmlStr = xmlStr.replace("{czbz}", GDUtils.formatStr(data.getCzbz()));//操作标志 xmlStr = xmlStr.replace("{zhgxsj}", GDUtils.formatDate(data.getZhgxsj(), "yyyy-MM-dd HH:mm:ss"));//最后更新时间 return xmlStr; } }