销售订单修订-是否赠品取值调整和增行逻辑调整
This commit is contained in:
		
							parent
							
								
									0bf5ded6c9
								
							
						
					
					
						commit
						1b2f6d5d9c
					
				|  | @ -282,18 +282,20 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | |||
|             String primaryKey = hvo.getCsaleorderid(); | ||||
|             SaleOrderVO bipVo = vosMap.get(primaryKey); | ||||
|             // 创建一个Set来存储vos中多的csaleorderbid | ||||
|             Set<String> delBids = findOtherBids(bipVo.getChildrenVO(), vo.getChildrenVO()); | ||||
|             // Set<String> delBids = findOtherBids(bipVo.getChildrenVO(), vo.getChildrenVO()); | ||||
|             // 设置单据状态 | ||||
|             hvo.setStatus(VOStatus.UPDATED); | ||||
|             // 比较combinBillVOs中的BVO和vos中的BVO | ||||
|             for (SaleOrderBVO bvo : vo.getChildrenVO()) { | ||||
|                 bvo.setStatus(VOStatus.UPDATED); | ||||
|                 // 设置删除的物料行的状态 | ||||
|                 if (!delBids.isEmpty() && delBids.contains(bvo.getCsaleorderbid())) { | ||||
|                 for (SaleOrderBVO bipBVO : bipVo.getChildrenVO()) { | ||||
|                     if (bvo.getCsaleorderbid().equals(bipBVO.getCsaleorderbid()) && (1 == bipBVO.getDr())) { | ||||
|                         bvo.setStatus(VOStatus.DELETED); | ||||
|                         NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + bvo.getCsaleorderbid()); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             // 更新 combinBillVO 中的字段为 vos 中的值 | ||||
|             updateFields(vo, bipVo); | ||||
|             // 设置新增的物料行 | ||||
|  | @ -434,6 +436,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | |||
|                     // 价税合计 | ||||
|                     targetBVO.setNorigtaxmny(sourceBVO.getNorigtaxmny()); | ||||
|                     targetBVO.setCmaterialvid(sourceBVO.getCmaterialvid()); | ||||
|                     // 是否赠品 | ||||
|                     targetBVO.setBlargessflag(sourceBVO.getBlargessflag()); | ||||
|                     // 折本汇率 | ||||
|                     UFDouble nexchangerate = getUFDouble_NullAsOne(sourceBVO.getNexchangerate()); | ||||
|                     targetBVO.setNexchangerate(nexchangerate); | ||||
|  | @ -553,7 +557,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | |||
|     private Set<String> findOtherBids(SaleOrderBVO[] bipBVOs, SaleOrderBVO[] nccBVOs) { | ||||
|         Set<String> bipBids = new HashSet<>(); | ||||
|         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<>(); | ||||
|  | @ -574,17 +581,21 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | |||
|             for (int i = 0; i < oldVOs.length; i++) { | ||||
|                 copyVOs[i] = (SaleOrderVO) oldVOs[i].clone(); | ||||
|             } | ||||
|             // 将 vos 中的元素按主键存储在 Map 中 | ||||
|             Map<String, SaleOrderVO> vosMap = new HashMap<>(); | ||||
|             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(); | ||||
|                 SaleOrderBVO[] bvos = vo.getChildrenVO(); | ||||
|                 List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos)); | ||||
|                 String csaleorderid = hvo.getCsaleorderid(); | ||||
|                 String ybpk = hvo.getCorigcurrencyid(); | ||||
|                 Map<String, Object> objectMap = Collections.emptyMap(); | ||||
|                 for (Map<String, Object> map : paramList) { | ||||
|                     objectMap = (Map<String, Object>) map.get(csaleorderid); | ||||
|                 } | ||||
|                 if (objectMap != null && !objectMap.isEmpty()) { | ||||
|                 SaleOrderBVO[] bvos = vo.getChildrenVO(); | ||||
|                 List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos)); | ||||
| 
 | ||||
|                 List<Object> bodyArr = (List<Object>) objectMap.get("so_saleorder_b"); | ||||
|                 for (Object body : bodyArr) { | ||||
|                     Map<String, Object> bodydata = (Map<String, Object>) body; | ||||
|  | @ -712,32 +723,43 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | |||
|                         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]); | ||||
|                 vo.setChildrenVO(array); | ||||
|             } | ||||
| 
 | ||||
|             // 填充默认值 | ||||
|             new SaleOrderSaveFillValue().setDefValue(copyVOs); | ||||
|             SaleOrderBVO newBvo = null; | ||||
|             Map<String, List<SaleOrderBVO>> listMap = new HashMap<>(); | ||||
|             for (SaleOrderVO copyVO : copyVOs) { | ||||
|                 List<SaleOrderBVO> newBvoList = new ArrayList<>(); | ||||
|                 for (SaleOrderBVO saleOrderBVO : copyVO.getChildrenVO()) { | ||||
|                     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) { | ||||
|                     String csaleorderid = oldVO.getParentVO().getCsaleorderid(); | ||||
|                     List<SaleOrderBVO> newBvoList = listMap.get(csaleorderid); | ||||
|                     if (newBvoList != null && !newBvoList.isEmpty()) { | ||||
|                         SaleOrderBVO[] bvos = oldVO.getChildrenVO(); | ||||
|                         List<SaleOrderBVO> bvoList = new ArrayList<>(Arrays.asList(bvos)); | ||||
|                     bvoList.add(newBvo); | ||||
|                         bvoList.addAll(newBvoList); | ||||
|                         SaleOrderBVO[] array = bvoList.toArray(new SaleOrderBVO[0]); | ||||
|                         oldVO.setChildrenVO(array); | ||||
|                     } | ||||
| 
 | ||||
|                 } | ||||
|             } | ||||
|             /*for (SaleOrderVO combinBillVO : copyVOs) { | ||||
|                 for (SaleOrderBVO saleOrderBVO : combinBillVO.getChildrenVO()) { | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ import nc.vo.so.m30.revise.entity.SaleOrderHistoryVO; | |||
| import nccloud.api.rest.utils.NCCRestUtils; | ||||
| import nccloud.api.so.m30.IAPISaleOrderMaitain; | ||||
| import nccloud.api.so.m30.IAPISaleOrderQuery; | ||||
| import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||
| import nccloud.framework.core.exception.ExceptionUtils; | ||||
| import nccloud.openapi.scmpub.pub.NCCPubRestResource; | ||||
| import nccloud.openapi.scmpub.pub.TransferMapToVOTool; | ||||
|  | @ -378,7 +379,6 @@ public class SaleOrderResource extends NCCPubRestResource { | |||
|                     TransferMapToVOTool.transferMapToAggVO(paramList, SaleOrderVO.class, | ||||
|                             true); | ||||
|             SaleOrderVO[] vos = vosList.toArray(new SaleOrderVO[vosList.size()]); | ||||
|             List<Map<String, Object>> addMapList = new ArrayList<Map<String, Object>>(); | ||||
|             for (Map<String, Object> objectMap : paramList) { | ||||
|                 Map<String, Object> headdata = (Map<String, Object>) objectMap.get(HEADTABLE); | ||||
|                 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; | ||||
|                     if (!(bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) { | ||||
|                         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]'  "; | ||||
|                         countSql = countSql.replace("[csaleorderid]", csaleorderid); | ||||
|                         countSql = countSql.replace("[vbdef11]", vbdef11); | ||||
|                         Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); | ||||
|                         if (num <= 0) { | ||||
|                         if ("0".equals(dr) && num <= 0) { | ||||
|                             bodydata.put("status", "add"); | ||||
|                             Map map = new HashMap(); | ||||
|                             map.put(headdata.get("csaleorderid"), objectMap); | ||||
|                             addMapList.add(map); | ||||
|                         } | ||||
| 
 | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             // 调用接口保存 | ||||
|             IAPISaleOrderMaitain service = | ||||
|                     NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class); | ||||
|             SaleOrderVO[] results = service.update(vos, addMapList); | ||||
|             SaleOrderVO[] results = service.update(vos, paramList); | ||||
|             // 包装返回信息 | ||||
|             return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildSuccessResult( | ||||
|                     results, "销售订单修改成功")); | ||||
|         } catch (Exception e) { | ||||
|             NCCForUAPLogger.debug("update:" + e.getMessage()); | ||||
|             return NCCRestUtils.toJSONString(CallReturnBuildUtil.buildFailResult( | ||||
|                     null, "销售订单修改异常:" + e.getMessage())); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue