diff --git a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java index d720b0c..72587d5 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -14,6 +14,7 @@ import nc.pubitf.so.m30.api.ISaleOrderQueryAPI; import nc.vo.ml.NCLangRes4VoTransl; import nc.vo.pub.BusinessException; import nc.vo.pub.VOStatus; +import nc.vo.pub.billtype.BilltypeVO; import nc.vo.pub.lang.UFBoolean; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; @@ -40,6 +41,7 @@ import nccloud.api.so.m30.IAPISaleOrderMaitain; import nccloud.baseapp.core.log.NCCForUAPLogger; import nccloud.dto.scmpub.pflow.SCMCloudPFlowContext; import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService; +import nccloud.riart.pubimpl.billtype.BilltypeServiceImpl; import java.math.BigDecimal; import java.util.*; @@ -74,9 +76,9 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (o1 == null) { throw new BusinessException("表体币种不能为空或币种不存在"); } - String csettleorgid = bvos[0].getCsettleorgid(); + // String csettleorgid = bvos[0].getCsettleorgid(); String ccurrencyorgid = o1.toString(); - UFDouble exchangerate = SOCurrencyUtil.getInCurrencyRateByOrg(csettleorgid, BFPubTools.getString_TrimAsNull(o), ccurrencyorgid, dbilldate); + // UFDouble exchangerate = SOCurrencyUtil.getInCurrencyRateByOrg(csettleorgid, BFPubTools.getString_TrimAsNull(o), ccurrencyorgid, dbilldate); for (SaleOrderBVO bvo : bvos) { bvo.setCcurrencyid(BFPubTools.getString_TrimAsNull(o1)); if (!BFPubTools.getString_TrimAsNull(o).equals(ccurrencyorgid)) { @@ -84,7 +86,9 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } else { // bvo.setNexchangerate(UFDouble.ONE_DBL); } - + // 折本汇率判空及保留小数位数 + UFDouble exchangerate1 = getUFDouble_NullAsOne(bvo.getNexchangerate()).setScale(2, UFDouble.ROUND_HALF_UP); + bvo.setNexchangerate(exchangerate1); } // bvo.setNexchangerate(rateReturnObject.getRate()); @@ -293,16 +297,28 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } } for (SaleOrderVO vo : combinBillVOs) { + SaleOrderHVO hvo = vo.getParentVO(); + SaleOrderHVO originHvo = null; + for (SaleOrderVO originVo : originVos) { + if (hvo.getCsaleorderid().equals(originVo.getParentVO().getCsaleorderid())) { + originHvo = originVo.getParentVO(); + } + } + String new_ctrantypeid = hvo.getCtrantypeid(); + boolean isChangedTranType = false;// 订单类型不修改 + if (originHvo != null && new_ctrantypeid != null && !new_ctrantypeid.equals(originHvo.getCtrantypeid())) { + isChangedTranType = true; + } SaleOrderBVO[] bvos = vo.getChildrenVO(); // 判断是否存在新增的子表 boolean hasNewStatus = Arrays.stream(bvos) .anyMatch(bvo -> bvo.getStatus() == VOStatus.NEW); - // 新增子表的情况下不校验是否存在下游 - if (!hasNewStatus) { + // 新增子表或改订单类型的情况下不校验是否存在下游 + if (!hasNewStatus && !isChangedTranType) { String countSql = "SELECT count(1) FROM so_saleinvoice_b a" + " LEFT JOIN so_saleinvoice b ON a.csaleinvoiceid = b.csaleinvoiceid" + " WHERE b.fopposeflag = 0 AND nvl(b.dr, 0) = 0 and csrcid = '[csrcid]' "; - countSql = countSql.replace("[csrcid]", vo.getParentVO().getCsaleorderid()); + countSql = countSql.replace("[csrcid]", hvo.getCsaleorderid()); Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); if (num > 0) { // fopposeflag 对冲标记 0=正常 1=已被对冲 2=对冲生成 @@ -344,7 +360,14 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { String csaleorderid = orderHVO.getCsaleorderid(); String cdeptvid = orderHVO.getCdeptvid(); String cemployeeid = orderHVO.getCemployeeid(); + // 开票客户 String cinvoicecustid = orderHVO.getCinvoicecustid(); + // 客户 + String ccustomerid = orderHVO.getCcustomerid(); + // 订单类型 + // String ctrantypeid = orderHVO.getAttributeValue("ctrantypeid") + ""; + String vtrantypecode = orderHVO.getVtrantypecode(); + NCCForUAPLogger.debug("setOtherId-ccustomerid:" + ccustomerid + ",vtrantypecode:" + vtrantypecode); try { String sql = ""; // 部门 @@ -377,10 +400,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } // 开票客户 if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { - sql = " select pk_customer from bd_customer where code = '[code]' "; + sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; sql = sql.replace("[code]", cinvoicecustid); Object invCustObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); - NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-invCustObj:" + invCustObj); + NCCForUAPLogger.debug("setOtherId-invCustObj:" + invCustObj); if (invCustObj != null) { String id = BFPubTools.getString_TrimAsNull(invCustObj); if (!id.isEmpty()) { @@ -388,6 +411,28 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } } } + // 客户 + if (ccustomerid != null && !ccustomerid.isEmpty()) { + sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; + sql = sql.replace("[code]", ccustomerid); + Object custObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); + NCCForUAPLogger.debug("setOtherId-custObj:" + custObj); + if (custObj != null) { + String id = BFPubTools.getString_TrimAsNull(custObj); + if (!id.isEmpty()) { + orderHVO.setCcustomerid(id); + } + } + } + // 交易类型 + if (vtrantypecode != null && !vtrantypecode.isEmpty()) { + BilltypeServiceImpl billtypeService = new BilltypeServiceImpl(); + BilltypeVO billtype = billtypeService.getBilltype(vtrantypecode); + if (billtype != null && billtype.getPk_billtypeid() != null) { + NCCForUAPLogger.debug("setOtherId-pk_billtypeid:" + billtype.getPk_billtypeid()); + orderHVO.setCtrantypeid(billtype.getPk_billtypeid()); + } + } } catch (Exception e) { NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-exp:" + e.getMessage()); throw new RuntimeException(e); @@ -415,6 +460,20 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { targetHVO.setCinvoicecustid(cinvoicecustid); } + String ccustomerid = sourceHVO.getCcustomerid(); + if (ccustomerid != null && !ccustomerid.isEmpty()) { + targetHVO.setCcustomerid(ccustomerid); + } + // 订单类型id + String ctrantypeid = sourceHVO.getCtrantypeid(); + if (ctrantypeid != null && !ctrantypeid.isEmpty()) { + targetHVO.setCtrantypeid(ctrantypeid); + } + // 订单类型编码 + String vtrantypecode = sourceHVO.getVtrantypecode(); + if (vtrantypecode != null && !vtrantypecode.isEmpty()) { + targetHVO.setVtrantypecode(vtrantypecode); + } // 更新 SaleOrderBVO 字段 SaleOrderBVO[] targetBVOs = target.getChildrenVO(); @@ -614,8 +673,11 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { newBvo.setStatus(VOStatus.NEW); newBvo.setAttributeValue("pk_group", pk_group); String cprojectid = bodydata.get("cprojectid") + ""; - if (oneBvo != null) { + if (oneBvo != null && oneBvo.getCprojectid() != null && !"".equals(oneBvo.getCprojectid())) { cprojectid = oneBvo.getCprojectid(); + } else { + String sql = " select pk_project from bd_project where project_code='" + cprojectid + "' and nvl(dr,0)=0 "; + cprojectid = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor()); } newBvo.setAttributeValue("cprojectid", cprojectid); // newBvo.setAttributeValue("ctrafficorgvid", pkOrg);