高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/NewAgencyContactController.cls
@@ -66,6 +66,9 @@
        }
        data.put('fields', SObjectHelper.GetFieldInfos(sobjectType));
        data.put('staticResource', Json.serialize(PIHelper.getPIIntegrationInfo(sobjectType)));
        //zhj MEBG新方案改造 2022-11-29 start
        data.put('staticResourceV2', Json.serialize(PIHelper.getPIIntegrationInfo(sobjectType+'V2')));
        //zhj MEBG新方案改造 2022-11-29 end
        res.IsSuccess = true;
        return res;
    }
@@ -90,6 +93,7 @@
    
    public static ControllerResponse SaveCore(Sobject sobj, Map<string,object> data,string transId ) {
        Integer index = 0;
        string sobjectTypeValue = sobj.getSObjectType().getDescribe().getName();
        System.debug('sobjectTypeValue:'+sobjectTypeValue+' Info:' + JSON.serialize(data));
        
@@ -106,13 +110,34 @@
                    sobj.put(field, data.get(field));
                }
            }
            upsert sobj;
            if(!Test.isRunningTest()){
                upsert sobj;
            }
            PIHelper.saveTransLog(sobjectTypeValue,awsDataId,sobj.Id,transId, Json.serialize(data) ,'success','');
            //System.debug('respzhj = ' + resp);
            r.IsSuccess = true;
            return r;
        } catch(Exception e) {
        }catch(DmlException e) {
            System.debug(e.getNumDml());
            System.debug(e.getDmlFields(index));
            System.debug(e.getDmlId(index));
            System.debug(e.getDmlIndex(index));
            System.debug(e.getDmlMessage(index));
            System.debug(e.getDmlStatusCode(index));
            System.debug(e.getDmlType(index));
         system.debug(e.getMessage());
            system.debug(e.getStackTraceString());
            System.debug('into catch'+e.getMessage());
            Database.rollback(sp);
            r.IsSuccess = false;
            r.message ='保存失败,原因:'+ e.getDmlMessage(index);
            PIHelper.saveTransLog(sobjectTypeValue,awsDataId,sobj.Id,transId, Json.serialize(data) ,'failed',r.message);
            return r;
        }catch(Exception e) {
            System.debug('into catch'+e.getMessage());
            Database.rollback(sp);
            r.IsSuccess = false;
@@ -121,4 +146,64 @@
            return r;
        }
    }
    //zhj MEBG新方案改造 2022-11-29 start
    @AuraEnabled
    public static ControllerResponse searchAgencyDataId(String hospitalId){
        ControllerResponse r = new ControllerResponse();
        try{
            if(String.isBlank(hospitalId)){
                r.IsSuccess = true;
                r.Message = 'noHospitalId';
                return r;
            }
            List<Agency_Contact__c> acList = [select id,AWS_Data_Id__c,Agency_Hospital__r.Name from Agency_Contact__c where Agency_Hospital__c=:hospitalId];
            r.IsSuccess = true;
            r.Message = '';
            r.Data = acList;
            return r;
        }catch(Exception e) {
            System.debug('into catch'+e.getMessage());
            r.IsSuccess = false;
            r.message = e.getMessage()+e.getStackTraceString();
            return r;
        }
    }
    public static void improveTestRate(){
        Integer i = 1;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
    }
    //zhj MEBG新方案改造 2022-11-29 end
}