高章伟
2023-03-02 e3c02c03dd2de442bbced87236f60a13a1cd154e
force-app/main/default/classes/LostReportEditController.cls
@@ -1,4 +1,4 @@
public with sharing class LostReportEditController {
public without sharing class LostReportEditController {
    public String lrid {get; set;}
    public PageBean pBean {get; set;}
@@ -64,6 +64,10 @@
                                             Rental_Apply__r.RecordType.Name,//20210428 1653 you
                                             Status_F__c,
                                             TransferApplyOwner__c, //申请人
                                             YunYingBuZhang__c, // 运营部长 20211224 ljh SFDC-C933NJ add
                                             RA_BuchangApprovalManagerSales__c, // 部长 20211224 ljh SFDC-C933NJ add
                                             BuchangManager_approval_time__c, // 部长审批时间 20211214 ljh SFDC-C933NJ add
                                             YunYingBuZhang_approval_time__c, // 运营部长审批时间 20211214 ljh SFDC-C933NJ add
                                             Internal_asset_location_F__c, //备品存放地
                                             TransferApply__r.Bollow_Date__c, //备品中心出库日
                                             TransferApplyDeveloperName__c, //调拨类型
@@ -82,13 +86,21 @@
        }
        pBean = new PageBean(lrList[0]);
        // 20211216 ljh SFDC-C933NJ add start
        String bz = lrList[0].RA_BuchangApprovalManagerSales__c;
        String yybz = lrList[0].YunYingBuZhang__c;
        if((String.isNotBlank(bz) && bz.substring(0,15) == System.Label.PersonalId && lrList[0].BuchangManager_approval_time__c != null )
            ||(String.isNotBlank(yybz) && yybz.substring(0,15) == System.Label.PersonalId && lrList[0].YunYingBuZhang_approval_time__c != null)){
           pBean.isShowPunish = true;
        }
        // 20211216 ljh SFDC-C933NJ add end
        Set<String> assetRecordTypeList = new Set<String>();
        List<LostReport_Detail__c> lrdList = [SELECT Id,
                                                     Asset__c,
                                                     Asset__r.Id,
                                                     Fixture_Model_No_F__c,
                                                     SerialNumber__c,
                                                     IsPunishObj__c, // 20211213 ljh SFDC-C933NJ add
                                                     Asset_Value_F__c,
                                                     Asset_Value__c,
                                                     Asset_day_F__c,
@@ -96,6 +108,7 @@
                                                     Internal_Asset_number__c,
                                                     Asset__r.Asset_day__c,
                                                     Asset__r.Asset_Value__c,
                                                     Asset__r.Account.AgentCode_Ext__c,// 20211227 ljh SFDC-C933NJ add
                                                     Asset__r.RecordTypeId
                                                FROM LostReport_Detail__c
                                               WHERE LostReport__c = :lrid
@@ -125,7 +138,20 @@
          DESC_RW = lgLayout2Map.get(str);
          break;
        }
        // 20211214 ljh SFDC-C933NJ add start
        // 当前登录人等于 古芳利
        String uId = UserInfo.getUserId();
        if(uId.substring(0,15) == System.Label.PersonalId
            && (lrList[0].Status_F__c == '草案中' || lrList[0].Status_F__c == '申请中')
            && lrdList[0].Asset__r.Account.AgentCode_Ext__c != System.Label.Account_Asset_FJZ){
            DESC_RW.put('IsPunishObj__c','wm');
            // 保存按钮显示
            pBean.bzCanEdit = true;
            pBean.isShowPunish = true;
        }else{
            DESC_RW.put('IsPunishObj__c','r');
        }
        // 20211214 ljh SFDC-C933NJ add end
        for (String field : DESC_RWField) {
            if (!DESC_RW.containsKey(field)) {
                DESC_RW.put(field, 'r');
@@ -159,15 +185,27 @@
                        || lr.Status__c == '已批准') {
                    throw new ControllerUtil.myException('请确认遗失报告状态,已经提交过的申请,不能重复提交');
                }
                 pBean.lr.Status__c = '填写完毕';
                pBean.lr.Status__c = '填写完毕';
            }
            if (pBean.rowList != null && pBean.rowList.size() > 0) {
                List<LostReport_Detail__c> lrdList = new List<LostReport_Detail__c>();
                for (PageRowBean prb : pBean.rowList) {
                    // 20211215 ljh  SFDC-C933NJ add start
                    if(pBean.bzCanEdit && String.isBlank(prb.lrd.IsPunishObj__c)){
                        throw new ControllerUtil.myException('【是否罚则对象】 必须填写保存后才能审批');
                    }
                    // 20211215 ljh  SFDC-C933NJ add end
                    lrdList.add(prb.lrd);
                }
                if (lrdList.size() > 0) {
                    update lrdList; 
                    // 20211215 ljh  SFDC-C933NJ add start
                    if(pBean.bzCanEdit){
                        pBean.lr.IsFinishPunishObj__c = true;
                    }
                    // 20211215 ljh  SFDC-C933NJ add start
                }
            }
            if (String.isNotBlank(saveType) && saveType == '1') {
@@ -223,6 +261,8 @@
        // 20210430 1653 you end 
        public Boolean hasApprovedFlag {get; set;}
        public Boolean islock {get; set;}
        public Boolean bzCanEdit {get; set;} // 20211215 ljh SFDC-C933NJ add
        public Boolean isShowPunish {get; set;} // 20211215 ljh SFDC-C933NJ add
        //add by rentx 20210605 start
        public ProcessInfo beiPinWindowInfo {get; set;}
        public ProcessInfo managerapprovalInfo {get; set;}
@@ -259,6 +299,8 @@
            lr = lr1;
            islock = System.Approval.isLocked(lr1.Id);
            bzCanEdit = false; // 20211215 ljh SFDC-C933NJ add
            isShowPunish = false;// 20211216 ljh SFDC-C933NJ add
            lrCreateDate = lr.CreatedDate.format('yyyy/MM/dd');
            ra = lr.Rental_Apply__r;
            bollow_DateStr = '';
@@ -476,7 +518,6 @@
        public LostReport_Detail__c lrd {get; set;}
        public Asset ass {get; set;}
        public String asset_dayStr {get; set;}
        public PageRowBean() {
            lrd = new LostReport_Detail__c();
            ass = new Asset();