zhangzhengmei
2023-08-06 a82f0830a132be063a63dcd7dd2ccca2179d5738
force-app/main/default/classes/QISTrigger.cls
@@ -95,6 +95,98 @@
                qr.Photo_4_Text__c = phtTxt;
                QIS_Ids.add(qr.Id);
            }
            //加4个字段 20230627
             // Photo5
            if (Trigger.isInsert && String.isBlank(qr.Photo_5__c) == false
                    || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_5__c != qr.Photo_5__c)
                    || (Trigger.isUpdate && String.isBlank(qr.Photo_5__c) == false && String.isBlank(qr.Photo_5_Text__c))
            ) {
                String phtTxt = '';
                if (String.isBlank(qr.Photo_5__c) == false) {
                    Integer pStt = qr.Photo_5__c.indexOf('<img');
                    if (pStt >= 0) {
                        pStt = qr.Photo_5__c.indexOf('src="');
                        if (pStt >= 0) {
                            Integer pEnd = qr.Photo_5__c.indexOf('"', pStt + 5);
                            if (pEnd >= 0) {
                                phtTxt = qr.Photo_5__c.substring(pStt + 5, pEnd);
                                phtTxt = phtTxt.unescapeHtml4();
                            }
                        }
                    }
                }
                qr.Photo_5_Text__c = phtTxt;
                QIS_Ids.add(qr.Id);
            }
             // Photo6
            if (Trigger.isInsert && String.isBlank(qr.Photo_6__c) == false
                    || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_6__c != qr.Photo_6__c)
                    || (Trigger.isUpdate && String.isBlank(qr.Photo_6__c) == false && String.isBlank(qr.Photo_6_Text__c))
            ) {
                String phtTxt = '';
                if (String.isBlank(qr.Photo_6__c) == false) {
                    Integer pStt = qr.Photo_6__c.indexOf('<img');
                    if (pStt >= 0) {
                        pStt = qr.Photo_6__c.indexOf('src="');
                        if (pStt >= 0) {
                            Integer pEnd = qr.Photo_6__c.indexOf('"', pStt + 5);
                            if (pEnd >= 0) {
                                phtTxt = qr.Photo_6__c.substring(pStt + 5, pEnd);
                                phtTxt = phtTxt.unescapeHtml4();
                            }
                        }
                    }
                }
                qr.Photo_6_Text__c = phtTxt;
                QIS_Ids.add(qr.Id);
            }
             // Photo7
            if (Trigger.isInsert && String.isBlank(qr.Photo_7__c) == false
                    || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_7__c != qr.Photo_7__c)
                    || (Trigger.isUpdate && String.isBlank(qr.Photo_7__c) == false && String.isBlank(qr.Photo_7_Text__c))
            ) {
                String phtTxt = '';
                if (String.isBlank(qr.Photo_7__c) == false) {
                    Integer pStt = qr.Photo_7__c.indexOf('<img');
                    if (pStt >= 0) {
                        pStt = qr.Photo_7__c.indexOf('src="');
                        if (pStt >= 0) {
                            Integer pEnd = qr.Photo_7__c.indexOf('"', pStt + 5);
                            if (pEnd >= 0) {
                                phtTxt = qr.Photo_7__c.substring(pStt + 5, pEnd);
                                phtTxt = phtTxt.unescapeHtml4();
                            }
                        }
                    }
                }
                qr.Photo_7_Text__c = phtTxt;
                QIS_Ids.add(qr.Id);
            }
             // Photo8
            if (Trigger.isInsert && String.isBlank(qr.Photo_8__c) == false
                    || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_8__c != qr.Photo_8__c)
                    || (Trigger.isUpdate && String.isBlank(qr.Photo_8__c) == false && String.isBlank(qr.Photo_8_Text__c))
            ) {
                String phtTxt = '';
                if (String.isBlank(qr.Photo_8__c) == false) {
                    Integer pStt = qr.Photo_8__c.indexOf('<img');
                    if (pStt >= 0) {
                        pStt = qr.Photo_8__c.indexOf('src="');
                        if (pStt >= 0) {
                            Integer pEnd = qr.Photo_8__c.indexOf('"', pStt + 5);
                            if (pEnd >= 0) {
                                phtTxt = qr.Photo_8__c.substring(pStt + 5, pEnd);
                                phtTxt = phtTxt.unescapeHtml4();
                            }
                        }
                    }
                }
                qr.Photo_8_Text__c = phtTxt;
                QIS_Ids.add(qr.Id);
            }
        }
    }
}