var taskGroups = {};
for (var i = 0; i < tasks.Count; i++) {
if (tasks[i].WorkGroupName != "物理组") continue;
var taskGroup = taskGroups[tasks[i].Title] || {};
taskGroup.Title = tasks[i].Title;
taskGroup.TestCodeArr = taskGroup.TestCodeArr||[];
taskGroup.DetectionCodeActual = tasks[i].DetectionCodeActual;
taskGroup.Colors = taskGroup.Colors || [];
taskGroup.TitleParts = taskGroup.TitleParts || [];
taskGroup.IsMultiTestCode = false;
if (tasks[i].Color && taskGroup.Colors.indexOf(tasks[i].Color) == -1) taskGroup.Colors.push(tasks[i].Color);
if (tasks[i].TitlePart && taskGroup.TitleParts.indexOf(tasks[i].TitlePart) == -1) taskGroup.TitleParts.push(tasks[i].TitlePart);
if (tasks[i].DetectionCodeActual) {
var currentTask = {};
currentTask.Color=tasks[i].Color;
currentTask.TitlePart=tasks[i].TitlePart;
currentTask.DetectionCodeActual=tasks[i].DetectionCodeActual;
taskGroup.TestCodeArr.push(currentTask);
}
for(var k=0;k<taskGroup.TestCodeArr.length;k++){
for(var z=1;z<taskGroup.TestCodeArr.length;z++){
if(taskGroup.TestCodeArr[k].DetectionCodeActual!==taskGroup.TestCodeArr[z].DetectionCodeActual){
taskGroup.IsMultiTestCode = true;
break;
}
}
}
taskGroups[tasks[i].Title] = taskGroup;
}
var strs = [];
for (var propertyName in taskGroups) {
var taskGroup = taskGroups[propertyName];
var str="";
if (taskGroup.Colors.length && taskGroup.TitleParts.length) {
if(!taskGroup.IsMultiTestCode){
str = taskGroup.Title + '[' + taskGroup.Colors.join(',') + ']' + '(' + taskGroup.TitleParts.join(',') + ')' + '(' + taskGroup.DetectionCodeActual + ')';
}else{
for(var j=0;j<taskGroup.TestCodeArr.length;j++){
var tem = taskGroup.Title+"["+taskGroup.TestCodeArr[j].Color+"]"+"("+taskGroup.TestCodeArr[j].TitlePart+")"+"("+taskGroup.TestCodeArr[j].DetectionCodeActual+")";;
strs.push(tem);
}
}
} else if (taskGroup.Colors.length && !taskGroup.TitleParts.length) {
if(!taskGroup.IsMultiTestCode){
str = taskGroup.Title + '[' + taskGroup.Colors.join(',') + ']' + '(' + taskGroup.DetectionCodeActual + ')';
}else{
for(var j=0;j<taskGroup.TestCodeArr.length;j++){
var tem = taskGroup.Title+"["+taskGroup.TestCodeArr[j].Color+"]"+"("+taskGroup.TestCodeArr[j].DetectionCodeActual+")";;
strs.push(tem);
}
}
} else if (!taskGroup.Colors.length && taskGroup.TitleParts.length) {
if(!taskGroup.IsMultiTestCode){
str = taskGroup.Title + '(' + taskGroup.TitleParts.join(',') + ')' + '(' + taskGroup.DetectionCodeActual + ')';
}else{
for(var j=0;j<taskGroup.TestCodeArr.length;j++){
var tem = taskGroup.Title+"("+taskGroup.TestCodeArr[j].TitlePart+")"+"("+taskGroup.TestCodeArr[j].DetectionCodeActual+")";;
strs.push(tem);
}
}
} else {
if(!taskGroup.IsMultiTestCode){
str = taskGroup.Title + '(' + taskGroup.DetectionCodeActual + ')';
}else{
for(var j=0;j<taskGroup.TestCodeArr.length;j++){
var tem = taskGroup.Title+"("+taskGroup.TestCodeArr[j].DetectionCodeActual+")";;
strs.push(tem);
}
}
}
if(str!==""){
strs.push(str);
}
}
current.Range.Value2 =strs.join('、');
console