采购订单审批,弃审后推送第三方
This commit is contained in:
		
							parent
							
								
									ef7078fc2b
								
							
						
					
					
						commit
						7342b958d2
					
				|  | @ -0,0 +1,130 @@ | |||
| package nc.impl.pu.m21.action.rule.def; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| 
 | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| 
 | ||||
| import nc.bs.dao.DAOException; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.trade.business.HYSuperDMO; | ||||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.pubitf.ic.egap.INCCForEGAPIntf; | ||||
| import nc.vo.bd.material.MaterialVO; | ||||
| import nc.vo.bd.material.measdoc.MeasdocVO; | ||||
| import nc.vo.bd.psn.PsndocVO; | ||||
| import nc.vo.bd.supplier.SupplierVO; | ||||
| import nc.vo.org.PurchaseOrgVO; | ||||
| import nc.vo.pu.m21.entity.OrderItemVO; | ||||
| import nc.vo.pu.m21.entity.OrderVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.vorg.PurchaseOrgVersionVO; | ||||
| import nccloud.commons.lang.ArrayUtils; | ||||
| 
 | ||||
| public class AfterApprovePushRule implements IRule<OrderVO> { | ||||
| 	 | ||||
| 	 | ||||
| 	public  INCCForEGAPIntf iNCCForEGAPIntf =null; | ||||
| 	 | ||||
| 	public INCCForEGAPIntf getiNCCForEGAPIntf() { | ||||
| 		if(iNCCForEGAPIntf == null) { | ||||
| 			iNCCForEGAPIntf = (INCCForEGAPIntf)NCLocator.getInstance().lookup(INCCForEGAPIntf.class.getName()); | ||||
| 		} | ||||
| 		return iNCCForEGAPIntf; | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void process(OrderVO[] vos) { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		if (ArrayUtils.isEmpty(vos)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		HYSuperDMO dmo = new HYSuperDMO(); | ||||
| 		ObjectMapper objectMapper = new ObjectMapper();   | ||||
| 		String token=""; | ||||
| 		for (int i = 0; i < vos.length; i++) { | ||||
| 			if(vos[i].getHVO().getForderstatus().intValue()==3) { | ||||
| 				HashMap<String, Object> h_bill = new HashMap<String, Object>(); | ||||
| 				h_bill.put("erpid", vos[i].getHVO().getPrimaryKey());//NCC主表ID | ||||
| 				 | ||||
| 				try { | ||||
| 					PurchaseOrgVO purchaseOrgVO = (PurchaseOrgVO) dmo.queryByPrimaryKey(PurchaseOrgVO.class, vos[i].getHVO().getPk_org()); | ||||
| 					h_bill.put("ccompany", purchaseOrgVO.getName());//公司名称 | ||||
| 					h_bill.put("cordercode", vos[i].getHVO().getVbillcode());//采购订单号 | ||||
| 					h_bill.put("cbilltype","月计划");//月计划\增补计划 | ||||
| 					 | ||||
| 					h_bill.put("corderlevel",vos[i].getHVO().getVdef1()==null?"普通":vos[i].getHVO().getVdef1());//普通\紧急 | ||||
| 					 | ||||
| 					h_bill.put("istop",vos[i].getHVO().getBfinalclose().booleanValue()?"1":"0"); | ||||
| 					h_bill.put("dstopdate",vos[i].getHVO().getDclosedate()==null?"":vos[i].getHVO().getDclosedate().toStdString());//停用日期 | ||||
| 					h_bill.put("dorderdate",vos[i].getHVO().getDbilldate().toStdString());//订单日期 | ||||
| 					if(vos[i].getHVO().getCemployeeid()!=null) { | ||||
| 						PsndocVO psndocVO =(PsndocVO) dmo.queryByPrimaryKey(PsndocVO.class, vos[i].getHVO().getCemployeeid()); | ||||
| 						 | ||||
| 						h_bill.put("copname",psndocVO.getName());//业务员姓名 | ||||
| 					}else { | ||||
| 						h_bill.put("copname","");//业务员姓名 | ||||
| 					} | ||||
| 					h_bill.put("cmark",vos[i].getHVO().getVmemo()==null?"":vos[i].getHVO().getVmemo());//备注 | ||||
| 					 | ||||
| 					SupplierVO supplierVO =(SupplierVO) dmo.queryByPrimaryKey(SupplierVO.class, vos[i].getHVO().getPk_supplier()); | ||||
| 					 | ||||
| 					h_bill.put("cvencode",supplierVO.getCode());//供应商编码 | ||||
| 					h_bill.put("cvenname",supplierVO.getName());//供应商名称 | ||||
| 					 | ||||
| 					ArrayList<Object> l_items = new ArrayList<Object>(); | ||||
| 					 | ||||
| 					 | ||||
| 					OrderItemVO[] itemVOs= vos[i].getBVO(); | ||||
| 					for (int j = 0; j < itemVOs.length; j++) { | ||||
| 						HashMap<String, Object> b_item = new HashMap<String, Object>(); | ||||
| 						b_item.put("cinvcode",itemVOs[j].getPk_material()); | ||||
| 						MaterialVO materialVO =(MaterialVO)dmo.queryByPrimaryKey(MaterialVO.class,itemVOs[j].getPk_material()); | ||||
| 						b_item.put("cinvenginnerno",materialVO.getCode()); | ||||
| 						b_item.put("cinvname",materialVO.getName()); | ||||
| 						b_item.put("cinvstd",materialVO.getMaterialspec()==null?"":materialVO.getMaterialspec()); | ||||
| 						MeasdocVO measdocVO = (MeasdocVO)dmo.queryByPrimaryKey(MeasdocVO.class, itemVOs[j].getCunitid()); | ||||
| 						b_item.put("cunit",measdocVO.getName()); | ||||
| 						b_item.put("isnullin",itemVOs[j].getVbdef1()==null?"0":"1"); | ||||
| 						b_item.put("iqty",itemVOs[j].getNastnum().toBigDecimal()); | ||||
| 						b_item.put("daskdate",itemVOs[j].getDplanarrvdate().toStdString()); | ||||
| 						b_item.put("cnote",itemVOs[j].getVbmemo()==null?"":itemVOs[j].getVbmemo()); | ||||
| 						b_item.put("idetstop",itemVOs[j].getFisactive().intValue()); | ||||
| 						b_item.put("ddetstopdate",itemVOs[j].getDcorrectdate()==null?"":itemVOs[j].getDcorrectdate().toStdString()); | ||||
| 						b_item.put("cerpsubid",itemVOs[j].getPrimaryKey()); | ||||
| 						l_items.add(b_item); | ||||
| 					} | ||||
| 					HashMap<String, Object> h_podata = new HashMap<String, Object>(); | ||||
| 					h_podata.put("bill", h_bill); | ||||
| 					h_podata.put("billdetail", l_items); | ||||
| 					 | ||||
| 					HashMap<String, Object> bill = new HashMap<String, Object>(); | ||||
| 					bill.put("token", token); | ||||
| 					bill.put("podata", h_podata); | ||||
| 					String add_json = objectMapper.writeValueAsString(bill); | ||||
| 					nc.bs.logging.Logger.error("采购订单 审批后接口报文:"+add_json); | ||||
| 					getiNCCForEGAPIntf().sendEGAP(add_json, "HFNCCINF030", vos[i].getHVO().getPrimaryKey()); | ||||
| //					h_podata.put("bill",h_bill); | ||||
| //					h_podata.put("bill",h_bill); | ||||
| 				} catch (DAOException e) { | ||||
| 					// TODO Auto-generated catch block | ||||
| 					e.printStackTrace(); | ||||
| 				} catch (JsonProcessingException e) { | ||||
| 					// TODO Auto-generated catch block | ||||
| 					e.printStackTrace(); | ||||
| 				} catch (BusinessException e) { | ||||
| 					// TODO Auto-generated catch block | ||||
| //					e.printStackTrace(); | ||||
| 					ExceptionUtils.wrappException(e); | ||||
| 				} | ||||
| 				 | ||||
| 				 | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,64 @@ | |||
| package nc.impl.pu.m21.action.rule.def; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| 
 | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| 
 | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.trade.business.HYSuperDMO; | ||||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.pubitf.ic.egap.INCCForEGAPIntf; | ||||
| import nc.vo.pu.m21.entity.OrderVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nccloud.commons.lang.ArrayUtils; | ||||
| 
 | ||||
| public class AfterUnApprovePushRule implements IRule<OrderVO> { | ||||
| 	 | ||||
| 	 | ||||
| public  INCCForEGAPIntf iNCCForEGAPIntf =null; | ||||
| 	 | ||||
| 	public INCCForEGAPIntf getiNCCForEGAPIntf() { | ||||
| 		if(iNCCForEGAPIntf == null) { | ||||
| 			iNCCForEGAPIntf = (INCCForEGAPIntf)NCLocator.getInstance().lookup(INCCForEGAPIntf.class.getName()); | ||||
| 		} | ||||
| 		return iNCCForEGAPIntf; | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void process(OrderVO[] vos) { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		if (ArrayUtils.isEmpty(vos)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		HYSuperDMO dmo = new HYSuperDMO(); | ||||
| 		ObjectMapper objectMapper = new ObjectMapper();   | ||||
| 		String token=""; | ||||
| 		for (int i = 0; i < vos.length; i++) { | ||||
| 			if(vos[i].getHVO().getForderstatus().intValue()!=3) { | ||||
| 				HashMap<String, Object> h_bill = new HashMap<String, Object>(); | ||||
| 				h_bill.put("token", token); | ||||
| 				h_bill.put("ERPID", vos[i].getHVO().getVbillcode()); | ||||
| 				 | ||||
| 				try { | ||||
| 					String add_json = objectMapper.writeValueAsString(h_bill); | ||||
| 					nc.bs.logging.Logger.error("采购订单 弃审后口报文:"+add_json); | ||||
| 					 | ||||
| 					getiNCCForEGAPIntf().sendEGAP(add_json,"HFNCCINF031",vos[i].getHVO().getPrimaryKey()); | ||||
| 					 | ||||
| 				} catch (JsonProcessingException e) { | ||||
| 					// TODO Auto-generated catch block | ||||
| 					e.printStackTrace(); | ||||
| 				} catch (BusinessException e) { | ||||
| 					// TODO Auto-generated catch block | ||||
| //					e.printStackTrace(); | ||||
| 					ExceptionUtils.wrappException(e); | ||||
| 				} | ||||
| 				 | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue