销售订单修订-物料增行调整
This commit is contained in:
parent
5a11c77417
commit
0fafc2b8c4
|
@ -1,6 +1,5 @@
|
||||||
package nccloud.api.impl.so.m30;
|
package nccloud.api.impl.so.m30;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import nc.bd.itf.tools.BFPubTools;
|
import nc.bd.itf.tools.BFPubTools;
|
||||||
import nc.bs.dao.BaseDAO;
|
import nc.bs.dao.BaseDAO;
|
||||||
import nc.bs.framework.common.NCLocator;
|
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.pattern.exception.ExceptionUtils;
|
||||||
import nc.vo.pubapp.pflow.PfUserObject;
|
import nc.vo.pubapp.pflow.PfUserObject;
|
||||||
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
|
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.res.billtype.SOBillType;
|
||||||
import nc.vo.scmpub.util.StringUtil;
|
import nc.vo.scmpub.util.StringUtil;
|
||||||
import nc.vo.so.m30.entity.SaleOrderBVO;
|
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.AggVOUtil;
|
||||||
import nc.vo.so.pub.util.SOCurrencyUtil;
|
import nc.vo.so.pub.util.SOCurrencyUtil;
|
||||||
import nccloud.api.impl.so.m30.check.SaleOrderValidator;
|
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.impl.so.m30.fill.SaleOrderSaveFillValue;
|
||||||
import nccloud.api.so.m30.IAPISaleOrderMaitain;
|
import nccloud.api.so.m30.IAPISaleOrderMaitain;
|
||||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||||
import nccloud.dto.scmpub.pflow.SCMCloudPFlowContext;
|
import nccloud.dto.scmpub.pflow.SCMCloudPFlowContext;
|
||||||
import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService;
|
import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,12 +298,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
updateFields(vo, bipVo);
|
updateFields(vo, bipVo);
|
||||||
// 设置新增的物料行
|
// 设置新增的物料行
|
||||||
if (paramList != null && !paramList.isEmpty()) {
|
if (paramList != null && !paramList.isEmpty()) {
|
||||||
// addBvo(combinBillVOs, paramList);
|
addBvo(combinBillVOs, paramList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 联动计算
|
// 联动计算
|
||||||
INumPriceMnyCalculator cal = new SaleOrderNPriceMnyCal<SaleOrderVO>(combinBillVOs);
|
// INumPriceMnyCalculator cal = new SaleOrderNPriceMnyCal<SaleOrderVO>(combinBillVOs);
|
||||||
cal.calculate();
|
// cal.calculate();
|
||||||
// 保存
|
// 保存
|
||||||
ISaleOrderScriptMaintain maintainsrv =
|
ISaleOrderScriptMaintain maintainsrv =
|
||||||
NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class);
|
NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class);
|
||||||
|
@ -437,7 +435,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny());
|
targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny());
|
||||||
targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid());
|
targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid());
|
||||||
// 折本汇率
|
// 折本汇率
|
||||||
targetBVO.setNexchangerate(sourceBVO.getNexchangerate());
|
UFDouble nexchangerate = getUFDouble_NullAsOne(sourceBVO.getNexchangerate());
|
||||||
|
targetBVO.setNexchangerate(nexchangerate);
|
||||||
// 物料编码
|
// 物料编码
|
||||||
String cmaterialvid = sourceBVO.getCmaterialvid();
|
String cmaterialvid = sourceBVO.getCmaterialvid();
|
||||||
// 物料关联字段赋值
|
// 物料关联字段赋值
|
||||||
|
@ -542,6 +541,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
"";
|
"";
|
||||||
|
|
||||||
String o_pk_project = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor());
|
String o_pk_project = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor());
|
||||||
|
// ˰Âë
|
||||||
bVO.setAttributeValue("ctaxcodeid", o_pk_project);
|
bVO.setAttributeValue("ctaxcodeid", o_pk_project);
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setMaterl:" + e.getMessage());
|
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setMaterl:" + e.getMessage());
|
||||||
|
@ -568,9 +568,13 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
/**
|
/**
|
||||||
* 修订销售订单的时候新增销售订单物料行的数据
|
* 修订销售订单的时候新增销售订单物料行的数据
|
||||||
*/
|
*/
|
||||||
private void addBvo(SaleOrderVO[] combinBillVOs, List<Map<String, Object>> paramList) {
|
private void addBvo(SaleOrderVO[] oldVOs, List<Map<String, Object>> paramList) {
|
||||||
try {
|
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();
|
SaleOrderHVO hvo = vo.getParentVO();
|
||||||
SaleOrderBVO[] bvos = vo.getChildrenVO();
|
SaleOrderBVO[] bvos = vo.getChildrenVO();
|
||||||
List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos));
|
List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos));
|
||||||
|
@ -608,7 +612,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
newBvo.setAttributeValue("csendcountryid", "CN");
|
newBvo.setAttributeValue("csendcountryid", "CN");
|
||||||
|
|
||||||
newBvo.setAttributeValue("fbuysellflag", 1);
|
newBvo.setAttributeValue("fbuysellflag", 1);
|
||||||
UFDouble nexchangerateBip = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nexchangerate"));
|
UFDouble nexchangerateBip = getUFDouble_NullAsOne(bodydata.get("nexchangerate"));
|
||||||
newBvo.setNexchangerate(nexchangerateBip);
|
newBvo.setNexchangerate(nexchangerateBip);
|
||||||
// 设置物料的关联字段的值
|
// 设置物料的关联字段的值
|
||||||
newBvo.setCmaterialvid(bodydata.get("cmaterialvid") + "");
|
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);
|
UFDouble Nprice = nqtorigtaxprice.div(dVqtunitrate).div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
|
||||||
newBvo.setNprice(Nprice.setScale(4, 4));
|
newBvo.setNprice(Nprice.setScale(4, 4));
|
||||||
//,ntaxnetprice --主本币含税净价
|
//,ntaxnetprice --主本币含税净价
|
||||||
//£¬nnetprice --Ö÷±¾±ÒÎÞ˰¾»¼Û
|
|
||||||
newBvo.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
|
newBvo.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
|
||||||
UFDouble Nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate);
|
//£¬nnetprice --Ö÷±¾±ÒÎÞ˰¾»¼Û
|
||||||
newBvo.setNnetprice(Nnetprice.multiply(nexchangerate).setScale(4, 4));
|
UFDouble nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate);
|
||||||
|
nnetprice = nnetprice.multiply(nexchangerate).setScale(4, 4);
|
||||||
|
newBvo.setNnetprice(nnetprice);
|
||||||
// nmny --本币无税金额
|
// nmny --本币无税金额
|
||||||
// ntaxmny-- 本币价税合计
|
// ntaxmny-- 本币价税合计
|
||||||
newBvo.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate)));
|
newBvo.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate)));
|
||||||
|
@ -714,15 +719,33 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
||||||
SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]);
|
SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]);
|
||||||
vo.setChildrenVO(array);
|
vo.setChildrenVO(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充默认值
|
// 填充默认值
|
||||||
new SaleOrderSaveFillValue().setDefValue(combinBillVOs);
|
new SaleOrderSaveFillValue().setDefValue(copyVOs);
|
||||||
for (SaleOrderVO combinBillVO : combinBillVOs) {
|
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<SaleOrderBVO> 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()) {
|
for (SaleOrderBVO saleOrderBVO : combinBillVO.getChildrenVO()) {
|
||||||
// 将实体对象转换为JSON字符串
|
// 将实体对象转换为JSON字符串
|
||||||
String jsonString = JSON.toJSONString(saleOrderBVO);
|
String jsonString = JSON.toJSONString(saleOrderBVO);
|
||||||
NCCForUAPLogger.debug("jsonString:" + jsonString);
|
NCCForUAPLogger.debug("jsonString:" + jsonString);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-addBvo:" + e.getMessage());
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue