From 0fafc2b8c40b8482c494115bc519ee5bf9af5578 Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Wed, 5 Mar 2025 15:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E4=BF=AE?= =?UTF-8?q?=E8=AE=A2-=E7=89=A9=E6=96=99=E5=A2=9E=E8=A1=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/so/m30/APISaleOrderMaitainImpl.java | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) 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 0fbe25c..9cfa93f 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -1,6 +1,5 @@ package nccloud.api.impl.so.m30; -import com.alibaba.fastjson.JSON; import nc.bd.itf.tools.BFPubTools; import nc.bs.dao.BaseDAO; import nc.bs.framework.common.NCLocator; @@ -22,7 +21,6 @@ import nc.vo.pubapp.AppContext; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.pubapp.pflow.PfUserObject; import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule; -import nc.vo.scmpub.fill.pricemny.INumPriceMnyCalculator; import nc.vo.scmpub.res.billtype.SOBillType; import nc.vo.scmpub.util.StringUtil; import nc.vo.so.m30.entity.SaleOrderBVO; @@ -37,13 +35,13 @@ import nc.vo.so.pub.keyvalue.VOKeyValue; import nc.vo.so.pub.util.AggVOUtil; import nc.vo.so.pub.util.SOCurrencyUtil; import nccloud.api.impl.so.m30.check.SaleOrderValidator; -import nccloud.api.impl.so.m30.fill.SaleOrderNPriceMnyCal; import nccloud.api.impl.so.m30.fill.SaleOrderSaveFillValue; 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 java.math.BigDecimal; import java.util.*; /** @@ -300,12 +298,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { updateFields(vo, bipVo); // 设置新增的物料行 if (paramList != null && !paramList.isEmpty()) { - // addBvo(combinBillVOs, paramList); + addBvo(combinBillVOs, paramList); } } // 联动计算 - INumPriceMnyCalculator cal = new SaleOrderNPriceMnyCal(combinBillVOs); - cal.calculate(); + // INumPriceMnyCalculator cal = new SaleOrderNPriceMnyCal(combinBillVOs); + // cal.calculate(); // 保存 ISaleOrderScriptMaintain maintainsrv = NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class); @@ -437,7 +435,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny()); targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid()); // 折本汇率 - targetBVO.setNexchangerate(sourceBVO.getNexchangerate()); + UFDouble nexchangerate = getUFDouble_NullAsOne(sourceBVO.getNexchangerate()); + targetBVO.setNexchangerate(nexchangerate); // 物料编码 String cmaterialvid = sourceBVO.getCmaterialvid(); // 物料关联字段赋值 @@ -542,6 +541,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { ""; String o_pk_project = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor()); + // 税码 bVO.setAttributeValue("ctaxcodeid", o_pk_project); } catch (BusinessException e) { NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setMaterl:" + e.getMessage()); @@ -568,9 +568,13 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { /** * 修订销售订单的时候新增销售订单物料行的数据 */ - private void addBvo(SaleOrderVO[] combinBillVOs, List> paramList) { + private void addBvo(SaleOrderVO[] oldVOs, List> paramList) { try { - for (SaleOrderVO vo : combinBillVOs) { + SaleOrderVO[] copyVOs = new SaleOrderVO[oldVOs.length]; + for (int i = 0; i < oldVOs.length; i++) { + copyVOs[i] = (SaleOrderVO) oldVOs[i].clone(); + } + for (SaleOrderVO vo : copyVOs) { SaleOrderHVO hvo = vo.getParentVO(); SaleOrderBVO[] bvos = vo.getChildrenVO(); List bvoList = new ArrayList<>(Arrays.asList(bvos)); @@ -608,7 +612,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { newBvo.setAttributeValue("csendcountryid", "CN"); newBvo.setAttributeValue("fbuysellflag", 1); - UFDouble nexchangerateBip = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nexchangerate")); + UFDouble nexchangerateBip = getUFDouble_NullAsOne(bodydata.get("nexchangerate")); newBvo.setNexchangerate(nexchangerateBip); // 设置物料的关联字段的值 newBvo.setCmaterialvid(bodydata.get("cmaterialvid") + ""); @@ -695,10 +699,11 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { UFDouble Nprice = nqtorigtaxprice.div(dVqtunitrate).div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate); newBvo.setNprice(Nprice.setScale(4, 4)); //,ntaxnetprice --主本币含税净价 - //,nnetprice --主本币无税净价 newBvo.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4)); - UFDouble Nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate); - newBvo.setNnetprice(Nnetprice.multiply(nexchangerate).setScale(4, 4)); + //,nnetprice --主本币无税净价 + UFDouble nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate); + nnetprice = nnetprice.multiply(nexchangerate).setScale(4, 4); + newBvo.setNnetprice(nnetprice); // nmny --本币无税金额 // ntaxmny-- 本币价税合计 newBvo.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate))); @@ -714,15 +719,33 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); vo.setChildrenVO(array); } + // 填充默认值 - new SaleOrderSaveFillValue().setDefValue(combinBillVOs); - for (SaleOrderVO combinBillVO : combinBillVOs) { + new SaleOrderSaveFillValue().setDefValue(copyVOs); + SaleOrderBVO newBvo = null; + for (SaleOrderVO copyVO : copyVOs) { + for (SaleOrderBVO saleOrderBVO : copyVO.getChildrenVO()) { + if (VOStatus.NEW == saleOrderBVO.getStatus()) { + newBvo = (SaleOrderBVO) saleOrderBVO.clone(); + } + } + } + if (newBvo != null) { + for (SaleOrderVO oldVO : oldVOs) { + SaleOrderBVO[] bvos = oldVO.getChildrenVO(); + List bvoList = new ArrayList<>(Arrays.asList(bvos)); + bvoList.add(newBvo); + SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); + oldVO.setChildrenVO(array); + } + } + /*for (SaleOrderVO combinBillVO : copyVOs) { for (SaleOrderBVO saleOrderBVO : combinBillVO.getChildrenVO()) { // 将实体对象转换为JSON字符串 String jsonString = JSON.toJSONString(saleOrderBVO); NCCForUAPLogger.debug("jsonString:" + jsonString); } - } + }*/ } catch (Exception e) { NCCForUAPLogger.debug("APISaleOrderMaitainImpl-addBvo:" + e.getMessage()); @@ -730,4 +753,15 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } } + private UFDouble getUFDouble_NullAsOne(Object value) { + if ((value == null) || (value.toString().trim().equals("")) || (value.toString().trim().equals("~"))) + return UFDouble.ONE_DBL; + if ((value instanceof UFDouble)) + return (UFDouble) value; + if ((value instanceof BigDecimal)) { + return new UFDouble((BigDecimal) value); + } + return new UFDouble(value.toString().trim()); + } + }