销售订单修订-是否赠品取值调整和增行逻辑调整

This commit is contained in:
mzr 2025-03-07 10:57:18 +08:00
parent 0bf5ded6c9
commit 1b2f6d5d9c
2 changed files with 165 additions and 145 deletions

View File

@ -282,16 +282,18 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
String primaryKey = hvo.getCsaleorderid(); String primaryKey = hvo.getCsaleorderid();
SaleOrderVO bipVo = vosMap.get(primaryKey); SaleOrderVO bipVo = vosMap.get(primaryKey);
// 创建一个Set来存储vos中多的csaleorderbid // 创建一个Set来存储vos中多的csaleorderbid
Set<String> delBids = findOtherBids(bipVo.getChildrenVO(), vo.getChildrenVO()); // Set<String> delBids = findOtherBids(bipVo.getChildrenVO(), vo.getChildrenVO());
// 设置单据状态 // 设置单据状态
hvo.setStatus(VOStatus.UPDATED); hvo.setStatus(VOStatus.UPDATED);
// 比较combinBillVOs中的BVO和vos中的BVO // 比较combinBillVOs中的BVO和vos中的BVO
for (SaleOrderBVO bvo : vo.getChildrenVO()) { for (SaleOrderBVO bvo : vo.getChildrenVO()) {
bvo.setStatus(VOStatus.UPDATED); bvo.setStatus(VOStatus.UPDATED);
// 设置删除的物料行的状态 // 设置删除的物料行的状态
if (!delBids.isEmpty() && delBids.contains(bvo.getCsaleorderbid())) { for (SaleOrderBVO bipBVO : bipVo.getChildrenVO()) {
bvo.setStatus(VOStatus.DELETED); if (bvo.getCsaleorderbid().equals(bipBVO.getCsaleorderbid()) && (1 == bipBVO.getDr())) {
NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + bvo.getCsaleorderbid()); bvo.setStatus(VOStatus.DELETED);
NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + bvo.getCsaleorderbid());
}
} }
} }
// 更新 combinBillVO 中的字段为 vos 中的值 // 更新 combinBillVO 中的字段为 vos 中的值
@ -434,6 +436,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
// 价税合计 // 价税合计
targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny()); targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny());
targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid()); targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid());
// 是否赠品
targetBVO.setBlargessflag(sourceBVO.getBlargessflag());
// 折本汇率 // 折本汇率
UFDouble nexchangerate = getUFDouble_NullAsOne(sourceBVO.getNexchangerate()); UFDouble nexchangerate = getUFDouble_NullAsOne(sourceBVO.getNexchangerate());
targetBVO.setNexchangerate(nexchangerate); targetBVO.setNexchangerate(nexchangerate);
@ -553,7 +557,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
private Set<String> findOtherBids(SaleOrderBVO[] bipBVOs, SaleOrderBVO[] nccBVOs) { private Set<String> findOtherBids(SaleOrderBVO[] bipBVOs, SaleOrderBVO[] nccBVOs) {
Set<String> bipBids = new HashSet<>(); Set<String> bipBids = new HashSet<>();
for (SaleOrderBVO bvo : bipBVOs) { for (SaleOrderBVO bvo : bipBVOs) {
bipBids.add(bvo.getCsaleorderbid()); String csaleorderbid = bvo.getCsaleorderbid();
if (csaleorderbid != null && !csaleorderbid.isEmpty()) {
bipBids.add(csaleorderbid);
}
} }
Set<String> deletedBids = new HashSet<>(); Set<String> deletedBids = new HashSet<>();
@ -574,169 +581,184 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
for (int i = 0; i < oldVOs.length; i++) { for (int i = 0; i < oldVOs.length; i++) {
copyVOs[i] = (SaleOrderVO) oldVOs[i].clone(); copyVOs[i] = (SaleOrderVO) oldVOs[i].clone();
} }
// vos 中的元素按主键存储在 Map
Map<String, SaleOrderVO> vosMap = new HashMap<>();
for (SaleOrderVO vo : copyVOs) { for (SaleOrderVO vo : copyVOs) {
vosMap.put(vo.getParentVO().getCsaleorderid(), vo);
}
for (Map<String, Object> objectMap : paramList) {
Map<String, Object> headdata = (Map<String, Object>) objectMap.get("so_saleorder");
String primaryKey = headdata.getOrDefault("csaleorderid", "") + "";
SaleOrderVO vo = vosMap.get(primaryKey);
SaleOrderHVO hvo = vo.getParentVO(); SaleOrderHVO hvo = vo.getParentVO();
SaleOrderBVO[] bvos = vo.getChildrenVO();
List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos));
String csaleorderid = hvo.getCsaleorderid(); String csaleorderid = hvo.getCsaleorderid();
String ybpk = hvo.getCorigcurrencyid(); String ybpk = hvo.getCorigcurrencyid();
Map<String, Object> objectMap = Collections.emptyMap(); SaleOrderBVO[] bvos = vo.getChildrenVO();
for (Map<String, Object> map : paramList) { List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos));
objectMap = (Map<String, Object>) map.get(csaleorderid);
}
if (objectMap != null && !objectMap.isEmpty()) {
List<Object> bodyArr = (List<Object>) objectMap.get("so_saleorder_b");
for (Object body : bodyArr) {
Map<String, Object> bodydata = (Map<String, Object>) body;
if ("add".equals(bodydata.get("status"))) {
String pkOrgV = hvo.getPk_org_v();
String pkOrg = hvo.getPk_org();
String pk_group = AppContext.getInstance().getPkGroup();
// 新数据的实体
// SaleOrderBVO newBvo = (SaleOrderBVO) bvos[0].clone();
SaleOrderBVO newBvo = new SaleOrderBVO();
newBvo.setStatus(VOStatus.NEW);
newBvo.setAttributeValue("pk_group", pk_group);
newBvo.setAttributeValue("cprojectid", bodydata.get("cprojectid"));
// newBvo.setAttributeValue("ctrafficorgvid", pkOrg);
// newBvo.setAttributeValue("csendstockorgvid", pkOrg);
// newBvo.setAttributeValue("csendstordocid", pkOrg);
// newBvo.setAttributeValue("csendstockorgid", pkOrg);
// newBvo.setAttributeValue("carorgid", pkOrg);
// newBvo.setAttributeValue("carorgvid", pkOrg);
// newBvo.setAttributeValue("csettleorgid", pkOrg);
// newBvo.setAttributeValue("csettleorgvid", pkOrg);
newBvo.setAttributeValue("ctaxcountryid", "CN"); List<Object> bodyArr = (List<Object>) objectMap.get("so_saleorder_b");
newBvo.setAttributeValue("crececountryid", "CN"); for (Object body : bodyArr) {
newBvo.setAttributeValue("csendcountryid", "CN"); Map<String, Object> bodydata = (Map<String, Object>) body;
if ("add".equals(bodydata.get("status"))) {
String pkOrgV = hvo.getPk_org_v();
String pkOrg = hvo.getPk_org();
String pk_group = AppContext.getInstance().getPkGroup();
// 新数据的实体
// SaleOrderBVO newBvo = (SaleOrderBVO) bvos[0].clone();
SaleOrderBVO newBvo = new SaleOrderBVO();
newBvo.setStatus(VOStatus.NEW);
newBvo.setAttributeValue("pk_group", pk_group);
newBvo.setAttributeValue("cprojectid", bodydata.get("cprojectid"));
// newBvo.setAttributeValue("ctrafficorgvid", pkOrg);
// newBvo.setAttributeValue("csendstockorgvid", pkOrg);
// newBvo.setAttributeValue("csendstordocid", pkOrg);
// newBvo.setAttributeValue("csendstockorgid", pkOrg);
// newBvo.setAttributeValue("carorgid", pkOrg);
// newBvo.setAttributeValue("carorgvid", pkOrg);
// newBvo.setAttributeValue("csettleorgid", pkOrg);
// newBvo.setAttributeValue("csettleorgvid", pkOrg);
newBvo.setAttributeValue("fbuysellflag", 1); newBvo.setAttributeValue("ctaxcountryid", "CN");
UFDouble nexchangerateBip = getUFDouble_NullAsOne(bodydata.get("nexchangerate")); newBvo.setAttributeValue("crececountryid", "CN");
newBvo.setNexchangerate(nexchangerateBip); newBvo.setAttributeValue("csendcountryid", "CN");
// 设置物料的关联字段的值
newBvo.setCmaterialvid(bodydata.get("cmaterialvid") + "");
UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(bodydata.get("ntaxrate"));
UFDouble nnum = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum"));
newBvo.setAttributeValue("ntaxrate", ntaxrate);
newBvo.setAttributeValue("nnum", nnum);
newBvo.setVbdef11(bodydata.getOrDefault("vbdef11", "") + "");
UFDouble norigtaxprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("norigtaxprice")); newBvo.setAttributeValue("fbuysellflag", 1);
newBvo.setAttributeValue("norigtaxprice", norigtaxprice); UFDouble nexchangerateBip = getUFDouble_NullAsOne(bodydata.get("nexchangerate"));
UFDouble norigprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("norigprice")); newBvo.setNexchangerate(nexchangerateBip);
newBvo.setAttributeValue("norigprice", norigprice); // 设置物料的关联字段的值
setMaterl(newBvo); newBvo.setCmaterialvid(bodydata.get("cmaterialvid") + "");
newBvo.setCsaleorderbid(null); UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(bodydata.get("ntaxrate"));
UFDouble nnum = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nnum"));
newBvo.setAttributeValue("ntaxrate", ntaxrate);
newBvo.setAttributeValue("nnum", nnum);
newBvo.setVbdef11(bodydata.getOrDefault("vbdef11", "") + "");
newBvo.setCcurrencyid(ybpk); UFDouble norigtaxprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("norigtaxprice"));
String zbbz = newBvo.getCcurrencyid(); newBvo.setAttributeValue("norigtaxprice", norigtaxprice);
UFDouble norigprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("norigprice"));
newBvo.setAttributeValue("norigprice", norigprice);
setMaterl(newBvo);
newBvo.setCsaleorderbid(null);
newBvo.setFtaxtypeflag(1); newBvo.setCcurrencyid(ybpk);
String zbbz = newBvo.getCcurrencyid();
// 折本汇率 newBvo.setFtaxtypeflag(1);
UFDouble nexchangerate = newBvo.getNexchangerate();
// 含税单价
UFDouble nqtorigtaxprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nqtorigtaxprice"));
newBvo.setAttributeValue("nqtorigtaxprice", nqtorigtaxprice);
// 无税单价
UFDouble nqtorigprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
// 价税合计
UFDouble norigtaxmny = nqtorigtaxprice.multiply(newBvo.getNqtunitnum()).setScale(2, 4);
newBvo.setNorigtaxmny(norigtaxmny);
// 无税金额
UFDouble norigmny = nqtorigprice.multiply(newBvo.getNqtunitnum());
newBvo.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny)); // 折本汇率
// 税额 UFDouble nexchangerate = newBvo.getNexchangerate();
newBvo.setNqtorigprice(nqtorigprice.setScale(4, 4)); // 含税单价
UFDouble nqtorigtaxprice = BFPubTools.getUFDouble_NullAsZero(bodydata.get("nqtorigtaxprice"));
newBvo.setAttributeValue("nqtorigtaxprice", nqtorigtaxprice);
// 无税单价
UFDouble nqtorigprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
// 价税合计
UFDouble norigtaxmny = nqtorigtaxprice.multiply(newBvo.getNqtunitnum()).setScale(2, 4);
newBvo.setNorigtaxmny(norigtaxmny);
// 无税金额
UFDouble norigmny = nqtorigprice.multiply(newBvo.getNqtunitnum());
// 无税本币金额单价 newBvo.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny));
UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); // 税额
newBvo.setNqtorigprice(nqtorigprice.setScale(4, 4));
// 无税本币金额单价
UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100)));
nqtorigprice = nqtorigprice.setScale(4, 4); nqtorigprice = nqtorigprice.setScale(4, 4);
// nqtorigtaxnetprc--含税净价 // nqtorigtaxnetprc--含税净价
newBvo.setNqtorigtaxnetprc(nqtorigtaxprice); newBvo.setNqtorigtaxnetprc(nqtorigtaxprice);
//,nqtorignetprice --无税净价 //,nqtorignetprice --无税净价
newBvo.setNqtorignetprice(nqtorigprice); newBvo.setNqtorignetprice(nqtorigprice);
String Vqtunitrate = newBvo.getVqtunitrate(); String Vqtunitrate = newBvo.getVqtunitrate();
UFDouble dVqtunitrate = UFDouble.ONE_DBL; UFDouble dVqtunitrate = UFDouble.ONE_DBL;
if (Vqtunitrate != null) { if (Vqtunitrate != null) {
dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]); dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]);
}
//,norigtaxprice --主含税单价
UFDouble wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(newBvo.getCqtunitid()).equals(BFPubTools.getString_TrimAsNull(newBvo.getCastunitid()))) {
wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
}
wsje = Currency.getFormaUfValue(zbbz, wsje);
// 本币无税金额
newBvo.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4));
//,norigprice --主无税单价
newBvo.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4));
//,norigtaxnetprice --主含税净价
newBvo.setNorigtaxnetprice(newBvo.getNorigtaxprice());
//,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);
newBvo.setNqtprice(bbwsd.setScale(4, 4));
// nqttaxnetprice --本币含税净价
newBvo.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate));
//nqtnetprice --本币无税净价
UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
newBvo.setNqtnetprice(Nqtnetprice.setScale(4, 4));
//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);
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);
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.setNcaltaxmny(wsje);
UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje);
newBvo.setNtax(ntax.setScale(2, 4));
newBvo.setCrowno(bodydata.get("crowno") + "");
bvoList.add(newBvo);
} }
//,norigtaxprice --主含税单价
UFDouble wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(newBvo.getCqtunitid()).equals(BFPubTools.getString_TrimAsNull(newBvo.getCastunitid()))) {
wsje = taxspric.multiply(nexchangerate).multiply(newBvo.getNqtunitnum());
}
wsje = Currency.getFormaUfValue(zbbz, wsje);
// 本币无税金额
newBvo.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4));
//,norigprice --主无税单价
newBvo.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4));
//,norigtaxnetprice --主含税净价
newBvo.setNorigtaxnetprice(newBvo.getNorigtaxprice());
//,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);
newBvo.setNqtprice(bbwsd.setScale(4, 4));
// nqttaxnetprice --本币含税净价
newBvo.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate));
//nqtnetprice --本币无税净价
UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate);
newBvo.setNqtnetprice(Nqtnetprice.setScale(4, 4));
//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);
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);
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.setNcaltaxmny(wsje);
UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje);
newBvo.setNtax(ntax.setScale(2, 4));
newBvo.setCrowno(bodydata.get("crowno") + "");
// 是否赠品
String blargessflag = bodydata.getOrDefault("blargessflag", "N") + "";
newBvo.setBlargessflag(UFBoolean.valueOf(blargessflag));
bvoList.add(newBvo);
} }
} }
SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]);
vo.setChildrenVO(array); vo.setChildrenVO(array);
} }
// 填充默认值 // 填充默认值
new SaleOrderSaveFillValue().setDefValue(copyVOs); new SaleOrderSaveFillValue().setDefValue(copyVOs);
SaleOrderBVO newBvo = null; Map<String, List<SaleOrderBVO>> listMap = new HashMap<>();
for (SaleOrderVO copyVO : copyVOs) { for (SaleOrderVO copyVO : copyVOs) {
List<SaleOrderBVO> newBvoList = new ArrayList<>();
for (SaleOrderBVO saleOrderBVO : copyVO.getChildrenVO()) { for (SaleOrderBVO saleOrderBVO : copyVO.getChildrenVO()) {
if (VOStatus.NEW == saleOrderBVO.getStatus()) { if (VOStatus.NEW == saleOrderBVO.getStatus()) {
newBvo = (SaleOrderBVO) saleOrderBVO.clone(); SaleOrderBVO newBvo = (SaleOrderBVO) saleOrderBVO.clone();
newBvoList.add(newBvo);
} }
} }
listMap.put(copyVO.getParentVO().getCsaleorderid(), newBvoList);
} }
if (newBvo != null) { if (!listMap.isEmpty()) {
for (SaleOrderVO oldVO : oldVOs) { for (SaleOrderVO oldVO : oldVOs) {
SaleOrderBVO[] bvos = oldVO.getChildrenVO(); String csaleorderid = oldVO.getParentVO().getCsaleorderid();
List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos)); List<SaleOrderBVO> newBvoList = listMap.get(csaleorderid);
bvoList.add(newBvo); if (newBvoList != null && !newBvoList.isEmpty()) {
SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); SaleOrderBVO[] bvos = oldVO.getChildrenVO();
oldVO.setChildrenVO(array); List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos));
bvoList.addAll(newBvoList);
SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]);
oldVO.setChildrenVO(array);
}
} }
} }
/*for (SaleOrderVO combinBillVO : copyVOs) { /*for (SaleOrderVO combinBillVO : copyVOs) {

View File

@ -32,6 +32,7 @@ import nc.vo.so.m30.revise.entity.SaleOrderHistoryVO;
import nccloud.api.rest.utils.NCCRestUtils; import nccloud.api.rest.utils.NCCRestUtils;
import nccloud.api.so.m30.IAPISaleOrderMaitain; import nccloud.api.so.m30.IAPISaleOrderMaitain;
import nccloud.api.so.m30.IAPISaleOrderQuery; import nccloud.api.so.m30.IAPISaleOrderQuery;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import nccloud.framework.core.exception.ExceptionUtils; import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.openapi.scmpub.pub.NCCPubRestResource; import nccloud.openapi.scmpub.pub.NCCPubRestResource;
import nccloud.openapi.scmpub.pub.TransferMapToVOTool; import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
@ -378,7 +379,6 @@ public class SaleOrderResource extends NCCPubRestResource {
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOrderVO.class, TransferMapToVOTool.transferMapToAggVO(paramList, SaleOrderVO.class,
true); true);
SaleOrderVO[] vos = vosList.toArray(new SaleOrderVO[vosList.size()]); SaleOrderVO[] vos = vosList.toArray(new SaleOrderVO[vosList.size()]);
List<Map<String, Object>> addMapList = new ArrayList<Map<String, Object>>();
for (Map<String, Object> objectMap : paramList) { for (Map<String, Object> objectMap : paramList) {
Map<String, Object> headdata = (Map<String, Object>) objectMap.get(HEADTABLE); Map<String, Object> headdata = (Map<String, Object>) objectMap.get(HEADTABLE);
List<Object> bodyArr = (List<Object>) objectMap.get(BODYTABLE); List<Object> bodyArr = (List<Object>) objectMap.get(BODYTABLE);
@ -386,30 +386,28 @@ public class SaleOrderResource extends NCCPubRestResource {
Map<String, Object> bodydata = (Map<String, Object>) body; Map<String, Object> bodydata = (Map<String, Object>) body;
if (!(bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) { if (!(bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) {
String vbdef11 = bodydata.get("vbdef11") + ""; String vbdef11 = bodydata.get("vbdef11") + "";
String dr = bodydata.getOrDefault("dr", "0") + "";
String csaleorderid = bodydata.get("csaleorderid") + ""; String csaleorderid = bodydata.get("csaleorderid") + "";
String countSql = "SELECT count(1) FROM so_saleorder_b" + String countSql = "SELECT count(1) FROM so_saleorder_b" +
" WHERE nvl(dr,0) = 0 and csaleorderid = '[csaleorderid]' and vbdef11 = '[vbdef11]' "; " WHERE nvl(dr,0) = 0 and csaleorderid = '[csaleorderid]' and vbdef11 = '[vbdef11]' ";
countSql = countSql.replace("[csaleorderid]", csaleorderid); countSql = countSql.replace("[csaleorderid]", csaleorderid);
countSql = countSql.replace("[vbdef11]", vbdef11); countSql = countSql.replace("[vbdef11]", vbdef11);
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
if (num <= 0) { if ("0".equals(dr) && num <= 0) {
bodydata.put("status", "add"); bodydata.put("status", "add");
Map map = new HashMap();
map.put(headdata.get("csaleorderid"), objectMap);
addMapList.add(map);
} }
} }
} }
} }
// 调用接口保存 // 调用接口保存
IAPISaleOrderMaitain service = IAPISaleOrderMaitain service =
NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class); NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class);
SaleOrderVO[] results = service.update(vos, addMapList); SaleOrderVO[] results = service.update(vos, paramList);
// 包装返回信息 // 包装返回信息
return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildSuccessResult( return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildSuccessResult(
results, "销售订单修改成功")); results, "销售订单修改成功"));
} catch (Exception e) { } catch (Exception e) {
NCCForUAPLogger.debug("update:" + e.getMessage());
return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildFailResult( return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildFailResult(
null, "销售订单修改异常:" + e.getMessage())); null, "销售订单修改异常:" + e.getMessage()));
} }