@RestResource(urlMapping = '/NFM612/*')
|
global with sharing class NFM612Rest {
|
/* 迁移ali sushanhu 20231027
|
//add to AWS 回复 start sushanhu 20220225
|
static Boolean SFStatus=true;
|
static String SFMessage='';
|
//add to AWS 回复 end sushanhu 20220225
|
*/
|
public static final String LOG_TYPE = 'NFM612';
|
global class GeData {
|
public RepairOderInfo repairOderInfo;
|
public ApplyRepairInfo applyRepairInfo;
|
public problem problem;
|
public Logistics logistics; //物流 zhj 改造新增字段 2023-02-14
|
public String item0010; //备用字段 zhj 改造新增字段 2023-02-14
|
public String item0020; //备用字段 zhj 改造新增字段 2023-02-14
|
public String item0030; //备用字段 zhj 改造新增字段 2023-02-14
|
public String item0040; //备用字段 zhj 改造新增字段 2023-02-14
|
public String item0050; //备用字段 zhj 改造新增字段 2023-02-14
|
}
|
//报修单信息
|
public class RepairOderInfo {
|
public String repairOrderNo; //报修单号
|
public String repairOrderNo2; //报修单子单号
|
public String hospitalCd; //报修医院编码
|
public String strategicDepartmenCd; //战略科室编码
|
public String departmentCd; //报修科室编码
|
public String repairApplyPerson; //报修人用户编码
|
public String repairApplicantName; //报修人姓名
|
//public String repairApplicantNameEncrypted; //报修人姓名密文 add20220214 //zhj新方案改造 2022-12-07
|
public String repairApplyPersonTel; //报修人联系人电话
|
//public String repairApplyPersonTelEncrypted;//保修人联系电话 密文 add 20220214 //zhj新方案改造 2022-12-07
|
//public String DataId;//aws 存储凭证 add 20220214 //迁移ali sushanhu 20231017
|
public String repairApplyType; // 报修人岗位
|
public String equipmentCategory; //设备大类
|
public String assetType; //设备类型
|
public String equipmentCd; //机身编码(医院)
|
public String faultDate; //故障发生日
|
public String repairOrderTime; //报修时间
|
public String faultType; //故障类型
|
public String problemDesc; //问题描述
|
public String problemPhotoName; //问题照片
|
public String problemPhotofile; //照片附件
|
public String repairSubOrderType; //报修单类型
|
public String responseResultType; //应对结果类型
|
public String receiverType; //受理人类型
|
public String receiverId; //受理人用户编号
|
public String receiverDate; //受理日
|
public String plannedVisitDay; //计划上门日
|
//public String actualVisitTimeFirst;//实际上门日
|
public String startTimeFirst; //开始时间
|
public String endTimeFirst; //结束时间
|
public String faultDescriptionFirst; //故障描述
|
public String actualVisitTimeSecond; //二次上门日
|
public String startTimeSecond; //二次上门开始时间
|
public String endTimeSecond; //二次上门结束时间
|
public String faultDescriptionSecond; //二次故障描述
|
public String actualVisitTimeThird; //三次上门日
|
public String startTimeThird; //三次上门开始时间
|
public String endTimeThird; //三次上门结束时间
|
public String faultDescriptionThird; //三次故障描述
|
public String applicantType; //申请修理人类型
|
public String applicantId; //申请修理人编号
|
public String applyDate; //申请时间
|
public String repairOrderNo2FSEID; //报修子单所属FSE的ID
|
// 2022/4/6 zhangyuheng update start
|
public String RepairFinishDate; //修理品处理完成日
|
public String ApplicanterPhone; //处理人电话
|
public String CancelDate; //受理人取消报修日
|
// 2022/4/6 zhangyuheng update end
|
|
// 上线前 报修子单与修理上的相关字段都删除
|
public String responseResultsFirst; //上门应对结果(暂时注掉)
|
public String responseResultsSecond; //二次上门应对结果(暂时注掉)
|
public String responseResultsThird; //三次上门应对结果(暂时注掉)
|
public String cancellerType; //取消人类型
|
public String cancellerId; //取消人用户编号
|
public String cancelleRepairDate; //取消报修日
|
public String cancelReportReason; //取消报修原因
|
|
|
|
|
|
}
|
//设备信息
|
public class ApplyRepairInfo {
|
public String equipmentModel; //设备型号
|
public String equipmentCd; //机身编码(工程师)
|
public String responseResultDesc; //应对描述
|
public String processResult; //处理结果
|
}
|
//故障处理信息
|
public class problem {
|
public String dateReceiptQuestions; //投诉知悉日(Complaint Aware Date)
|
public String ifDeadHurt; //是否有死亡、伤害、感染
|
public String problemOccurred; //问题发生时间情况
|
public String problemOccurredSelect; //问题发生时间情况 其他
|
public String reportAdverseEvents; //医院有没有向政府机关报告不良事件或疑似不良事件
|
public String whatProject; //做的是哪个项目
|
public String operationOrExaminationName; //手术/检查名称
|
public String breakORFallOff; //是否有发生断裂或脱落
|
public String useFailProductFinish; //是否用该产品完成了手术/检查
|
public String supportingProducts; //配套使用产品
|
public String afterFailureInformation; //发现故障后,医院对患者的处理情况
|
public String delay15Min; //发现故障现象后,有延误15分钟以上的手术实施的情况发生吗
|
public String informationFrom; //信息是从医院的谁那里得到的
|
public String failureQInHospital; //在医院,故障发生的频率是多少
|
public String delayReportReason; //超时报告的理由
|
public String isProductFaultRelated; //是否与这次产品故障相关
|
}
|
//物流
|
public class logistics {
|
public String isOts; //是否使用ots
|
public String senderOrgCode; //送修机构代码
|
public String senderCompany; //送修机构名称
|
public String senderName; //送修人姓名
|
public String senderMobilePhone; //送修人手机
|
public String senderAddress; //送修人地址
|
public String recepientCompany; //接收机构名称
|
public String recepientName; //接收送修人姓名
|
public String recepientMobilePhone; //接收人手机
|
public String recepientAddress; //接收人地址
|
public String returnWayType; //返品方式
|
public String orderNumber; //送修物流单号
|
public String failureReason; //下单失败原因
|
public String logisticsSendDate; //送修物流发送日
|
|
public String returnedProvince; //deloitte-zhj 20230920 新增字段 返品所属省
|
public String returnedCity; //deloitte-zhj 20230920 新增字段 返品所属市
|
public String returnedPersonName; //deloitte-zhj 20230920 新增字段 返品人姓名
|
public String returnedPersonPhone; //deloitte-zhj 20230920 新增字段 返品人电话
|
public String returnedAddress; //deloitte-zhj 20230920 新增字段 返品地址
|
public String returnedCustomer; //deloitte-zhj 20230920 新增字段 返品客户
|
public String returnedZipCode; //deloitte-zhj 20230920 新增字段 返品邮编
|
// public String item0010; //备用字段1
|
// public String item0020; //备用字段2
|
// public String item0030; //备用字段3
|
// public String item0040; //备用字段4
|
// public String item0050; //备用字段5
|
}
|
@HttpPost
|
global static void doPost() {
|
// 取得接口传输内容
|
String strData = RestContext.request.requestBody.toString();
|
List < GeData > ges = (List < GeData > ) JSON.deserializeStrict(strData, List < GeData > .class);
|
if (ges == null) {
|
return;
|
}
|
BatchIF_Log__c iflog = new BatchIF_Log__c();
|
iflog.Type__c = LOG_TYPE;
|
iflog.ErrorLog__c = '';
|
iflog.Log__c = 'callout start\n';
|
BatchIF_Log__c rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, ges);
|
insert rowData;
|
if (String.isBlank(rowData.Log__c) == false) {
|
executefuture(rowData.Id);
|
}
|
// JSONを戻す
|
RestResponse res = RestContext.response;
|
res.addHeader('Content-Type', 'application/json');
|
res.statusCode = 200;
|
//String jsonResponse = '{"status": "Success", "Message":' + gedata + '}';
|
String jsonResponse = '{"status": "Success", "Message":"成功"}';
|
res.responseBody = Blob.valueOf(jsonResponse);
|
/*迁移ali sushanhu 20231017
|
//updata response toAWS 20220225 sushanhu start
|
NFMUtil.NFMResponse result = NFMUtil.getNFMResponse();
|
result.SFStatus=SFStatus;
|
result.SFMessage=SFMessage;
|
String jsonResponse =JSON.serialize(result);
|
system.debug('result---'+jsonResponse);
|
res.responseBody = blob.valueOf(jsonResponse);
|
//updata response toAWS 20220225 sushanhu end
|
*/
|
return;
|
}
|
@future(callout = true)
|
global static void executefuture(String rowData_Id) {
|
main(rowData_Id);
|
}
|
global static void main(String rowData_Id) {
|
BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id];
|
String logstr = ' start\n';
|
String logerr = '';
|
BatchIF_Log__c iflog = new BatchIF_Log__c();
|
iflog.Type__c = LOG_TYPE;
|
// iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
|
iflog.MessageGroupNumber__c = rowData.Name;
|
system.debug('zyhtest==========='+rowData.MessageGroupNumber__c+'=============='+rowData.Name);
|
iflog.Log__c = logstr;
|
iflog.ErrorLog__c = '';
|
String rowDataStr = NFMUtil.getRowDataStr(rowData);
|
List < GeData > itemMasterList = (List < GeData > ) JSON.deserialize(rowDataStr, List < GeData > .class);
|
if (itemMasterList == null || itemMasterList.size() == 0) {
|
return;
|
}
|
Savepoint sp = Database.setSavepoint();
|
/*List<RepairSubOrder__c> rsoList = [SELECT Id FROM RepairSubOrder__c WHERE Name = ged.repairOderInfo.repairOrderNo2];
|
if (rsoList.size() > 0) {
|
|
}
|
*/
|
try {
|
List < RepairSubOrder__c > repairList = new List < RepairSubOrder__c > ();
|
Map < String, GeData > gedMap = new Map < String, GeData > ();
|
List < String > managementCodeList = new List < String > (); //存放科室编码
|
List < String > rpersonList = new List < String > (); //存放报修人用户编码
|
List < String > canIdList = new List < String > (); //存放取消人用户编号
|
List < String > repairNoList = new List < String > (); //存放报修子单号
|
for (GeData ged: itemMasterList) {
|
String dataComplete = verify(ged);
|
if (!String.isBlank(dataComplete)) {
|
logstr += dataComplete;
|
logerr += '报修子单No['+ged.repairOderInfo.repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
gedMap.put(ged.repairOderInfo.repairOrderNo2, ged);
|
|
managementCodeList.add(ged.repairOderInfo.departmentCd);
|
// 报修人用户编码
|
if (String.isNotBlank(ged.repairOderInfo.repairApplyPerson)) {
|
rpersonList.add(ged.repairOderInfo.repairApplyPerson);
|
}
|
//申请修理人编号
|
if (String.isNotBlank(ged.repairOderInfo.applicantId)) {
|
// canIdList.add(ged.repairOderInfo.applicantId);
|
rpersonList.add(ged.repairOderInfo.applicantId);
|
|
}
|
// 受理人用户编号(经销商用户、社内用户)
|
if (String.isNotBlank(ged.repairOderInfo.receiverId)) {
|
rpersonList.add(ged.repairOderInfo.receiverId);
|
// canIdList.add(ged.repairOderInfo.receiverId);
|
}
|
canIdList.add(ged.repairOderInfo.repairOrderNo2FSEID);
|
}
|
if (gedMap.size() > 0) {
|
|
// 根据科室编码获取科室、战略科室、医院
|
Map < String, Account > accountMap = getAccountMap(managementCodeList);
|
//存放报修人用户编码,id
|
Map < String, Id > personMap = getContactMap(rpersonList);
|
//存放取消人用户编码,受理人id.申请修理人编号,报修子单所属FSE的ID,id
|
Map < String, User > canidMap = getUserMap(canIdList);
|
|
// 附件下载标记
|
Boolean attachmentDownloadFlg = false;
|
String repairOrderNo2Str = '报修子单No [ \n';
|
Map<String,RepairSubOrder__c> RsoMap = new Map<String,RepairSubOrder__c>();
|
for (String repairOrderNo2: gedMap.keySet()) {
|
GeData ged = gedMap.get(repairOrderNo2);
|
|
if (!accountMap.containsKey(ged.repairOderInfo.departmentCd)) {
|
logstr += ged.repairOderInfo.departmentCd + '该科室不存在,此条数据跳过!';
|
logerr += '报修子单No['+repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
if (String.isNotBlank(ged.repairOderInfo.repairApplyPerson) && !personMap.containsKey(ged.repairOderInfo.repairApplyPerson)) {
|
logstr += ged.repairOderInfo.repairApplyPerson + '报修人用户编码不存在,此条数据跳过';
|
logerr += '报修子单No['+repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
|
if (!personMap.containsKey(ged.repairOderInfo.receiverId)) {
|
logstr += ged.repairOderInfo.receiverId + '受理人用户编号不存在,此条数据跳过';
|
logerr += '报修子单No['+repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
|
if ('申请修理'.equals(ged.applyRepairInfo.processResult) && !personMap.containsKey(ged.repairOderInfo.applicantId)) {
|
logstr += ged.repairOderInfo.applicantId + '申请修理人编号不存在,此条数据跳过';
|
logerr += '报修子单No['+repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
if (!canidMap.containsKey(ged.repairOderInfo.repairOrderNo2FSEID)) {
|
logstr += ged.repairOderInfo.repairOrderNo2FSEID + '报修子单所属FSE的ID不存在,此条数据跳过';
|
logerr += '报修子单No['+repairOrderNo2+']\n' + logstr; //2022-07-11 zyh add
|
continue;
|
}
|
RepairSubOrder__c repair = new RepairSubOrder__c();
|
repair.RepairOrderNo__c = ged.repairOderInfo.repairOrderNo; //报修单号
|
repair.RepairSubOrderNo__c = ged.repairOderInfo.repairOrderNo2; //报修单子单号
|
repair.Name = ged.repairOderInfo.repairOrderNo2; //报修单名称
|
Account dep = accountMap.get(ged.repairOderInfo.departmentCd);
|
repair.Hospital__c = dep.Parent.ParentId; //报修医院编码
|
repair.StrategicDepartment__c = dep.ParentId; //战略科室
|
repair.Department__c = dep.Id; //报修科室编码
|
//XLIU-CFZ3AR LY 20220705 Start
|
system.debug('12121121'+dep.Province_formula__c);
|
repair.State__c = dep.Province_formula__c; //省
|
//XLIU-CFZ3AR LY 20220705 End
|
|
repair.RepairApplicant__c = personMap.get(ged.repairOderInfo.repairApplyPerson); //报修人用户编码
|
repair.RepairApplicantName__c = ged.repairOderInfo.repairApplicantName; //报修人姓名
|
repair.RepairApplicantTel__c = ged.repairOderInfo.repairApplyPersonTel; //报修人联系电话
|
repair.RepairSubOrderPost__c = ged.repairOderInfo.repairApplyType; //报修人岗位
|
repair.EquipmentCategory__c = ged.repairOderInfo.equipmentCategory; //设备大类
|
repair.AssetType__c = ged.repairOderInfo.assetType; //设备类型
|
repair.AssetCode__c = ged.repairOderInfo.equipmentCd; //机身编码
|
repair.FaultTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.faultDate); //故障发生日
|
repair.RepairTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.repairOrderTime); //报修时间
|
repair.FaultType__c = ged.repairOderInfo.faultType; //故障类型
|
repair.ProblemDescription__c = ged.repairOderInfo.problemDesc; //问题描述
|
repair.RepairSubOrderType__c = ged.repairOderInfo.repairSubOrderType; //报修单类型
|
repair.ResponseResultType__c = ged.repairOderInfo.responseResultType; //应对结果类型
|
|
repair.ReceiverType__c = ged.repairOderInfo.receiverType; //受理人类型
|
|
// repair.ReceiverFSE__c = canidMap.get(ged.repairOderInfo.receiverId).Id; //受理人(FSE)
|
repair.Receiver__c = personMap.get(ged.repairOderInfo.receiverId); //受理人
|
repair.ReceiverTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.receiverDate); //受理日
|
repair.PlannedVisitDay__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.plannedVisitDay); //计划上门日
|
repair.StartTimeFirst__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeFirst); //开始时间
|
repair.EndTimeFirst__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeThird); //结束时间
|
repair.FaultDescriptionFirst__c = ged.repairOderInfo.faultDescriptionFirst; //故障描述
|
repair.ActualVisitTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.actualVisitTimeSecond); //二次上门日--->二次计划上门日
|
repair.StartTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeSecond); //二次上门开始时间--->二次上门日
|
repair.EndTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeSecond); //二次上门结束时间
|
repair.FaultDescriptionSecond__c = ged.repairOderInfo.faultDescriptionSecond; //二次故障描述
|
repair.ActualVisitTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.actualVisitTimeThird); //三次上门日--->三次计划上门日
|
repair.StartTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeThird); //三次上门开始时间--->三次上门日
|
repair.EndTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeThird); //三次上门结束时间
|
repair.FaultDescriptionThird__c = ged.repairOderInfo.faultDescriptionThird; //三次故障描述
|
repair.ApplicantType__c = ged.repairOderInfo.applicantType; //申请修理人类型
|
//repair.RepairApplicantName_Encrypted__c =ged.repairOderInfo.repairApplicantNameEncrypted; //报修人姓名密文 add 20220214 //zhj 新方案改造 2022-12-09
|
//repair.RepairApplicantTel_Encrypted__c = ged.repairOderInfo.repairApplyPersonTelEncrypted;//保修人联系电话密文 add 20220214 //zhj 新方案改造 2022-12-09
|
//repair.AWS_Data_Id__c =ged.repairOderInfo.DataId;//AWS 存储凭证 add 20220214 /*迁移ali sushanhu 20231017
|
// repair.Applicant__c = canidMap.get(ged.repairOderInfo.applicantId).Id; //申请修理人编号
|
repair.Applicanter__c = personMap.get(ged.repairOderInfo.applicantId);//申请修理人编号
|
repair.ApplicationTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.applyDate); //申请时间
|
|
repair.Ownerid = canidMap.get(ged.repairOderInfo.repairOrderNo2FSEID).Id; //报修子单所属FSE的ID
|
repair.AssetModel__c = ged.applyRepairInfo.equipmentModel; //设备型号
|
repair.AirframeCodeEngineer__c = ged.applyRepairInfo.equipmentCd; //机身编码(工程师)
|
repair.ResponseResultDesc__c = ged.applyRepairInfo.responseResultDesc; //应对描述--->问题描述(工程师)
|
repair.ProcessResult__c = ged.applyRepairInfo.processResult; //处理结果
|
|
// 2022/4/6 zhangyuheng update start
|
repair.RepairFinishDate__c = NFMUtil.parseDateTimeStr2Date(ged.repairOderInfo.RepairFinishDate) ; //修理品处理完成日
|
repair.ApplicanterPhone__c = ged.repairOderInfo.ApplicanterPhone; //处理人电话
|
repair.CancelleRepairTime__c = NFMUtil.parseDateTimeStr2Date(ged.repairOderInfo.CancelDate); //受理人取消报修日
|
// repair.CancelleRepairTime__c = NFMUtil.parseStr2Date(ged.repairOderInfo.CancelDate); //受理人取消报修日
|
repair.RepairCancelReason__c = ged.repairOderInfo.cancelReportReason; //修理取消原因
|
// 2022/4/6 zhangyuheng update end
|
// 2023-02-20 zyh add start
|
repair.DateReceiptQuestions__c = NFMUtil.parseDateTimeStr2Date(ged.problem.dateReceiptQuestions); //投诉知悉日(Complaint Aware Date)
|
repair.IfDeadHurt__c = ged.problem.ifDeadHurt; //是否有死亡、伤害、感染
|
repair.ProblemOccurred__c = ged.problem.problemOccurred; //问题发生时间情况
|
repair.ProblemOccurredSelect__c = ged.problem.problemOccurredSelect; //问题发生时间情况 其他
|
repair.ReportAdverseEvents__c = ged.problem.reportAdverseEvents; //医院有没有向政府机关报告不良事件或疑似不良事件
|
repair.WhatProject__c = ged.problem.whatProject; //做的是哪个项目
|
repair.OperationOrExaminationName__c = ged.problem.operationOrExaminationName; //手术/检查名称
|
repair.BreakORFallOff__c = ged.problem.breakORFallOff; //是否有发生断裂或脱落
|
repair.UseFailProductFinish__c = ged.problem.useFailProductFinish; //是否用该产品完成了手术/检查
|
repair.SupportingProducts__c = ged.problem.supportingProducts; //配套使用产品
|
repair.AfterFailureInformation__c = ged.problem.afterFailureInformation; //发现故障后,医院对患者的处理情况
|
repair.Delay15Min__c = ged.problem.delay15Min; //发现故障现象后,有延误15分钟以上的手术实施的情况发生吗
|
repair.InformationFrom__c = ged.problem.informationFrom; //信息是从医院的谁那里得到的
|
repair.FailureQInHospital__c = ged.problem.failureQInHospital; //在医院,故障发生的频率是多少
|
repair.DelayReportReason__c = ged.problem.delayReportReason; //超时报告的理由
|
repair.IsProductFaultRelated__c = ged.problem.isProductFaultRelated; //是否与这次产品故障相关
|
if(String.isNotBlank(ged.logistics.isOts)){
|
repair.IsOts__c = ged.logistics.isOts; //是否使用ots
|
}
|
if(String.isNotBlank(ged.logistics.senderOrgCode)){
|
repair.SenderOrgCode__c = ged.logistics.senderOrgCode; //送修机构代码
|
}
|
if(String.isNotBlank(ged.logistics.senderOrgCode)){
|
repair.SenderCompany__c = ged.logistics.senderOrgCode; //送修机构名称
|
}
|
if(String.isNotBlank(ged.logistics.senderName)){
|
repair.SenderName__c = ged.logistics.senderName; //送修人姓 名
|
}
|
if(String.isNotBlank(ged.logistics.senderMobilePhone)){
|
repair.SenderMobilePhone__c = ged.logistics.senderMobilePhone; //送修人手机
|
}
|
if(String.isNotBlank(ged.logistics.senderAddress)){
|
repair.SenderAddress__c = ged.logistics.senderAddress; //送修人地址
|
}
|
if(String.isNotBlank(ged.logistics.recepientCompany)){
|
repair.RecepientCompany__c = ged.logistics.recepientCompany; //接收机构名称
|
}
|
if(String.isNotBlank(ged.logistics.recepientName)){
|
repair.RecepientName__c = ged.logistics.recepientName; //接收送修人姓名
|
}
|
if(String.isNotBlank(ged.logistics.recepientMobilePhone)){
|
repair.RecepientMobilePhone__c = ged.logistics.recepientMobilePhone; //接收人手机
|
}
|
if(String.isNotBlank(ged.logistics.recepientAddress)){
|
repair.RecepientAddress__c = ged.logistics.recepientAddress; //接收人地址
|
}
|
if(String.isNotBlank(ged.logistics.returnWayType)){
|
repair.ReturnWayType__c = ged.logistics.returnWayType; //返品方式
|
}
|
if(String.isNotBlank(ged.logistics.orderNumber)){
|
repair.OrderNumber__c = ged.logistics.orderNumber; //送修物流单号
|
}
|
//deloitte-zhj 20230920 PIPL 新增返品字段 start
|
if(String.isNotBlank(ged.logistics.returnedProvince)){
|
repair.ReturnedProvince__c = ged.logistics.returnedProvince; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedCity)){
|
repair.ReturnedCity__c = ged.logistics.returnedCity; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedPersonName)){
|
repair.ReturnedPersonName__c = ged.logistics.returnedPersonName; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedPersonPhone)){
|
repair.ReturnedPersonPhone__c = ged.logistics.returnedPersonPhone; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedAddress)){
|
repair.ReturnedAddress__c = ged.logistics.returnedAddress; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedCustomer)){
|
repair.ReturnedCustomer__c = ged.logistics.returnedCustomer; //送修物流单号
|
}
|
if(String.isNotBlank(ged.logistics.returnedZipCode)){
|
repair.ReturnedZipCode__c = ged.logistics.returnedZipCode; //送修物流单号
|
}
|
//deloitte-zhj 20230920 PIPL 新增返品字段 end
|
System.debug(ged.logistics.orderNumber + '=========OTS');
|
System.debug(ged.logistics + '=========OTS1');
|
repair.FailureReason__c = ged.logistics.failureReason; //下单失败原因
|
repair.LogisticsSendDate__c = NFMUtil.parseDateTimeStr2Date(ged.logistics.logisticsSendDate); //送修物流发送日
|
repair.Item0010__c = ged.item0010; //备用字段1
|
repair.Item0020__c = ged.item0020; //备用字段2
|
repair.Item0030__c = ged.item0030; //备用字段3
|
repair.Item0040__c = ged.item0040; //备用字段4
|
repair.Item0050__c = ged.item0050; //备用字段5
|
// 2023-02-20 zyh add end
|
//LLIU-CG53S9 20220715 LY start
|
if ('问题已解决'.equals(ged.applyRepairInfo.processResult) ||'需做质量判定'.equals(ged.applyRepairInfo.processResult) ||'用户选择不修理'.equals(ged.applyRepairInfo.processResult)) {
|
//LLIU-CG53S9 20220715 LY end
|
// repair.Status__c = '关闭';
|
repair.Status__c = '已完成'; // 2022/4/6 zhangyuheng
|
} else {
|
repair.Status__c = '待处理';
|
|
}
|
// 附件信息
|
repair.AttachmentLink__c = ged.repairOderInfo.problemPhotofile;
|
String attachmentName = ged.repairOderInfo.problemPhotoName;
|
|
if (ged.repairOderInfo != null && String.isNotBlank(ged.repairOderInfo.problemPhotofile)) {
|
repair.AttachmentDownload__c = true;
|
attachmentDownloadFlg = true;
|
if (String.isBlank(attachmentName) || (String.isNotBlank(attachmentName) && !attachmentName.contains('.zip'))){
|
attachmentName = '附件.zip';
|
}
|
|
}
|
repair.AttachmentName__c = attachmentName;
|
repairOrderNo2Str += repairOrderNo2 + '\n';
|
repairList.add(repair);
|
repairNoList.add(ged.repairOderInfo.repairOrderNo2);
|
RsoMap.put(ged.repairOderInfo.repairOrderNo2,repair);
|
}
|
// 2022/4/6 zhangyuheng update start
|
List<RepairSubOrder__c> upList = new List<RepairSubOrder__c>();
|
List<RepairSubOrder__c> repairSOList1 = [SELECT Id,RepairSubOrderNo__c,DateReceiptQuestions__c,
|
IfDeadHurt__c,
|
ProblemOccurred__c,
|
ProblemOccurredSelect__c,
|
ReportAdverseEvents__c,
|
WhatProject__c,
|
OperationOrExaminationName__c,
|
BreakORFallOff__c,
|
UseFailProductFinish__c,
|
SupportingProducts__c,
|
AfterFailureInformation__c,
|
Delay15Min__c,
|
InformationFrom__c,
|
FailureQInHospital__c,
|
DelayReportReason__c,
|
IsProductFaultRelated__c,
|
// 2023-04-25 zyh add 小程序新加放开 start
|
SenderMobilePhone__c,
|
SenderName__c,
|
SenderAddress__c,
|
RecepientCompany__c,
|
ReturnWayType__c,
|
LogisticsSendDate__c
|
// 2023-04-25 zyh add 小程序新加放开 end
|
,Status__c
|
FROM RepairSubOrder__c WHERE RepairSubOrderNo__c in: repairNoList];
|
if (repairSOList1.size() > 0) {
|
for(RepairSubOrder__c rso: repairSOList1){
|
if(RsoMap.containsKey(rso.RepairSubOrderNo__c)){
|
RepairSubOrder__c temp = new RepairSubOrder__c();
|
temp = RsoMap.get(rso.RepairSubOrderNo__c);
|
temp.Id = rso .Id;
|
if(rso.Status__c != '已完成' || rso.Status__c != '待处理'){
|
temp.Status__c = rso.Status__c;
|
}
|
upList.add(temp);
|
}
|
}
|
logstr += repairOrderNo2Str + ']-已存在';
|
update upList;
|
System.debug(repairSOList1[0].Id + '===' + repairSOList1[0].DateReceiptQuestions__c);
|
logstr += repairOrderNo2Str + '更新完成, 更新总数为:' + repairSOList1.size() + '\n' + repairSOList1;
|
}
|
// if (repairList.size() > 0) {==== 2022/4/6 zhangyuheng注释掉
|
else {
|
// 2022/4/6 zhangyuheng update end
|
insert repairList;
|
repairOrderNo2Str += ' ]\n';
|
logstr += repairOrderNo2Str + '新增完成, 新增总数数为:' + repairList.size() + '\n';
|
if (attachmentDownloadFlg) {
|
NFM609Schedule.assignOneMinute('RepairSubOrder__c');
|
}
|
|
}
|
}
|
logstr += 'End\n';
|
rowData.retry_cnt__c = 0;
|
} catch (Exception ex) {
|
Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
|
// エラーが発生した場合
|
Database.rollback(sp);
|
logstr += '\n' + ex.getMessage();
|
iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
|
if (!Test.isRunningTest()) {
|
rowData = NFMUtil.LogAutoSend(rowData, ex, null);
|
}
|
}
|
rowData.MessageGroupNumber__c = rowData.Name;
|
update rowData;
|
iflog.Log__c = logstr;
|
iflog.ErrorLog__c = logerr;//2022-07-11 zyh add
|
insert iflog;
|
}
|
/**
|
* [getAccountMap description] 根据科室编码查找科室,与科室对应的战略科室和医院
|
* @param managementCodeList [可数的管理编码]
|
* @return [科室信息]
|
*/
|
private static Map < String, Account > getAccountMap(List < String > managementCodeList) {
|
List < Account > accountList =
|
[SELECT id, Management_Code__c, ParentId, Parent.ParentId
|
//XLIU-CFZ3AR LY 20220705 Start
|
,Province_formula__c
|
//XLIU-CFZ3AR LY 20220705 End
|
FROM Account
|
WHERE Management_Code__c
|
IN: managementCodeList
|
];
|
|
Map < String, Account > hosMap = new Map < String, Account > ();
|
for (Account ac: accountList) {
|
hosMap.put(ac.Management_Code__c, ac);
|
}
|
return hosMap;
|
}
|
/**
|
* [获取系统里的联系人]
|
* @param rpersonList [报修人/申请人/受理人的管理人员编号或对应用户的员工编码]
|
* @return [联系人信息]
|
*/
|
private static Map < String, Id > getContactMap(List < String > rpersonList) {
|
List < Contact > couList = [
|
SELECT id, CManageCode__c,Employee_No_manual__c
|
FROM Contact
|
WHERE CManageCode__c IN: rpersonList OR Employee_No_manual__c IN:rpersonList];
|
Map < String, Id > contactMap = new Map < String, Id > ();
|
for (Contact con: couList) {
|
contactMap.put(con.CManageCode__c, con.Id);
|
if (String.isNotBlank(con.Employee_No_manual__c)) {
|
contactMap.put(con.Employee_No_manual__c, con.Id);
|
}
|
}
|
return contactMap;
|
}
|
/**
|
* [获取系统里的用户]
|
* @param canIdList [description]
|
* @return [description]
|
*/
|
private static Map < String, User > getUserMap(List < String > canIdList) {
|
List < User > userList =
|
[SELECT id, Employee_No__c, Contact.CManageCode__c,IsActive,Contact.Employee_No_manual__c
|
FROM User
|
WHERE Employee_No__c IN: canIdList OR Contact.CManageCode__c IN: canIdList OR Contact.Employee_No_manual__c IN:canIdList
|
];
|
Map < String, User > result = new Map < String, User > ();
|
for (User u: userList) {
|
if (String.isNotBlank(u.Contact.CManageCode__c)) {
|
result.put(u.Contact.CManageCode__c, u);
|
}
|
if (String.isNotBlank(u.Contact.Employee_No_manual__c)) {
|
result.put(u.Contact.Employee_No_manual__c, u);
|
}
|
result.put(u.Employee_No__c, u);
|
}
|
|
return result;
|
}
|
|
private static String verify(GeData ged) {
|
String result = '';
|
String repairOrderNo2 = '';
|
if (ged.repairOderInfo == null) {
|
result += ' DataError: repairOderInfo is null!\n';
|
} else {
|
if (ged.repairOderInfo.repairOrderNo == null) {
|
result += ' DataError: 报修单 [ repairOrderNo ] is null!\n';
|
}
|
if (ged.repairOderInfo.repairOrderNo2 == null) {
|
result += ' DataError: 报修子单 [ repairOrderNo2 ] is null!\n';
|
} else {
|
repairOrderNo2 = '报修子单 [ ' + ged.repairOderInfo.repairOrderNo2 + ' ]\n';
|
}
|
if (ged.repairOderInfo.departmentCd == null) {
|
result += ' DataError: 报修科室编码 [ departmentCd ] is null!\n';
|
}
|
|
if (ged.repairOderInfo.faultDate == null) {
|
result += ' DataError: 故障发生日 [ faultDate ] is null!\n';
|
}
|
if (ged.repairOderInfo.repairOrderTime == null) {
|
result += ' DataError: 报修时间 [ repairOrderTime ] is null!\n';
|
}
|
/*if (ged.repairOderInfo.faultType == null) {
|
result += ' DataError: 故障类型 [ faultType ] is null!\n';
|
}*/ // 2023-3-20 zyh add 小程序注释
|
if (ged.repairOderInfo.repairSubOrderType == null) {
|
result += ' DataError: 报修单类型 [ repairSubOrderType ] is null!\n';
|
}
|
|
if (String.isBlank(ged.repairOderInfo.receiverType)) {
|
result += ' DataError: 受理人类型 [ receiverType ] is null!\n';
|
}
|
if (String.isBlank(ged.repairOderInfo.receiverId)) {
|
result += ' DataError: 受理人用户编号 [ receiverId ] is null!\n';
|
}
|
if (String.isBlank(ged.repairOderInfo.receiverDate)) {
|
result += ' DataError: 受理日 [ receiverDate ] is null!\n';
|
}
|
if (ged.repairOderInfo.repairOrderNo2FSEID == null) {
|
result += ' DataError: 报修子单所属FSE的ID [ repairOrderNo2FSEID ] is null!\n';
|
}
|
}
|
if (ged.applyRepairInfo == null) {
|
result += ' DataError: applyRepairInfo is null!\n';
|
} else {
|
if (String.isBlank(ged.applyRepairInfo.equipmentModel)) {
|
result += ' DataError: 设备型号 [ equipmentModel ] is null!\n';
|
}
|
|
if (String.isBlank(ged.applyRepairInfo.processResult)) {
|
result += ' DataError: 处理结果 [ processResult ] is null!\n';
|
} else {
|
if ('申请修理'.equals(ged.applyRepairInfo.processResult)) {
|
if (String.isBlank(ged.repairOderInfo.applicantId)) {
|
result += ' DataError: 申请修理人编号 [ applicantId ] is null!\n';
|
}
|
if (String.isBlank(ged.repairOderInfo.applyDate)) {
|
result += ' DataError: 申请时间 [ applyDate ] is null!\n';
|
}
|
}
|
}
|
}
|
|
if (String.isNotBlank(repairOrderNo2) && String.isNotBlank(result)) {
|
result = repairOrderNo2 + result;
|
}
|
return result;
|
}
|
|
|
}
|