package com.fzzy.push.gd2020.v2; import com.fzzy.api.data.AuthToken; import com.fzzy.api.entity.Api1102; import com.fzzy.api.entity.Api1105; import com.fzzy.api.entity.Api1208; 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/16 */ @Slf4j public class InventoryRecordLiquidWebService { public static InventoryInsertRecordSolidWebService newInstance() { return new InventoryInsertRecordSolidWebService(); } public String xml_webService = "{hwmc}{foodstuff_grade_id}{glfs}{scdd}{clfs}{rcsj}{production_year}{gb}{store_location_id}{storehouse_id}{ownership}{foodstuff_varieties_id}{foodstuff_nature_id}{grain_authority}{storage_qty}{production}{put_in_time}{goods_allocation_id}{jjsl}{bclbs}{sjzlxg}{ldtj}{ldkxd}{granary_id}{hwzt}{ccwcsj}{fcrq}{qcsj}{bz}{keep_people}{czbz}{zhgxsj}"; private String method = "inventoryInsertRecordByLiquid";// 填写数据方法名 private String wsdl = "/inventoryRecordLiquidWebService?wsdl";//填写调用库点信息接口服务 private String nameSpace = "http://service.sljt.com";// 填写调用省平台命名空间 public InvokeResult webService(AuthToken authToken,ApiConfs conf, Api1208 data, Api1102 api1102, Api1105 api1105) { InvokeResult invokeResult = new InvokeResult(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); String url = conf.getApiUrl() + wsdl; // 填写调用粮食库存数据接口服务 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, api1102, api1105);// 获取接口的输入报文,根据需要填写相应的报文 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; } private String webServiceXml(Api1208 data, Api1102 api1102, Api1105 api1105) { String xmlStr = xml_webService; xmlStr = xmlStr.replace("{store_location_id}", GDUtils.formatStr(data.getKqdm()));//库点代码 xmlStr = xmlStr.replace("{storehouse_id}", GDUtils.formatStr(data.getHwdm()));// 仓房名称 -值为货位代码 xmlStr = xmlStr.replace("{ownership}", GDUtils.formatStr(api1102.getXzqhdm()));//粮权归属行政区划 -使用库区的行政区 xmlStr = xmlStr.replace("{foodstuff_varieties_id}", GDUtils.formatStr(data.getLspzdm()));//粮食品种 xmlStr = xmlStr.replace("{foodstuff_nature_id}", GDUtils.formatStr(data.getLsxzdm()));//粮食性质 xmlStr = xmlStr.replace("{grain_authority}", GDUtils.formatStr(data.getLqgsdwdm()));//粮权所属企业 xmlStr = xmlStr.replace("{storage_qty}", GDUtils.formatNum(data.getSjsl()));//库存量 xmlStr = xmlStr.replace("{jjsl}", GDUtils.formatNum(data.getJjsl()));//计价数量 xmlStr = xmlStr.replace("{bclbs}", GDUtils.formatNum(data.getBclbs()));//包存粮包数 xmlStr = xmlStr.replace("{sjzlxg}", GDUtils.formatNum(data.getSjzlxg()));//实际装粮线高 xmlStr = xmlStr.replace("{ldtj}", GDUtils.formatNum(data.getLdtj()));//粮堆体积 xmlStr = xmlStr.replace("{ldkxd}", "");//粮堆孔隙度 xmlStr = xmlStr.replace("{put_in_time}", GDUtils.formatDate(data.getRcsj(), "yyyy-MM-dd"));//入库日期 xmlStr = xmlStr.replace("{production}", GDUtils.formatStr(data.getCd()));//产地 xmlStr = xmlStr.replace("{granary_id}", "");//廒间 xmlStr = xmlStr.replace("{goods_allocation_id}", GDUtils.formatStr(data.getHwdm()));//货位编码 xmlStr = xmlStr.replace("{hwmc}", GDUtils.formatStr(api1105.getHwmc()));//货位名称 xmlStr = xmlStr.replace("{keep_people}", GDUtils.formatStr(data.getBgy()));//保管员姓名 xmlStr = xmlStr.replace("{production_year}", GDUtils.formatStr(data.getShnd()));// 收获年度 xmlStr = xmlStr.replace("{shnd}", GDUtils.formatStr(data.getShnd()));//收获年度 xmlStr = xmlStr.replace("{foodstuff_grade_id}", GDUtils.formatStr(data.getLsdjdm()));//粮食等级 xmlStr = xmlStr.replace("{gb}", GDUtils.formatStr(data.getGb()));//国别 xmlStr = xmlStr.replace("{hwzt}", GDUtils.formatStr(data.getHwzt()));//货位(油罐)状态 xmlStr = xmlStr.replace("{glfs}", GDUtils.formatStr(data.getGlfs()));//管理方式 xmlStr = xmlStr.replace("{scdd}", GDUtils.formatStr(data.getScdd()));//收储地点 xmlStr = xmlStr.replace("{clfs}", GDUtils.formatStr(data.getClfs()));//储粮方式 xmlStr = xmlStr.replace("{rcsj}", GDUtils.formatDate(data.getRcsj(), "yyyy-MM-dd HH:mm:ss"));//入仓时间 xmlStr = xmlStr.replace("{ccwcsj}", GDUtils.formatDate(data.getCcwcsj(), "yyyy-MM-dd HH:mm:ss"));//出仓完成时间 xmlStr = xmlStr.replace("{fcrq}", GDUtils.formatDate(data.getFcrq(), "yyyy-MM-dd"));//封仓日期 xmlStr = xmlStr.replace("{qcsj}", "");//清仓时间 xmlStr = xmlStr.replace("{bz}", GDUtils.formatStr(data.getBz()));//备注 xmlStr = xmlStr.replace("{czbz}", GDUtils.formatStr(data.getCzbz()));//操作标志 xmlStr = xmlStr.replace("{zhgxsj}", GDUtils.formatDate(data.getZhgxsj(), "yyyy-MM-dd HH:mm:ss"));//最后更新时间 return xmlStr; } }