适配销售订单保存接口

This commit is contained in:
zhangxinah@yonyou.com 2025-04-01 16:12:22 +08:00
parent f5d2261494
commit a3c56f4e64
2 changed files with 1027 additions and 827 deletions

View File

@ -43,6 +43,13 @@ import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
import nccloud.putitf.riart.billtype.IBilltypeService;
import org.apache.commons.lang3.ArrayUtils;
import nc.itf.uap.pf.IPFBusiAction;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.lang.UFDate;
import nc.vo.so.pub.SOConstant;
import nc.vo.so.pub.util.SOCurrencyUtil;
import nc.vo.so.pub.keyvalue.IKeyValue;
import nc.vo.so.pub.keyvalue.VOKeyValue;
import java.math.BigDecimal;
import java.util.*;
@ -58,6 +65,177 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
private static String BODYTABLE = "so_saleorder_b";
private static String HEADTABLE = "so_saleorder";
public SaleOrderVO[] save(SaleOrderVO[] vos) throws BusinessException {
SaleOrderVO[] fillvos = vos;
// 检查非空项
for (SaleOrderVO vo : vos) {
SaleOrderHVO hvo = vo.getParentVO();
UFDate dbilldate = hvo.getDbilldate();
SaleOrderBVO[] bvos = vo.getChildrenVO();
String sql = " select bd_currtype.pk_currtype from bd_currtype where (code='" + hvo.getCorigcurrencyid()
+ "' or pk_currtype='" + hvo.getCorigcurrencyid() + "') and dr=0 ";
Object o = new BaseDAO().executeQuery(sql, new ColumnProcessor());
if (o != null) {
hvo.setCorigcurrencyid(BFPubTools.getString_TrimAsNull(o));
} else {
throw new BusinessException("表头币种不能为空或币种不存在");
}
sql = " select bd_currtype.pk_currtype from bd_currtype where (code='" + bvos[0].getCcurrencyid()
+ "' or pk_currtype='" + bvos[0].getCcurrencyid() + "') and dr=0 ";
Object o1 = new BaseDAO().executeQuery(sql, new ColumnProcessor());
if (o1 == null) {
throw new BusinessException("表体币种不能为空或币种不存在");
}
String csettleorgid = bvos[0].getCsettleorgid();
String ccurrencyorgid = o1.toString();
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)) {
bvo.setNexchangerate(exchangerate);
} else {
bvo.setNexchangerate(UFDouble.ONE_DBL);
}
}
}
BillVOsCheckRule checker = new BillVOsCheckRule(new SaleOrderValidator());
checker.check(vos);
// 填充默认值
new SaleOrderSaveFillValue().setDefValue(vos);
// 有值不覆盖
for (SaleOrderVO ordervo : vos) {
calculatorPrice(ordervo);
}
SaleOrderVO[] combinBillVOs = (SaleOrderVO[]) AggVOUtil.combinBillVO(fillvos, vos);
// 保存
SaleOrderVO[] retvos = (SaleOrderVO[]) PfServiceScmUtil.processBatch(SOConstant.WRITE,
SOBillType.Order.getCode(), combinBillVOs, null, null);
SaleOrderVO[] billvos = ((ISaleOrderQueryAPI) NCLocator.getInstance().lookup(ISaleOrderQueryAPI.class))
.queryVOByIDs(new String[] { retvos[0].getParentVO().getPrimaryKey() });
if (billvos != null) {
((IPFBusiAction) NCLocator.getInstance().lookup(IPFBusiAction.class)).processAction("APPROVE",
billvos[0].getParentVO().getVtrantypecode(), null, billvos[0], null, null);
}
return retvos;
}
public void calculatorPrice(SaleOrderVO ordervo) throws BusinessException {
IKeyValue keyValue = new VOKeyValue<SaleOrderVO>(ordervo);
String ctrantypeid = keyValue.getHeadStringValue(SaleOrderHVO.CTRANTYPEID);
if (StringUtil.isEmptyTrimSpace(ctrantypeid)) {
ExceptionUtils.wrappBusinessException(
NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0024")/* @res "请先选择交易类型!" */);
}
// 1.缓存交易类型VO
SaleOrderBVO[] vbos = ordervo.getChildrenVO();
UFDouble sumnum = UFDouble.ZERO_DBL;
UFDouble sumnny = UFDouble.ZERO_DBL;
String ybpk = ordervo.getParentVO().getCorigcurrencyid();
for (int i = 0; i < vbos.length; i++) {
SaleOrderBVO childrenVO = vbos[i];
String zbbz = childrenVO.getCcurrencyid();
childrenVO.setFtaxtypeflag(1);
// 得到税率
UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(childrenVO.getNtaxrate());
// 折本汇率
UFDouble nexchangerate = childrenVO.getNexchangerate();
// 含税单价
UFDouble nqtorigtaxprice = childrenVO.getNqtorigtaxprice();
// 无税单价
UFDouble nqtorigprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
// 价税合计
// UFDouble norigtaxmny=nqtorigtaxprice.multiply(childrenVO.getNqtunitnum());
UFDouble norigtaxmny = nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()).setScale(2, 4);
childrenVO.setNorigtaxmny(norigtaxmny);
// 无税金额
UFDouble norigmny = nqtorigprice.multiply(childrenVO.getNqtunitnum());
childrenVO.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny));
// 税额
childrenVO.setNqtorigprice(nqtorigprice.setScale(4, 4));
// 无税本币金额单价
UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
sumnum = sumnum.add(childrenVO.getNastnum());
sumnny = sumnny.add(childrenVO.getNorigtaxmny());
nqtorigprice = nqtorigprice.setScale(4, 4);
// nqtorigtaxnetprc--含税净价
childrenVO.setNqtorigtaxnetprc(nqtorigtaxprice);
// ,nqtorignetprice --无税净价
childrenVO.setNqtorignetprice(nqtorigprice);
String Vqtunitrate = childrenVO.getVqtunitrate();
UFDouble dVqtunitrate = UFDouble.ONE_DBL;
if (Vqtunitrate != null) {
dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]);
}
// ,norigtaxprice --主含税单价
UFDouble wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum());
if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(childrenVO.getCqtunitid())
.equals(BFPubTools.getString_TrimAsNull(childrenVO.getCastunitid()))) {
wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum());
}
wsje = Currency.getFormaUfValue(zbbz, wsje);
// 本币无税金额
childrenVO.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4));
// ,norigprice --主无税单价
childrenVO.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4));
// ,norigtaxnetprice --主含税净价
childrenVO.setNorigtaxnetprice(childrenVO.getNorigtaxprice());
// ,norignetprice --主无税净价
childrenVO.setNorignetprice(childrenVO.getNorigprice());
// ncaltaxmny --计税金额
// nqttaxprice --本币含税单价
childrenVO.setNqttaxprice(nqtorigtaxprice.multiply(nexchangerate));
// nqtprice --本币无税单价
UFDouble bbwsd = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
childrenVO.setNqtprice(bbwsd.setScale(4, 4));
// nqttaxnetprice --本币含税净价
childrenVO.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate));
// nqtnetprice --本币无税净价
UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
childrenVO.setNqtnetprice(Nqtnetprice.setScale(4, 4));
// ntaxprice --主本币含税单价 nprice --主本币无税单价
childrenVO.setNtaxprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
UFDouble Nprice = nqtorigtaxprice.div(dVqtunitrate).div(UFDouble.ONE_DBL.add(ntaxrate.div(100)))
.multiply(nexchangerate);
childrenVO.setNprice(Nprice.setScale(4, 4));
// ntaxnetprice --主本币含税净价
// nnetprice --主本币无税净价
childrenVO.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
UFDouble Nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate);
childrenVO.setNnetprice(Nnetprice.multiply(nexchangerate).setScale(4, 4));
// nmny --本币无税金额
// ntaxmny --本币价税合计
childrenVO.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate)));
childrenVO.setNtaxmny(
nqtorigtaxprice.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()).setScale(2, 4));
// childrenVO.setNtaxmny(nqtorigtaxprice.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()));
childrenVO.setNcaltaxmny(wsje);
UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje);
childrenVO.setNtax(ntax.setScale(2, 4));
}
ordervo.getParentVO().setNtotalnum(sumnum);
// ordervo.getParentVO().setNtotalorigmny(sumnny);
ordervo.getParentVO().setNtotalorigmny(sumnny.setScale(2, 4));
}
@Override
public SaleOrderVO[] save(List<Map<String, Object>> paramList) throws BusinessException {
try {
@ -69,7 +247,6 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
SaleOrderSaveUtil saveUtil = new SaleOrderSaveUtil();
return saveUtil.processBill(vos);
} catch (Exception e) {
@ -107,8 +284,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
String vbdef11 = bodydata.get("vbdef11") + "";
String dr = bodydata.getOrDefault("dr", "0") + "";
String csaleorderid = bodydata.get("csaleorderid") + "";
String countSql = "SELECT count(1) FROM so_saleorder_b" +
" WHERE nvl(dr,0) = 0 and csaleorderid = '[csaleorderid]' and vbdef11 = '[vbdef11]' ";
String countSql = "SELECT count(1) FROM so_saleorder_b"
+ " WHERE nvl(dr,0) = 0 and csaleorderid = '[csaleorderid]' and vbdef11 = '[vbdef11]' ";
countSql = countSql.replace("[csaleorderid]", csaleorderid);
countSql = countSql.replace("[vbdef11]", vbdef11);
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
@ -121,7 +298,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
// SetUpdateData setData = new SetUpdateData();
// setData.setData(vos, originVos);
// SaleOrderVO[] combinBillVOs = (SaleOrderVO[]) AggVOUtil.combinBillVO(vos, originVos);
// SaleOrderVO[] combinBillVOs = (SaleOrderVO[]) AggVOUtil.combinBillVO(vos,
// originVos);
// 创建一个新的数组并进行深拷贝
SaleOrderVO[] combinBillVOs = new SaleOrderVO[originVos.length];
for (int i = 0; i < originVos.length; i++) {
@ -181,13 +359,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
SaleOrderBVO[] bvos = vo.getChildrenVO();
// 判断是否存在新增的子表
boolean hasNewStatus = Arrays.stream(bvos)
.anyMatch(bvo -> bvo.getStatus() == VOStatus.NEW);
boolean hasNewStatus = Arrays.stream(bvos).anyMatch(bvo -> bvo.getStatus() == VOStatus.NEW);
// 新增子表或改订单类型的情况下不校验是否存在下游
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]' ";
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]", hvo.getCsaleorderid());
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
if (num > 0) {
@ -201,14 +378,11 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
fillcustomervidbyoid(combinBillVOs);
// 保存
ISaleOrderScriptMaintain maintainsrv =
NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class);
SaleOrderVO[] retvos =
maintainsrv.saleOrderUpdate(combinBillVOs, null, originVos);
ISaleOrderScriptMaintain maintainsrv = NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class);
SaleOrderVO[] retvos = maintainsrv.saleOrderUpdate(combinBillVOs, null, originVos);
return retvos;
}
private Map<String, Set<String>> getIds(SaleOrderVO[] vos) {
Map<String, Set<String>> ids = new HashMap<String, Set<String>>();
for (SaleOrderVO vo : vos) {
@ -391,7 +565,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
targetBVO.setVbdef13(sourceBVO.getVbdef13());// 国网行项目号
NCCForUAPLogger.debug(String.format(
"cmaterialvid = [%S], vbdef1 = [%S], vbdef5 = [%S], vbdef10 = [%S], vbdef13 = [%S]",
cmaterialvid, targetBVO.getVbdef1(), targetBVO.getVbdef5(), targetBVO.getVbdef10(), targetBVO.getVbdef13()));
cmaterialvid, targetBVO.getVbdef1(), targetBVO.getVbdef5(), targetBVO.getVbdef10(),
targetBVO.getVbdef13()));
}
}
@ -403,7 +578,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
*/
private Map<String, String> getDefList(String code) {
Map<String, String> map = new HashMap<String, String>();
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='" + code + "' and dr=0 ) and dr = 0";
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='" + code
+ "' and dr=0 ) and dr = 0";
try {
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
if (defdocVOs != null && defdocVOs.length > 0) {
@ -429,7 +605,6 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
PfServiceScmUtil.processBatch("DELETE", SOBillType.Order.getCode(), saleOrderVOs, null, null);
}
private void fillcustomervidbyoid(SaleOrderVO[] combinBillVOs) {
Set<String> customeridSet = new HashSet<String>();
Map<String, String> customeridMap = new HashMap<String, String>();
@ -440,24 +615,24 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
customeridSet.add(hvo.getCcustomerid());
}
if (!StringUtil.isSEmptyOrNull(hvo.getCinvoicecustid()) && StringUtil.isSEmptyOrNull(hvo.getCinvoicecustvid())) {
if (!StringUtil.isSEmptyOrNull(hvo.getCinvoicecustid())
&& StringUtil.isSEmptyOrNull(hvo.getCinvoicecustvid())) {
customeridSet.add(hvo.getCinvoicecustid());
}
if (!StringUtil.isSEmptyOrNull(hvo.getChreceivecustid()) &&
StringUtil.isSEmptyOrNull(hvo.getChreceivecustvid())) {
if (!StringUtil.isSEmptyOrNull(hvo.getChreceivecustid())
&& StringUtil.isSEmptyOrNull(hvo.getChreceivecustvid())) {
customeridSet.add(hvo.getChreceivecustid());
}
SaleOrderBVO[] bvos = vo.getChildrenVO();
for (SaleOrderBVO bvo : bvos) {
if (!StringUtil.isSEmptyOrNull(bvo.getCreceivecustid()) &&
StringUtil.isSEmptyOrNull(bvo.getCreceivecustvid())) {
if (!StringUtil.isSEmptyOrNull(bvo.getCreceivecustid())
&& StringUtil.isSEmptyOrNull(bvo.getCreceivecustvid())) {
customeridSet.add(bvo.getCreceivecustid());
}
if (!StringUtil.isSEmptyOrNull(bvo.getCvendorid()) && StringUtil.isSEmptyOrNull(bvo.getCvendorvid())) {
customeridSet.add(bvo.getCvendorid());
}
@ -465,7 +640,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
if (!customeridSet.isEmpty()) {
customeridMap = CustomerPubService.queryCustomerVidsByOids((String[]) CollectionUtils.setToArray(customeridSet));
customeridMap = CustomerPubService
.queryCustomerVidsByOids((String[]) CollectionUtils.setToArray(customeridSet));
}
for (SaleOrderVO vo : combinBillVOs) {
@ -479,7 +655,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
}
if (!StringUtil.isSEmptyOrNull(hvo.getCinvoicecustid()) && StringUtil.isSEmptyOrNull(hvo.getCinvoicecustvid())) {
if (!StringUtil.isSEmptyOrNull(hvo.getCinvoicecustid())
&& StringUtil.isSEmptyOrNull(hvo.getCinvoicecustvid())) {
if (null == customeridMap || customeridMap.size() == 0) {
hvo.setCinvoicecustvid(hvo.getCinvoicecustid());
} else {
@ -487,8 +664,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
}
if (!StringUtil.isSEmptyOrNull(hvo.getChreceivecustid()) &&
StringUtil.isSEmptyOrNull(hvo.getChreceivecustvid())) {
if (!StringUtil.isSEmptyOrNull(hvo.getChreceivecustid())
&& StringUtil.isSEmptyOrNull(hvo.getChreceivecustvid())) {
if (null == customeridMap || customeridMap.size() == 0) {
hvo.setChreceivecustvid(hvo.getChreceivecustid());
} else {
@ -499,8 +676,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
SaleOrderBVO[] bvos = vo.getChildrenVO();
for (SaleOrderBVO bvo : bvos) {
if (!StringUtil.isSEmptyOrNull(bvo.getCreceivecustid()) &&
StringUtil.isSEmptyOrNull(bvo.getCreceivecustvid())) {
if (!StringUtil.isSEmptyOrNull(bvo.getCreceivecustid())
&& StringUtil.isSEmptyOrNull(bvo.getCreceivecustvid())) {
if (null == customeridMap || customeridMap.size() == 0) {
bvo.setCreceivecustvid(bvo.getCreceivecustid());
} else {
@ -508,7 +685,6 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
}
if (!StringUtil.isSEmptyOrNull(bvo.getCvendorid()) && StringUtil.isSEmptyOrNull(bvo.getCvendorvid())) {
if (null == customeridMap || customeridMap.size() == 0) {
bvo.setCvendorvid(bvo.getCvendorid());
@ -560,13 +736,14 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
try {
for (SaleOrderVO aggvo : vos) {
SaleOrderHVO parentVO = aggvo.getParentVO();
if (!BillStatus.FREE.equalsValue(parentVO.getFstatusflag()) &&
!BillStatus.AUDIT.equalsValue(parentVO.getFstatusflag()) &&
!BillStatus.AUDITING.equalsValue(parentVO.getFstatusflag())) {
if (!BillStatus.FREE.equalsValue(parentVO.getFstatusflag())
&& !BillStatus.AUDIT.equalsValue(parentVO.getFstatusflag())
&& !BillStatus.AUDITING.equalsValue(parentVO.getFstatusflag())) {
ExceptionUtils.wrappBusinessException("当前销售订单:" + parentVO.getVbillcode() + "状态不符合审批条件,不能审批");
}
}
return (SaleOrderVO[]) PfServiceScmUtil.processBatch("APPROVE", SOBillType.Order.getCode(), vos, null, null);
return (SaleOrderVO[]) PfServiceScmUtil.processBatch("APPROVE", SOBillType.Order.getCode(), vos, null,
null);
} catch (Exception e) {
ExceptionUtils.marsh(e);
return null;
@ -579,19 +756,19 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
try {
for (SaleOrderVO aggvo : vos) {
SaleOrderHVO parentVO = aggvo.getParentVO();
if (!BillStatus.AUDIT.equalsValue(parentVO.getFstatusflag()) &&
!BillStatus.AUDITING.equalsValue(parentVO.getFstatusflag())) {
if (!BillStatus.AUDIT.equalsValue(parentVO.getFstatusflag())
&& !BillStatus.AUDITING.equalsValue(parentVO.getFstatusflag())) {
ExceptionUtils.wrappBusinessException("当前销售订单:" + parentVO.getVbillcode() + "状态不符合弃审条件,不能弃审");
}
}
return (SaleOrderVO[]) PfServiceScmUtil.processBatch("UNAPPROVE", SOBillType.Order.getCode(), vos, null, null);
return (SaleOrderVO[]) PfServiceScmUtil.processBatch("UNAPPROVE", SOBillType.Order.getCode(), vos, null,
null);
} catch (Exception e) {
ExceptionUtils.marsh(e);
return null;
}
}
private SaleOrderVO[] querySaleOrder(String[] hids) throws BusinessException {
ISaleOrderQueryAPI service = (ISaleOrderQueryAPI) NCLocator.getInstance().lookup(ISaleOrderQueryAPI.class);
SaleOrderVO[] vos = service.queryVOByIDs(hids);
@ -611,15 +788,14 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
UFDouble nnum = bVO.getNnum();
UFDouble ntaxrate = bVO.getNtaxrate();
try {
String sql = " select a.pk_material,a.pk_source, a.pk_measdoc cunitid,nvl(b.pk_measdoc,a.pk_measdoc) castunitid,nvl(b.measrate,'1/1') measrate " +
"from bd_material a left join bd_materialconvert b on a.pk_material=b.pk_material " +
"where a.code='" + cmaterialvid + "' ";
String sql = " select a.pk_material,a.pk_source, a.pk_measdoc cunitid,nvl(b.pk_measdoc,a.pk_measdoc) castunitid,nvl(b.measrate,'1/1') measrate "
+ "from bd_material a left join bd_materialconvert b on a.pk_material=b.pk_material "
+ "where a.code='" + cmaterialvid + "' ";
Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
if (map == null) {
throw new BusinessException(cmaterialvid + "物料未查到");
}
NCCForUAPLogger.debug(String.format(
"setMaterl: cqtunitid = [%S], cunitid = [%S], castunitid = [%S]",
NCCForUAPLogger.debug(String.format("setMaterl: cqtunitid = [%S], cunitid = [%S], castunitid = [%S]",
map.get("cqtunitid"), map.get("cunitid"), map.get("castunitid")));
bVO.setAttributeValue("castunitid", map.get("castunitid"));
bVO.setAttributeValue("vchangerate", map.get("vchangerate"));
@ -631,11 +807,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
bVO.setAttributeValue("cmaterialid", map.get("pk_material"));
bVO.setAttributeValue("cmaterialvid", map.get("pk_material"));
UFDouble nqtunitnum = BFPubTools.getUFDouble_NullAsZero(nnum).div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0]));
UFDouble nqtunitnum = BFPubTools.getUFDouble_NullAsZero(nnum)
.div(BFPubTools.getUFDouble_NullAsZero(map.get("measrate").toString().split("/")[0]));
bVO.setAttributeValue("nqtunitnum", nqtunitnum);
sql = "select sl.pk_taxcode from bd_taxrate sl inner join bd_taxcode sm on sl.pk_taxcode=sm.pk_taxcode where sl.taxrate=" + ntaxrate + " and sm.pk_group<>'~' " +
"";
sql = "select sl.pk_taxcode from bd_taxrate sl inner join bd_taxcode sm on sl.pk_taxcode=sm.pk_taxcode where sl.taxrate="
+ ntaxrate + " and sm.pk_group<>'~' " + "";
String o_pk_project = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor());
// 税码
@ -687,7 +864,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
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 ";
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);
@ -747,60 +925,65 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
// 无税本币金额单价
UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
nqtorigprice = nqtorigprice.setScale(4, 4);
// nqtorigtaxnetprc--含税净价
newBvo.setNqtorigtaxnetprc(nqtorigtaxprice);
//,nqtorignetprice --无税净价
// ,nqtorignetprice --无税净价
newBvo.setNqtorignetprice(nqtorigprice);
String Vqtunitrate = newBvo.getVqtunitrate();
UFDouble dVqtunitrate = UFDouble.ONE_DBL;
if (Vqtunitrate != null) {
dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]);
}
//,norigtaxprice --主含税单价
// ,norigtaxprice --主含税单价
UFDouble wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(newBvo.getCqtunitid()).equals(BFPubTools.getString_TrimAsNull(newBvo.getCastunitid()))) {
if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(newBvo.getCqtunitid())
.equals(BFPubTools.getString_TrimAsNull(newBvo.getCastunitid()))) {
wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
}
wsje = nc.itf.fi.pub.Currency.getFormaUfValue(zbbz, wsje);
// 本币无税金额
newBvo.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4));
//,norigprice --主无税单价
// ,norigprice --主无税单价
newBvo.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4));
//,norigtaxnetprice --主含税净价
// ,norigtaxnetprice --主含税净价
newBvo.setNorigtaxnetprice(newBvo.getNorigtaxprice());
//,norignetprice --主无税净价
// ,norignetprice --主无税净价
newBvo.setNorignetprice(newBvo.getNorigprice());
// ncaltaxmny --计税金额
// nqttaxprice --本币含税单价
newBvo.setNqttaxprice(nqtorigtaxprice.multiply(nexchangerate));
//nqtprice --本币无税单价
UFDouble bbwsd = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
// nqtprice --本币无税单价
UFDouble bbwsd = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)))
.multiply(nexchangerate);
newBvo.setNqtprice(bbwsd.setScale(4, 4));
// nqttaxnetprice --本币含税净价
// nqttaxnetprice --本币含税净价
newBvo.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate));
//nqtnetprice --本币无税净价
UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
// nqtnetprice --本币无税净价
UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)))
.multiply(nexchangerate);
newBvo.setNqtnetprice(Nqtnetprice.setScale(4, 4));
//ntaxprice --主本币含税单价 nprice --主本币无税单价
// ntaxprice --主本币含税单价 nprice --主本币无税单价
newBvo.setNtaxprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
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));
//ntaxnetprice --主本币含税净价
newBvo.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4));
//nnetprice --主本币无税净价
UFDouble nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate);
// ntaxnetprice --主本币含税净价
newBvo.setNtaxnetprice(
nqtorigtaxprice.div(dVqtunitrate).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)));
newBvo.setNtaxmny(nqtorigtaxprice.multiply(nexchangerate).multiply(newBvo.getNqtunitnum()).setScale(2, 4));
newBvo.setNtaxmny(nqtorigtaxprice.multiply(nexchangerate).multiply(newBvo.getNqtunitnum())
.setScale(2, 4));
newBvo.setNcaltaxmny(wsje);
UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje);
newBvo.setNtax(ntax.setScale(2, 4));
@ -852,13 +1035,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
}
/*for (SaleOrderVO combinBillVO : copyVOs) {
for (SaleOrderBVO saleOrderBVO : combinBillVO.getChildrenVO()) {
// 将实体对象转换为JSON字符串
String jsonString = JSON.toJSONString(saleOrderBVO);
NCCForUAPLogger.debug("jsonString:" + jsonString);
}
}*/
/*
* 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());
@ -878,9 +1060,3 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
}
}
/* Location: D:\home_taikaijt\bipgj\home\yonyou\YonBIP2312\modules\so\META-INF\lib\so_openapi.jar!/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.0.7
*/

View File

@ -0,0 +1,24 @@
package nccloud.api.so.m30;
import java.util.List;
import java.util.Map;
import nc.vo.pub.BusinessException;
import nc.vo.so.m30.entity.SaleOrderVO;
public interface IAPISaleOrderMaitain {
SaleOrderVO[] save(List<Map<String, Object>> paramList) throws BusinessException;
SaleOrderVO[] update(List<Map<String, Object>> paramList) throws BusinessException;
void delete(String[] paramArrayOfString) throws BusinessException;
SaleOrderVO[] sendApprove(String[] paramArrayOfString) throws BusinessException;
SaleOrderVO[] unSendApprove(String[] paramArrayOfString) throws BusinessException;
SaleOrderVO[] approve(String[] paramArrayOfString) throws BusinessException;
SaleOrderVO[] unApprove(String[] paramArrayOfString) throws BusinessException;
public SaleOrderVO[] save(SaleOrderVO[] vos) throws BusinessException;
}