销售发票红冲接口代码
This commit is contained in:
		
							parent
							
								
									9033478c93
								
							
						
					
					
						commit
						99abe02779
					
				|  | @ -1,16 +1,19 @@ | |||
| package nccloud.api.so.saleinvoice.operator; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.framework.core.util.ObjectCreator; | ||||
| import nc.bs.logging.Logger; | ||||
| import nc.bs.trade.business.HYSuperDMO; | ||||
| import nc.itf.uap.IUAPQueryBS; | ||||
| import nc.jdbc.framework.processor.MapProcessor; | ||||
| import nc.pubitf.so.m32.api.ISaleinvoiceQueryAPI; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.lang.UFBoolean; | ||||
| import nc.vo.pub.lang.UFDate; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.pubapp.calculator.HslParseUtil; | ||||
| import nc.vo.pubapp.pattern.tool.performance.DeepCloneTool; | ||||
| import nc.vo.scmpub.res.billtype.SOBillType; | ||||
| import nc.vo.so.m32.entity.SaleInvoiceBVO; | ||||
|  | @ -23,6 +26,7 @@ import nccloud.api.baseapp.exchange.convert.IExchangeForService; | |||
| import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject; | ||||
| import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult; | ||||
| import nccloud.api.rest.utils.ResultMessageUtil; | ||||
| import nccloud.commons.lang.StringUtils; | ||||
| import nccloud.itf.sscivm.ivsale.impl.IVApplicationServiceImpl; | ||||
| import nccloud.pubitf.riart.pflow.CloudPFlowContext; | ||||
| import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService; | ||||
|  | @ -34,6 +38,7 @@ import javax.ws.rs.POST; | |||
| import javax.ws.rs.Path; | ||||
| import javax.ws.rs.Produces; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| /** | ||||
|  * 销售发票红冲接口 | ||||
|  | @ -113,8 +118,9 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|             context.setBillVos(new SaleInvoiceVO[]{saleInvoiceRedRushVO}); | ||||
|             context.setActionName("WRITE"); | ||||
|             SaleInvoiceVO[] returnSaveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context); | ||||
| //            SaleInvoiceVO[] returnSaveSaleInvoiceVO = (SaleInvoiceVO[])PfServiceScmUtil.processBatch("WRITE", SOBillType.Invoice.getCode(), new SaleInvoiceVO[] { saleInvoiceRedRushVO }, null, null); | ||||
|             Logger.error("=========================inv-save============== "); | ||||
|             if (returnSaveSaleInvoiceVOs != null && returnSaveSaleInvoiceVOs.length > 0) { | ||||
|                 Logger.error("inv-save = " + JSONArray.toJSONString(returnSaveSaleInvoiceVOs)); | ||||
|                 // 生成红冲发票成功后,执行销售发票审批动作 | ||||
|                 context.setBillType("32"); | ||||
|                 context.setBillVos(returnSaveSaleInvoiceVOs); | ||||
|  | @ -123,6 +129,8 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|                 if (returnApproveSaleInvoiceVOs == null || returnApproveSaleInvoiceVOs.length <= 0) { | ||||
|                     throw new BusinessException("生成销售发票审核失败"); | ||||
|                 } | ||||
|                 Logger.error("=========================inv-audit============== "); | ||||
|                 Logger.error("inv-audit = " + JSONArray.toJSONString(returnApproveSaleInvoiceVOs)); | ||||
|                 /** | ||||
|                  * 开票申请红冲逻辑: | ||||
|                  *  1.根据销售发票号查询下游开票申请 | ||||
|  | @ -138,13 +146,8 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|                 // 调用函数封装开票申请红冲VO | ||||
|                 IVApplicationAggVO iVApplicationAggVO = makeNewRedRushIVApplicationAggVO(iVApplicationHeadVO[0], iVApplicationBodyVOs, bject, returnApproveSaleInvoiceVOs); | ||||
|                 // 生成红冲的开票申请 | ||||
| //                context.setBillType("SSCIVA"); | ||||
| //                context.setBillVos( new IVApplicationAggVO[] { iVApplicationAggVO }); | ||||
| //                context.setActionName("SAVE"); | ||||
| //                IVApplicationAggVO[] returnSaveIVApplicationAggVO = (IVApplicationAggVO[] )flowService.exeScriptPFlow(context); | ||||
|                 IVApplicationServiceImpl serviceImpl = new IVApplicationServiceImpl(); | ||||
|                 IVApplicationAggVO returnSaveIVApplicationAggVO = serviceImpl.save(iVApplicationAggVO); | ||||
| //                Object returnIVApplicationAggVO = PfServiceScmUtil.processBatch("SAVE", "SSCIVA", new IVApplicationAggVO[] { iVApplicationAggVO }, null, null); | ||||
|                 if (returnSaveIVApplicationAggVO != null) { | ||||
|                     return ResultMessageUtil.toJSON(returnApproveSaleInvoiceVOs, "接口调用成功"); | ||||
|                 } else { | ||||
|  | @ -212,8 +215,21 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|                 // 赋值之后修改子实体红冲时字段 | ||||
|                 newInvBVO.setCsaleinvoicebid(null); // 发票子实体id | ||||
|                 newInvBVO.setDbilldate(dbilldate); // 开票日期 | ||||
|                 newInvBVO.setNastnum(new UFDouble(bipBvoJson.getString("nastnum"))); // ÊýÁ¿ | ||||
|                 newInvBVO.setNnum(new UFDouble(bipBvoJson.getString("nnum"))); // Ö÷ÊýÁ¿ | ||||
|                 String vchangerate = "1/1"; // 换算率 | ||||
|                 Map<String, Object> soMap = getSaleOrderInfo(bipBvoJson.getString("csrcbid")); | ||||
|                 if (soMap != null && StringUtils.isNotEmpty(soMap.getOrDefault("vchangerate", "") + "")) { | ||||
|                     vchangerate = soMap.get("vchangerate") + ""; // 销售订单的换算率 | ||||
|                 } | ||||
|                 newInvBVO.setVchangerate(vchangerate); // 换算率 | ||||
|                 UFDouble[] vchangerateNums = HslParseUtil.parseHsl(vchangerate); | ||||
|                 UFDouble vchangerateNum = UFDouble.ONE_DBL; | ||||
|                 if (null != vchangerateNums && vchangerateNums.length != 0) { | ||||
|                     vchangerateNum = vchangerateNums[0].div(vchangerateNums[1]).setScale(2, 4); | ||||
|                 } | ||||
|                 // BIP合同平台的数量对应BIP2312的主数量,BIP2312的 数量=主数量*换算关系 | ||||
|                 UFDouble nastnum = new UFDouble(bipBvoJson.getString("nastnum")); | ||||
|                 newInvBVO.setNastnum(nastnum.multiply(vchangerateNum).setScale(2, 4)); // 数量 | ||||
|                 newInvBVO.setNnum(nastnum); // 主数量 | ||||
|                 newInvBVO.setNtax(new UFDouble(bipBvoJson.getString("ntax"))); // 税额 | ||||
|                 newInvBVO.setNmny(new UFDouble(bipBvoJson.getString("nmny"))); // 本币无税金额 | ||||
|                 newInvBVO.setNtaxmny(new UFDouble(bipBvoJson.getString("ntaxmny"))); // 本币价税合计 | ||||
|  | @ -226,7 +242,6 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|                 newInvBVO.setNtotalcostnum(null); // 累计成本结算数量 | ||||
|                 newInvBVO.setNtotalincomemny(null); // 累计确认应收金额 | ||||
|                 newInvBVO.setNtotalincomenum(null); // 累计确认应收数量 | ||||
|                 newInvBVO.setVchangerate("1.00/1.00"); // »»ËãÂÊ | ||||
|                 newSaleInvoiceBVOs[i++] = newInvBVO; | ||||
|                 sumNum = sumNum.add(new UFDouble(bipBvoJson.getString("nnum"))); | ||||
|                 sumNtax = sumNtax.add(new UFDouble(bipBvoJson.getString("ntax"))); | ||||
|  | @ -366,4 +381,17 @@ public class BillSaveAction extends AbstractNCCRestResource { | |||
|         return NCLocator.getInstance().lookup(IUAPQueryBS.class); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     private static Map<String, Object> getSaleOrderInfo(String csaleorderbid) throws BusinessException { | ||||
|         IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); | ||||
|         String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," + | ||||
|                 " sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate," + | ||||
|                 " nvl(sb.vchangerate, '1/1') vchangerate, bdc.code currencycode" + | ||||
|                 " from so_saleorder_b sb" + | ||||
|                 " inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" + | ||||
|                 " left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" + | ||||
|                 " where sb.csaleorderbid='" + csaleorderbid + "' "; | ||||
|         return (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor()); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue