package ysr.com.teamcenter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class BPMTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		sendPStartNotificationToPLM();
//		sendOrderNoticeToPLM();
//		sendTravelOrderToPLM();
		SendDeliveryDateToPLM();
//		SendAccepComToPLM();
	}

	public static void SendAccepComToPLM(){
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
				"<Body>"+
					"<Order ItemID=\"000262\" object_name=\"验收委托单\">"+
						"<ysr8_Feedbacker>张国良</ysr8_Feedbacker>"+
						"<ysr8_FeedbackDate>2017-10-06 17:59:06</ysr8_FeedbackDate>"+//希望答复日期
						"<ysr8_HaveAnnex>有</ysr8_HaveAnnex>"+
						"<ysr8_VerifyResults>确认结果</ysr8_VerifyResults>"+
						"<ysr8_Reason2>原因</ysr8_Reason2>"+
						"<ysr8_RemainingMatters>遗留事项</ysr8_RemainingMatters>"+
						"<ysr8_CustomerAdvice>客户意见及建议</ysr8_CustomerAdvice>"+
						"<ysr8_BPMURL_YSWT>URL</ysr8_BPMURL_YSWT>"+
					"</Order>"+
				"</Body>";
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendAccepComToPLM(xml);
		System.out.println("rError="+rError);
	}
	
	public static void SendDeliveryDateToPLM(){
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendDeliveryDateToPLM("000108", "2017-10-06 17:59:06");
		System.out.println("rError="+rError);
	}
	public static void sendQuotationToPLM(){
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
				"<Body>"+
					"<Quotation ItemID=\"Q000001\" object_name=\"名称\">"+
						"<ysr8_OrderManufacturer>订货厂家</ysr8_OrderManufacturer>"+
						"<ysr8_CustomerName>最终用户</ysr8_CustomerName>"+
						"<ysr8_QuotationLevel>报价水平</ysr8_QuotationLevel>"+
						"<ysr8_ReceiveDate>19-Apr-2017 01:00:34</ysr8_ReceiveDate>"+//收到日期2017-05-06 08:59:06
						"<ysr8_RequestedDate>2017-10-06 17:59:06</ysr8_RequestedDate>"+//希望答复日期
						"<ysr8_Sales>销售担当</ysr8_Sales>"+
						"<ysr8_ProjectManager>项目经理</ysr8_ProjectManager>"+
						"<ysr8_ProjectLevel>报价等级</ysr8_ProjectLevel>"+
						"<ysr8_FinishedDate>报价完成时间</ysr8_FinishedDate>"+
						"<ysr8_Contact>联系人</ysr8_Contact>"+
						"<ysr8_ContactDept>所属部门</ysr8_ContactDept>"+
						"<ysr8_ContactPosition>职务</ysr8_ContactPosition>"+
						"<ysr8_ContactPhone>联系电话</ysr8_ContactPhone>"+
						"<ysr8_OfferAmount>报价金额</ysr8_OfferAmount>"+
						"<ysr8_BPMURL_BJWT>URL</ysr8_BPMURL_BJWT>"+
					"</Quotation>"+
				"</Body>";
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendQuotationToPLM(xml);
		System.out.println("rError="+rError);
	}
	
	public static void sendPStartNotificationToPLM(){
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
				"<Body>"+
					"<Notification ItemID=\"N000001\" object_name=\"名称\">"+
						"<ysr8_RequestDate>2017-05-06 08:59:06</ysr8_RequestDate>"+
						"<ysr8_ReleseDate>2017-10-06 17:59:06</ysr8_ReleseDate>"+
						"<ysr8_Revision>发行版本</ysr8_Revision>"+
						"<ysr8_ProjectCode>订货单编号</ysr8_ProjectCode>"+
						"<ysr8_ProjectCategory>类型</ysr8_ProjectCategory>"+
						"<ysr8_ContractAmount>10.2</ysr8_ContractAmount>"+
						"<ysr8_Cost>2</ysr8_Cost>"+
						"<ysr8_ProfitMargins>80</ysr8_ProfitMargins>"+
						"<ysr8_Sales>销售担当</ysr8_Sales>"+	
						"<ysr8_OrderManufacturer>订货客户</ysr8_OrderManufacturer>"+				
						"<ysr8_CustomerName>最终用户</ysr8_CustomerName>"+	
						"<ysr8_ProjectContent>项目内容</ysr8_ProjectContent>"+
						"<ysr8_PaymentMethod>预计合同支付方式</ysr8_PaymentMethod>"+
						"<ysr8_SigningDate>2017-11-06 17:59:06</ysr8_SigningDate>"+	
						"<ysr8_DeliveryDate>2018-10-06 17:59:06</ysr8_DeliveryDate>"+				
						"<ysr8_OtherContents>其他说明</ysr8_OtherContents>"+
						"<ysr8_BPMURL_QDTZ >URL</ysr8_BPMURL_QDTZ >"+
					"</Notification>"+
				"</Body>";
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendPStartNotificationToPLM(xml);
		System.out.println("rError="+rError);
	}
	
	public static void sendOrderNoticeToPLM(){
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
				"<Body>"+
					"<Order ItemID=\"OR000001\" object_name=\"名称\">"+
						"<ysr8_Type>类型</ysr8_Type>"+
						"<ysr8_RequestDate>2017-05-06 08:59:06</ysr8_RequestDate>"+
						"<ysr8_ReleseDate>2017-10-06 17:59:06</ysr8_ReleseDate>"+
						"<ysr8_Sales>营业担当</ysr8_Sales>"+
						"<ysr8_ProjectCode>报价单编号</ysr8_ProjectCode>"+
						"<ysr8_OrderManufacturer>合同买方</ysr8_OrderManufacturer>"+
						"<ysr8_CustomerName>最终用户</ysr8_CustomerName>"+
						"<ysr8_CustomerType>客户类别</ysr8_CustomerType>"+
						"<ysr8_Employers>出资国</ysr8_Employers>"+		
						"<ysr8_Industry>行业</ysr8_Industry>"+
						"<ysr8_ProductName>产品名称</ysr8_ProductName>"+
						"<ysr8_Use>用途</ysr8_Use>"+
						"<ysr8_DeliveryDate></ysr8_DeliveryDate>"+		
						"<ysr8_RobotNum>10</ysr8_RobotNum>"+
						"<ysr8_Receipt>收货公司名称</ysr8_Receipt>"+
						"<ysr8_ReceiptAddress>公司地址、邮编</ysr8_ReceiptAddress>"+
						"<ysr8_Receiver>联系人</ysr8_Receiver>"+
						"<ysr8_ReceiverPhone>电话</ysr8_ReceiverPhone>"+			
						"<ysr8_Remark>备注</ysr8_Remark>"+
						"<ysr8_BPMURL_DHTZ>URL</ysr8_BPMURL_DHTZ>"+
					"</Order>"+
				"</Body>";
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendOrderNoticeToPLM(xml);
		System.out.println("rError="+rError);
	}
	
	public static void sendTravelOrderToPLM(){
		String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"+
				"<Body>"+
					"<Notification ItemID=\"T000001\" object_name=\"名称\">"+
						"<ysr8_Principal>委托人</ysr8_Principal>"+
						"<ysr8_CommissionDate>2017-05-06 08:59:06</ysr8_CommissionDate>"+
						"<ysr8_TravelStartDate>2017-05-10 08:59:06</ysr8_TravelStartDate>"+
						"<ysr8_TravelEndDate>2017-06-06 08:59:06</ysr8_TravelEndDate>"+
						"<ysr8_CustomerName>客户名称</ysr8_CustomerName>"+
						"<ysr8_ProjectCode>项目号</ysr8_ProjectCode>"+
						"<ysr8_ReceiptAddress>客户地址</ysr8_ReceiptAddress>"+
						"<ysr8_Receiver>客户联系人</ysr8_Receiver>"+
						"<ysr8_ReceiverPhone>客户电话</ysr8_ReceiverPhone>"+
						"<ysr8_TravelContent>出差内容</ysr8_TravelContent>"+
						"<ysr8_TravelerNumber>22</ysr8_TravelerNumber>"+
						"<ysr8_TravelDays>30</ysr8_TravelDays>"+
						"<ysr8_EntrustedDept>受托部门</ysr8_EntrustedDept>"+
						"<ysr8_Travelers>出差人员</ysr8_Travelers>"+
						"<ysr8_Remark>备注</ysr8_Remark>"+
						"<ysr8_HaveAnnex>是否有附件</ysr8_HaveAnnex>"+		
						"<ysr8_BPMURL_CCWT>URL</ysr8_BPMURL_CCWT>"+
					"</Notification>"+
				"</Body>";
		YSRServerService ysrServer = new YSRServerService();
		String rError = ysrServer.getYSRServerPort().sendTravelOrderToPLM(xml);
		System.out.println("rError="+rError);
	}
	
	private void test(){
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss",Locale.ENGLISH);// HH:mm:ss 
		try {
			System.out.println(sdf.parse("19-Apr-2017 01:00:34"));
//			System.out.println(sdf.parse("1970-02-30 00:00:00").getTime());
			
			SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss",Locale.ENGLISH);
			String date = dateFormat.format(new Date());
			System.out.println("date="+date);
			
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
