销售订单折本汇率保留2位小数,增加订单类型和客户的变更逻辑,新增物料行的项目增加判空逻辑
This commit is contained in:
		
							parent
							
								
									c787a28f45
								
							
						
					
					
						commit
						7f472d5694
					
				|  | @ -14,6 +14,7 @@ import nc.pubitf.so.m30.api.ISaleOrderQueryAPI; | ||||||
| import nc.vo.ml.NCLangRes4VoTransl; | import nc.vo.ml.NCLangRes4VoTransl; | ||||||
| import nc.vo.pub.BusinessException; | import nc.vo.pub.BusinessException; | ||||||
| import nc.vo.pub.VOStatus; | import nc.vo.pub.VOStatus; | ||||||
|  | import nc.vo.pub.billtype.BilltypeVO; | ||||||
| import nc.vo.pub.lang.UFBoolean; | import nc.vo.pub.lang.UFBoolean; | ||||||
| import nc.vo.pub.lang.UFDate; | import nc.vo.pub.lang.UFDate; | ||||||
| import nc.vo.pub.lang.UFDouble; | import nc.vo.pub.lang.UFDouble; | ||||||
|  | @ -40,6 +41,7 @@ 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 nccloud.riart.pubimpl.billtype.BilltypeServiceImpl; | ||||||
| 
 | 
 | ||||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||||
| import java.util.*; | import java.util.*; | ||||||
|  | @ -74,9 +76,9 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|             if (o1 == null) { |             if (o1 == null) { | ||||||
|                 throw new BusinessException("表体币种不能为空或币种不存在"); |                 throw new BusinessException("表体币种不能为空或币种不存在"); | ||||||
|             } |             } | ||||||
|             String csettleorgid = bvos[0].getCsettleorgid(); |             // String csettleorgid = bvos[0].getCsettleorgid(); | ||||||
|             String ccurrencyorgid = o1.toString(); |             String ccurrencyorgid = o1.toString(); | ||||||
|             UFDouble exchangerate = SOCurrencyUtil.getInCurrencyRateByOrg(csettleorgid, BFPubTools.getString_TrimAsNull(o), ccurrencyorgid, dbilldate); |             // UFDouble exchangerate = SOCurrencyUtil.getInCurrencyRateByOrg(csettleorgid, BFPubTools.getString_TrimAsNull(o), ccurrencyorgid, dbilldate); | ||||||
|             for (SaleOrderBVO bvo : bvos) { |             for (SaleOrderBVO bvo : bvos) { | ||||||
|                 bvo.setCcurrencyid(BFPubTools.getString_TrimAsNull(o1)); |                 bvo.setCcurrencyid(BFPubTools.getString_TrimAsNull(o1)); | ||||||
|                 if (!BFPubTools.getString_TrimAsNull(o).equals(ccurrencyorgid)) { |                 if (!BFPubTools.getString_TrimAsNull(o).equals(ccurrencyorgid)) { | ||||||
|  | @ -84,7 +86,9 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|                 } else { |                 } else { | ||||||
|                     // bvo.setNexchangerate(UFDouble.ONE_DBL); |                     // bvo.setNexchangerate(UFDouble.ONE_DBL); | ||||||
|                 } |                 } | ||||||
| 
 |                 // 折本汇率判空及保留小数位数 | ||||||
|  |                 UFDouble exchangerate1 = getUFDouble_NullAsOne(bvo.getNexchangerate()).setScale(2, UFDouble.ROUND_HALF_UP); | ||||||
|  |                 bvo.setNexchangerate(exchangerate1); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| //		bvo.setNexchangerate(rateReturnObject.getRate()); | //		bvo.setNexchangerate(rateReturnObject.getRate()); | ||||||
|  | @ -293,16 +297,28 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         for (SaleOrderVO vo : combinBillVOs) { |         for (SaleOrderVO vo : combinBillVOs) { | ||||||
|  |             SaleOrderHVO hvo = vo.getParentVO(); | ||||||
|  |             SaleOrderHVO originHvo = null; | ||||||
|  |             for (SaleOrderVO originVo : originVos) { | ||||||
|  |                 if (hvo.getCsaleorderid().equals(originVo.getParentVO().getCsaleorderid())) { | ||||||
|  |                     originHvo = originVo.getParentVO(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             String new_ctrantypeid = hvo.getCtrantypeid(); | ||||||
|  |             boolean isChangedTranType = false;// 订单类型不修改 | ||||||
|  |             if (originHvo != null && new_ctrantypeid != null && !new_ctrantypeid.equals(originHvo.getCtrantypeid())) { | ||||||
|  |                 isChangedTranType = true; | ||||||
|  |             } | ||||||
|             SaleOrderBVO[] bvos = vo.getChildrenVO(); |             SaleOrderBVO[] bvos = vo.getChildrenVO(); | ||||||
|             // 判断是否存在新增的子表 |             // 判断是否存在新增的子表 | ||||||
|             boolean hasNewStatus = Arrays.stream(bvos) |             boolean hasNewStatus = Arrays.stream(bvos) | ||||||
|                     .anyMatch(bvo -> bvo.getStatus() == VOStatus.NEW); |                     .anyMatch(bvo -> bvo.getStatus() == VOStatus.NEW); | ||||||
|             // 新增子表的情况下不校验是否存在下游 |             // 新增子表或改订单类型的情况下不校验是否存在下游 | ||||||
|             if (!hasNewStatus) { |             if (!hasNewStatus && !isChangedTranType) { | ||||||
|                 String countSql = "SELECT count(1) FROM so_saleinvoice_b a" + |                 String countSql = "SELECT count(1) FROM so_saleinvoice_b a" + | ||||||
|                         " LEFT JOIN so_saleinvoice b ON a.csaleinvoiceid = b.csaleinvoiceid" + |                         " LEFT JOIN so_saleinvoice b ON a.csaleinvoiceid = b.csaleinvoiceid" + | ||||||
|                         " WHERE b.fopposeflag = 0 AND nvl(b.dr, 0) = 0 and csrcid = '[csrcid]'  "; |                         " WHERE b.fopposeflag = 0 AND nvl(b.dr, 0) = 0 and csrcid = '[csrcid]'  "; | ||||||
|                 countSql = countSql.replace("[csrcid]", vo.getParentVO().getCsaleorderid()); |                 countSql = countSql.replace("[csrcid]", hvo.getCsaleorderid()); | ||||||
|                 Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); |                 Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); | ||||||
|                 if (num > 0) { |                 if (num > 0) { | ||||||
|                     // fopposeflag 对冲标记 0=正常 1=已被对冲 2=对冲生成 |                     // fopposeflag 对冲标记 0=正常 1=已被对冲 2=对冲生成 | ||||||
|  | @ -344,7 +360,14 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|             String csaleorderid = orderHVO.getCsaleorderid(); |             String csaleorderid = orderHVO.getCsaleorderid(); | ||||||
|             String cdeptvid = orderHVO.getCdeptvid(); |             String cdeptvid = orderHVO.getCdeptvid(); | ||||||
|             String cemployeeid = orderHVO.getCemployeeid(); |             String cemployeeid = orderHVO.getCemployeeid(); | ||||||
|  |             // 开票客户 | ||||||
|             String cinvoicecustid = orderHVO.getCinvoicecustid(); |             String cinvoicecustid = orderHVO.getCinvoicecustid(); | ||||||
|  |             // 客户 | ||||||
|  |             String ccustomerid = orderHVO.getCcustomerid(); | ||||||
|  |             // 订单类型 | ||||||
|  |             // String ctrantypeid = orderHVO.getAttributeValue("ctrantypeid") + ""; | ||||||
|  |             String vtrantypecode = orderHVO.getVtrantypecode(); | ||||||
|  |             NCCForUAPLogger.debug("setOtherId-ccustomerid:" + ccustomerid + ",vtrantypecode:" + vtrantypecode); | ||||||
|             try { |             try { | ||||||
|                 String sql = ""; |                 String sql = ""; | ||||||
|                 // 部门 |                 // 部门 | ||||||
|  | @ -377,10 +400,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|                 } |                 } | ||||||
|                 // 开票客户 |                 // 开票客户 | ||||||
|                 if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { |                 if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { | ||||||
|                     sql = " select pk_customer from bd_customer where code = '[code]' "; |                     sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; | ||||||
|                     sql = sql.replace("[code]", cinvoicecustid); |                     sql = sql.replace("[code]", cinvoicecustid); | ||||||
|                     Object invCustObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); |                     Object invCustObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); | ||||||
|                     NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-invCustObj:" + invCustObj); |                     NCCForUAPLogger.debug("setOtherId-invCustObj:" + invCustObj); | ||||||
|                     if (invCustObj != null) { |                     if (invCustObj != null) { | ||||||
|                         String id = BFPubTools.getString_TrimAsNull(invCustObj); |                         String id = BFPubTools.getString_TrimAsNull(invCustObj); | ||||||
|                         if (!id.isEmpty()) { |                         if (!id.isEmpty()) { | ||||||
|  | @ -388,6 +411,28 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |                 // 客户 | ||||||
|  |                 if (ccustomerid != null && !ccustomerid.isEmpty()) { | ||||||
|  |                     sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; | ||||||
|  |                     sql = sql.replace("[code]", ccustomerid); | ||||||
|  |                     Object custObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); | ||||||
|  |                     NCCForUAPLogger.debug("setOtherId-custObj:" + custObj); | ||||||
|  |                     if (custObj != null) { | ||||||
|  |                         String id = BFPubTools.getString_TrimAsNull(custObj); | ||||||
|  |                         if (!id.isEmpty()) { | ||||||
|  |                             orderHVO.setCcustomerid(id); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 // 交易类型 | ||||||
|  |                 if (vtrantypecode != null && !vtrantypecode.isEmpty()) { | ||||||
|  |                     BilltypeServiceImpl billtypeService = new BilltypeServiceImpl(); | ||||||
|  |                     BilltypeVO billtype = billtypeService.getBilltype(vtrantypecode); | ||||||
|  |                     if (billtype != null && billtype.getPk_billtypeid() != null) { | ||||||
|  |                         NCCForUAPLogger.debug("setOtherId-pk_billtypeid:" + billtype.getPk_billtypeid()); | ||||||
|  |                         orderHVO.setCtrantypeid(billtype.getPk_billtypeid()); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } catch (Exception e) { |             } catch (Exception e) { | ||||||
|                 NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-exp:" + e.getMessage()); |                 NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-exp:" + e.getMessage()); | ||||||
|                 throw new RuntimeException(e); |                 throw new RuntimeException(e); | ||||||
|  | @ -415,6 +460,20 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|         if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { |         if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { | ||||||
|             targetHVO.setCinvoicecustid(cinvoicecustid); |             targetHVO.setCinvoicecustid(cinvoicecustid); | ||||||
|         } |         } | ||||||
|  |         String ccustomerid = sourceHVO.getCcustomerid(); | ||||||
|  |         if (ccustomerid != null && !ccustomerid.isEmpty()) { | ||||||
|  |             targetHVO.setCcustomerid(ccustomerid); | ||||||
|  |         } | ||||||
|  |         // 订单类型id | ||||||
|  |         String ctrantypeid = sourceHVO.getCtrantypeid(); | ||||||
|  |         if (ctrantypeid != null && !ctrantypeid.isEmpty()) { | ||||||
|  |             targetHVO.setCtrantypeid(ctrantypeid); | ||||||
|  |         } | ||||||
|  |         // 订单类型编码 | ||||||
|  |         String vtrantypecode = sourceHVO.getVtrantypecode(); | ||||||
|  |         if (vtrantypecode != null && !vtrantypecode.isEmpty()) { | ||||||
|  |             targetHVO.setVtrantypecode(vtrantypecode); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         // 更新 SaleOrderBVO 字段 |         // 更新 SaleOrderBVO 字段 | ||||||
|         SaleOrderBVO[] targetBVOs = target.getChildrenVO(); |         SaleOrderBVO[] targetBVOs = target.getChildrenVO(); | ||||||
|  | @ -614,8 +673,11 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { | ||||||
|                         newBvo.setStatus(VOStatus.NEW); |                         newBvo.setStatus(VOStatus.NEW); | ||||||
|                         newBvo.setAttributeValue("pk_group", pk_group); |                         newBvo.setAttributeValue("pk_group", pk_group); | ||||||
|                         String cprojectid = bodydata.get("cprojectid") + ""; |                         String cprojectid = bodydata.get("cprojectid") + ""; | ||||||
|                         if (oneBvo != null) { |                         if (oneBvo != null && oneBvo.getCprojectid() != null && !"".equals(oneBvo.getCprojectid())) { | ||||||
|                             cprojectid = oneBvo.getCprojectid(); |                             cprojectid = oneBvo.getCprojectid(); | ||||||
|  |                         } else { | ||||||
|  |                             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); |                         newBvo.setAttributeValue("cprojectid", cprojectid); | ||||||
|                         // newBvo.setAttributeValue("ctrafficorgvid", pkOrg); |                         // newBvo.setAttributeValue("ctrafficorgvid", pkOrg); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue