`
diding
  • 浏览: 81248 次
  • 性别: Icon_minigender_1
  • 来自: 四川
社区版块
存档分类
最新评论

Flex Array多参数排名(含有并列名次)

    博客分类:
  • Flex
阅读更多
最近有一个项目,客户不仅要求报表同时呈现:
1.员工在整个公司的排名
2.员工在其子公司的排名
3.员工在其专业组别的排名

由于是从数据库单一读取数据,并不含有排名信息,所以,在Flex中,需要对数据进行多参数排名处理,为此,用到了此函数:
//对指定数组进行多参数排名
		private function setDataRate(sortFieldName:String, objProperty:String, tempArr:Array, DataValue:String):Object
		{
			tempArr.sortOn(sortFieldName, Array.NUMERIC | Array.DESCENDING);
			
			var order:Number=0;
			var tempObj:Object=new Object();
			
			for (var k:int=0; k < tempArr.length; k++)
			{
				if ((k == 0) && (tempArr[k][sortFieldName] == DataValue))
				{
					order=Number(k + 1);
					tempObj[objProperty]=order;
					break;
				}
				else if (k > 0)
				{
					if ((tempArr[k][sortFieldName] == tempArr[k - 1][sortFieldName]) && (tempArr[k][sortFieldName] == DataValue))
					{
						order=order;
						tempObj[objProperty]=order;
						break;
					}
					else if ((tempArr[k][sortFieldName] == DataValue))
					{
						order=Number(k + 1);
						tempObj[objProperty]=order;
						break;
					}
					
				}
				
			}
			return tempObj;
			//---------------------------------
		}

调用方法:
for (var k:int=0; k < tempArr.length; k++)
			{
				var tempObj:Object=new Object();
				//复制数组
				var cloneArr:Array= tempArr.concat();
				var obj1:Object =new Object();
				obj1 = setDataRate("priceTotal","priceWeekRate",cloneArr,tempArr[k].priceTotal);
				tempObj.priceWeekRate = obj1.priceWeekRate;
				
				var obj2:Object =new Object();
				obj2 = setDataRate("guestTotal","guestWeekRate",cloneArr,tempArr[k].guestTotal);
				tempObj.guestWeekRate = obj2.guestWeekRate;
				
				var obj3:Object =new Object();
				obj3 = setDataRate("salaryTotal","salaryWeekRate",cloneArr,tempArr[k].salaryTotal);
				tempObj.salaryWeekRate = obj3.salaryWeekRate;
				
				var obj4:Object =new Object();
				obj4 = setDataRate("chooseGuestTotal","chooseGuestWeekRate",cloneArr,tempArr[k].chooseGuestTotal);
				tempObj.chooseGuestWeekRate = obj4.chooseGuestWeekRate;
				
				var obj5:Object =new Object();
				obj5 = setDataRate("countTotalMassage","massageWeekRate",cloneArr,tempArr[k].countTotalMassage);
				tempObj.massageWeekRate = obj5.massageWeekRate;
                                //将对象压入数组
				sendDataArr.push(tempObj);
			}

附工程运用图例:

图例核心代码:
package project.module.dataReport.company.page
{
	import mx.collections.ArrayCollection;
	import mx.containers.VBox;
	import project.golbal.EmployeeServiceItemsArgsName;
	
	public class AnalyzeMonthDataPage extends VBox
	{
		[Bindable]
		public var AllStoreEmployeeAndBaseSalaryArr:Array;
		[Bindable]
		public var distinctMonthEmpoyeeIDArr:Array;
		[Bindable]
		public var IDArr:Array;
		[Bindable]
		public var employeeServiceItemNameArr:Array;
		[Bindable]
		public var employeeIDArr:Array;
		[Bindable]
		public var employeeNameArr:Array;
		[Bindable]
		public var employeeRegPlaceArr:Array;
		[Bindable]
		public var employeeGroupArr:Array;
		[Bindable]
		public var fromDateArr:Array;
		[Bindable]
		public var toDateArr:Array;
		[Bindable]
		public var countTotalGuestCountArr:Array;
		[Bindable]
		public var guestWeekRateArr:Array;
		[Bindable]
		public var countTotalChooseGuestArr:Array;
		[Bindable]
		public var chooseGuestWeekRateArr:Array;
		[Bindable]
		public var countTotalMassageArr:Array;
		[Bindable]
		public var countTotalUnMassageArr:Array;
		[Bindable]
		public var massageWeekRateArr:Array;
		[Bindable]
		public var countTotalPriceArr:Array;
		[Bindable]
		public var priceWeekRateArr:Array;
		[Bindable]
		public var countTotalSalaryArr:Array;
		[Bindable]
		public var salaryWeekRateArr:Array;
		[Bindable]
		public var temp_month_honor_employeeIDArr:Array;
		[Bindable]
		public var temp_month_honor_employeeNameArr:Array;
		[Bindable]
		public var temp_month_honor_employeeRegPlaceArr:Array;
		[Bindable]
		public var temp_month_honor_employeeGroupArr:Array
		[Bindable]
		public var temp_month_honor_salaryTotalArr:Array;
		[Bindable]
		public var temp_month_font_honor_employeeIDArr:Array;
		[Bindable]
		public var temp_month_font_honor_employeeNameArr:Array;
		[Bindable]
		public var temp_month_font_honor_employeeRegPlaceArr:Array;
		[Bindable]
		public var temp_month_font_honor_employeeGroupArr:Array;
		[Bindable]
		public var temp_month_font_honor_salaryTotalArr:Array;
		[Bindable]
		public var temp_month_overdrawn_employeeIDArr:Array;
		[Bindable]
		public var temp_month_overdrawn_employeeNameArr:Array;
		[Bindable]
		public var temp_month_overdrawn_employeeRegPlaceArr:Array;
		[Bindable]
		public var temp_month_overdrawn_employeeGroupArr:Array;
		[Bindable]
		public var temp_month_overdrawn_priceTotalArr:Array;
		
		public function AnalyzeMonthDataPage()
		{
			super();
		}
		
		
		private var controlPage:Object;
		public function AnalyzeeAllEmployeeMonthData(page:Object):void
		{
			controlPage=page;
			
			for (var i:int=0; i < distinctMonthEmpoyeeIDArr.length; i++)
			{
				var obj:Object=new Object();
				
				RolateData(distinctMonthEmpoyeeIDArr[i])
			}
			mergeEmpoyeeHonor();
		}
		
		
		private var RolateEmployeePriceArr:Array=new Array();
		
		private function RolateData(employeeID:String):void
		{
			for (var i:int=0; i < IDArr.length; i++)
			{
				if (employeeID == employeeIDArr[i])
				{
					var obj:Object
					var returnNum:Number=findIsDataInArrays("employeeID",employeeIDArr[i], RolateEmployeePriceArr);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeID",employeeIDArr[i], RolateEmployeePriceArr);
						//obj=RolateEmployeePriceArr.getItemAt(idx);
						obj=RolateEmployeePriceArr[idx];
					}
					else
					{
						//没有找到
						obj=new Object();
					}
					var itemName:String=employeeServiceItemNameArr[i];
					switch (itemName)
					{
						case EmployeeServiceItemsArgsName.PermArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp1:Number=Number(obj.permTotalSalary) ? Number(obj.permTotalSalary) : 0
							obj.permTotalSalary=temp1 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.PermNurseArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp2:Number=Number(obj.permNurseTotalSalary) ? Number(obj.permNurseTotalSalary) : 0;
							obj.permNurseTotalSalary=temp2 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.DyeArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp3:Number=Number(obj.dyeTotalSalary) ? Number(obj.dyeTotalSalary) : 0;
							obj.dyeTotalSalary=temp3 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.DyeNurseArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp4:Number=Number(obj.dyeNurseTotalSalary) ? Number(obj.dyeNurseTotalSalary) : 0;
							obj.dyeNurseTotalSalary=temp4 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							
							break;
						case EmployeeServiceItemsArgsName.ClipDryArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp5:Number=Number(obj.clipDryTotalSalary) ? Number(obj.clipDryTotalSalary) : 0;
							obj.clipDryTotalSalary=temp5 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							
							break;
						case EmployeeServiceItemsArgsName.CommonWashArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp6:Number=Number(obj.commonWashTotalSalary) ? Number(obj.commonWashTotalSalary) : 0;
							
							obj.commonWashTotalSalary=temp6 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.SaleArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp7:Number=Number(obj.saleTotalSalary) ? Number(obj.saleTotalSalary) : 0;
							obj.saleTotalSalary=temp7 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.AddedWashArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp8:Number=Number(obj.addedWashTotalSalary) ? Number(obj.addedWashTotalSalary) : 0;
							obj.addedWashTotalSalary=temp8 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.ProcessMaintainArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp9:Number=Number(obj.processMaintainTotalSalary) ? Number(obj.processMaintainTotalSalary) : 0;
							obj.processMaintainTotalSalary=temp9 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.PrepaidCardArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp10:Number=Number(obj.prepaidTotalSalary) ? Number(obj.prepaidTotalSalary) : 0
							obj.prepaidTotalSalary=temp10 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.PhysiotherapyArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp11:Number=Number(obj.physiotherapyTotalSalary) ? Number(obj.physiotherapyTotalSalary) : 0;
							obj.physiotherapyTotalSalary=temp11 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
						case EmployeeServiceItemsArgsName.WorkOvertimeArgsName():
							obj.employeeID=employeeIDArr[i];
							obj.employeeName=employeeNameArr[i];
							obj.employeeRegPlace=employeeRegPlaceArr[i];
							obj.employeeGroup=employeeGroupArr[i];
							
							var temp12:Number=Number(obj.workOvertimeTotalSalary) ? Number(obj.workOvertimeTotalSalary) : 0
							obj.workOvertimeTotalSalary=temp12 + (Number(countTotalSalaryArr[i]) ? Number(countTotalSalaryArr[i]) : 0);
							
							break;
					}
					
					if (returnNum != -1)
					{
					}
					else
					{
						RolateEmployeePriceArr.push(obj)
					}
				}
			}
			
		}
		
		
		/***********
		 * 员工奖励
		 * ********************/
		private var emloyeeHonorCashAco:Array=new Array();
		
		private function mergeEmpoyeeHonor():void
		{
			if (temp_month_honor_employeeNameArr)
			{
				for (var i:int=0; i < temp_month_honor_employeeNameArr.length; i++)
				{
					var obj:Object
					var returnNum:Number=findIsDataInArrays("employeeID",temp_month_honor_employeeIDArr[i], emloyeeHonorCashAco);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeID",temp_month_honor_employeeIDArr[i], emloyeeHonorCashAco);
						obj=emloyeeHonorCashAco[idx];
					}
					else
					{
						//没有找到
						obj=new Object();
					}
					obj.employeeID=temp_month_honor_employeeIDArr[i]
					obj.employeeName=temp_month_honor_employeeNameArr[i]
					obj.employeeRegPlace=temp_month_honor_employeeRegPlaceArr[i];
					obj.employeeGroupArr=temp_month_honor_employeeGroupArr[i];
					//取值赋值
					var temp1:Number=Number(obj.salaryTotal) ? Number(obj.salaryTotal) : 0;
					obj.salaryTotal=temp1 + (Number(temp_month_honor_salaryTotalArr[i]) ? Number(temp_month_honor_salaryTotalArr[i]) : 0);
					
					if (returnNum != -1)
					{
					}
					else
					{
						emloyeeHonorCashAco.push(obj)
					}
				}
				
				mergeEmployeeFrontHonor()
			}
			else
			{
				mergeEmployeeFrontHonor()
			}
		}
		
		//-------------------------------
		private function mergeEmployeeFrontHonor():void
		{
			if (temp_month_font_honor_employeeNameArr)
			{
				for (var i:int=0; i < temp_month_font_honor_employeeNameArr.length; i++)
				{
					var obj:Object
					var returnNum:Number=findIsDataInArrays("employeeID",temp_month_font_honor_employeeIDArr[i], emloyeeHonorCashAco);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeID",temp_month_font_honor_employeeIDArr[i], emloyeeHonorCashAco);
						obj=emloyeeHonorCashAco[idx];
					}
					else
					{
						//没有找到
						obj=new Object();
					}
					obj.employeeID=temp_month_font_honor_employeeIDArr[i];
					obj.employeeName=temp_month_font_honor_employeeNameArr[i];
					obj.employeeRegPlace=temp_month_font_honor_employeeRegPlaceArr[i];
					obj.employeeGroup=temp_month_font_honor_employeeGroupArr[i];
					
					var temp1:Number=Number(obj.salaryTotal) ? Number(obj.salaryTotal) : 0;
					obj.salaryTotal=temp1 + (Number(temp_month_font_honor_salaryTotalArr[i]) ? Number(temp_month_font_honor_salaryTotalArr[i]) : 0);
					
					if (returnNum != -1)
					{
					}
					else
					{
						emloyeeHonorCashAco.push(obj)
					}
				}
				doMergeOverDrawnPrice()
			}
			else
			{
				doMergeOverDrawnPrice()
			}
		}
		//------------------------------------------------
		private var mergeOverDrawPriceACO:Array=new Array();
		
		private function doMergeOverDrawnPrice():void
		{
			if (temp_month_overdrawn_employeeNameArr)
			{
				for (var i:int=0; i < temp_month_overdrawn_employeeNameArr.length; i++)
				{
					var obj:Object
					var returnNum:Number=findIsDataInArrays("employeeID",temp_month_overdrawn_employeeIDArr[i], mergeOverDrawPriceACO);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeID",temp_month_overdrawn_employeeIDArr[i], mergeOverDrawPriceACO);
						obj=mergeOverDrawPriceACO[idx];
					}
					else
					{
						//没有找到
						obj=new Object();
					}
					
					obj.employeeID=temp_month_overdrawn_employeeIDArr[i]
					obj.employeeName=temp_month_overdrawn_employeeNameArr[i]
					obj.employeeRegPlace=temp_month_overdrawn_employeeRegPlaceArr[i];
					obj.employeeGroup=temp_month_overdrawn_employeeGroupArr[i];
					
					var temp1:Number=Number(obj.priceTotal) ? Number(obj.priceTotal) : 0;
					obj.priceTotal=temp1 + (Number(temp_month_overdrawn_priceTotalArr[i]) ? Number(temp_month_overdrawn_priceTotalArr[i]) : 0);
					
					if (returnNum != -1)
					{
					}
					else
					{
						mergeOverDrawPriceACO.push(obj)
					}
				}
				AddHonorAndOverDrawnData()
			}
			else
			{
				AddHonorAndOverDrawnData()
			}
		}
		
		//----------------------------------------
		private function AddHonorAndOverDrawnData():void
		{
			for (var i:int=0; i < RolateEmployeePriceArr.length; i++)
			{
				var oldObj:Object=RolateEmployeePriceArr[i];
				
				if (emloyeeHonorCashAco)
				{
					oldObj.honorSalaryTotal=addHonorIntoObj(RolateEmployeePriceArr[i].employeeID).honorSalaryTotal;
				}
			}
			//填弃数据
			fillDataGridItemData()
		}
		
		
		private var allEmployeeMonthWageRateArr:Array;
		
		private function fillDataGridItemData():void
		{
			for (var j:int=0; j < AllStoreEmployeeAndBaseSalaryArr.length; j++)
			{
				var oldObj:Object=AllStoreEmployeeAndBaseSalaryArr[j];
				var getObj:Object=getLockEmployeeEachItem(AllStoreEmployeeAndBaseSalaryArr[j].employeeID);
				var temp1:Number=Number(AllStoreEmployeeAndBaseSalaryArr[j].baseSalary) ? Number(AllStoreEmployeeAndBaseSalaryArr[j].baseSalary) : 0
				oldObj.baseSalary=temp1.toFixed(2);
				
				var temp2:Number=Number(getObj.monthSalaryTotal) ? Number(getObj.monthSalaryTotal) : 0;
				oldObj.monthSalaryTotal=temp2.toFixed(2);
				
				var temp3:Number=Number(getObj.overDrawnPriceTotal) ? Number(getObj.overDrawnPriceTotal) : 0;
				oldObj.overDrawnPriceTotal=temp3.toFixed(2);
				
				oldObj.MonthWageTotal=Number(temp1 + temp2 - temp3).toFixed(2);
				
			}
			//最终生成公司所有员工的工资数组
			//AllStoreEmployeeAndBaseSalaryArr.sortOn("MonthWageTotal", Array.NUMERIC | Array.DESCENDING);
			//设置全部员工的薪水排名;
			allEmployeeMonthWageRateArr=doSetMonthWageRate(AllStoreEmployeeAndBaseSalaryArr);
			
			//设置分组
			AnalyzeEmployeeGroup()
		}
		private function getLockEmployeeEachItem(employeeID:String):Object
		{
			var tempObj:Object=new Object();
			for (var j:int=0; j < RolateEmployeePriceArr.length; j++)
			{
				if (employeeID == String(RolateEmployeePriceArr[j].employeeID))
				{
					tempObj.overDrawnPriceTotal=addOverDrawnIntoObj(RolateEmployeePriceArr[j].employeeID).overDrawnPriceTotal;
					tempObj.monthSalaryTotal=getDataScore(RolateEmployeePriceArr[j].employeeID).monthSalaryTotal;
				}
			}
			return tempObj;
		}
		
		private function addHonorIntoObj(employeeID:String):Object
		{
			var tempObj:Object=new Object();
			var honorSalaryTotal:Number=0
			for (var j:int=0; j < emloyeeHonorCashAco.length; j++)
			{
				if (employeeID == String(emloyeeHonorCashAco[j].employeeID))
				{
					honorSalaryTotal=emloyeeHonorCashAco[j].salaryTotal
					break;
				}
			}
			tempObj.honorSalaryTotal=honorSalaryTotal;
			return (tempObj)
		}
		
		//员工的月支出
		private function addOverDrawnIntoObj(employeeID:String):Object
		{
			var tempObj:Object=new Object();
			var overDrawnPriceTotal:Number=0;
			if (mergeOverDrawPriceACO)
			{
				for (var j:int=0; j < mergeOverDrawPriceACO.length; j++)
				{
					if (employeeID == String(mergeOverDrawPriceACO[j].employeeID))
					{
						overDrawnPriceTotal=mergeOverDrawPriceACO[j].priceTotal;
						break;
					}
				}
			}
			tempObj.overDrawnPriceTotal=overDrawnPriceTotal
			return (tempObj)
		}
		
		//员工业绩薪酬+荣誉奖励现金
		private function getDataScore(employeeID:String):Object
		{
			var score:Number=0;
			var tempObj:Object=new Object();
			for (var j:int=0; j < RolateEmployeePriceArr.length; j++)
			{
				if (employeeID == String(RolateEmployeePriceArr[j].employeeID))
				{
					var Num1:Number=Number(RolateEmployeePriceArr[j].permTotalSalary) ? Number(RolateEmployeePriceArr[j].permTotalSalary) : 0;
					var Num2:Number=Number(RolateEmployeePriceArr[j].permNurseTotalSalary) ? Number(RolateEmployeePriceArr[j].permNurseTotalSalary) : 0;
					var Num3:Number=Number(RolateEmployeePriceArr[j].dyeTotalSalary) ? Number(RolateEmployeePriceArr[j].dyeTotalSalary) : 0;
					var Num4:Number=Number(RolateEmployeePriceArr[j].dyeNurseTotalSalary) ? Number(RolateEmployeePriceArr[j].dyeNurseTotalSalary) : 0;
					var Num5:Number=Number(RolateEmployeePriceArr[j].clipDryTotalSalary) ? Number(RolateEmployeePriceArr[j].clipDryTotalSalary) : 0;
					var Num6:Number=Number(RolateEmployeePriceArr[j].commonWashTotalSalary) ? Number(RolateEmployeePriceArr[j].commonWashTotalSalary) : 0;
					var Num7:Number=Number(RolateEmployeePriceArr[j].saleTotalSalary) ? Number(RolateEmployeePriceArr[j].saleTotalSalary) : 0;
					var Num8:Number=Number(RolateEmployeePriceArr[j].addedWashTotalSalary) ? Number(RolateEmployeePriceArr[j].addedWashTotalSalary) : 0;
					var Num9:Number=Number(RolateEmployeePriceArr[j].processMaintainTotalSalary) ? Number(RolateEmployeePriceArr[j].processMaintainTotalSalary) : 0;
					var Num10:Number=Number(RolateEmployeePriceArr[j].prepaidTotalSalary) ? Number(RolateEmployeePriceArr[j].prepaidTotalSalary) : 0;
					var Num11:Number=Number(RolateEmployeePriceArr[j].physiotherapyTotalSalary) ? Number(RolateEmployeePriceArr[j].physiotherapyTotalSalary) : 0;
					var Num12:Number=Number(RolateEmployeePriceArr[j].workOvertimeTotalSalary) ? Number(RolateEmployeePriceArr[j].workOvertimeTotalSalary) : 0;
					
					var Num13:Number
					if (emloyeeHonorCashAco)
					{
						Num13=Number(RolateEmployeePriceArr[j].honorSalaryTotal) ? Number(RolateEmployeePriceArr[j].honorSalaryTotal) : 0;
					}
					score=(Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num7 + Num8 + Num9 + Num10 + Num11 + Num12 + Num13)
				}
			}
			tempObj.monthSalaryTotal=score;
			return (tempObj)
		}
		
		
		private function doSetMonthWageRate(tempArr:Array):Array
		{
			//排名 并附值
			var re_EmployeeMonthWageRateArr:Array=[];
			for (var k:int=0; k < tempArr.length; k++)
			{
				var tempObj:Object=new Object();
				
				tempObj.employeeID=tempArr[k].employeeID
				tempObj.employeeName=tempArr[k].employeeName
				tempObj.employeeRegPlace=tempArr[k].employeeRegPlace;
				tempObj.employeeGroup=tempArr[k].employeeGroup;
				
				
				tempObj.baseSalary=tempArr[k].baseSalary;
				tempObj.monthSalaryTotal=tempArr[k].monthSalaryTotal;
				tempObj.overDrawnPriceTotal=tempArr[k].overDrawnPriceTotal;
				tempObj.MonthWageTotal=tempArr[k].MonthWageTotal;
				
				//复制数组
				var cloneArr:Array=tempArr.concat();
				var obj1:Object=new Object();
				//全部员工的薪水排名
				obj1=setDataRate("MonthWageTotal", "MonthWageTotalRate", cloneArr, tempArr[k].MonthWageTotal);
				tempObj.MonthWageTotalRate=obj1.MonthWageTotalRate;
				
				re_EmployeeMonthWageRateArr.push(tempObj)
			}
			return re_EmployeeMonthWageRateArr;
		}
		
		
		
		private var AnalyzedGroupACOData:ArrayCollection=new ArrayCollection()
		
		private function AnalyzeEmployeeGroup():void
		{
			for (var k:int=0; k < allEmployeeMonthWageRateArr.length; k++)
			{
				var obj:Object=new Object();
				var obj2:Object=new Object()
				var childrenACO:ArrayCollection=new ArrayCollection();
				if (k == 0)
				{
					obj.employeeGroup=allEmployeeMonthWageRateArr[k].employeeGroup;
					childrenACO.addItem(allEmployeeMonthWageRateArr[k])
					obj.children=childrenACO;
					AnalyzedGroupACOData.addItem(obj)
				}
				else
				{
					//判断companyEmployeeDBDataArr[k].employeeGroup是否在数组中,如果存在,
					//取得其索引,加入children
					//否则  新加入数组
					var returnNum:Number=findIsDataInArrays("employeeGroup",allEmployeeMonthWageRateArr[k].employeeGroup,AnalyzedGroupACOData);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeGroup",allEmployeeMonthWageRateArr[k].employeeGroup,AnalyzedGroupACOData);
						var oldObj:Object=AnalyzedGroupACOData.getItemAt(idx);
						ArrayCollection(oldObj.children).addItem(allEmployeeMonthWageRateArr[k])
					}
					else
					{
						//没有找到
						obj.employeeGroup=allEmployeeMonthWageRateArr[k].employeeGroup;
						childrenACO.addItem(allEmployeeMonthWageRateArr[k])
						obj.children=childrenACO;
						AnalyzedGroupACOData.addItem(obj);
					}
				}
			}
			//设置分组排名
			AnalyzeeEmployeeGroupRate()
		}
		
		
		private function AnalyzeeEmployeeGroupRate():void
		{
			//各个分组一组一组的解析
			for (var i:int=0; i < AnalyzedGroupACOData.length; i++)
			{
				//取得 Children
				var tempArr:*=(AnalyzedGroupACOData[i].children);
				var childrenArr:Array=[];
				var newArr:Array=[];
				for (var j:int=0; j < tempArr.length; j++)
				{
					var tempObj2:Object=new Object();
					tempObj2.employeeID=tempArr[j].employeeID;
					tempObj2.MonthWageTotal=tempArr[j].MonthWageTotal;
					newArr.push(tempObj2)
				}
				for (var k:int=0; k < newArr.length; k++)
				{
					var tempObj:Object=new Object();
					tempObj.employeeID=newArr[k].employeeID;
					//复制数组
					var cloneArr:Array=newArr.concat();
					var obj1:Object=new Object();
					//全部员工的薪水排名
					obj1=setDataRate("MonthWageTotal", "groupRate", cloneArr, newArr[k].MonthWageTotal);
					tempObj.groupRate=obj1.groupRate;
					
					childrenArr.push(tempObj)
				}
				//执行绑定
				bidingGroupRate(childrenArr)
				
			}
			//班次排名
			AnalyzeEmployeeRegPlace()
		}
		
		private function bidingGroupRate(tempArr:Array):void
		{
			for (var j:int=0; j < allEmployeeMonthWageRateArr.length; j++)
			{
				//取得对应的对象
				var oldObj:Object=allEmployeeMonthWageRateArr[j];
				
				for (var k:int=0; k < tempArr.length; k++)
				{
					//传送过来的小组含有排名,绑定名次
					if (allEmployeeMonthWageRateArr[j].employeeID == tempArr[k].employeeID)
					{
						oldObj.groupRate=tempArr[k].groupRate
					}
				}
			}
		}
		//---------------------------------------------------
		private var AnalyzedRegplaceACOData:ArrayCollection=new ArrayCollection()
		
		private function AnalyzeEmployeeRegPlace():void
		{
			for (var k:int=0; k < allEmployeeMonthWageRateArr.length; k++)
			{
				var obj:Object=new Object();
				var obj2:Object=new Object()
				var childrenACO:ArrayCollection=new ArrayCollection();
				if (k == 0)
				{
					obj.employeeRegPlace=allEmployeeMonthWageRateArr[k].employeeRegPlace;
					childrenACO.addItem(allEmployeeMonthWageRateArr[k])
					obj.children=childrenACO;
					AnalyzedRegplaceACOData.addItem(obj)
				}
				else
				{
					//判断companyEmployeeDBDataArr[k].employeeRegPlace是否在数组中,如果存在,
					//取得其索引,加入children
					//否则  新加入数组
					var returnNum:Number=findIsDataInArrays("employeeRegPlace",allEmployeeMonthWageRateArr[k].employeeRegPlace,AnalyzedRegplaceACOData);
					//找到有
					if (returnNum != -1)
					{
						//索引值
						var idx:Number=findDataInArraysOrder("employeeRegPlace",allEmployeeMonthWageRateArr[k].employeeRegPlace,AnalyzedRegplaceACOData);
						var oldObj:Object=AnalyzedRegplaceACOData.getItemAt(idx);
						ArrayCollection(oldObj.children).addItem(allEmployeeMonthWageRateArr[k])
					}
					else
					{
						//没有找到
						obj.employeeRegPlace=allEmployeeMonthWageRateArr[k].employeeRegPlace;
						childrenACO.addItem(allEmployeeMonthWageRateArr[k])
						obj.children=childrenACO;
						AnalyzedRegplaceACOData.addItem(obj);
					}
				}
			}
			//设置班次排名
			AnalyzeeEmployeeRegPlaceRate()
		}
		
		
		private function AnalyzeeEmployeeRegPlaceRate():void
		{
			//各个分组一组一组的解析
			for (var i:int=0; i < AnalyzedRegplaceACOData.length; i++)
			{
				//取得 Children
				var tempArr:*=(AnalyzedRegplaceACOData[i].children);
				var childrenArr:Array=[];
				var newArr:Array=[];
				for (var j:int=0; j < tempArr.length; j++)
				{
					var tempObj2:Object=new Object();
					tempObj2.employeeID=tempArr[j].employeeID;
					tempObj2.MonthWageTotal=tempArr[j].MonthWageTotal;
					newArr.push(tempObj2)
				}
				
				for (var k:int=0; k < newArr.length; k++)
				{
					var tempObj:Object=new Object();
					tempObj.employeeID=newArr[k].employeeID;
					//复制数组
					var cloneArr:Array=newArr.concat();
					var obj1:Object=new Object();
					//全部员工的薪水排名
					obj1=setDataRate("MonthWageTotal", "regPlaceRate", cloneArr, newArr[k].MonthWageTotal);
					tempObj.regPlaceRate=obj1.regPlaceRate;
					
					childrenArr.push(tempObj)
				}
				//执行绑定
				bidingRegplaceRate(childrenArr)
			}
			
			//各个分组解析完毕
			//最终设置好所有员工的全部数据表	
			//调用页执行相关函数
			controlPage.fillADG(allEmployeeMonthWageRateArr)
		}
		
		private function bidingRegplaceRate(tempArr:Array):void
		{
			for (var j:int=0; j < allEmployeeMonthWageRateArr.length; j++)
			{
				//取得对应的对象
				var oldObj:Object=allEmployeeMonthWageRateArr[j];
				
				for (var k:int=0; k < tempArr.length; k++)
				{
					//传送过来的小组含有排名,绑定名次
					if (allEmployeeMonthWageRateArr[j].employeeID == tempArr[k].employeeID)
					{
						oldObj.regPlaceRate=tempArr[k].regPlaceRate
					}
				}
			}
		}
		//--------------------------------------------------------
 
		//查对对象比较并返回
		private function findIsDataInArrays(fieldName:String,input:String,compareArr:*):Number
		{
			for (var i:int=0; i < compareArr.length; i++)
			{
				if (compareArr[i][fieldName]=== input)
				{
					return i;
				}
			}
			return -1;
		}
		
		private function findDataInArraysOrder(fieldName:String,input:String,compareArr:*):Number
		{
			for (var i:int=0; i < compareArr.length; i++)
			{
				if (compareArr[i][fieldName]=== input)
				{
					return i;
					break;
				}
			}
			return -1;
		}
		
		//对指定数组进行多参数排名
		private function setDataRate(sortFieldName:String, objProperty:String, tempArr:Array, DataValue:String):Object
		{
			tempArr.sortOn(sortFieldName, Array.NUMERIC | Array.DESCENDING);
			
			var order:Number=0;
			var tempObj:Object=new Object();
			
			for (var k:int=0; k < tempArr.length; k++)
			{
				if ((k == 0) && (tempArr[k][sortFieldName] == DataValue))
				{
					order=Number(k + 1);
					tempObj[objProperty]=order;
					break;
				}
				else if (k > 0)
				{
					if ((tempArr[k][sortFieldName] == tempArr[k - 1][sortFieldName]) && (tempArr[k][sortFieldName] == DataValue))
					{
						order=order;
						tempObj[objProperty]=order;
						break;
					}
					else if ((tempArr[k][sortFieldName] == DataValue))
					{
						order=Number(k + 1);
						tempObj[objProperty]=order;
						break;
					}
					
				}
				
			}
			return tempObj;
			//---------------------------------
		}
		//--------------------------------------------------
	}
}
  • 大小: 108.7 KB
分享到:
评论

相关推荐

    NetApp FlexArray虚拟化软件介绍.pdf

    FlexArray软件利用NetApp的Data ONTAP操作系统,提供了一系列集成的数据保护和存储效率技术,如数据压缩、重复数据删除等,承诺可以将存储需求减少35%甚至更多,并在九个月内实现投资回报。通过“主机到存储”的闪存...

    NetApp FlexArray存储虚拟化软件介绍.pdf

    NetApp FlexArray存储虚拟化软件是一款能够帮助用户充分利用现有存储阵列的解决方案,其主要优势在于提供存储虚拟化的灵活性,并使得不同来源的存储设备能够在统一的管理平台下工作。该软件的详细介绍和优势可以从...

    flex array 一些操作

    var flexArray:Array = new Array(); flexArray.push("Adobe"); // 向数组末尾添加 "Adobe" 元素 trace(flexArray); // 输出: ["Adobe"] ``` 可以看到,通过`push`方法可以轻松地向数组添加新元素。该方法非常适合...

    flex array应用实例源码

    在`AS_0600_Array`这个文件中,可能包含了一个或多个C++源代码文件,这些文件展示了如何使用`flex array`进行各种操作,如初始化、添加元素、删除元素、遍历以及查找等。源代码可能包含以下关键部分: 1. **定义:*...

    NetApp FlexArray快速参考指南.pdf

    - 经营理念:FlexArray的推广理念是通过整合现有资源和投资,而不是替换它们,为客户创造更多价值。NetApp为FlexArray提供了九个月的投资回报担保计划。 - 竞争信息:FlexArray在市场上具有竞争优势,因为它结合了...

    FlexArray虚拟化存储软件白皮书.pdf

    NetApp FlexArray虚拟化存储软件是一款专为解决IT扩展性和复杂性挑战而设计的解决方案,它将SAN(存储区域网络)和NAS(网络附加存储)整合在一个统一的平台上,为用户提供高效、灵活且经济的存储管理体验。Flex...

    NetApp FlexArray虚拟化软件技术白皮书.pdf

    通过将多个存储阵列虚拟化,FlexArray能够提供高级存储功能,如无缝云部署和存储管理标准化,从而简化IT运维。 该技术的一个关键特性是它支持无中断运行,这意味着在更新或扩展存储基础设施时,不会对用户造成任何...

    flex Array插入和删除

    在Flex编程中,Array类是用于存储动态大小的元素集合,它可以包含任意类型的对象。Array类提供了丰富的功能,包括插入和删除元素,这对于构建灵活的数据结构和处理动态数据至关重要。让我们深入探讨一下如何在Flex中...

    flex_array.rar_flex

    在源代码文件flex_array.c中,我们可以期待找到实现这些操作的函数,比如`flex_array_init()`, `flex_array_push()`, `flex_array_pop()`, `flex_array_insert()`, `flex_array_remove()`等。而在flex_array.h头文件...

    flex接收网页参数

    flex接收网页参数,flex与js交互,flex调用js,js调用flex

    flex array 搜索 遍历

    在IT行业中,数组是数据结构的基础,而Flex Array是一种在ActionScript 3(AS3)中使用的特定类型的数组。在Flex编程中,处理数组时,我们可能会遇到需要搜索或遍历数组的需求,尤其是在处理对象数组时,这通常涉及...

    NetApp FlexArray存储虚拟化平台介绍.pptx

    NetApp FlexArray存储虚拟化平台介绍.pptx

    Flex中Tree组件的数据源举例(xml,array,object)

    本篇将详细介绍如何为Flex中的Tree组件设置不同的数据源,包括XML、Array和Object。 首先,让我们从XML数据源开始。XML因其结构化的特性,非常适合用来表示层次数据。在Flex中,我们可以使用mx.collections....

    Flex的Array和ArrayCollection

    Flex的Array和ArrayCollection

    flex获得浏览器参数,flex获得url参数

    该文件是一个基于Flex框架创建的MXML应用程序,用于获取浏览器URL中的参数并显示在界面中。Flex是一个用于构建富互联网应用程序(RIA)的开源框架,它基于ActionScript和MXML,通常与Adobe Flash Player或Adobe AIR...

    flex builder 编译器参数

    ### Flex Builder 编译器参数详解 在Flex开发过程中,合理设置编译器参数对于优化应用程序性能、提高代码质量及确保应用的可访问性等方面都至关重要。本文将详细介绍Flex Builder中的编译器参数及其功能,帮助...

    flex获得html容器传递的url参数值

    在本文中,我们将深入探讨如何在Flex中获取这些URL参数值。 首先,我们要明白,当我们使用Flex Builder开发应用程序时,编译后的SWF文件会被一个HTML容器包裹,因此在实际运行时,我们实际上是在运行这个HTML文件。...

    flex 数组排序

    flexArray.push({productName: "Flash", version: 8}); flexArray.push({productName: "Flash", version: 9}); flexArray.push({productName: "Flex", version: 1.5}); flexArray.push({productName: "Flex", ...

Global site tag (gtag.js) - Google Analytics