高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
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
public with sharing class EnquiryNoBiddingController {
    public EnquiryNoBiddingController() {
 
    }
 
    //import GetInspectById from '@salesforce/apex/EnquiryNoBiddingController.GetInspectById';
// import SaveDataYB from '@salesforce/apex/EnquiryNoBiddingController.SaveDataYB';
// import ChangeDataYB from '@salesforce/apex/EnquiryNoBiddingController.ChangeDataYB';
// import GetIrresponsibleReason from '@salesforce/apex/EnquiryNoBiddingController.GetIrresponsibleReason';
 
// import CheckOwnerRequest from '@salesforce/apex/EnquiryNoBiddingController.CheckOwner';
 
    class EnquiryNoBiddingModel 
    {
        public Opportunity opp;
        public Tender_information__c tender;
        public Enquiry_No_Bidding_Apply__c enquiry;
    }
 
    @AuraEnabled
    public  static string GetDataById(string Id)
    {
        EnquiryNoBiddingModel model = new EnquiryNoBiddingModel();
        //Opp_Bid__c | Bidding_Project_Name_BidId__c
        string OpportunityProp = CommonUtils.GetSqlToPorps(Opportunity.SObjectType);
        string sql = 'select '+OpportunityProp+' from Opportunity where Id = :Id';
        List<Opportunity> arrays = Database.query(sql);
 
        model.opp = arrays[0];
        string bId = arrays[0].Bidding_Project_Name_Bid__c;
        string oId = arrays[0].Opp_Bid__c;
        if(bId!= null)
        {
            string TenderProp = CommonUtils.GetSqlToPorps(Tender_information__c.SObjectType);
            string sql2 = 'select '+TenderProp+' from Tender_information__c where Id = :bId';
            List<Tender_information__c> arraysTender = Database.query(sql2);
            model.tender = arraysTender[0];
        }
        if(oId != null)
        {
            string EnquiryNoProp = CommonUtils.GetSqlToPorps(Enquiry_No_Bidding_Apply__c.SObjectType);
            string sql3 = 'select '+EnquiryNoProp+' from Enquiry_No_Bidding_Apply__c where Id = :oId';
            List<Enquiry_No_Bidding_Apply__c> arraysEnquiry = Database.query(sql3);     
            model.enquiry = arraysEnquiry[0];
        }
        return JSON.serialize(model); 
    }
 
     //根据ID查询  Enquiry_No_Bidding_Apply__c
     @AuraEnabled
     public  static string GetInspectById(String Id){
         QueryWrapper query = new QueryWrapper(Enquiry_No_Bidding_Apply__c.SObjectType);
         query.eq('Id', Id);
         List<Enquiry_No_Bidding_Apply__c> arrays = DataBasePlus.listPlus(query);
         return JSON.serialize(arrays); 
     }
 
 
    //根据ID查询  招投标项目
    @AuraEnabled
    public  static string GetTenderInformationById(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); 
    }
 
      //招投标项目列表字段 irresponsibleReason__c 所有的值
     @AuraEnabled
     public  static string GetIrresponsibleReason(){
       String JsonData = CommonUtils.GetSelectedValues( Enquiry_No_Bidding_Apply__c.irresponsibleReason__c.getDescribe());
       return JsonData;
     }
 
  
 
 
     //保存 应标数据 JSONData 是 招投标项目 对象的 json格式的值 
      @AuraEnabled
     public  static String SaveDataYB(String JsonData,String Id,String IsInsert){
        QueryWrapper query = new QueryWrapper(Opportunity.SObjectType);
        query.eq('Id', Id);
        List<Opportunity> arrays = DataBasePlus.listPlus(query);
        Opportunity OppTemp = arrays[0];
        
        try{
            Enquiry_No_Bidding_Apply__c temp = (Enquiry_No_Bidding_Apply__c)JSON.deserialize(JsonData,Enquiry_No_Bidding_Apply__c.class);
            temp.Opportunity__c = Id;
            temp.InfoOwner__c = OppTemp.ownerid;
            temp.NotBidApprovalStatus__c = '草案中';
            if(IsInsert == '是')
            {
                insert temp;
                OppTemp.Opp_Bid__c = temp.Id;
                update OppTemp;
                
            }
            else{
                update temp;
            }
            return '成功';
            
         }catch(Exception ex)
         {
             return  ex.getMessage();
         }
        //  return  '成功';
     }
 
     //提交审核 应标数据 JSONData 是 招投标项目 对象的 json格式的值 
     @AuraEnabled
     public  static String ChangeDataYB(String JsonData,String Id,String IsInsert){
        QueryWrapper query = new QueryWrapper(Opportunity.SObjectType); 
        query.eq('Id', Id);
        List<Opportunity> arrays = DataBasePlus.listPlus(query);
        Opportunity OppTemp = arrays[0]; 
 
        try{
            Enquiry_No_Bidding_Apply__c temp = (Enquiry_No_Bidding_Apply__c)JSON.deserialize(JsonData,Enquiry_No_Bidding_Apply__c.class);
            temp.Opportunity__c = Id;
        
             temp.InfoOwner__c = OppTemp.ownerid;
             temp.leading_Cadre_Assistant__c = OppTemp.Sales_assistant_name_text__c;
             boolean flag = false;
             if(temp.NotBidApprovalStatus__c == null)
             {
                temp.NotBidApprovalStatus__c = '草案中';
                flag = true;
             }
             if(IsInsert == '是')
             {
                 insert temp;
                 OppTemp.Opp_Bid__c = temp.Id;
                 update OppTemp;
                 
             }
             else{
                 update temp;
             }
            temp.NotBidApprovalStatus__c = '填写完毕';
 
            update temp;
             
             return '成功';
         }catch(Exception ex)
         {
             return  ex.getMessage();
         }
     }
 
 
 
     
     //判断当前登录用户 是否是 所有人
     @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;
     } 
 
}