111
沙世明
2022-11-22 928399eceec50e3d37ea08669a12789a9410a9d2
force-app/main/default/classes/NFM608Rest.cls
@@ -69,10 +69,10 @@
        }
        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';
        String logstr = rowData.Name + ' start\n';//MessageGroupNumber__c
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = LOG_TYPE;
        iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
        iflog.MessageGroupNumber__c = rowData.Name;//rowData.MessageGroupNumber__c;
        iflog.Log__c = logstr;
        iflog.ErrorLog__c = '';
        insert iflog;
@@ -83,7 +83,7 @@
        }
        Savepoint sp = Database.setSavepoint();
        try {
            rowData.retry_cnt__c = 0; //必加
            // 必填字段验证 Start
            String dataComplete = verify(ged);
            // 必填字段验证 End
@@ -114,6 +114,23 @@
                    logstr += '拜访区分 [ ' + ged.visitDistinction + ' ]无效,此条数据跳过不执行 \n';
                    return;
                }
                //日报审批通过之后,不能在创建报告一览
                if(null!=drc){
                   if(drc.Status__c=='承認'){
                      logstr += '日报状态 [' + drc.Status__c +' ],此条数据跳过不执行 \n';
                      return;
                   }
                }
                Datetime startdate1 = NFMUtil.parseStr2DateTime(ged.visitStartDate);
                Datetime enddate1 = NFMUtil.parseStr2DateTime(ged.visitEndDate);
                Long timeDif = enddate1.getTime() - startdate1.getTime();
                Integer ts = Integer.valueOf((enddate1.getTime() - startdate1.getTime()) / 1000 / 3600 /24);
                system.debug( startdate1.getTime()+'==='+enddate1.getTime()+'==='+startdate1+'==='+enddate1+'==='+ts);
                if(ts > 14){
                   logstr += '事件的持续时间不能超过 14 天,此条数据跳过不执行 \n';
                      return;
                }
                // 查找访问对象
                String contactId = null;
                if (String.isNotBlank(ged.applicantId)) {
@@ -129,7 +146,6 @@
                report.whatid__c = departmentAccount.Id;
                // report.VisitType__c = ged.visitInfo;//任务类型
                report.Visitor1_ID__c = contactId; //訪問者1
                report.Visitor1__c = contactId;
                report.StartDateTime__c = NFMUtil.parseStr2DateTime(ged.visitStartDate);//开始时间
                report.ActivityDate__c = NFMUtil.parseDateTimeStr2Date(ged.visitStartDate);//活动日期
                report.EndDateTime__c = NFMUtil.parseStr2DateTime(ged.visitEndDate);//结束时间
@@ -147,8 +163,8 @@
                insert report;
                logstr +=  '报告一览 [ '+ged.replyID+' ] 保存成功!\n';
            }
           // rowData.retry_cnt__c = 0; //必加
            
            rowData.retry_cnt__c = 0; //必加
        } catch (Exception ex) {
            // エラーが発生した場合
            Database.rollback(sp);
@@ -193,7 +209,7 @@
        }
        List < Daily_Report__c > drcs = [select Id, Reporter__r.Employee_No__c from Daily_Report__c where Reported_Date__c =: visitStartDate and Reporter__r.Employee_No__c =: ged.mngCd];
        List < Daily_Report__c > drcs = [select Id, Reporter__r.Employee_No__c,Status__c from Daily_Report__c where Reported_Date__c =: visitStartDate and Reporter__r.Employee_No__c =: ged.mngCd];
        if (drcs.size() > 0) {
            result = drcs[0];
        } else {