From f76fc42505d9938200d9abfd021d63dc5f4f48f6 Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Fri, 28 Feb 2025 14:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusiregForSyncSaleorderAndToBIP.java | 261 ++++ .../resource/GatheringbillRestResource.java | 1145 +++++++++++++++++ 2 files changed, 1406 insertions(+) create mode 100644 arap/src/private/nc/bs/arap/busireg/BusiregForSyncSaleorderAndToBIP.java create mode 100644 arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java diff --git a/arap/src/private/nc/bs/arap/busireg/BusiregForSyncSaleorderAndToBIP.java b/arap/src/private/nc/bs/arap/busireg/BusiregForSyncSaleorderAndToBIP.java new file mode 100644 index 0000000..31c099f --- /dev/null +++ b/arap/src/private/nc/bs/arap/busireg/BusiregForSyncSaleorderAndToBIP.java @@ -0,0 +1,261 @@ +package nc.bs.arap.busireg; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.yonyou.cloud.utils.StringUtils; +import nc.bs.businessevent.BdUpdateEvent; +import nc.bs.businessevent.BusinessEvent; +import nc.bs.businessevent.IBusinessEvent; +import nc.bs.businessevent.IBusinessListener; +import nc.bs.dao.BaseDAO; +import nc.bs.trade.business.HYSuperDMO; +import nc.bs.uapbd.util.IgnoreSslUtil; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapProcessor; +import nc.vo.arap.basebill.BaseAggVO; +import nc.vo.arap.utils.ArrayUtil; +import nc.vo.pub.AggregatedValueObject; +import nc.vo.pub.BusinessException; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pub.lang.UFDouble; +import nc.vo.so.m30.entity.SaleOrderHVO; +import nccloud.bs.arap.sagas.util.SagasUtils; +import nccloud.commons.lang.ArrayUtils; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.HttpsURLConnection; +import java.io.*; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +public class BusiregForSyncSaleorderAndToBIP implements IBusinessListener{ + + @Override + public void doAction(IBusinessEvent event) throws BusinessException { + // TODO Auto-generated method stub + BaseAggVO[] bills = getBills(event); + if (ArrayUtils.isEmpty(bills) || SagasUtils.isCompensateStage()) { + return; + } + // 更新 销售订单 + try { + BaseDAO dao = new BaseDAO(); + for(BaseAggVO aggvo : bills) { + CircularlyAccessibleValueObject headvo = aggvo.getParentVO(); + // 本次收款金额 + Object money = headvo.getAttributeValue("money"); + // 收款单主键 + Object pk_busibill = headvo.getAttributeValue("pk_gatherbill"); + // 销售订单主键 + Object csaleorderid = headvo.getAttributeValue("def3"); + // 根据销售订单主键,查询比较字段 + String sql = "select vdef17, vdef15, vdef14, vdef11, vdef9 from so_saleorder where csaleorderid = '" + csaleorderid + "' and dr = 0 "; + HashMap hm = (HashMap)dao.executeQuery(sql, new MapProcessor()); + Object vdef17 = hm.get("vdef17"); + Object vdef15 = hm.get("vdef15"); + Object vdef14 = hm.get("vdef14"); + Object vdef11 = hm.get("vdef11"); + Object vdef9 = hm.get("vdef9"); + // 合同号 + Object ctpk = aggvo.getChildrenVO()[0].getAttributeValue("def6"); + // 查询合同号下 + String sql1 = " select sum(ar_gatheritem.money_cr) sk_effect_money " + + " from ar_gatheritem " + + " left join ar_gatherbill on ar_gatherbill.pk_gatherbill = ar_gatheritem.pk_gatherbill " + + " where ar_gatherbill.dr = 0 and ar_gatheritem.dr = 0 and ar_gatherbill.EFFECTSTATUS = 10 " + + " and ar_gatheritem.def6 = '" + ctpk + "'"; + Object obj = dao.executeQuery(sql1, new ColumnProcessor()); + // 收款单累计金额 + UFDouble sk_effect_money = UFDouble.ZERO_DBL; + if(obj != null) { + sk_effect_money = new UFDouble(obj.toString()); + } + // 表头合同金额 + UFDouble ctmoney = UFDouble.ZERO_DBL; + if(vdef17 != null) { + ctmoney = new UFDouble(vdef17.toString()); + } + // 预收比例 + UFDouble preratio = UFDouble.ZERO_DBL; + if(vdef15 != null) { + preratio = new UFDouble(vdef15.toString()); + } + // 收款大于预收 + if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) >= 0) { + String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk01') where csaleorderid = '" + csaleorderid + "'"; + dao.executeUpdate(updateSQL); + } else if (sk_effect_money.compareTo(UFDouble.ZERO_DBL) > 0 && sk_effect_money.sub(ctmoney.multiply(preratio)).compareTo(UFDouble.ZERO_DBL) < 0) { + String updateSQL = "update so_saleorder set vdef11 = (select pk_defdoc from bd_defdoc where code = 'fhk02') where csaleorderid = '" + csaleorderid + "'"; + dao.executeUpdate(updateSQL); + } + JSONObject HTXSDD = new JSONObject(); + HTXSDD.put("id", vdef9); + HYSuperDMO dmo= new HYSuperDMO(); + SaleOrderHVO[] hvo = (SaleOrderHVO[])dmo.queryByWhereClause(SaleOrderHVO.class, "csaleorderid='"+csaleorderid+"'"); + + + // 实际预收款 npreceivemny + UFDouble npreceivemny = hvo[0].getNpreceivemny(); + JSONObject p = new JSONObject(); + HTXSDD.put("actPreRecvAmt", npreceivemny.getDouble()); + // 实际收款金额 nreceivedmny + UFDouble nreceivedmny = hvo[0].getNreceivedmny(); + HTXSDD.put("actRecvAmt", nreceivedmny.getDouble()); + // 是否收到预收款 + Object vdef14Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef14 + "'", new ColumnProcessor()); + HTXSDD.put("isPreRecv", vdef14Code); + // 是否收到发货款 + Object vdef11Code = dao.executeQuery("select code from bd_defdoc where pk_defdoc = '" + vdef11 + "'", new ColumnProcessor()); + HTXSDD.put("isShipRecdAmt", vdef11Code); + p.put("HTXSDD", HTXSDD); + System.out.println(p.toJSONString()); + // 获取旗舰版的token + Map params = new HashMap<>(); + String appKey = "a3c57e0d871240e9b9bf56b35001a324"; + String appSecret = "a959f7786db8dbb9a2c0493b5855a46bea68ad75"; + String tokenUrl="https://www.tkkfbip.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; + String toBipUrl="https://www.tkkfbip.com/iuap-api-gateway/oxp4h3x6/current_yonbip_default_sys/KKAPI/contractSaleOrder/update?access_token="; + // 除签名外的其他参数 + params.put("appKey", appKey); + String timestamp = String.valueOf(System.currentTimeMillis()); + params.put("timestamp", timestamp); + // 计算签名 + Map treeMap; + if (params instanceof TreeMap) { + treeMap = params; + } else { + treeMap = new TreeMap<>(params); + } + StringBuilder stringBuilder = new StringBuilder(); + for (Map.Entry entry : treeMap.entrySet()) { + stringBuilder.append(entry.getKey()).append(entry.getValue()); + } + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); + byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8)); + String base64String = Base64.getEncoder().encodeToString(signData); + String signature = URLEncoder.encode(base64String, "UTF-8"); + params.put("signature", signature); + String responseString = doGet(tokenUrl, params); + Gson gson = new Gson(); + Map result = gson.fromJson(responseString, Map.class); + if (StringUtils.equals("00000", result.get("code").toString())) { + Map tokenInfo = (Map) result.get("data"); + String access_token = (String) tokenInfo.get("access_token"); + doPost(toBipUrl+ access_token, p); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private BaseAggVO[] getBills(IBusinessEvent event) { + Object value = null; + if (event instanceof BusinessEvent) { + value = ((BusinessEvent)event).getObject(); + } else if (event instanceof BdUpdateEvent) { + value = ((BdUpdateEvent)event).getNewObject(); + } + BaseAggVO[] bills = null; + if (null != value) { + if (value.getClass().isArray()) { + Object[] objs = (Object[])value; + bills = (objs instanceof BaseAggVO[]) ? (BaseAggVO[])objs : (BaseAggVO[])ArrayUtil.convertSupers2Subs((AggregatedValueObject[])objs, BaseAggVO.class); + } else { + bills = new BaseAggVO[1]; + bills[0] = (BaseAggVO)value; + } + } + return bills; + } + +private String doGet(String requestUrl, Map paramMap) throws IOException { + + StringBuilder param = new StringBuilder("?"); + if (paramMap != null) { + for (Map.Entry entry : paramMap.entrySet()) { + param.append(entry.getKey()); + param.append("="); + param.append(entry.getValue()); + param.append("&"); + } + param.deleteCharAt(param.length() - 1); + } + String url = requestUrl + param; + URL u = new URL(url); + try { + if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任,不信任则调用忽略信任工具类SslUtil + IgnoreSslUtil.ignoreSsl(); + } + HttpsURLConnection connection = (HttpsURLConnection)u.openConnection(); + connection.setRequestMethod("GET"); + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + connection.connect(); + StringBuilder response =new StringBuilder(); + int responsecode = connection.getResponseCode(); + if(responsecode == HttpsURLConnection.HTTP_OK) { + InputStream inputstream =connection.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream)); + String line; + + while((line =reader.readLine()) != null) { + response.append(line); + } + reader.close(); + } + connection.disconnect(); + return response.toString(); + } catch(Exception e) { + e.printStackTrace(); + } + + + + return null; + } + + private String doPost(String requestUrl, JSONObject json) throws IOException { + URL u = new URL(requestUrl); + try { + if("https".equalsIgnoreCase(u.getProtocol())){//判定网址是否信任,不信任则调用忽略信任工具类SslUtil + IgnoreSslUtil.ignoreSsl(); + } + HttpsURLConnection connection = (HttpsURLConnection)u.openConnection(); + // 设置请求方法 + connection.setRequestMethod("POST"); + // 设置请求属性 + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + // 发送POST请求必须设置如下两行 + connection.setDoOutput(true); + connection.setDoInput(true); + byte[] outputInBytes = json.toJSONString().getBytes(StandardCharsets.UTF_8); + // 写入数据到请求体 + OutputStream os = connection.getOutputStream(); + os.write(outputInBytes); + // 获取响应码 + int responseCode = connection.getResponseCode(); + System.out.println("Response Code: " + responseCode); + // 读取响应 + String response = ""; + try(BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + br.readLine(); + System.out.println("Response: " + response); + } + // 关闭连接 + connection.disconnect(); + return response; + } catch(Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java new file mode 100644 index 0000000..ae08f10 --- /dev/null +++ b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java @@ -0,0 +1,1145 @@ +/* */ +package nc.api.arap.resource; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import nc.bd.itf.tools.BFPubTools; +import nc.bs.dao.BaseDAO; +import nc.bs.dao.DAOException; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.framework.common.NCLocator; +import nc.bs.sec.esapi.NCESAPI; +import nc.bs.trade.business.HYPubBO; +import nc.bs.trade.business.HYSuperDMO; +import nc.itf.arap.pub.IArapBillService; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapProcessor; +import nc.vo.arap.basebill.BaseAggVO; +import nc.vo.arap.gathering.AggGatheringBillVO; +import nc.vo.arap.gathering.GatheringBillItemVO; +import nc.vo.arap.gathering.GatheringBillVO; +import nc.vo.bd.defdoc.DefdocVO; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.pub.BusinessException; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.pub.MathTool; +import nc.vo.so.m30.entity.SaleOrderBVO; +import nc.vo.so.m30.entity.SaleOrderHVO; +import nccloud.api.rest.utils.NCCRestUtils; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.commons.lang.StringUtils; +import nccloud.pubitf.arap.openapi.IARAPOpenAPIService; +import nccloud.pubitf.arap.openapi.IGatheringbillOpenService; +import org.json.JSONString; +import uap.ws.rest.util.UAPRSConstance; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.*; +import java.util.zip.GZIPInputStream; +/* */ +/* */ +/* */ +/* */ +/* */ + + +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +@Path("arap/gatheringbill") +/* */ public class GatheringbillRestResource + /* */ extends ArapBaseRestResource + /* */ { + + + HYSuperDMO dmo = null; + + public HYSuperDMO getSuperDMO() { + + if (dmo == null) { + dmo = new HYSuperDMO(); + } + + return dmo; + } + + + @POST + @Path("/insert") + @Consumes(UAPRSConstance.MEDIATYPE_JSON) + @Produces(UAPRSConstance.MEDIATYPE_JSON) + public JSONString insertPaybill(JSONString str) { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = super.fromJson(json, Map.class); + GatheringBillVO headvo = (GatheringBillVO) super.fromJsonToVO(billMap, GatheringBillVO.class); + + @SuppressWarnings("unchecked") + List> itemMaps = (List>) billMap.get("items"); + List itemvos = new ArrayList(); + if (itemMaps != null && itemMaps.size() > 0) { + for (Map item : itemMaps) { + GatheringBillItemVO itemvo = (GatheringBillItemVO) super.fromJsonToVO(item, GatheringBillItemVO.class); + itemvos.add(itemvo); + } + } + AggGatheringBillVO bill = new AggGatheringBillVO(); + bill.setParentVO(headvo); + bill.setChildrenVO(itemvos.toArray(new GatheringBillItemVO[0])); + + try { + Map returnMap = NCLocator.getInstance().lookup(IGatheringbillOpenService.class).saveBill(bill); + return ResultMessageUtil.toJSON(returnMap); + } catch (BusinessException e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + /** + * 该收款单保存为BIP专业保存方法。请谨慎修改; + * + * @param str + * @return + */ + + + /* */ + @POST + /* */ + @Path("/bipinsert") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString bipInsertPaybill(JSONString str) { + InvocationInfoProxy.getInstance().setGroupId("0001A110000000000677"); + /* 48 */ + NCCRestUtils.initInvocationInfo(); + /* 49 */ + String json = str.toJSONString(); + /* 50 */ + Map billMap = (Map) fromJson(json, Map.class); + billMap.put("recaccount", billMap.get("ar_recaccount")); + /* 51 */ + GatheringBillVO headvo = (GatheringBillVO) ArapBaseRestResource.fromJsonToVO(billMap, GatheringBillVO.class); + + headvo.setDef28(headvo.getBilldate().toStdString());// 交易日期 + + // 汇率为空时,默认为1 + if (headvo.getRate() == null) { + headvo.setRate(UFDouble.ONE_DBL); + } + /* */ + // 结算方式名称 + Object balatypeName = ""; + // 金额 + UFDouble money = new UFDouble(0); + // 组织本币金额 + UFDouble local_money = new UFDouble(0); + // 税率 + UFDouble ntaxrate = new UFDouble(0); + // 税码 + String ctaxcode = ""; + + BaseDAO dao = new BaseDAO(); + + // 销售订单号 + String csaleorderid = ""; + + try { + HYPubBO hybo = new HYPubBO(); + headvo.setIsinit(new UFBoolean(false)); + // 默认 收款类型 默认合同收款单 + Object pk_billtypecode = hybo.findColValue("bd_billtype", "PK_BILLTYPECODE", "billtypename = '合同收款单' "); + headvo.setPk_tradetype(pk_billtypecode.toString()); + // 业务流程 默认【收款结算】 + Object pk_busitype = hybo.findColValue("bd_busitype", "busicode", "businame = '收款结算' "); + headvo.setPk_busitype(pk_busitype.toString()); + // 往来对象0-客户 2-部门 3-业务员 默认客户 + headvo.setObjtype(0); + // 销售订单号 + csaleorderid = headvo.getDef3(); + // 客户 + Object customerid = hybo.findColValue("so_saleorder", "ccustomerid", "csaleorderid = '" + csaleorderid + "' "); + Object customerCode = hybo.findColValue("bd_customer", "code", "pk_customer = '" + customerid + "' "); + headvo.setCustomer(customerCode.toString()); + + Object tr = dao.executeQuery("select ntaxrate from so_saleorder_b where csaleorderid = '" + csaleorderid + "'", new ColumnProcessor()); + if (tr != null) { + ntaxrate = new UFDouble(tr.toString()); + } + + // 税码 + Object ctaxcodeid = hybo.findColValue("so_saleorder_b", "ctaxcodeid", "csaleorderid = '" + csaleorderid + "' "); + Object tc = hybo.findColValue("bd_taxcode", "code", "pk_taxcode = '" + ctaxcodeid + "' "); + ctaxcode = BFPubTools.getString_TrimAsNull(tc); + + // 业务员 + Object cemployeeid = hybo.findColValue("so_saleorder", "cemployeeid", "csaleorderid = '" + csaleorderid + "' "); + if (cemployeeid != null) {// 能够获取到值,但是该值可能在销售订单生成的时候,没有翻译,依然存的是人员编码,如果存的是人员编码,则说明该人员在erp系统中不存在 + Object cemployeeCode = hybo.findColValue("bd_psndoc", "code", "pk_psndoc = '" + cemployeeid + "' "); + if (cemployeeCode != null) { + headvo.setPk_psndoc(cemployeeCode.toString()); + // 部门 + Object deptCode = hybo.findColValue("org_orgs", "code", + " pk_org in( select pk_dept from bd_psnjob where pk_psndoc = '" + cemployeeid + "')"); + if (deptCode != null) { + headvo.setPk_deptid(deptCode.toString()); + } + + } + + } + + + // pk_currtype 币种编码 默认人民币 + if (headvo.getPk_currtype() == null || headvo.getPk_currtype().isEmpty()) { + headvo.setPk_currtype("CNY"); + } + + // accessorynum 附件张数 默认2 + headvo.setAccessorynum(2); + // 制单人 默认BIP + headvo.setBillmaker("BIP"); + // 结算方式名称 + String balatypeCode = headvo.getPk_balatype(); + if (!StringUtils.isEmpty(balatypeCode)) { + Object pk_balatype = hybo.findColValue("bd_balatype", "pk_balatype", " code = '" + balatypeCode + "' "); +// headvo.setPk_balatype(pk_balatype.toString()); + if (pk_balatype != null) { + balatypeName = hybo.findColValue("bd_balatype", "name", " code = '" + balatypeCode + "' "); + } + + } + + // 银行收款账号 + // 原币金额 + // 单据状态 + headvo.setBillstatus(-1); + // 单据来源系统编码 + headvo.setSrc_syscode(17); + // 合同金额 + // 结算组织 + headvo.setSett_org(headvo.getPk_org()); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + + /* */ + /* 54 */ + List> itemMaps = (List) billMap.get("items"); + /* 55 */ + List itemvos = new ArrayList(); + /* 56 */ + if (itemMaps != null && itemMaps.size() > 0) { + /* 57 */ + for (Map item : itemMaps) { + /* 58 */ + GatheringBillItemVO itemvo = (GatheringBillItemVO) ArapBaseRestResource.fromJsonToVO(item, GatheringBillItemVO.class); + + try { + HYPubBO hybo = new HYPubBO(); + itemvo.setRecaccount(headvo.getRecaccount()); + // pk_balatype 结算方式 表头带出 + itemvo.setPk_balatype(headvo.getPk_balatype()); + // 票据类型 checktype 结算方式:银行承兑汇票-电子、银行承兑汇票-纸质=银行承兑汇票;商业承兑汇票-电子、商业承兑汇票-纸质=商业承兑汇票 + String checktypeName = ""; + +// if("银行承兑汇票-电子".equals(balatypeName) || "银行承兑汇票-纸质".equals(balatypeName)) { +// checktypeName = "银行承兑汇票"; +// } +// if("商业承兑汇票-电子".equals(balatypeName) || "商业承兑汇票-纸质".equals(balatypeName)) { +// checktypeName = "商业承兑汇票"; +// } + + if ("银行承兑汇票-电子".equals(balatypeName)) { + checktypeName = "电子银行承兑汇票"; + } else if ("商业承兑汇票-电子".equals(balatypeName)) { + checktypeName = "电子商业承兑汇票"; + } else if ("商业承兑汇票-纸质".equals(balatypeName)) { + checktypeName = "商业承兑汇票"; + } else if ("银行承兑汇票-纸质".equals(balatypeName)) { + checktypeName = "银行承兑汇票"; + } + + if (checktypeName != "") { + Object checktypeCode = hybo.findColValue("bd_notetype", "code", " name = '" + checktypeName + "' "); + itemvo.setChecktype(checktypeCode.toString()); + } + +// Object checktypeCode = hybo.findColValue("bd_notetype", "code", " name = '" + checktypeName + "' "); +// itemvo.setChecktype(checktypeCode.toString()); + // objtype 往来对象0-客户 2-部门 3-业务员 表头带出 + itemvo.setObjtype(headvo.getObjtype()); + // supplier 客户编码 表头带出 + itemvo.setCustomer(headvo.getCustomer()); + // pk_dept 部门编码 表头带出 + itemvo.setPk_deptid(headvo.getPk_deptid()); + // pk_psndoc 业务员编码 表头带出 + itemvo.setPk_psndoc(headvo.getPk_psndoc()); + // pk_currtype 币种编码 表头带出 + itemvo.setPk_currtype(headvo.getPk_currtype()); + // prepay 收款性质 默认应收款 0 + itemvo.setPrepay(0); + // + UFDouble money_cr = itemvo.getMoney_cr(); + UFDouble local_tax_cr = money_cr.multiply(ntaxrate).div(100); + itemvo.setLocal_tax_cr(local_tax_cr); + // + UFDouble notax_cr = money_cr.sub(local_tax_cr); + itemvo.setNotax_cr(notax_cr); + itemvo.setRate(headvo.getRate()); + // 组织本币汇率 + if (itemvo.getRate() == null) { + itemvo.setRate(UFDouble.ZERO_DBL); + } + // + itemvo.setTaxcodeid(ctaxcode); + // + itemvo.setTaxrate(ntaxrate); + + // 收支项目 + itemvo.setPk_subjcode("201"); +// itemvo.setSubjcode("201"); + money = money.add(itemvo.getMoney_cr()); + UFDouble local_money_cr = itemvo.getMoney_cr().multiply(itemvo.getRate()).setScale(2, 4); + itemvo.setLocal_money_cr(local_money_cr); + local_money.add(local_money_cr); + + Object def2 = itemvo.getDef2(); + if (def2 != null) + itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def2 + "' ") + ""); + Object def3 = itemvo.getDef3(); + if (def3 != null) + itemvo.setDef3(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def3 + "' ") + ""); + Object def6 = itemvo.getDef6(); + if (def6 != null) + itemvo.setDef6(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def6 + "' ") + ""); + Object def36 = itemvo.getDef36(); + if (def36 != null) + itemvo.setDef36(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def36 + "' ") + ""); + + + HYSuperDMO dmo = new HYSuperDMO(); + SaleOrderHVO[] hvo = (SaleOrderHVO[]) dmo.queryByWhereClause(SaleOrderHVO.class, "vbillcode='" + def2 + "'"); + SaleOrderBVO[] bvos = (SaleOrderBVO[]) dmo.queryByWhereClause(SaleOrderBVO.class, "csaleorderid='" + hvo[0].getPrimaryKey() + "'"); + if (bvos != null) { + itemvo.setSrc_billid(bvos[0].getCsaleorderid()); + itemvo.setSrc_itemid(bvos[0].getCsaleorderbid()); + itemvo.setSrc_billtype("30"); + itemvo.setSrc_tradetype(hvo[0].getVtrantypecode()); + itemvo.setTop_billid(bvos[0].getCsaleorderid()); + itemvo.setTop_itemid(bvos[0].getCsaleorderbid()); + itemvo.setTop_billtype("30"); + } + + + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + + + /* 59 */ + itemvos.add(itemvo); + /* */ + } + /* */ + } + + headvo.setMoney(money); + headvo.setGloballocal(money); + // headvo.setRate(new UFDouble(1)); + headvo.setLocal_money(local_money); + + /* 62 */ + AggGatheringBillVO bill = new AggGatheringBillVO(); + /* 63 */ + bill.setParentVO(headvo); + /* 64 */ + bill.setChildrenVO((CircularlyAccessibleValueObject[]) itemvos.toArray(new GatheringBillItemVO[0])); + /* */ + /* */ + try { + /* 67 */ + Map returnMap = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).saveBill(bill); + + JSONString resultJson = ResultMessageUtil.toJSON(returnMap); + // 保存后动作 + + + JSONObject js_result = JSON.parseObject(resultJson.toJSONString()); + + if (js_result.containsKey("success")) { + if (js_result.getString("success").equals("true")) { + if (js_result.containsKey("data")) { + JSONObject js_data = js_result.getJSONObject("data"); + String pk_gatherid = js_data.getString("pk_bill"); + String pk_org = js_data.getString("pk_org"); + + GatheringBillItemVO[] billItemVOs = (GatheringBillItemVO[]) bill.getChildrenVO(); + + for (GatheringBillItemVO gatheringBillItemVO : billItemVOs) { + afterChangeMny(gatheringBillItemVO.getSrc_billid(), pk_org, billItemVOs[0].getDef6(), pk_gatherid); + } + + + } + } + } + +// afterChangeMny(); + + +///* 68 */ return ResultMessageUtil.toJSON(returnMap); + return resultJson; + /* 69 */ + } catch (BusinessException e) { + /* 70 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + + + // 实际收款金额 01无约定预付款 02有约定已收到预付款 03有约定未收到款 + + /** + * @param csaleorderid 销售订单id + * @param pk_org 组织 + * @param ctid 合同id + * @param pk_gatherid 收款单id + */ + private void afterChangeMny(String csaleorderid, String pk_org, String ctid, String pk_gatherid) { + + + try { + + // 合同id + if (StringUtils.isEmpty(ctid)) { + return; + } + + // 获取销售订单表头 + SaleOrderHVO hvo = (SaleOrderHVO) getSuperDMO().queryByPrimaryKey(SaleOrderHVO.class, csaleorderid); + if (hvo == null) { + return; + } + + String vdef9 = hvo.getVdef9();// BIP 合同销售订单id + if (StringUtils.isEmpty(vdef9)) {// 为空,不是从bip 生成的 + return; + } + // 合同金额vdef17 + UFDouble ctmny = new UFDouble(hvo.getVdef17() == null ? "0" : hvo.getVdef17()); + // 预收比例vdef15 + UFDouble yfrate = new UFDouble(hvo.getVdef15() == null ? "0" : hvo.getVdef15()); + UFDouble temp_yf_mny = ctmny.multiply(yfrate); + + // 发货比例vdef16 + UFDouble fhrate = new UFDouble(hvo.getVdef16() == null ? "0" : hvo.getVdef16()); + UFDouble temp_fh_mny = ctmny.multiply(fhrate); + + // vdef14 预付款标识 + String vdef14 = "01";// 01无约定预付款 + + // vdef11 发货款标识 + String vdef11 = "fhk03";// fhk03无约定发货款 + + UFDouble total_mny = UFDouble.ZERO_DBL;// 当前组织下本合同所有收款单金额累计 + + String sum_sql = "select sum(money_cr) as money_cr from ar_gatheritem where def6 not in ('~') and dr=0 and def6='" + ctid + "'"; + Map map = (Map) new BaseDAO().executeQuery(sum_sql, new MapProcessor()); + if (map != null) { + total_mny = new UFDouble(String.valueOf(map.get("money_cr"))); + } + + + if ((MathTool.compareTo(yfrate, UFDouble.ZERO_DBL) == 0)) { + + } else { + if (MathTool.compareTo(total_mny, temp_yf_mny) >= 0) {// 累计收款金额≥合同金额*预收比例 + vdef14 = "02"; // 02有约定已收到预付款 + } else { + vdef14 = "03";// 03 有约定未收到款 + } + + } + + if ((MathTool.compareTo(fhrate, UFDouble.ZERO_DBL) == 0)) { + + } else { + if (MathTool.compareTo(total_mny, temp_fh_mny) >= 0) {// 累计收款金额≥合同金额*发货比例 + vdef11 = "fhk01";// fhk01有约定已收到发货款 + } else { + vdef11 = "fhk02";// fhk02有约定未收到发货款 + } + + + } + + DefdocVO[] defdocVOs = (DefdocVO[]) getSuperDMO().queryByWhereClause(DefdocVO.class, " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='xsdd' ) and code='" + vdef14 + "' and dr=0 "); + if (defdocVOs != null && defdocVOs.length > 0) { + hvo.setVdef14(defdocVOs[0].getPrimaryKey()); + } + + defdocVOs = (DefdocVO[]) getSuperDMO().queryByWhereClause(DefdocVO.class, " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='FHK' ) and code='" + vdef11 + "' and dr=0 "); + if (defdocVOs != null && defdocVOs.length > 0) { + hvo.setVdef11(defdocVOs[0].getPrimaryKey()); + } + + +// getSuperDMO().update(hvo); + pushBipCtOrderUpdate(hvo, vdef14, vdef11); + + } catch (DAOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * BIP 合同销售订单更新 + * + * @param hvo + * @param vdef14 预付款标识 + * @param vdef11 发货款标识 + */ + private void pushBipCtOrderUpdate(SaleOrderHVO hvo, String vdef14, String vdef11) { + + String baseUrl = ""; + + Map bipParamMap = checkBipParam(); + if (bipParamMap.isEmpty()) { + return; + } + + baseUrl = bipParamMap.get("baseUrl"); + String contractSaleOrderUrl = bipParamMap.get("contractSaleOrder");// 开票申请单回传 + if (StringUtils.isEmpty(contractSaleOrderUrl)) { + return; + } + Gson gson = new Gson(); + try { + String accessToken = getAccessToken(baseUrl, bipParamMap); + if (accessToken != "") { + Map tokenParam = new HashMap<>(); + tokenParam.put("access_token", accessToken); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + String custUpdateUrl = baseUrl + contractSaleOrderUrl; + JSONObject js_apct_detail = new JSONObject(); + JSONObject js_apct = new JSONObject(); + js_apct.put("id", hvo.getVdef9()); + js_apct.put("isShipRecdAmt", vdef11); + js_apct.put("isPreRecv", vdef14); + js_apct.put("actRecvAmt", hvo.getNreceivedmny().floatValue()); + js_apct.put("actPreRecvAmt", hvo.getNpreceivemny().floatValue()); + js_apct_detail.put("HTXSDD", js_apct); + String resultString = doSendHttp(custUpdateUrl, "POST", tokenParam, "", headers, js_apct_detail.toJSONString()); + Map updateMap = gson.fromJson(resultString, Map.class); + if (StringUtils.equals("200", updateMap.get("code").toString())) {// 保存更新成功后需要更新日志表 + getSuperDMO().update(hvo); + } else { +// getSuperDMO().update(hvo); + } + + } + } catch (InvalidKeyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DAOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + /** + * 检查bip参数是否完整 + * + * @return + */ + private Map checkBipParam() { + + Map map = new HashMap(); + + String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='BIP-sq' and dr=0 ) and dr=0"; + + try { + DefdocVO[] defdocVOs = (DefdocVO[]) getSuperDMO().queryByWhereClause(DefdocVO.class, strWhere); + if (defdocVOs != null && defdocVOs.length > 0) { + for (DefdocVO defdocVO : defdocVOs) { + + map.put(defdocVO.getCode().trim(), defdocVO.getName()); + + } + } + } catch (DAOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return map; + + } + + + private static String doGet(String path, Map params) throws IOException { + HttpURLConnection conn = null; + InputStream is = null; + BufferedReader br = null; + StringBuilder result = new StringBuilder(); + try { + if (params != null) { + String paramStr = ""; + for (String key : params.keySet()) { + if (!paramStr.isEmpty()) { + paramStr += '&'; + } + paramStr += key + '=' + params.get(key); + } + + if (path.indexOf('?') > 0) { + path += '&' + paramStr; + } else { + path += '?' + paramStr; + } + } + // 创建远程url连接对象 + URL url = new URL(path); + if ("https".equalsIgnoreCase(url.getProtocol())) {// 判定网址是否信任,不信任则调用忽略信任工具类SslUtil + IgnoreSslUtil.ignoreSsl(); + } + // 通过远程url连接对象打开一个连接,强转成HTTPURLConnection类 + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + // 设置连接超时时间和读取超时时间 + conn.setConnectTimeout(120000); + conn.setReadTimeout(120000); + conn.setRequestProperty("Accept", "application/json"); + // 发送请求 + conn.connect(); + // 通过conn取得输入流,并使用Reader读取 + if (200 == conn.getResponseCode()) { + is = conn.getInputStream(); + br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + String line; + while ((line = br.readLine()) != null) { + result.append(line); + System.out.println(line); + } + } else { + System.out.println("ResponseCode is an error code:" + conn.getResponseCode()); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } +// finally { +// try { +// if (br != null) { +// br.close(); +// } +// if (is != null) { +// is.close(); +// } +// } catch (IOException ioe) { +// ioe.printStackTrace(); +// } +// conn.disconnect(); +// } + return result.toString(); + } + + + private String getAccessToken(String baseUrl, Map bipParamMap) throws NoSuchAlgorithmException, InvalidKeyException, IOException { + String tokenUrl = baseUrl + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; +// String appKey = "f10c4bf17b1d4e1fb08eb82bf8540eab"; + String appKey = bipParamMap.get("appKey"); + +// String appSecret = "71dc2a58ca378c1a1143231a62e73e75a60e9236"; + String appSecret = bipParamMap.get("appSecret"); + String accessToken = ""; + Map params = new HashMap<>(); + + + params.put("appKey", appKey); + String timestamp = String.valueOf(System.currentTimeMillis()); + params.put("timestamp", timestamp); + // 计算签名 + Map treeMap; + if (params instanceof TreeMap) { + treeMap = params; + } else { + treeMap = new TreeMap<>(params); + } + StringBuilder stringBuilder = new StringBuilder(); + for (Map.Entry entry : treeMap.entrySet()) { + stringBuilder.append(entry.getKey()).append(entry.getValue()); + } + Mac mac = Mac.getInstance("HmacSHA256"); + + mac.init(new SecretKeySpec(appSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); + byte[] signData = mac.doFinal(stringBuilder.toString().getBytes(StandardCharsets.UTF_8)); + String base64String = Base64.getEncoder().encodeToString(signData); + String signature = URLEncoder.encode(base64String, "UTF-8"); + params.put("signature", signature); + + String responseString = doGet(tokenUrl, params); + + Gson gson = new Gson(); + Map result = gson.fromJson(responseString, Map.class); + if (StringUtils.equals("00000", result.get("code").toString())) { + Map tokenInfo = (Map) result.get("data"); + accessToken = (String) tokenInfo.get("access_token"); + + } + + + return accessToken; + } + + + public static String doSendHttp(String baseUrl, String method, Map paramMap, String mediaType, Map headers, String json) { + HttpURLConnection urlConnection = null; + InputStream in = null; + OutputStream out = null; + BufferedReader bufferedReader = null; + String result = null; + try { + StringBuffer sb = new StringBuffer(); + sb.append(baseUrl); + if (paramMap != null) { + sb.append("?"); + for (Map.Entry entry : paramMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + sb.append(key + "=" + value).append("&"); + baseUrl = sb.toString().substring(0, sb.toString().length() - 1); + } + } +// log.error("uRL:" + baseUrl); +// // 打印请求URL和方法 +// log.error("Request URL: " + baseUrl); +// log.error("Request Method: " + method); + URL urlobj = new URL(baseUrl); + if ("https".equalsIgnoreCase(urlobj.getProtocol())) {// 判定网址是否信任,不信任则调用忽略信任工具类SslUtil + IgnoreSslUtil.ignoreSsl(); + } + urlConnection = (HttpURLConnection) urlobj.openConnection(); + urlConnection.setConnectTimeout(50000); + urlConnection.setRequestMethod(method); + urlConnection.setDoInput(true); + urlConnection.setUseCaches(false); + // 如果设置了自定义头,则打印它们 + if (headers != null && !headers.isEmpty()) { + for (Map.Entry entry : headers.entrySet()) { + urlConnection.addRequestProperty(entry.getKey(), entry.getValue()); +// log.error("Request Header: " + entry.getKey() + ": " + entry.getValue()); + } + } + if (json != null && json.length() > 0) { +// log.error("Request Body: " + json); + urlConnection.setDoInput(true); + urlConnection.setDoOutput(true); + out = urlConnection.getOutputStream(); + out.write(json.getBytes("utf-8")); + out.flush(); + } + int resCode = urlConnection.getResponseCode(); + String ecod = urlConnection.getContentEncoding(); + if (resCode == HttpURLConnection.HTTP_OK || resCode == HttpURLConnection.HTTP_CREATED + || resCode == HttpURLConnection.HTTP_ACCEPTED) { + if (StringUtils.isNotEmpty(ecod) && ecod.equals("gzip")) { + in = new GZIPInputStream(urlConnection.getInputStream()); + } else { + in = urlConnection.getInputStream(); + } + } else { + in = urlConnection.getErrorStream(); + } + bufferedReader = new BufferedReader(new InputStreamReader(in, "utf-8")); + StringBuffer temp = new StringBuffer(); + String line = bufferedReader.readLine(); + while (line != null) { + temp.append(line).append("\r\n"); + line = bufferedReader.readLine(); + } + if (ecod == null || ecod.equals("gzip")) { + ecod = Charset.forName("utf-8").name(); + } + result = new String(temp.toString().getBytes("utf-8"), ecod); + } catch (Exception e) { + JSONObject js = new JSONObject(); + js.put("", -1); + js.put("message", "调用外系统接口失败:" + e.getMessage()); + result = js.toString(); + e.printStackTrace(); + } finally { + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != out) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != in) { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + urlConnection.disconnect(); + } + return result; + } + + + /* */ + /* */ + @POST + /* */ + @Path("/query") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString queryPayablebill(Map conditionMap) { + /* 79 */ + NCCRestUtils.initInvocationInfo(); + /* */ + try { + /* 81 */ + List> bills = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).queryBill(conditionMap); + /* 82 */ + return ResultMessageUtil.toJSON(bills); + /* 83 */ + } catch (BusinessException e) { + /* 84 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + + /* */ + /* */ + /* */ + /* */ + @POST + /* */ + @Path("/update") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString updatePayablebill(JSONString str) { + /* 95 */ + NCCRestUtils.initInvocationInfo(); + /* 96 */ + String json = str.toJSONString(); + /* 97 */ + Map billMap = (Map) fromJson(json, Map.class); + /* */ + try { + /* 99 */ + Map returnMap = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).updateBill(billMap); + /* 100 */ + return ResultMessageUtil.toJSON(returnMap); + /* 101 */ + } catch (BusinessException e) { + /* 102 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + + /* */ + /* */ + /* */ + @POST + /* */ + @Path("/delete") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString deleteGatheringbill(JSONString str) { + /* 112 */ + NCCRestUtils.initInvocationInfo(); + /* 113 */ + String json = str.toJSONString(); + /* 114 */ + Map billMap = (Map) fromJson(json, Map.class); + /* 115 */ + String[] pk_gatherbills = null; + /* 116 */ + if (StringUtils.isEmpty((CharSequence) billMap.get("pk_gatherbill"))) { + /* */ + /* */ + try { + /* 119 */ + List returnMap = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).getPkBySrc(billMap); + /* 120 */ + if (returnMap != null) { + /* 121 */ + pk_gatherbills = (String[]) returnMap.toArray(new String[returnMap.size()]); + /* */ + } else { + /* 123 */ + return ResultMessageUtil.exceptionToJSON(NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + /* */ + } + /* */ + /* 126 */ + } catch (BusinessException e) { + /* 127 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } else { + /* 130 */ + String pk_gatherbill = (String) billMap.get("pk_gatherbill"); + /* 131 */ + String PK_GATHERBILL = NCESAPI.sqlEncode(pk_gatherbill); + /* 132 */ + pk_gatherbills = PK_GATHERBILL.split(","); + /* */ + } + /* */ + try { + /* 135 */ + IArapBillService service = (IArapBillService) NCLocator.getInstance().lookup(IArapBillService.class); + /* 136 */ + BaseAggVO[] bills = service.queryArapBillByPKs(pk_gatherbills, "F2"); + /* 137 */ + ((IARAPOpenAPIService) NCLocator.getInstance().lookup(IARAPOpenAPIService.class)).executeBatchPM("DELETE", bills); + /* 138 */ + Map returnMap = new HashMap(); + /* 139 */ + returnMap.put("successful", "Y"); + /* 140 */ + return ResultMessageUtil.toJSON(returnMap); + /* 141 */ + } catch (BusinessException e) { + /* 142 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + + /* */ + /* */ + /* */ + @POST + /* */ + @Path("/commit") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString CommitGatheringbill(JSONString str) { + /* 152 */ + NCCRestUtils.initInvocationInfo(); + /* 153 */ + String json = str.toJSONString(); + /* 154 */ + Map billMap = (Map) fromJson(json, Map.class); + /* 155 */ + String[] pk_gatherbills = null; + /* 156 */ + if (StringUtils.isEmpty((CharSequence) billMap.get("pk_gatherbill"))) { + /* */ + try { + /* 158 */ + List returnMap = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).getPkBySrc(billMap); + /* */ + /* 160 */ + if (returnMap != null) { + /* 161 */ + pk_gatherbills = (String[]) returnMap.toArray(new String[returnMap.size()]); + /* */ + } else { + /* 163 */ + return ResultMessageUtil.exceptionToJSON(NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + /* */ + } + /* */ + /* 166 */ + } catch (BusinessException e) { + /* 167 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } else { + /* 170 */ + String pk_gatherbill = (String) billMap.get("pk_gatherbill"); + /* 171 */ + String PK_GATHERBILL = NCESAPI.sqlEncode(pk_gatherbill); + /* 172 */ + pk_gatherbills = PK_GATHERBILL.split(","); + /* */ + } + /* */ + try { + /* 175 */ + Map returnMap = ((IARAPOpenAPIService) NCLocator.getInstance().lookup(IARAPOpenAPIService.class)).doBatchCommit(pk_gatherbills, "F2", "COMMIT"); + /* 176 */ + if (Integer.parseInt(returnMap.get("failNum").toString()) == 0) { + /* 177 */ + return ResultMessageUtil.toJSON(returnMap.get("message")); + /* */ + } + /* 179 */ + if (Integer.parseInt(returnMap.get("successNum").toString()) == 0) { + /* 180 */ + return ResultMessageUtil.exceptionToJSON((String) returnMap.get("message"), "false"); + /* */ + } + /* 182 */ + return ResultMessageUtil.toJSON(returnMap.get("message")); + /* 183 */ + } catch (BusinessException e) { + /* 184 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + + /* */ + /* */ + /* */ + /* */ + /* */ + @POST + /* */ + @Path("/uncommit") + /* */ + @Consumes({"application/json"}) + /* */ + @Produces({"application/json"}) + /* */ public JSONString UnCommitGatheringbill(JSONString str) { + /* 196 */ + NCCRestUtils.initInvocationInfo(); + /* 197 */ + String json = str.toJSONString(); + /* 198 */ + Map billMap = (Map) fromJson(json, Map.class); + /* 199 */ + String[] pk_gatherbills = null; + /* 200 */ + if (StringUtils.isEmpty((CharSequence) billMap.get("pk_gatherbill"))) { + /* */ + try { + /* 202 */ + List returnMap = ((IGatheringbillOpenService) NCLocator.getInstance().lookup(IGatheringbillOpenService.class)).getPkBySrc(billMap); + /* */ + /* 204 */ + if (returnMap != null) { + /* 205 */ + pk_gatherbills = (String[]) returnMap.toArray(new String[returnMap.size()]); + /* */ + } else { + /* 207 */ + return ResultMessageUtil.exceptionToJSON(NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + /* */ + } + /* */ + /* 210 */ + } catch (BusinessException e) { + /* 211 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } else { + /* 214 */ + String pk_gatherbill = (String) billMap.get("pk_gatherbill"); + /* 215 */ + String PK_GATHERBILL = NCESAPI.sqlEncode(pk_gatherbill); + /* 216 */ + pk_gatherbills = PK_GATHERBILL.split(","); + /* */ + } + /* */ + try { + /* 219 */ + Map returnMap = ((IARAPOpenAPIService) NCLocator.getInstance().lookup(IARAPOpenAPIService.class)).doBatchCommit(pk_gatherbills, "F2", "UNCOMMIT"); + /* 220 */ + if (Integer.parseInt(returnMap.get("failNum").toString()) == 0) { + /* 221 */ + return ResultMessageUtil.toJSON(returnMap.get("message")); + /* */ + } + /* 223 */ + if (Integer.parseInt(returnMap.get("successNum").toString()) == 0) { + /* 224 */ + return ResultMessageUtil.exceptionToJSON((String) returnMap.get("message"), "false"); + /* */ + } + /* 226 */ + return ResultMessageUtil.toJSON(returnMap.get("message")); + /* 227 */ + } catch (BusinessException e) { + /* 228 */ + return ResultMessageUtil.exceptionToJSON(e); + /* */ + } + /* */ + } + /* */ +} + + +/* Location: E:\2024\tkncchome\modules\arap\lib\pubarap_openapi.jar!/nc/api/arap/resource/GatheringbillRestResource.class + * Java compiler version: 8 (52.0) + * JD-Core Version: 1.0.7 + */ \ No newline at end of file