高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
public  with sharing    class InspectCheckController {
    public InspectCheckController() {
 
    }
 
    //根据ID查询  招投标项目
    @AuraEnabled
    public  static string GetInspectById(String Id){
        QueryWrapper query = new QueryWrapper(Tender_information__c.SObjectType);
        query.eq('Id', Id);
        List<Tender_information__c> arrays = DataBasePlus.listPlus(query);
        return JSON.serialize(arrays); 
    }
 
 
     //招投标项目列表字段 irrelevantReasons__c 所有的值
    @AuraEnabled
    public  static string GetIrrelevantReasons(){
      String JsonData = CommonUtils.GetSelectedValues( Tender_information__c.irrelevantReasons__c.getDescribe());
      return JsonData;
    }
 
 
     //招投标项目列表字段 irresponsibleReason__c 所有的值
    @AuraEnabled
    public  static string GetIrresponsibleReason(){
      String JsonData = CommonUtils.GetSelectedValues( Tender_information__c.irresponsibleReason__c.getDescribe());
      return JsonData;
    }
 
 
  
 
      // 产品类
      public class Information {
        public  String hospital;//关联医院
        public  String account;// 关联普通科室
        public  String department;//关联医院
    }
 
    // 查询用户 根据父ID的值  
    @AuraEnabled
    public  static string  GetIsPrentIdArr(String Id){
        return CommonUtils.GetAccountPrentID(Id);
    }
 
 
    //保存数据  JSONData 是 招投标项目 对象的 json格式的值 
    @AuraEnabled
    public  static string  SaveData(String JsonData,String Id,String checkboxValue){
        System.debug('1234567890123');
        try{
            Tender_information__c temp = (Tender_information__c)JSON.deserialize(JsonData,Tender_information__c.class);
            // System.debug('temp=='+temp);
            // System.debug('----1----'+temp.InfoOwner__c+'=====2===='+temp.SP_assistant__c);
            // List<String> Apilist = new List<String>{'01210000000QezeAAC','01210000000QezjAAC','01210000000QezoAAC','01210000000QeztAAC'};
            // System.debug('=====1-----'+temp.department_selection__c);
            // List<String> tenDepartList = temp.department_selection__c.split(';');
            // if(tenDepartList.contains('01210000000QezeAAC')
            //     || tenDepartList.contains('01210000000QezjAAC')
            //     || tenDepartList.contains('01210000000QezoAAC')
            //     || tenDepartList.contains('01210000000QeztAAC')){
            //     System.debug('=====-----'+temp.department_selection__c);
            //     temp.InfoOwner__c = temp.SP_assistant__c;
            // }
            StaticParameter.EscapeOtherUpdateTenOwner = false;
            update temp;
            StaticParameter.EscapeOtherUpdateTenOwner = true;
            //String assvale=AssignValuesToOwner(Id,checkboxValue);
        }catch(Exception ex)
        {
           return  ex.getMessage();
        }
        return  '成功';
    }
 
    //保存 应标数据 JSONData 是 招投标项目 对象的 json格式的值 
     @AuraEnabled
    public  static String SaveDataYB(String JsonData){
        try{
            Tender_information__c temp = (Tender_information__c)JSON.deserialize(JsonData,Tender_information__c.class);
          //if (temp.IsBid__c == '否') {
                temp.NotBidApprovalStatus__c = '草案中';
                temp.ownerid = UserInfo.getUserId();
                
            //}else{
            //    temp.NotBidApprovalStatus__c = null;
            //    temp.irresponsibleReasonOther__c = null;
            //    temp.irresponsibleReason__c = null;
            //    temp.irresponseApplyTime__c = null;
            //    temp.RepsExtraContent__c = null;
            //}
            update temp;
        }catch(Exception ex)
        {
            return  ex.getMessage();
        }
        return  '成功';
    }
 
    //提交审核 应标数据 JSONData 是 招投标项目 对象的 json格式的值 
    @AuraEnabled
    public  static String ChangeDataYB(String JsonData){
        try{
            Tender_information__c temp = (Tender_information__c)JSON.deserialize(JsonData,Tender_information__c.class);
            if (temp.IsBid__c == '否') {
                temp.NotBidApprovalStatus__c = '填写完毕';
                temp.ownerid = UserInfo.getUserId();
            }
            update temp;
        }catch(Exception ex)
        {
            return  ex.getMessage();
        }
        return  '成功';
    }
 
 
    //查询战略科室
    @AuraEnabled
    public  static String SearchZLKS(String content,String[] ParentId){
        String jsonData = CommonUtils.GetZLKS(content,ParentId);
        return jsonData;
    }
 
    //查询医院
    @AuraEnabled
    public  static String SearchYY(String content){
        String jsonData = CommonUtils.GetYY(content);
        return jsonData;
    }
 
    //查询用户
    @AuraEnabled
    public  static String SearchYH(String content,String[] his){
 
        String sql2 = 'select ';
        String props2 = CommonUtils.GetSqlToPorps(account.SObjectType);
        sql2 += props2;
        sql2 += ' from account';
        sql2 += ' where Id  in :his';
        List<account> arraysAccount = Database.query(sql2);
    
        List<String>  ids = new  List<String>();
        List<String> names =new  List<String>();
        for(account a : arraysAccount)
        {
            ids.Add(a.GI_Main__c);
            ids.Add(a.BF_owner__c);
            ids.Add(a.ET_owner__c);
            ids.Add(a.SP_Main__c);
            ids.Add(a.URO_owner_ID__c);
            ids.Add(a.GYN_owner__c);
            ids.Add(a.ENT_owner_ID__c);
            ids.Add(a.ENT_owner_ID__c);
 
            if(a.Energy_LeaderStr__c != null && a.Energy_LeaderStr__c != '')
            {
                string energy =  a.Energy_LeaderStr__c;
                string[] eneArr = energy.split(',');
                for(string item : eneArr)
                {
                    names.Add(item);
                }
            }
           
 
        }
 
 
        //select Id,Name,Alias from user where Name Like '%赖 思吕%' and (id in ('00510000006xTn0AAE') or  alias in ('思赖'))  limit 100
        content = '%'+content+'%';
        String sql = 'select ';
        String props = CommonUtils.GetSqlToPorps(user.SObjectType);
        sql += props;
        sql += ' from user';
        sql += ' where (Name  Like :content or alias Like :content)';
        sql += ' and (Id in :ids or alias in :names)';
        sql += ' and IsActive = true';
        sql += ' limit 5 ';
        List<user> arrays = Database.query(sql);
        return JSON.serialize(arrays); 
    }
 
    //查询普通科室
    // @AuraEnabled
    // public  static String SearchPTKS(String content,String ParentId){
    //     String jsonData = CommonUtils.GetPTKS(content,ParentId);
    //     return jsonData;
    // }
 
    //查询普通科室 有医院限制的
    // @AuraEnabled
    // public  static String SearchPTKSByYYParent(String content,String ParentId){
    //     String jsonData = CommonUtils.GetPTKSByYYParent(content,ParentId);
    //     return jsonData;
    // }
    //查询父类
    @AuraEnabled
    public  static String SearchParent(String Id){
        String jsonData = CommonUtils.GetParent(Id);
        return jsonData;
    }
 
    //查询医院下的科室
    @AuraEnabled
    public  static String SearchYYChilders(String content,String ParentId){
    String jsonData = CommonUtils.GetYYChilders(content,ParentId);
    return jsonData;
    }
       
 
     //根据id查询医院
     @AuraEnabled
     public  static String SearchAccountById(String Id){
        QueryWrapper query = new QueryWrapper(account.SObjectType);
        query.eq('Id',Id);
        List<account> arraysTemp = DataBasePlus.listPlus(query);
        return JSON.serialize(arraysTemp);  
     }
 
    //根据id查询用户
    @AuraEnabled
    public  static String SearchUserById(String Id){
        QueryWrapper query = new QueryWrapper(user.SObjectType);
        query.eq('Id',Id);
        List<user> arraysTemp = DataBasePlus.listPlus(query);
        return JSON.serialize(arraysTemp);  
    }
 
 
    //判断当前登录用户 是否是 所有人
    @AuraEnabled
    public  static String CheckOwner(String Id){
        String OwnerId = UserInfo.getUserId();
        String sql = 'select Id, owner.Id ,Name from Tender_information__c where  Id = :Id ';
        List<Tender_information__c> arrays = Database.query(sql);
        
        if(UserInfo.getProfileId() == System.Label.ProfileId_SystemAdmin)
        {
            return '1'+ '==' + '1';
        }
        if(arrays.size()<1)
        {
            return  '2'+ '==' + '1';
        }
        return OwnerId + '==' + arrays[0].owner.Id;
    } 
 
 
     //查询用户
     @AuraEnabled
     public  static String SearchUserByIds(String[] his){
 
         String sql2 = 'select ';
         String props2 = CommonUtils.GetSqlToPorps(account.SObjectType);
         sql2 += props2;
         sql2 += ' from account';
         sql2 += ' where Id  in :his';
         List<account> arraysAccount = Database.query(sql2);
     
         List<String>  ids = new  List<String>();
         List<String> names =new  List<String>();
         for(account a : arraysAccount)
         {
             ids.Add(a.GI_Main__c);
             ids.Add(a.BF_owner__c);
             ids.Add(a.ET_owner__c);
             ids.Add(a.SP_Main__c);
             ids.Add(a.URO_owner_ID__c);
             ids.Add(a.GYN_owner__c);
             ids.Add(a.ENT_owner_ID__c);
             ids.Add(a.ENT_owner_ID__c);
 
             if(a.Energy_LeaderStr__c != null && a.Energy_LeaderStr__c != '')
             {
                 string energy =  a.Energy_LeaderStr__c;
                 string[] eneArr = energy.split(',');
                 for(string item : eneArr)
                 {
                     names.Add(item);
                 }
             }
            
 
         }
         String sql = 'select ';
         String props = CommonUtils.GetSqlToPorps(user.SObjectType);
         sql += props;
         sql += ' from user';
         sql += ' where';
         sql += ' Id in :ids or alias in :names ';
        //  sql += ' and IsActive = true';
         List<user> arrays = Database.query(sql);
         return JSON.serialize(arrays); 
     }
     //为所有人赋值
    //  @AuraEnabled
    //  public  static String AssignValuesToOwner(String Id,String checkboxValue){
    //      if(checkboxValue!=null){
    //         String sql = 'select Id,Hospital__r.GI_Main__c,Hospital__r.BF_owner__c,Hospital__r.SP_Main__c,Hospital__r.URO_owner_ID__c,Hospital__r.GYN_owner__c,Hospital__r.ENT_owner_ID__c,OwnerId from Tender_information__c where Id = :Id';
    //         List<Tender_information__c> arrays = Database.query(sql);
    //         List<String> chekv = checkboxValue.split(';');
    //         Map<String,String> cmap = new Map<String,String>();
    //         if(arrays.size()!=0){
    //             Tender_information__c tic= new Tender_information__c();
    //             tic = arrays[0];
    //             // for (String chek : chekv) {
    //             //     if(chekv.contains('01210000000QemLAAS')){//&&tic.Hospital__r.GI_Main__c!=null
    //             //         tic.OwnerId=tic.Hospital__r.GI_Main__c;
    //             //     }else if(chekv.contains('01210000000QezZAAS')){
    //             //         tic.OwnerId=tic.Hospital__r.BF_owner__c;
    //             //     }else if(chekv.contains('01210000000QezeAAC')){
    //             //         tic.OwnerId=tic.Hospital__r.SP_Main__c;
    //             //     }else if(chekv.contains('01210000000QezjAAC')){
    //             //         tic.OwnerId=tic.Hospital__r.URO_owner_ID__c;
    //             //     }else if(chekv.contains('01210000000QezoAAC')){
    //             //         tic.OwnerId=tic.Hospital__r.GYN_owner__c;
    //             //     }else if(chekv.contains('01210000000QeztAAC')){
    //             //         tic.OwnerId=tic.Hospital__r.ENT_owner_ID__c;
    //             //     }else{
    //             //         System.debug('UserInfo.getUserId===='+UserInfo.getUserId());
    //             //         System.debug('tic.OwnerId===='+tic.OwnerId);
    //             //         if(tic.OwnerId!=UserInfo.getUserId()){
    //             //             tic.OwnerId=UserInfo.getUserId();
    //             //         }
    //             //         System.debug('tic.OwnerId2===='+tic.OwnerId);
    //             //     }
    //             // }
    //             update tic;
    //         }
    //      }
    //      return '成功';
    //  } 
    
}