@isTest
|
private class NFM008RestTest {
|
|
static testMethod void resend_test() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
|
Asset ast = new Asset();
|
ast.Name = 'NFM008Ast1';
|
ast.Product2Id = prd.Id;
|
ast.SerialNumber = '2577010001675';
|
ast.Hospital__c = accList[0].Id;
|
ast.Department_Class__c = accList[1].Id;
|
ast.AccountId = accList[2].Id;
|
insert ast;
|
|
User loginUser = [Select Id, Alias, Province__c from User where Id = : UserInfo.getUserId()];
|
loginUser.Batch_User__c = true;
|
update loginUser;
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '21';
|
|
// update
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001675';
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoI.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
List<Asset> astList = [select Id, Product2.ProductCode, SerialNumber, Product_Serial_No__c,
|
Product2Id, AccountId, Department_Class__c, Hospital__c,
|
Posting_Date__c, InstallDate, SLMark__c,
|
Guarantee_period_for_products__c, Installation_Site__c
|
from Asset
|
where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
System.assertEquals(1, astList.size());
|
if (astList.size() == 1) {
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoH.PostingDate), astList[0].Posting_Date__c);
|
System.assertEquals(accList[2].Id, astList[0].AccountId);
|
System.assertEquals(accList[1].Id, astList[0].Department_Class__c);
|
System.assertEquals(accList[0].Id, astList[0].Hospital__c);
|
System.assertEquals(InstallationInfoI.MaterialNo, astList[0].Product2.ProductCode);
|
System.assertEquals(InstallationInfoI.SerialNo, astList[0].SerialNumber);
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI.InstallationDateI), astList[0].InstallDate);
|
System.assertEquals(InstallationInfoI.SLMark, astList[0].SLMark__c);
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI.GuaranteePeriod), astList[0].Guarantee_period_for_products__c);
|
//System.assertEquals(InstallationInfoI.Location, astList[0].Installation_Site__c);
|
}
|
|
List<BatchIF_Log__c> rowbl = [Select Id, Log__c,
|
ErrorLog__c
|
from BatchIF_Log__c
|
where RowDataFlg__c = true
|
and Type__c = 'NFM008'
|
order by CreatedDate desc];
|
System.assertEquals(1, rowbl.size());
|
rowbl[0].retry_cnt__c = 1;
|
update rowbl;
|
|
//NFM008Rest.execute(rowbl[0].id);
|
NFM008Rest.main(rowbl[0].id);
|
|
List<BatchIF_Log__c> bl = [Select Id, Is_Error__c,
|
Type__c, Log__c, ErrorLog__c, retry_cnt__c
|
from BatchIF_Log__c
|
where Id = :rowbl[0].id];
|
System.assertEquals(1, bl.size());
|
System.assertEquals(0, bl[0].retry_cnt__c);
|
|
}
|
|
static testMethod void testNFM008_void() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
// null
|
//NFM008Rest.NFM008(null);
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringをセットしない
|
//NFM008Rest.NFM008(InstallationInformation);
|
//BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
//if (String.isBlank(rowData.Log__c) == false)
|
// NFM008Rest.executefuture(rowData.Id);
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '01';
|
// InstallationInfoHをセットしない
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
// InstallationInfoIをセットしない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '02';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
// 病院と診療科の管理コードをセットしない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '03';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
InstallationInfoH.CompanyCode = 'NFM008TestABCD';
|
InstallationInfoH.DepartmentCode = 'NFM008TestDCBA';
|
// 病院と診療科の管理コードが存在しない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '04';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
// 診療科の管理コードが存在しない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '05';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
// InstallationInfoIの必須項目をセットしない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '06';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
// 必須項目をセットしない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '08';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
|
InstallationInfoI.MaterialNo = 'NFM008TstPrd1234';
|
InstallationInfoI.SerialNo = '2577010001675';
|
// 商品コードが存在しない
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '07';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
|
Asset[] rslts = [select Id from Asset];
|
System.assertEquals(0, rslts.size());
|
}
|
|
static testMethod void testNFM008_insert() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
|
Asset ast = new Asset();
|
ast.Name = 'NFM008Ast1';
|
ast.Product2Id = prd.Id;
|
ast.SerialNumber = '2577010001675';
|
ast.Hospital__c = accList[0].Id;
|
ast.Department_Class__c = accList[1].Id;
|
ast.AccountId = accList[2].Id;
|
insert ast;
|
|
Asset ast2 = new Asset();
|
ast2.Name = 'NFM008Ast1';
|
ast2.Product2Id = prd.Id;
|
ast2.SerialNumber = '2577010001676';
|
ast2.Hospital__c = accList[0].Id;
|
ast2.Department_Class__c = accList[1].Id;
|
ast2.AccountId = accList[2].Id;
|
insert ast2;
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI1 = new NFM008Rest.InstallationInfoI();
|
NFM008Rest.InstallationInfoI InstallationInfoI2 = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI1, InstallationInfoI2};
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '11';
|
|
// insert
|
InstallationInfoH.PostingDate = '20110112';
|
InstallationInfoH.CompanyCode = '0' + accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = '0' + accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '2';
|
InstallationInfoI1.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI1.SerialNo = '2577010001675';
|
InstallationInfoI1.InstallationDateI = '20110118';
|
InstallationInfoI1.SLMark = 'S';
|
InstallationInfoI1.GuaranteePeriod = '20121021';
|
InstallationInfoI1.Location = '门诊';
|
InstallationInfoI1.ReturnExchangeReplenishMark = '2';
|
InstallationInfoI1.PurposeOfAdvice = '2';
|
InstallationInfoI2.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI2.SerialNo = '2577010001676';
|
InstallationInfoI2.InstallationDateI = '20110118';
|
InstallationInfoI2.SLMark = 'S';
|
InstallationInfoI2.GuaranteePeriod = '20121021';
|
InstallationInfoI2.Location = '门诊';
|
InstallationInfoI2.ReturnExchangeReplenishMark = '2';
|
InstallationInfoI2.PurposeOfAdvice = '2';
|
|
System.Test.startTest();
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
|
String productSerialNo = InstallationInfoI1.MaterialNo + ':' + InstallationInfoI1.SerialNo;
|
List<Asset> astList = [select Id, Product2.ProductCode, SerialNumber, Product_Serial_No__c,
|
Product2Id, AccountId, Department_Class__c, Hospital__c,
|
Posting_Date__c, InstallDate, SLMark__c,
|
Guarantee_period_for_products__c, Installation_Site__c
|
from Asset
|
where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
System.assertEquals(1, astList.size());
|
//if (astList.size() == 1) {
|
// System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoH.PostingDate), astList[0].Posting_Date__c);
|
// System.assertEquals(accList[2].Id, astList[0].AccountId);
|
// System.assertEquals(accList[1].Id, astList[0].Department_Class__c);
|
// System.assertEquals(accList[0].Id, astList[0].Hospital__c);
|
// System.assertEquals(InstallationInfoI1.MaterialNo, astList[0].Product2.ProductCode);
|
// System.assertEquals(InstallationInfoI1.SerialNo, astList[0].SerialNumber);
|
// System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI1.InstallationDateI), astList[0].InstallDate);
|
// System.assertEquals(InstallationInfoI1.SLMark, astList[0].SLMark__c);
|
// System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI1.GuaranteePeriod), astList[0].Guarantee_period_for_products__c);
|
// System.assertEquals(InstallationInfoI1.Location, astList[0].Installation_Site__c);
|
//}
|
productSerialNo = InstallationInfoI2.MaterialNo + ':' + InstallationInfoI2.SerialNo;
|
astList = [select Id, Product2.ProductCode, SerialNumber, Product_Serial_No__c,
|
Product2Id, AccountId, Department_Class__c, Hospital__c,
|
Posting_Date__c, InstallDate, SLMark__c,
|
Guarantee_period_for_products__c, Installation_Site__c
|
from Asset
|
where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
System.assertEquals(1, astList.size());
|
}
|
|
static testMethod void testNFM008_update() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
|
Asset ast = new Asset();
|
ast.Name = 'NFM008Ast1';
|
ast.Product2Id = prd.Id;
|
ast.SerialNumber = '2577010001675';
|
ast.Hospital__c = accList[0].Id;
|
ast.Department_Class__c = accList[1].Id;
|
ast.AccountId = accList[2].Id;
|
insert ast;
|
|
User loginUser = [Select Id, Alias, Province__c from User where Id = : UserInfo.getUserId()];
|
loginUser.Batch_User__c = true;
|
update loginUser;
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '21';
|
|
// update
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001675';
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoI.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
List<Asset> astList = [select Id, Product2.ProductCode, SerialNumber, Product_Serial_No__c,
|
Product2Id, AccountId, Department_Class__c, Hospital__c,
|
Posting_Date__c, InstallDate, SLMark__c,
|
Guarantee_period_for_products__c, Installation_Site__c
|
from Asset
|
where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
System.assertEquals(1, astList.size());
|
if (astList.size() == 1) {
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoH.PostingDate), astList[0].Posting_Date__c);
|
System.assertEquals(accList[2].Id, astList[0].AccountId);
|
System.assertEquals(accList[1].Id, astList[0].Department_Class__c);
|
System.assertEquals(accList[0].Id, astList[0].Hospital__c);
|
System.assertEquals(InstallationInfoI.MaterialNo, astList[0].Product2.ProductCode);
|
System.assertEquals(InstallationInfoI.SerialNo, astList[0].SerialNumber);
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI.InstallationDateI), astList[0].InstallDate);
|
System.assertEquals(InstallationInfoI.SLMark, astList[0].SLMark__c);
|
System.assertEquals(NFMUtil.parseStr2Date(InstallationInfoI.GuaranteePeriod), astList[0].Guarantee_period_for_products__c);
|
//System.assertEquals(InstallationInfoI.Location, astList[0].Installation_Site__c);
|
}
|
}
|
|
static testMethod void testNFM008_delete() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
User loginUser = [Select Id, Alias, Province__c from User where Id = : UserInfo.getUserId()];
|
loginUser.Batch_User__c = true;
|
update loginUser;
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '31';
|
|
// InstallationInfoI.PurposeOfAdvice = 1
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '3';
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001675';
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoI.PurposeOfAdvice = '1';
|
|
//List<Asset> astList = [select Id, Return_Flag__c from Asset where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
//System.assertEquals(1, astList.size());
|
//System.assertEquals(false, astList[0].Return_Flag__c);
|
|
System.Test.startTest();
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
List<Asset> astList = [select Id, Return_Flag__c from Asset where Product_Serial_No__c = :productSerialNo and Information_From__c <> '失单'];
|
System.assertEquals(1, astList.size());
|
//System.assertEquals(true, astList[0].Return_Flag__c);
|
}
|
|
static testMethod void testNFM008_return() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
// テストデータ
|
|
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '41';
|
|
// InstallationInfoI.ReturnExchangeReplenishMark = 1 にてdelete
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '3';
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001676';
|
// InstallationInfoI.SerialNo = 'assnew';
|
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '1';
|
InstallationInfoH.PurposeOfAdvice = '3';
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
//List<Asset> astList = [select Id, Return_Flag__c from Asset where Product_Serial_No__c = :productSerialNo];
|
//System.assertEquals(1, astList.size());
|
//System.assertEquals(false, astList[0].Return_Flag__c);
|
|
System.Test.startTest();
|
//NFM008Rest.NFM008(InstallationInformation);
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
System.Test.stopTest();
|
List<Asset> astList = [select Id, Return_Flag__c from Asset where Product_Serial_No__c = :productSerialNo];
|
System.assertEquals(1, astList.size());
|
//System.assertEquals(true, astList[0].Return_Flag__c);
|
|
// 再度 InstallationInfoI.ReturnExchangeReplenishMark = 1 にてdelete
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '42';
|
//NFM008Rest.NFM008(InstallationInformation);
|
rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false)
|
NFM008Rest.executefuture(rowData.Id);
|
astList = [select Id, Return_Flag__c from Asset where Product_Serial_No__c = :productSerialNo];
|
System.assertEquals(1, astList.size());
|
//System.assertEquals(true, astList[0].Return_Flag__c);
|
}
|
|
|
|
// 报表可视化开发估时20210617 精琢科技 zxk 2021-08-26 start
|
|
static testMethod void testNFM008_newUpdate() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
//签收单最终用户记录类型
|
List<RecordType> recordTypeList = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (recordTypeList.size() == 0) {
|
return;
|
}
|
|
// 省
|
Address_Level__c al = new Address_Level__c();
|
al.Name = '東京';
|
al.Level1_Code__c = 'CN-99';
|
al.Level1_Sys_No__c = '999999';
|
upsert al;
|
// 市
|
Address_Level2__c al2 = new Address_Level2__c();
|
al2.Level1_Code__c = 'CN-99';
|
al2.Level1_Sys_No__c = '999999';
|
al2.Level1_Name__c = '東京';
|
al2.Name = '渋谷区';
|
al2.Level2_Code__c = 'CN-9999';
|
al2.Level2_Sys_No__c = '9999999';
|
al2.Address_Level__c = al.id;
|
upsert al2;
|
// 产品
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
upsert prd;
|
//客户医院
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
//签收单最终用户记录类型
|
Account recordType = new Account();
|
recordType.RecordTypeId = recordTypeList[0].Id;
|
recordType.Name = '*';
|
recordType.Department_Class_Label__c = '消化科';
|
recordType.ParentId = company.Id;
|
recordType.Hospital_Department_Class__c = company.Id;
|
upsert recordType;
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//询价
|
Opportunity opp = new Opportunity(
|
Name = 'testOpp1',
|
StageName = '引合',
|
CloseDate = Date.today(),
|
AccountId = depart.Id,
|
Trade__c = '内貿',
|
|
|
Sales_Root__c = '販売店',
|
Competitor__c = 'A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
upsert opp;
|
|
//注残
|
Statu_Achievements__c statuAchievements = new Statu_Achievements__c(
|
Name = '2021082013',
|
Opportunity__c = opp.id,
|
DeliveryDate__c = Date.today(),
|
ContractNO__c = 'ContractNO1',
|
ContractAmount__c = 1000
|
);
|
upsert statuAchievements;
|
//发货DN
|
Statu_Achievements_DN__c statuAchievementsDN = new Statu_Achievements_DN__c();
|
statuAchievementsDN.Statu_Achievements__c = statuAchievements.Id;
|
statuAchievementsDN.Name = '2021082049';
|
statuAchievementsDN.endUser__c = recordType.Id;
|
upsert statuAchievementsDN;
|
//保有设备
|
Asset assnew = new Asset(Asset_Owner__c = 'Olympus');
|
assnew.RecordTypeId = System.Label.Asset_RecordType;
|
assnew.SerialNumber = '2577010001678';
|
assnew.Name = 'assnew';
|
assnew.Product2Id = prd.Id;
|
assnew.Hospital__c = company.Id;
|
assnew.Department_Class__c = section.Id;
|
assnew.AccountId = depart.Id;
|
assnew.Asset_Owner__c = '医院资产';
|
assnew.Quantity = 1;
|
assnew.Status = '有库存';
|
assnew.Manage_type__c = '个体管理';
|
assnew.Internal_asset_location__c = '北京 备品中心';
|
assnew.Loaner_accsessary__c = true;
|
assnew.Delete_Flag__c = false;
|
assnew.Freeze_sign__c = false;
|
assnew.Out_of_wh__c = 0;
|
assnew.CIC_call_back_check__c = true;
|
upsert assnew;
|
//发货DN明细
|
Statu_Achievements_DN_details__c statuAchievementsDNDetails = new Statu_Achievements_DN_details__c();
|
statuAchievementsDNDetails.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
statuAchievementsDNDetails.Name = 'z1c200000292wse';
|
statuAchievementsDNDetails.asset__c = assnew.Id;
|
upsert statuAchievementsDNDetails;
|
|
|
//新建电子签收单
|
eSignForm__c eSignForm = new eSignForm__c();
|
eSignForm.Statu_Achievements__c = statuAchievements.Id;
|
eSignForm.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
eSignForm.Name = '::测试电子签收单';
|
upsert eSignForm;
|
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '41';
|
|
// InstallationInfoI.ReturnExchangeReplenishMark = 1 にてdelete
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '3';
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001678';
|
// InstallationInfoI.SerialNo = 'assnew';
|
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoH.PurposeOfAdvice = '3';
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
System.Test.startTest();
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false) {
|
NFM008Rest.executefuture(rowData.Id);
|
}
|
System.Test.stopTest();
|
}
|
|
static testMethod void testNFM008_newUpdate01() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
//签收单最终用户记录类型
|
List<RecordType> recordTypeList = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
|
if (recordTypeList.size() == 0) {
|
return;
|
}
|
|
// 省
|
Address_Level__c al = new Address_Level__c();
|
al.Name = '東京';
|
al.Level1_Code__c = 'CN-99';
|
al.Level1_Sys_No__c = '999999';
|
upsert al;
|
// 市
|
Address_Level2__c al2 = new Address_Level2__c();
|
al2.Level1_Code__c = 'CN-99';
|
al2.Level1_Sys_No__c = '999999';
|
al2.Level1_Name__c = '東京';
|
al2.Name = '渋谷区';
|
al2.Level2_Code__c = 'CN-9999';
|
al2.Level2_Sys_No__c = '9999999';
|
al2.Address_Level__c = al.id;
|
upsert al2;
|
// 产品
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
upsert prd;
|
//客户医院
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
//签收单最终用户记录类型
|
Account recordType = new Account();
|
recordType.RecordTypeId = recordTypeList[0].Id;
|
recordType.Name = '*';
|
recordType.Department_Class_Label__c = '消化科';
|
recordType.ParentId = company.Id;
|
recordType.Hospital_Department_Class__c = company.Id;
|
upsert recordType;
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//询价
|
Opportunity opp = new Opportunity(
|
Name = 'testOpp1',
|
StageName = '引合',
|
CloseDate = Date.today(),
|
AccountId = depart.Id,
|
Trade__c = '内貿',
|
|
|
|
Sales_Root__c = '販売店',
|
Competitor__c = 'A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
upsert opp;
|
|
//注残
|
Statu_Achievements__c statuAchievements = new Statu_Achievements__c(
|
Name = '2021082013',
|
Opportunity__c = opp.id,
|
DeliveryDate__c = Date.today(),
|
ContractNO__c = 'ContractNO1',
|
ContractAmount__c = 1000
|
);
|
upsert statuAchievements;
|
//发货DN
|
Statu_Achievements_DN__c statuAchievementsDN = new Statu_Achievements_DN__c();
|
statuAchievementsDN.Statu_Achievements__c = statuAchievements.Id;
|
statuAchievementsDN.Name = '2021082049';
|
statuAchievementsDN.endUser__c = recordType.Id;
|
upsert statuAchievementsDN;
|
//保有设备
|
Asset assnew = new Asset(Asset_Owner__c = 'Olympus');
|
assnew.RecordTypeId = System.Label.Asset_RecordType;
|
assnew.SerialNumber = '2577010001678';
|
assnew.Name = 'assnew';
|
assnew.Product2Id = prd.Id;
|
assnew.Hospital__c = company.Id;
|
assnew.Department_Class__c = section.Id;
|
assnew.AccountId = depart.Id;
|
assnew.Asset_Owner__c = '医院资产';
|
assnew.Quantity = 1;
|
assnew.Status = '有库存';
|
assnew.Manage_type__c = '个体管理';
|
assnew.Internal_asset_location__c = '北京 备品中心';
|
assnew.Loaner_accsessary__c = true;
|
assnew.Delete_Flag__c = false;
|
assnew.Freeze_sign__c = false;
|
assnew.Out_of_wh__c = 0;
|
assnew.CIC_call_back_check__c = true;
|
upsert assnew;
|
//发货DN明细
|
Statu_Achievements_DN_details__c statuAchievementsDNDetails = new Statu_Achievements_DN_details__c();
|
statuAchievementsDNDetails.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
statuAchievementsDNDetails.Name = 'z1c200000292wse';
|
statuAchievementsDNDetails.asset__c = assnew.Id;
|
upsert statuAchievementsDNDetails;
|
|
|
//新建电子签收单
|
eSignForm__c eSignForm = new eSignForm__c();
|
eSignForm.Statu_Achievements__c = statuAchievements.Id;
|
eSignForm.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
eSignForm.Name = '::测试电子签收单';
|
upsert eSignForm;
|
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '41';
|
|
// InstallationInfoI.ReturnExchangeReplenishMark = 1 にてdelete
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '3';
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001678';
|
// InstallationInfoI.SerialNo = 'assnew';
|
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoH.PurposeOfAdvice = '3';
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
System.Test.startTest();
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false) {
|
NFM008Rest.executefuture(rowData.Id);
|
}
|
System.Test.stopTest();
|
|
|
|
|
}
|
|
static testMethod void testNFM008_newUpdate02() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
//签收单最终用户记录类型
|
List<RecordType> recordTypeList = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (recordTypeList.size() == 0) {
|
return;
|
}
|
|
// 省
|
Address_Level__c al = new Address_Level__c();
|
al.Name = '東京';
|
al.Level1_Code__c = 'CN-99';
|
al.Level1_Sys_No__c = '999999';
|
upsert al;
|
// 市
|
Address_Level2__c al2 = new Address_Level2__c();
|
al2.Level1_Code__c = 'CN-99';
|
al2.Level1_Sys_No__c = '999999';
|
al2.Level1_Name__c = '東京';
|
al2.Name = '渋谷区';
|
al2.Level2_Code__c = 'CN-9999';
|
al2.Level2_Sys_No__c = '9999999';
|
al2.Address_Level__c = al.id;
|
upsert al2;
|
// 产品
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'NFM008Prd1';
|
prd.ProductCode = 'NFM008Prd1';
|
prd.Name = 'NFM008Prd1';
|
prd.Manual_Entry__c = false;
|
upsert prd;
|
//客户医院
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'NFM008TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM008TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
//签收单最终用户记录类型
|
Account recordType = new Account();
|
recordType.RecordTypeId = recordTypeList[0].Id;
|
recordType.Name = '*';
|
recordType.Department_Class_Label__c = '消化科';
|
recordType.ParentId = company.Id;
|
recordType.Hospital_Department_Class__c = company.Id;
|
upsert recordType;
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//询价
|
Opportunity opp = new Opportunity(
|
Name = 'testOpp1',
|
StageName = '引合',
|
CloseDate = Date.today(),
|
AccountId = depart.Id,
|
Trade__c = '内貿',
|
|
|
|
Sales_Root__c = 'OCM直接販売',
|
Competitor__c = 'A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
upsert opp;
|
|
//注残
|
Statu_Achievements__c statuAchievements = new Statu_Achievements__c(
|
Name = '2021082013',
|
Opportunity__c = opp.id,
|
DeliveryDate__c = Date.today(),
|
ContractNO__c = 'ContractNO1',
|
ContractAmount__c = 1000
|
);
|
upsert statuAchievements;
|
//发货DN
|
Statu_Achievements_DN__c statuAchievementsDN = new Statu_Achievements_DN__c();
|
statuAchievementsDN.Statu_Achievements__c = statuAchievements.Id;
|
statuAchievementsDN.Name = '2021082049';
|
statuAchievementsDN.endUser__c = recordType.Id;
|
upsert statuAchievementsDN;
|
//保有设备
|
Asset assnew = new Asset(Asset_Owner__c = 'Olympus');
|
assnew.RecordTypeId = System.Label.Asset_RecordType;
|
assnew.SerialNumber = '2577010001678';
|
assnew.Name = 'assnew';
|
assnew.Product2Id = prd.Id;
|
assnew.Hospital__c = company.Id;
|
assnew.Department_Class__c = section.Id;
|
assnew.AccountId = depart.Id;
|
assnew.Asset_Owner__c = '医院资产';
|
assnew.Quantity = 1;
|
assnew.Status = '有库存';
|
assnew.Manage_type__c = '个体管理';
|
assnew.Internal_asset_location__c = '北京 备品中心';
|
assnew.Loaner_accsessary__c = true;
|
assnew.Delete_Flag__c = false;
|
assnew.Freeze_sign__c = false;
|
assnew.Out_of_wh__c = 0;
|
assnew.CIC_call_back_check__c = true;
|
upsert assnew;
|
//发货DN明细
|
Statu_Achievements_DN_details__c statuAchievementsDNDetails = new Statu_Achievements_DN_details__c();
|
statuAchievementsDNDetails.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
statuAchievementsDNDetails.Name = 'z1c200000292wse';
|
statuAchievementsDNDetails.asset__c = assnew.Id;
|
upsert statuAchievementsDNDetails;
|
|
|
//新建电子签收单
|
eSignForm__c eSignForm = new eSignForm__c();
|
eSignForm.Statu_Achievements__c = statuAchievements.Id;
|
eSignForm.Statu_Achievements_DN__c = statuAchievementsDN.Id;
|
eSignForm.Name = '::测试电子签收单';
|
upsert eSignForm;
|
|
// 再取得
|
List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
|
List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id In :accountIds order by Management_Code_Auto__c];
|
|
NFM008Rest.InstallationInfo InstallationInfo = new NFM008Rest.InstallationInfo();
|
NFM008Rest.InstallationInformation InstallationInformation = new NFM008Rest.InstallationInformation();
|
NFM008Rest.InstallationInfoH InstallationInfoH = new NFM008Rest.InstallationInfoH();
|
InstallationInfo.InstallationInfoH = InstallationInfoH;
|
NFM008Rest.InstallationInfoI InstallationInfoI = new NFM008Rest.InstallationInfoI();
|
InstallationInfo.InstallationInfoI = new NFM008Rest.InstallationInfoI[] { InstallationInfoI };
|
InstallationInformation.InstallationInfo = new NFM008Rest.InstallationInfo[] { InstallationInfo };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
InstallationInformation.Monitoring = new NFMUtil.Monitoring();
|
InstallationInformation.Monitoring.MessageGroupNumber = nowStr + '41';
|
|
// InstallationInfoI.ReturnExchangeReplenishMark = 1 にてdelete
|
InstallationInfoH.PostingDate = '20120112';
|
InstallationInfoH.CompanyCode = accList[0].Management_Code_Auto__c;
|
InstallationInfoH.DepartmentCode = accList[2].Management_Code_Auto__c;
|
InstallationInfoH.PurposeOfAdvice = '3';
|
InstallationInfoI.MaterialNo = 'NFM008Prd1';
|
InstallationInfoI.SerialNo = '2577010001678';
|
// InstallationInfoI.SerialNo = 'assnew';
|
|
InstallationInfoI.InstallationDateI = '20120118';
|
InstallationInfoI.SLMark = 'L';
|
InstallationInfoI.GuaranteePeriod = '20131021';
|
InstallationInfoI.Location = '病房';
|
InstallationInfoI.ReturnExchangeReplenishMark = '3';
|
InstallationInfoH.PurposeOfAdvice = '3';
|
String productSerialNo = InstallationInfoI.MaterialNo + ':' + InstallationInfoI.SerialNo;
|
System.Test.startTest();
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(InstallationInformation.Monitoring, 'NFM008', InstallationInformation.InstallationInfo);
|
if (String.isBlank(rowData.Log__c) == false) {
|
NFM008Rest.executefuture(rowData.Id);
|
}
|
System.Test.stopTest();
|
|
}
|
// 报表可视化开发估时20210617 精琢科技 zxk 2021-08-26 end
|
|
|
@isTest static void test_method_execute() {
|
|
Test.startTest();
|
|
RestRequest req = new RestRequest();
|
RestResponse res = new RestResponse();
|
|
String JsonMsg = '{ "InstallationInformation": { "Monitoring": {}, "InstallationInfo": [] }}';
|
req.requestURI = 'services/apexrest/NFM008/execute';
|
req.httpMethod = 'POST';
|
req.requestBody = Blob.valueof(JsonMsg);
|
RestContext.request = req;
|
RestContext.response = res;
|
|
NFM008Rest.execute();
|
|
Test.stopTest();
|
}
|
}
|