|  | @@ -0,0 +1,123 @@
 | 
	
		
			
				|  |  | +package nc.bs.bd.bom.bom0202.pfxx.plugin;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import nc.bs.framework.common.InvocationInfoProxy;
 | 
	
		
			
				|  |  | +import nc.bs.framework.common.NCLocator;
 | 
	
		
			
				|  |  | +import nc.bs.pfxx.ISwapContext;
 | 
	
		
			
				|  |  | +import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
 | 
	
		
			
				|  |  | +import nc.itf.uap.pf.IPFBusiAction;
 | 
	
		
			
				|  |  | +import nc.vo.bd.bom.bom0202.entity.AggBomVO;
 | 
	
		
			
				|  |  | +import nc.vo.bd.bom.bom0202.entity.BomUseOrgVO;
 | 
	
		
			
				|  |  | +import nc.vo.bd.bom.bom0202.entity.BomVO;
 | 
	
		
			
				|  |  | +import nc.vo.pfxx.auxiliary.AggxsysregisterVO;
 | 
	
		
			
				|  |  | +import nc.vo.pfxx.util.PfxxPluginUtils;
 | 
	
		
			
				|  |  | +import nc.vo.pub.AggregatedValueObject;
 | 
	
		
			
				|  |  | +import nc.vo.pub.BusinessException;
 | 
	
		
			
				|  |  | +import nc.vo.pub.CircularlyAccessibleValueObject;
 | 
	
		
			
				|  |  | +import nc.vo.pub.VOStatus;
 | 
	
		
			
				|  |  | +import nc.vo.pubapp.pattern.exception.ExceptionUtils;
 | 
	
		
			
				|  |  | +import nc.vo.pubapp.pattern.pub.PubAppTool;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * <b> 在此处简要描述此类的功能 </b>
 | 
	
		
			
				|  |  | + * <p>
 | 
	
		
			
				|  |  | + * 在此处添加此类的描述信息
 | 
	
		
			
				|  |  | + * </p>
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @author ufsoft
 | 
	
		
			
				|  |  | + * @version Your Project V60
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +public class MMbdBomPfxxPlugin extends nc.bs.pfxx.plugin.AbstractPfxxPlugin {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private IBomBillMaintainService service = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private IBomBillMaintainService getiBomBillMaintainService() {
 | 
	
		
			
				|  |  | +        if (this.service == null) {
 | 
	
		
			
				|  |  | +            this.service = NCLocator.getInstance().lookup(IBomBillMaintainService.class);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return this.service;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 将由XML转换过来的VO导入NC系统。业务插件实现此方法即可。<br>
 | 
	
		
			
				|  |  | +     * 请注意,业务方法的校验一定要充分
 | 
	
		
			
				|  |  | +     * 
 | 
	
		
			
				|  |  | +     * @param vo
 | 
	
		
			
				|  |  | +     *            转换后的vo数据,在NC系统中可能为ValueObject,SuperVO,AggregatedValueObject,IExAggVO等。
 | 
	
		
			
				|  |  | +     * @param swapContext
 | 
	
		
			
				|  |  | +     *            各种交换参数,组织,接受方,发送方,帐套等等
 | 
	
		
			
				|  |  | +     * @param aggxsysvo
 | 
	
		
			
				|  |  | +     *            辅助信息vo
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     * @throws BusinessException
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    protected Object processBill(Object vo, ISwapContext swapContext, AggxsysregisterVO aggxsysvo)
 | 
	
		
			
				|  |  | +            throws BusinessException {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 1.得到转换后的VO数据,取决于向导第一步注册的VO信息
 | 
	
		
			
				|  |  | +        AggregatedValueObject resvo = (AggregatedValueObject) vo;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 2.查询此单据是否已经被导入过,有两个方法,具体使用哪一个请参考方法说明javadoc
 | 
	
		
			
				|  |  | +        String vopk = PfxxPluginUtils.queryBillPKBeforeSaveOrUpdate(swapContext.getBilltype(), swapContext.getDocID());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 3. 如果单据设置有辅助信息,aggxsysvo为用户配置的具体辅助信息
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 4.如果此单据没有导入过,那么准备保存新单据,保存单据前请进行必要的数据检查,并给出明确的业务异常...
 | 
	
		
			
				|  |  | +        AggregatedValueObject returnVO = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 单据数据检查逻辑
 | 
	
		
			
				|  |  | +        // this.checkBill(resvo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (PubAppTool.isNull(vopk)) {
 | 
	
		
			
				|  |  | +            resvo.getParentVO().setStatus(VOStatus.NEW);
 | 
	
		
			
				|  |  | +            for (CircularlyAccessibleValueObject bvo : resvo.getChildrenVO()) {
 | 
	
		
			
				|  |  | +                bvo.setStatus(VOStatus.NEW);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +    		try {
 | 
	
		
			
				|  |  | +    			// 线程设置业务日期
 | 
	
		
			
				|  |  | +    			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +    			Object dateTimeString  = resvo.getParentVO().getAttributeValue("tmaketime");
 | 
	
		
			
				|  |  | +    			if(dateTimeString != null) {
 | 
	
		
			
				|  |  | +    				Date date = format.parse(dateTimeString.toString());
 | 
	
		
			
				|  |  | +    				long timestamp = date.getTime();
 | 
	
		
			
				|  |  | +    				InvocationInfoProxy.getInstance().setBizDateTime(timestamp);
 | 
	
		
			
				|  |  | +    			}
 | 
	
		
			
				|  |  | +    		} catch (Exception e) {
 | 
	
		
			
				|  |  | +    			ExceptionUtils.wrappException(e);
 | 
	
		
			
				|  |  | +    		}
 | 
	
		
			
				|  |  | +            AggBomVO  aggBomVO = (AggBomVO) resvo;
 | 
	
		
			
				|  |  | +            BomVO bomVO = (BomVO) resvo.getParentVO();
 | 
	
		
			
				|  |  | +            BomUseOrgVO bomUseOrgVO = new BomUseOrgVO();
 | 
	
		
			
				|  |  | +            bomUseOrgVO.setPk_useorg(bomVO.getPk_org());
 | 
	
		
			
				|  |  | +            aggBomVO.setChildren(BomUseOrgVO.class, new BomUseOrgVO[] {bomUseOrgVO});
 | 
	
		
			
				|  |  | +            returnVO = this.getiBomBillMaintainService().insertBom(new AggBomVO[] {
 | 
	
		
			
				|  |  | +                (AggBomVO) resvo
 | 
	
		
			
				|  |  | +            })[0];
 | 
	
		
			
				|  |  | +            NCLocator.getInstance().lookup(IPFBusiAction.class) .processBatch("APPROVE", "19B1",new AggBomVO[] {(AggBomVO) returnVO}, null, null, null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            // 5.如果此单据已经导入过,请调用PfxxPluginUtils.checkBillCanBeUpdate(UfinterfaceVO
 | 
	
		
			
				|  |  | +            // swapContext)检查单据是否允许更新
 | 
	
		
			
				|  |  | +            // 如果不允许更新,此方法会抛出业务异常
 | 
	
		
			
				|  |  | +            // PfxxPluginUtils.checkBillCanBeUpdate(swapContext);
 | 
	
		
			
				|  |  | +            returnVO = this.getiBomBillMaintainService().updateBom(new AggBomVO[] {
 | 
	
		
			
				|  |  | +                (AggBomVO) resvo
 | 
	
		
			
				|  |  | +            })[0];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        vopk = returnVO.getParentVO().getPrimaryKey();
 | 
	
		
			
				|  |  | +        // 6.如果希望单据将来可以更新,请调用下列接口插入文档流水号与生成PK的对照关系
 | 
	
		
			
				|  |  | +        PfxxPluginUtils.addDocIDVsPKContrast(swapContext.getBilltype(), swapContext.getDocID(), vopk);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 7.准备返回值,此函数的返回值,最终会以字符串的形式返回给外系统,
 | 
	
		
			
				|  |  | +        // 对于普通单据可以返回NC系统生成的PK值,对于凭证可能返回凭证号,具体视单据而定
 | 
	
		
			
				|  |  | +        // 对于查询插件要求返回org.w3c.dom.Node[]数组 或者org.w3c.dom.Node
 | 
	
		
			
				|  |  | +        return vopk;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |