global with sharing class SBG204RestExecute {
    


    global class GeDatas {
        public NFMUtil.Monitoring Monitoring;
        public GeData[] GeData;
    }

    global class GeData {

        public String MaterialNo;         //物料号

        public String RegisterNo;         //注册证号
        public String RegisterNoClass_New; //注册证号经营范围编号(新)
        public String RegisterNoClass_Old; //注册证号经营范围编号(旧)

        public String ValidFrom;          //注册证号效期从
        public String ValidTo;            //注册证号效期至
        public String MedPrdClass;        //医疗器械分类

        public String Model;              //产品型号
        public String ProductName;        //产品名称(委托产品名称)
        public String PrdCompanyLicense;  //生产企业许可证号/备案凭证号
        public String PrdCompanyAddr;     //生产企业地址
        public String ClinicalCode;       //型号规格
        public String REG_Name;           // 注册人名称
        public String REG_ADD;            // 注册人住所



        public String AuthorizedCompany;  //委托方企业名称

        public String ApprovedDate;       //委托批准日期
        public String Z3PLAuthorized;    //是否3PL委托产品
        public String AuthorizedCompany_SH;
        public String ApprovedDate_SH;
        public String YXQX;

        public String Other1;
        public String Other2;
        public String Other3;

        public String MaterialGroup;      //物料组
        public String MaterialStatus;     //物料状态
        public String RegisterNoStatus;   //注册证号状态

        public String Unit;               //单位(基本单位)
        public String StroageCondition;   //储存条件
        public String TransCondition;     //运输条件
        public String Z3PLAuthorizedNo;   //3PL业务委托协议号
        public String PrdValidFrom;       //委托产品效期从
        public String PrdValidTo;         //委托产品效期至
        public String BusinessScope;      //经营范围

        public String MaterialStatusType;  // 状态 1:只更新物料状态


        public String APP_NAME_BJ;   //  北京首营审核人
        public String APP_DATE_BJ;   //  北京审核日期
        public String APP_RSLT_BJ;   //  北京首营审核结果
        public String APP_NAME_SH;   //  上海首营审核人
        public String APP_DATE_SH;   //  上海审核日期
        public String APP_RSLT_SH;   //  上海首营审核结果
        public String APP_NAME_GZ;   //  广州首营审核人
        public String APP_DATE_GZ;   //  广州审核日期
        public String APP_RSLT_GZ;   //  广州首营审核结果
        public String APP_NAME_OSH;   //  OSH首营审核人
        public String APP_DATE_OSH;   //  OSH审核日期
        public String APP_RSLT_OSH;   //  OSH首营审核结果
        public String PROD_ADD;       // 生产地址
        public String STRU_COM;      // 结构及组成
        public String ADOPT_RANGE;    // 适用范围


    }

    global static void executefuture(String rowData_Id) {
        main(rowData_Id);
    }

    global static void main (String rowData_Id) {
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
        BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id = :rowData_Id];
        String logstr = rowData.MessageGroupNumber__c + ' start\n';
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = 'SBG204';
        iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
        iflog.Log__c = logstr;
        iflog.ErrorLog__c = '';
        insert iflog;
        String groupNumber = rowData.MessageGroupNumber__c;
        String rowDataStr = NFMUtil.getRowDataStr(rowData);
        List<GeData> GeDataList = (List<GeData>) JSON.deserialize(rowDataStr, List<GeData>.class);

        if (GeDataList == null || GeDataList.size() == 0) {
            return;
        }

        for (GeData data : GeDataList) {
        	if (String.isNotBlank(data.ValidFrom)) {
        		String validFrom = data.ValidFrom;
        		// validFrom = String.valueOf(Datetime.valueOf(validFrom));
        		List<String> validFromList = validFrom.split(' ')[0].split('/');//6/12/2017 12:00:00 AM 
        		data.ValidFrom = '' +validFromList[2] + validFromList[1] +validFromList[0];
        		// System.debug('validFrom--->'+validFrom);
        	}
        	if (String.isNotBlank(data.ValidTo)){
        		String validTo = data.ValidTo;
        		List<String> validFromList = validTo.split(' ')[0].split('/');//6/12/2017 12:00:00 AM 
        		data.ValidTo = '' +validFromList[2] + validFromList[1] +validFromList[0];
        	}
        	System.debug('data.ValidFrom--->'+data.ValidFrom);
        	System.debug('data.ValidTo--->'+data.ValidTo);

        }
        String rowDataStr1 = JSON.serialize(GeDataList);
        System.debug('rowDataStr1--->'+rowDataStr1);
    }


}