package nc.impl.wgpt.process;

import nc.bs.pu.wgpt.process.CloseOrderProcess;
import nc.bs.pu.wgpt.process.QueryInventoryByConditionProcess;
import nc.bs.pu.wgpt.process.QueryProjectInfoProcess;
import nc.bs.pu.wgpt.process.WriteInvoiceInfoProcess;
import nc.bs.pu.wgpt.process.WriteOrderInfoProcess;
import nc.bs.pu.wgpt.process.WritePurchaseinInfoForNC;
import nc.bs.pu.wgpt.process.WritePurchaseinInfoProcess;
import nc.bs.uap.wgpt.process.WritePaybillRedInfoProcess;
import nc.itf.wgpt.process.IWuYeWgptBusiService;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.data.ValueUtils;
import ncc.pub.wywgpt.utils.WyWGPTUtils;
import uap.json.JSONObject;
/**
 * @Description:针对外部接口逻辑处理 
 * 
 * @author 谢文如 【碧桂园-物业板块-网购平台接口】
 * @date 2019-3-6
 * @version with NC V6.3
 */
public class WuYeWgptBusiImpl implements IWuYeWgptBusiService {

	@Override
	public String writeOrderInfo(JSONObject jsonobj) throws BusinessException {
		WriteOrderInfoProcess process = new WriteOrderInfoProcess();
		return process.writeOrderInfo(jsonobj);
	}

	@Override
	public String closeOrder(JSONObject jsonobj) throws BusinessException {
		CloseOrderProcess process = new CloseOrderProcess();
		return process.closeOrder(jsonobj);
	}

	@Override
	public String writeInvoiceInfo(JSONObject jsonobj) throws BusinessException {
		WriteInvoiceInfoProcess process = new WriteInvoiceInfoProcess();
		return process.writeInvoiceInfo(jsonobj);
	}
	
	/**
	 *【网购平台->NC】新加的方法，采购平台查询库存量
	 * @author 符耀铭
	 * @time 2019-4-29
	 */
	@Override
	public String queryInventoryByCondition(JSONObject jsonobj)
			throws BusinessException {
		QueryInventoryByConditionProcess queryInventoryProcess=new QueryInventoryByConditionProcess();
		return queryInventoryProcess.queryInventoryByCondition(jsonobj);
	}

	/**
	 * 【网购平台->NC】新加方法，采购平台传递库存采购入库单到NC
	 * @author 符耀铭
	 * @time 2019-6-12
	 */
	@Override
	public String writePurchaseinInfo(JSONObject jsonobj)
			throws BusinessException {
		WritePurchaseinInfoProcess process=new WritePurchaseinInfoProcess();
		return process.WritePurchasein(jsonobj);
	}

	/**
	 *【网购平台->NC】新加方法，创建新的事物保存和审批单据
	 * @author 符耀铭
	 * @time 2019-6-12
	 */
	@Override
	public void generateMaterialOut_RequiresNew(AggregatedValueObject aggregatedValueObject)
			throws BusinessException {
//		String[] bilnos = new String[aggregatedValueObject.getChildrenVO().length];
//		String[] pks = new String[aggregatedValueObject.getChildrenVO().length];
//		for(int i=0; i<aggregatedValueObject.getChildrenVO().length; i++) {
//			bilnos[i] = aggregatedValueObject.getChildrenVO()[i].getAttributeValue("pk_batchcode").toString();
//			aggregatedValueObject.getChildrenVO()[i].setAttributeValue("pk_batchcode", "");
//			pks[i] = aggregatedValueObject.getChildrenVO()[i].getAttributeValue("vbatchcode").toString();
//		}
		Object[] object = (Object[]) WyWGPTUtils.getIPFBusiAction().processAction("WRITE", ValueUtils.getString(aggregatedValueObject.getParentVO().getAttributeValue("vtrantypecode")), null, aggregatedValueObject, null, null);
		WyWGPTUtils.getIPFBusiAction().processAction("SIGN", ValueUtils.getString(aggregatedValueObject.getParentVO().getAttributeValue("vtrantypecode")), null, (AggregatedValueObject) object[0], null, null);
	}

	@Override
	public String queryProjectInfo(JSONObject jsonobj) throws BusinessException {
		QueryProjectInfoProcess process=new QueryProjectInfoProcess();
		return process.queryProject(jsonobj);
	}

	@Override
	public String writePaybillRedInfo(JSONObject jsonobj) throws BusinessException {
		WritePaybillRedInfoProcess process=new WritePaybillRedInfoProcess();
		return process.writePaybillRed(jsonobj);
	}

	public String writePurchase(JSONObject jsonobj) throws BusinessException {
		// TODO Auto-generated method stub
		WritePurchaseinInfoForNC process=new WritePurchaseinInfoForNC();
		return process.WritePurchasein(jsonobj);
	}

}
