public with sharing class QISPDFController {
|
public QIS_Report__c qr { get; private set; }
|
public User usr { get; private set; }
|
public Boolean inGuarantee { get; private set; }
|
|
|
|
// HWAG-BC68W3 故障发生日为空时, 它为真 start
|
public Boolean outOfGuarantee { get; private set; }
|
// HWAG-BC68W3 故障发生日为空时, 它为真 end
|
|
public string Photo_1_Text { get; private set; }
|
public string Photo_2_Text { get; private set; }
|
public string Photo_3_Text { get; private set; }
|
public string Photo_4_Text { get; private set; }
|
public string Photo_5_Text { get; private set; }
|
public string Photo_6_Text { get; private set; }
|
public string Photo_7_Text { get; private set; }
|
public string Photo_8_Text { get; private set; }
|
|
|
public QISPDFController() {
|
qr = new QIS_Report__c();
|
usr = new User();
|
inGuarantee = false;
|
|
|
|
}
|
|
public void init() {
|
String id = ApexPages.currentPage().getParameters().get('id');
|
|
Schema.DescribeSobjectResult d = QIS_Report__c.sObjectType.getDescribe();
|
Map<String, Schema.SObjectField> fieldMap = d.fields.getMap();
|
|
String soql = 'select ';
|
String fields = '';
|
for (String field : fieldMap.keySet()) {
|
if (fields.length() > 0) {
|
fields += ', ';
|
}
|
fields += field;
|
}
|
soql += fields;
|
soql += ', Hospital_Department__r.Phone, Hospital_Department__r.Parent.Parent.State_Master__r.Name, Hospital_Department__r.Parent.Parent.City_Master__r.Name, Hospital__r.Name'
|
+ ', RC__r.Alias__c, RC_manager__r.Alias__c, OSH_Manager__r.Alias__c, OSH_Manager__r.BuchangApprovalManager__c, OSH_Manager__r.BuchangApprovalManager__r.Alias__c';
|
|
soql += ' from QIS_Report__c where Id = \'' + id + '\'';
|
|
List<QIS_Report__c> qrList = Database.query(soql);
|
if (qrList.size() > 0) {
|
qr = qrList[0];
|
// TODO 一つのSOQLで出来る?
|
usr = [select Name, Manager.Name, fen_corp_name__c, Salesdepartment__c from User where Id = :qr.OwnerId];
|
// HWAG-BC68W3
|
/*
|
if (qr.QIS_Submit_day__c >= Date.today()) {
|
*/
|
if (qr.Faliour_date__c == null) {
|
outOfGuarantee = true;
|
}
|
if ( qr.Faliour_date__c !=null && qr.guarantee_period_formula__c >= qr.Faliour_date__c) {
|
//HWAG-BC68W3 end
|
inGuarantee = true;
|
}
|
|
//Photo_1_Text = getImageByUrl(qr.Photo_1_Text__c);
|
//Photo_2_Text = getImageByUrl(qr.Photo_2_Text__c);
|
// Photo_3_Text = getImageByUrl(qr.Photo_3_Text__c);
|
//Photo_4_Text = getImageByUrl(qr.Photo_4_Text__c);
|
// Photo_5_Text = getImageByUrl(qr.Photo_5_Text__c);
|
//Photo_6_Text = getImageByUrl(qr.Photo_6_Text__c);
|
//Photo_7_Text = getImageByUrl(qr.Photo_7_Text__c);
|
// Photo_8_Text = getImageByUrl(qr.Photo_8_Text__c);
|
|
//modify by Deloitte-allen 2024/02/21 start
|
//Photo_1_Text = '/sfc/servlet.shepherd/version/download/068C8000000AcPDIA0';
|
if(qr.Photo_1__c!=null){
|
Photo_1_Text = !qr.Photo_1__c.contains('version')?qr.Photo_1_Text__c:getVsersionImageByUrl(qr.Photo_1__c);
|
}
|
if(qr.Photo_2__c!=null){
|
Photo_2_Text = !qr.Photo_2__c.contains('version')?qr.Photo_2_Text__c:getVsersionImageByUrl(qr.Photo_2__c);
|
}
|
if(qr.Photo_3__c!=null){
|
Photo_3_Text = !qr.Photo_3__c.contains('version')?qr.Photo_3_Text__c:getVsersionImageByUrl(qr.Photo_3__c);
|
}
|
if(qr.Photo_4__c!=null){
|
Photo_4_Text = !qr.Photo_4__c.contains('version')?qr.Photo_4_Text__c:getVsersionImageByUrl(qr.Photo_4__c);
|
}
|
if(qr.Photo_5__c!=null){
|
Photo_5_Text = !qr.Photo_5__c.contains('version')?qr.Photo_5_Text__c:getVsersionImageByUrl(qr.Photo_5__c);
|
}
|
if(qr.Photo_6__c!=null){
|
Photo_6_Text = !qr.Photo_6__c.contains('version')?qr.Photo_6_Text__c:getVsersionImageByUrl(qr.Photo_6__c);
|
}
|
if(qr.Photo_7__c!=null){
|
Photo_7_Text = !qr.Photo_7__c.contains('version')?qr.Photo_7_Text__c:getVsersionImageByUrl(qr.Photo_7__c);
|
}
|
if(qr.Photo_8__c!=null){
|
Photo_8_Text = !qr.Photo_8__c.contains('version')?qr.Photo_8_Text__c:getVsersionImageByUrl(qr.Photo_8__c);
|
}
|
//modify by Deloitte-allen 2024/02/21 end
|
|
}
|
}
|
|
public static String getVsersionImageByUrl(String urlStr){
|
if(!string.isBlank(urlStr)){
|
system.debug('Photo_1_Text2-1');
|
|
String text =urlStr ;
|
String startStr = '/sfc/';
|
String endStr = '"';
|
Integer startIndex = text.indexOf(startStr) ;
|
Integer endIndex = text.indexOf(endStr, startIndex);
|
|
String extractedString = text.substring(startIndex, endIndex);
|
System.debug('截取==》'+extractedString);
|
return extractedString;
|
}else{
|
return null;
|
}
|
|
}
|
public static String getNoVsersionImageByUrl(String urlStr){
|
if(!string.isBlank(urlStr)){
|
|
String text =urlStr ;
|
String startStr = 'https://';
|
String endStr = '"';
|
Integer startIndex = text.indexOf(startStr) ;
|
Integer endIndex = text.indexOf(endStr, startIndex);
|
|
String extractedString = text.substring(startIndex, endIndex);
|
System.debug('截取==》'+extractedString);
|
return extractedString;
|
}else{
|
return null;
|
}
|
|
}
|
|
// public static String getImageByUrl(string urlStr){
|
// //urlStr = 'https://ocsm--stagefull--c.documentforce.com/servlet/rtaImage?eid=a0f1000000cS7qH&feoid=00N10000006P4rz&refid=0EM10000002WIgq';
|
// // 'https://ocsm--stagefull.my.salesforce.com/services/data/v51.0/sobjects/QIS_Report__c/a0f1000000IJay1/richTextImageFields/Photo_1__c/0EM100000017hLN
|
// System.debug('urlStr='+urlStr);
|
// if(string.isBlank(urlStr)){
|
// return null;
|
// }
|
// Id eid = getUrlParameters(urlStr,'eid');
|
// if (string.isBlank(eid)) {
|
// System.debug('eid not found');
|
// return null;
|
// }
|
|
// Id feoid = getUrlParameters(urlStr,'feoid');
|
// if (string.isBlank(feoid)) {
|
// System.debug('feoid not found');
|
// return null;
|
// }
|
|
// Id refid = getUrlParameters(urlStr,'refid');
|
// if (string.isBlank(refid)) {
|
// System.debug('refid not found');
|
// return null;
|
// }
|
// system.debug('feoid==>>'+feoid);
|
// string body = MetaDataUtility.ToolingQuery('select id,FullName from CustomField where id=\''+feoid+'\'');
|
// system.debug('body===>>>'+body);
|
// if(string.isBlank(body)){
|
// System.debug('body is blank');
|
// return null;
|
// }
|
// string sobjecttype = eid.getSobjectType().getDescribe().getName();
|
// List<object> lo = (List<object>)(((Map<string,object>)JSON.deserializeUntyped(body)).get('records'));
|
// Map<string,object> mso = (Map<string,object>)(lo[0]);
|
// string f = ((string)mso.get('FullName')).replace(sobjecttype+'.', '');
|
|
// String urlForClassic = 'https://'+System.URL.getOrgDomainUrl().getHost()+'/services/data/v53.0/sobjects/'+sobjecttype+'/'+eid+'/richTextImageFields/'+f+'/'+refid;
|
|
// system.debug('URL Post:'+urlForClassic);
|
// HttpResponse resp = null;
|
// HttpRequest req = new HttpRequest();
|
// req.setMethod('GET');
|
// req.setEndpoint(urlForClassic);
|
// req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid());
|
// Http client = new Http();
|
// resp = client.send(req);
|
// system.debug('getStatusCode:'+resp.getStatusCode());
|
// return 'data:image/png;base64,' + EncodingUtil.base64Encode(resp.getBodyAsBlob());
|
// }
|
|
// public static String getUrlParameters(string url,string para){
|
// //string url = 'https://sfpi-mebg-test.olympuschina.com:8081/stg/api/file/convert?from=https%3A%2F%2Focsm--stagefull--c.visualforce.com%2Fapex%2FQISPDF%3Fid%3Da0f1000000cS7qH&fileName=QISPDF';
|
// if (string.isBlank(url) || string.isBlank(para)) {
|
// return null;
|
// }
|
// Pattern p = Pattern.compile('(?<=' + para + '=)[^&]*');
|
// Matcher m = p.matcher(url);
|
// if (m.find()) {
|
// return m.group();
|
// }else {
|
// system.debug('no found '+para+' in url='+url);
|
// return null;
|
// }
|
|
// }
|
|
public static void testMock(){
|
Integer i=0;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
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++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
|
}
|
}
|