// // SalesDataAnalysisVC.m // IBOSS-HJ // // Created by 关宏厚 on 2020/12/30. // Copyright © 2020 elongtian. All rights reserved. // #import "SalesDataAnalysisVC.h" @interface SalesDataAnalysisVC () { UIScrollView *scroll; UIView *content; UIView *salesStatusContent; CAShapeLayer *btnSalesStatusCustomMaskLayer; CAShapeLayer *btnSalesStatusRecentlyThirtyDaysMaskLayer; NSInteger topMargin; UIView *vDate; UIView *collectionContent; UIView *salesAmountContent; UIView *orderStatusContent; UIView *repairStatusContent; UIView *shoppingGuideFilingContent; UIView *deliveryStatusContent; UIView *installStatusContent; UIView *salesAchievementContent; UIView *nextThreeDaysNeedDeliveyCountView; UIView *orderAmountContent; UILabel *lblSalesAmount; UILabel *lblCollectionAmount; UILabel *lblSalesAddCustomer; UILabel *lblOrderCustomerCount; UILabel *lblUnsubscribeCustomerCount; UILabel *lblOrderAmount; UILabel *lblUnsubscribeAmount; UIView *vCollectionStatusDate; UILabel *lblSalesCustomerCount; UILabel *lblSalesAchievementPercent; CAShapeLayer *btnSalesStatusChannelMaskLayer; CAShapeLayer *btnSalesStatusDepartmentMaskLayer; CAShapeLayer *btnCollectionStatusChannelMaskLayer; CAShapeLayer *btnCollectionStatusDepartmentMaskLayer; CAShapeLayer *btnCollectionStatusCustomMaskLayer; CAShapeLayer *btnCollectionStatusRecentlyThirtyDaysMaskLayer; UIView *collectionAmountContent; CAShapeLayer *btnOrderStatusCustomMaskLayer; CAShapeLayer *btnOrderStatusRecentlyThirtyDaysMaskLayer; CAShapeLayer *btnOrderStatusChannelMaskLayer; CAShapeLayer *btnOrderStatusDepartmentMaskLayer; CAShapeLayer *btnSalesAchievementCustomMaskLayer; CAShapeLayer *btnSalesAchievementCurrentMonthMaskLayer; UIView *vOrderStatusDate; UILabel *lblSalesAchievementPlanAmount; UILabel *lblSalesAchievementSalesAmount; CAShapeLayer *btnSalesAchievementDepartmentMaskLayer; CAShapeLayer *btnSalesAchievementStaffMaskLayer; UILabel *lblFilingCustomerCount; UILabel *lblTransactionCustomerCount; UILabel *lblTransactionPercent; UILabel *lblDeliveryPercent; UILabel *lblInstallPercent; UILabel *lblRepairPercent; UILabel *lblNeedDeliveryCustomerCount; UILabel *lblDeliveredCustomerCount; UILabel *lblNeedInstallCustomerCount; UILabel *lblInstalledCustomerCount; UILabel *lblNeedRepairCustomerCount; UILabel *lblRepairedCustomerCount; UILabel *lblNextDayNeedDeliveryCount; UILabel *lblNextTwoDaysNeedDeliveryCount; UILabel *lblNextThreeDaysNeedDeliveryCount; UILabel *lblNextDayNeedInstallCount; UILabel *lblNextTwoDaysNeedInstallCount; UILabel *lblNextThreeDaysNeedInstallCount; UILabel *lblNextDayNeedRepairCount; UILabel *lblNextTwoDaysNeedRepairCount; UILabel *lblNextThreeDaysNeedRepairCount; NSMutableArray *salesStatusXArray; NSMutableArray *salesStatusYArray; NSMutableArray *collectionStatusXArray; NSMutableArray *collectionStatusYArray; NSMutableArray *orderStatusXArray; NSMutableArray *orderStatusYArray; NSMutableArray *salesAchievementXArray; NSMutableArray *salesAchievementYArray; NSMutableArray *salesAchievementTitleArray; NSMutableArray *shoppingGuideXArray; NSMutableArray *shoppingGuideYArray; NSMutableArray *shoppingGuideTitleArray; CGFloat height; NSString *typeId; NSString *salesAchievementTypeId; NSString *cashStatusTypeId; NSString *orderStatusTypeId; UIView *nextDayNeedDeliveyCountView; UIView *nextDayNeedInstallCountView; UIView *nextDayNeedRepairCountView; CustomBorderView *salesStatusBorderV; CustomBorderView *collectionStatusBorderV; CustomBorderView *orderStatusBorderV; CustomBorderView *shoppingGuidePieBorderV; CustomBorderView *shoppingGuideChartBorderV; CustomBorderView *deliveryStatusBorderV; CustomBorderView *installStatusBorderV; CustomBorderView *repairStatusBorderV; CustomBorderView *salesAchievementBorderV; CustomBorderView *salesAchievementPieBorderV; int borderWidth; } @end @implementation SalesDataAnalysisVC #pragma mark - 公共函数 - (void)viewDidLoad { [super viewDidLoad]; topMargin=15; typeId=@"1"; height=0; borderWidth=1; cashStatusTypeId=@"1"; orderStatusTypeId=@"1"; salesAchievementTypeId=@"0"; salesStatusXArray=[[NSMutableArray alloc]init]; salesStatusYArray=[[NSMutableArray alloc]init]; collectionStatusXArray=[[NSMutableArray alloc]init]; collectionStatusYArray=[[NSMutableArray alloc]init]; NSArray *initDateArray= [DateFormat getMonthFirstLastDay]; _shoppingGuideStartDate=[initDateArray objectAtIndex:0]; _shoppingGuideEndDate=[DateFormat getCurrentDate]; _deliveryStatusStartDate=[initDateArray objectAtIndex:0]; _deliveryStatusEndDate=[DateFormat getCurrentDate]; _installStatusStartDate=[initDateArray objectAtIndex:0]; _installStatusEndDate=[DateFormat getCurrentDate]; _repairStatusStartDate=[initDateArray objectAtIndex:0]; _repairStatusEndDate=[DateFormat getCurrentDate]; orderStatusXArray=[[NSMutableArray alloc]init]; orderStatusYArray=[[NSMutableArray alloc]init]; salesAchievementXArray=[[NSMutableArray alloc]init]; // [salesAchievementXArray addObject:@"总经办"]; // [salesAchievementXArray addObject:@"工程部"]; // [salesAchievementXArray addObject:@"采购中心"]; salesAchievementYArray=[[NSMutableArray alloc]init]; // NSMutableDictionary *dic=[[NSMutableDictionary alloc]init]; // [dic setObject:@"40000" forKey:@"planAmount"]; // [dic setObject:@"38000" forKey:@"saleAmount"]; // [salesAchievementYArray addObject:dic]; // NSMutableDictionary *dic1=[[NSMutableDictionary alloc]init]; // [dic1 setObject:@"30000" forKey:@"planAmount"]; // [dic1 setObject:@"20000" forKey:@"saleAmount"]; // [salesAchievementYArray addObject:dic1]; // // NSMutableDictionary *dic2=[[NSMutableDictionary alloc]init]; // [dic2 setObject:@"35000" forKey:@"planAmount"]; // [dic2 setObject:@"23000" forKey:@"saleAmount"]; // [salesAchievementYArray addObject:dic2]; salesAchievementTitleArray=[[NSMutableArray alloc]init]; [salesAchievementTitleArray addObject:@"任务额"]; [salesAchievementTitleArray addObject:@"销售额"]; shoppingGuideXArray=[[NSMutableArray alloc]init]; shoppingGuideTitleArray=[[NSMutableArray alloc]init]; [shoppingGuideTitleArray addObject:@"成交客户数"]; [shoppingGuideTitleArray addObject:@"报备客户数"]; shoppingGuideYArray=[[NSMutableArray alloc]init]; [self loadNavStyle]; [self initUI]; [self startLoading]; _salesStatusStartDate=[initDateArray objectAtIndex:0]; _salesStatusEndDate=[DateFormat getCurrentDate]; _collectionStatusStartDate=[initDateArray objectAtIndex:0]; _collectionStatusEndDate=[DateFormat getCurrentDate]; // _orderStatusStartDate=[DateFormat getCurrentDate]; _orderStatusStartDate=[initDateArray objectAtIndex:0]; _orderStatusEndDate=[DateFormat getCurrentDate]; cashStatusTypeId=@"1"; _salesAchievementMonth=[DateFormat getCurrentNoSeparateMonth]; [self asyncConcurrent]; } #pragma mark - 私有函数 /** 切换销售利润按钮颜色 */ -(void)changeSalesStatusButtonColor { btnSalesStatusCustomMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; _btnSalesStatusToday.layer.borderColor=[UIColor lightGrayColor].CGColor; _btnSalesStatusYesterday.layer.borderColor=[UIColor lightGrayColor].CGColor; _btnSalesStatusRecentlySevenDays.layer.borderColor=[UIColor lightGrayColor].CGColor; btnSalesStatusRecentlyThirtyDaysMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesStatusCustom setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_btnSalesStatusToday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_btnSalesStatusYesterday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_btnSalesStatusRecentlySevenDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_btnSalesStatusRecentlyThirtyDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)changeOrderStatusButtonColor { btnOrderStatusCustomMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusCustom setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnOrderStatusToday.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusToday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnOrderStatusYesterday.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusYesterday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnOrderStatusRecentlySevenDays.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusRecentlySevenDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnOrderStatusRecentlyThirtyDaysMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusRecentlyThirtyDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)changeCashStatusButtonColor { btnCollectionStatusCustomMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusCustom setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnCollectionStatusToday.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusToday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnCollectionStatusYesterday.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusYesterday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _btnCollectionStatusRecentlySevenDays.layer.borderColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusRecentlySevenDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnCollectionStatusRecentlyThirtyDaysMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusRecentlyThirtyDays setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)clearSalesStatusData { lblSalesAmount.text=@"0.00"; lblSalesAddCustomer.text=@"0"; lblSalesCustomerCount.text=@"0"; } -(void)clearCollectionStatusData { lblCollectionAmount.text=@"0.00"; } -(void)clearOrderStatusData { lblOrderCustomerCount.text=@"0"; lblUnsubscribeCustomerCount.text=@"0"; lblOrderAmount.text=@"0.00"; lblUnsubscribeAmount.text=@"0.00"; } -(void)clearSalesAchievementData { lblSalesAchievementPercent.text=@"完成率0.00%"; lblSalesAchievementSalesAmount.text=@"0.00"; lblSalesAchievementPlanAmount.text=@"0.00"; } -(void)clearShoppingGuideFilingData { lblFilingCustomerCount.text=@"0"; lblTransactionCustomerCount.text=@"0"; lblTransactionPercent.text=@"成交率0.00%"; } -(void)clearDeliveryData { lblDeliveredCustomerCount.text=@"0"; lblNeedDeliveryCustomerCount.text=@"0"; lblNextDayNeedDeliveryCount.text=@"0"; lblNextTwoDaysNeedDeliveryCount.text=@"0"; lblNextThreeDaysNeedDeliveryCount.text=@"0"; lblDeliveryPercent.text=@"完成率0.00%"; } -(void)clearInstallData { lblNeedInstallCustomerCount.text=@"0"; lblInstalledCustomerCount.text=@"0"; lblNextDayNeedInstallCount.text=@"0"; lblNextTwoDaysNeedInstallCount.text=@"0"; lblNextThreeDaysNeedInstallCount.text=@"0"; lblInstallPercent.text=@"完成率0.00%"; } -(void)clearRepairData { lblNeedRepairCustomerCount.text=@"0"; lblRepairedCustomerCount.text=@"0"; lblNextDayNeedRepairCount.text=@"0"; lblNextTwoDaysNeedRepairCount.text=@"0"; lblNextThreeDaysNeedRepairCount.text=@"0"; } /** 导航按钮样式 */ -(void)loadNavStyle { self.navigationItem.title=@"销售数据分析"; //返回 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0, 15, 18); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; } /** 获取y轴最大值 */ -(double)getYAxisMaximumValue:(NSMutableArray*) yValueArray { double maximumValue=[[yValueArray objectAtIndex:0]doubleValue]; for(int i=1;imaximumValue) { maximumValue=yValue; } } return maximumValue; } /** 获取y轴最小值 */ -(double)getYAxisMinimumValue:(NSMutableArray*) yValueArray { double minimumValue=[[yValueArray objectAtIndex:0]doubleValue]; for(int i=1;i)formatter xAxisLabelCount:(NSInteger)count maximumValue:(double)maximumValue minimumValue:(double)minimumValue { chartView.delegate = self; chartView.extraBottomOffset=20; chartView.chartDescription.enabled = NO; chartView.pinchZoomEnabled = NO; chartView.drawBarShadowEnabled = NO; chartView.drawGridBackgroundEnabled = NO; chartView.maxVisibleCount = 60; BalloonMarker *marker = [[BalloonMarker alloc] initWithColor: [UIColor colorWithWhite:210/255. alpha:1.0] font: [UIFont systemFontOfSize:12.0] textColor: UIColor.whiteColor insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)]; marker.chartView = chartView; marker.minimumSize = CGSizeMake(80.f, 40.f); chartView.marker = marker; ChartLegend *legend = chartView.legend; legend.horizontalAlignment = ChartLegendHorizontalAlignmentCenter; legend.verticalAlignment = ChartLegendVerticalAlignmentBottom; legend.orientation = ChartLegendOrientationHorizontal ; legend.drawInside = NO; legend.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:12.0f]; legend.yOffset = 1.0; legend.xOffset = 1.0; legend.yEntrySpace =1; ChartXAxis *xAxis = chartView.xAxis; xAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]; xAxis.axisMinimum = 0.0; xAxis.granularity = 1.0f; xAxis.labelCount=count; xAxis.labelRotationAngle=20; xAxis.drawGridLinesEnabled=NO; xAxis.centerAxisLabelsEnabled = YES; xAxis.labelPosition = XAxisLabelPositionBottom; xAxis.valueFormatter =formatter ; ChartYAxis *leftAxis = chartView.leftAxis; leftAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]; leftAxis.valueFormatter = [[YAxisValueFormatter alloc] init]; leftAxis.drawGridLinesEnabled = YES; leftAxis.gridColor = [UIColor colorWithRed:200/255.0f green:200/255.0f blue:200/255.0f alpha:1];//网格线颜色 leftAxis.spaceTop = 0.35; leftAxis.granularityEnabled=YES; leftAxis.gridLineWidth =1; if(minimumValue<0) { leftAxis.axisMinimum = minimumValue; } else { leftAxis.axisMinimum=0; } leftAxis.axisMaximum=maximumValue+100; leftAxis.decimals=2; // leftAxis.granularity=maximumValue/5; chartView.rightAxis.enabled = NO; float groupSpace = 0.1f; float barSpace = 0.15f; float barWidth = 0.3f; NSMutableArray *yVals1 = [[NSMutableArray alloc] init]; NSMutableArray *yVals2 = [[NSMutableArray alloc] init]; int start =0; long end = barchartArray.count; for (int i = start; i < end; i++) { NSMutableDictionary *barchartDic=barchartArray[i]; double y1=0; double y2=0; if([[barchartDic allKeys] containsObject:@"planAmount"]) { y1= [[barchartDic objectForKey:@"planAmount"]doubleValue]; } if([[barchartDic allKeys] containsObject:@"saleAmount"]) { y2=[[barchartDic objectForKey:@"saleAmount"]doubleValue]; } [yVals1 addObject:[[BarChartDataEntry alloc] initWithX:i y:y1]]; [yVals2 addObject:[[BarChartDataEntry alloc] initWithX:i y:y2]]; } BarChartDataSet *set1 = nil, *set2 = nil; if (chartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)chartView.data.dataSets[0]; set2 = (BarChartDataSet *)chartView.data.dataSets[1]; [set1 replaceEntries:yVals1]; [set2 replaceEntries:yVals2]; BarChartData *data = chartView.barData; chartView.xAxis.axisMinimum = start; chartView.xAxis.axisMaximum = [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * end + start; [data groupBarsFromX: start groupSpace: groupSpace barSpace: barSpace]; [chartView.data notifyDataChanged]; [chartView notifyDataSetChanged]; } else { set1 = [[BarChartDataSet alloc] initWithEntries:yVals1 label:receivablesTitleArry[0]]; [set1 setColor:[UIColor colorWithRed:70/255.0f green:116/255.0f blue:193/255.0f alpha:1]]; set2 = [[BarChartDataSet alloc] initWithEntries:yVals2 label:receivablesTitleArry[1]]; [set2 setColor:[UIColor colorWithRed:235/255.0f green:125/255.0f blue:60/255.0f alpha:1]]; [set1 setDrawValuesEnabled:NO]; [set2 setDrawValuesEnabled:NO]; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; [dataSets addObject:set2]; BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]]; data.barWidth = barWidth; // restrict the x-axis range chartView.xAxis.axisMinimum = start; // groupWidthWithGroupSpace(...) is a helper that calculates the width each group needs based on the provided parameters chartView.xAxis.axisMaximum = start+ [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * end; [data groupBarsFromX: start groupSpace: groupSpace barSpace: barSpace]; chartView.data = data; } } -(void)drawHorizontalTwoBarchart:(NSMutableArray*)barchartArray receivablesTitleArray:(NSMutableArray*)receivablesTitleArry barChartView:(HorizontalBarChartView*) chartView axisValueFormatter:(id)formatter xAxisLabelCount:(NSInteger)count maximumValue:(double)maximumValue minimumValue:(double)minimumValue { chartView.delegate = self; chartView.extraBottomOffset=20; chartView.chartDescription.enabled = NO; chartView.pinchZoomEnabled = NO; chartView.drawBarShadowEnabled = NO; chartView.drawGridBackgroundEnabled = NO; chartView.maxVisibleCount = 60; BalloonMarker *marker = [[BalloonMarker alloc] initWithColor: [UIColor colorWithWhite:210/255. alpha:1.0] font: [UIFont systemFontOfSize:12.0] textColor: UIColor.whiteColor insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)]; marker.chartView = chartView; marker.minimumSize = CGSizeMake(80.f, 40.f); chartView.marker = marker; ChartLegend *legend = chartView.legend; legend.horizontalAlignment = ChartLegendHorizontalAlignmentCenter; legend.verticalAlignment = ChartLegendVerticalAlignmentBottom; legend.orientation = ChartLegendOrientationHorizontal ; legend.drawInside = NO; legend.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:12.0f]; legend.yOffset = 1.0; legend.xOffset = 1.0; legend.yEntrySpace =1; ChartXAxis *xAxis = chartView.xAxis; xAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]; xAxis.axisMinimum = 0.0; xAxis.granularity = 1.0f; xAxis.labelCount=count; xAxis.labelRotationAngle=20; xAxis.drawGridLinesEnabled=NO; xAxis.centerAxisLabelsEnabled = YES; xAxis.labelPosition = XAxisLabelPositionBottom; xAxis.valueFormatter =formatter ; ChartYAxis *leftAxis = chartView.leftAxis; leftAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]; leftAxis.valueFormatter = [[YAxisValueFormatter alloc] init]; leftAxis.drawGridLinesEnabled = YES; leftAxis.gridColor = [UIColor colorWithRed:200/255.0f green:200/255.0f blue:200/255.0f alpha:1];//网格线颜色 leftAxis.spaceTop = 0.35; leftAxis.granularityEnabled=YES; leftAxis.gridLineWidth =1; if(minimumValue<0) { leftAxis.axisMinimum = minimumValue; } else { leftAxis.axisMinimum=0; } leftAxis.axisMaximum=maximumValue+100; leftAxis.decimals=2; // leftAxis.granularity=maximumValue/5; chartView.rightAxis.enabled = NO; float groupSpace = 0.1f; float barSpace = 0.15f; float barWidth = 0.3f; NSMutableArray *yVals1 = [[NSMutableArray alloc] init]; NSMutableArray *yVals2 = [[NSMutableArray alloc] init]; int start =0; long end = barchartArray.count; for (int i = start; i < end; i++) { NSMutableDictionary *barchartDic=barchartArray[i]; double y1=0; double y2=0; if([[barchartDic allKeys] containsObject:@"transactionCount"]) { y1= [[barchartDic objectForKey:@"transactionCount"]doubleValue]; } if([[barchartDic allKeys] containsObject:@"filingCount"]) { y2=[[barchartDic objectForKey:@"filingCount"]doubleValue]; } [yVals1 addObject:[[BarChartDataEntry alloc] initWithX:i y:y1]]; [yVals2 addObject:[[BarChartDataEntry alloc] initWithX:i y:y2]]; } BarChartDataSet *set1 = nil, *set2 = nil; if (chartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)chartView.data.dataSets[0]; set2 = (BarChartDataSet *)chartView.data.dataSets[1]; [set1 replaceEntries:yVals1]; [set2 replaceEntries:yVals2]; BarChartData *data = chartView.barData; chartView.xAxis.axisMinimum = start; chartView.xAxis.axisMaximum = [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * end + start; [data groupBarsFromX: start groupSpace: groupSpace barSpace: barSpace]; [chartView.data notifyDataChanged]; [chartView notifyDataSetChanged]; } else { set1 = [[BarChartDataSet alloc] initWithEntries:yVals1 label:receivablesTitleArry[0]]; [set1 setColor:[UIColor colorWithRed:70/255.0f green:116/255.0f blue:193/255.0f alpha:1]]; set2 = [[BarChartDataSet alloc] initWithEntries:yVals2 label:receivablesTitleArry[1]]; [set2 setColor:[UIColor colorWithRed:235/255.0f green:125/255.0f blue:60/255.0f alpha:1]]; [set1 setDrawValuesEnabled:NO]; [set2 setDrawValuesEnabled:NO]; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; [dataSets addObject:set2]; BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]]; data.barWidth = barWidth; // restrict the x-axis range chartView.xAxis.axisMinimum = start; // groupWidthWithGroupSpace(...) is a helper that calculates the width each group needs based on the provided parameters chartView.xAxis.axisMaximum = start+ [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * end; [data groupBarsFromX: start groupSpace: groupSpace barSpace: barSpace]; chartView.data = data; } } /** 切换渠道部门按钮颜色 */ -(void)changeSalesStatusChannelDepartmentColor { btnSalesStatusChannelMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesStatusChannel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnSalesStatusDepartmentMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesStatusDepartment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)changeSalesAchievementDepartmentStaffColor { btnSalesAchievementDepartmentMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesAchievementDepartment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnSalesAchievementStaffMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesAchievementStaff setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)changeOrderStatusChannelDepartmentColor { btnOrderStatusChannelMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusChannel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnOrderStatusDepartmentMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnOrderStatusDepartment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)selectSalesAchievementCustomDate { [self changeSalesAchievementMonthColor]; [_btnSalesAchievementCustom setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; btnSalesAchievementCustomMaskLayer.strokeColor=[UIColor redColor].CGColor; ITDatePickerController *datePickerController = [[ITDatePickerController alloc] init]; datePickerController.tag = 100; datePickerController.delegate = self; datePickerController.showToday = NO; datePickerController.defaultDate = nil; [self presentViewController:datePickerController animated:YES completion:nil]; } -(void)getSalesAchievementCurrentMonth { [self changeSalesAchievementMonthColor]; btnSalesAchievementCurrentMonthMaskLayer.strokeColor=[UIColor redColor].CGColor; [_btnSalesAchievemmentToday setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; //NSDate转NSString _salesAchievementMonth = [DateFormat getCurrentNoSeparateMonth]; [_btnSalesAchievemmentToday setTitle: [DateFormat getCurrentMonth] forState:UIControlStateNormal]; [self clearSalesAchievementData]; [self startLoading]; [self loadSalesAchievementData]; } -(void)changeSalesAchievementMonthColor { btnSalesAchievementCustomMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesAchievementCustom setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnSalesAchievementCurrentMonthMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnSalesAchievemmentToday setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } /** 切换收款状态渠道部门按钮颜色 */ -(void)changeCollectionStatusChannelDepartmentColor { btnCollectionStatusChannelMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusChannel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btnCollectionStatusDepartmentMaskLayer.strokeColor=[UIColor lightGrayColor].CGColor; [_btnCollectionStatusDepartment setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; } -(void)btnSelectShoppingGuideStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempShoppingGuideStartDate=date; } andCompletionBlock:^(void){ _shoppingGuideStartDate = _tempShoppingGuideStartDate; [weakself.btnShoppingGuideStartDate setTitle:_shoppingGuideStartDate forState:UIControlStateNormal]; [self clearShoppingGuideFilingData]; [self startLoading]; [self loadShoppingGuideData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectShoppingGuideEndDate { _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempShoppingGuideEndDate=date; } andCompletionBlock:^(void){ _shoppingGuideEndDate = _tempShoppingGuideEndDate; [_btnShoppingGuideEndDate setTitle:_shoppingGuideEndDate forState:UIControlStateNormal]; [self clearShoppingGuideFilingData]; [self startLoading]; [self loadShoppingGuideData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectCollectionStatusStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempCollectionStatusStartDate=date; } andCompletionBlock:^(void){ _collectionStatusStartDate = _tempCollectionStatusStartDate; [weakself.btnCollectionStatusStartDate setTitle:_collectionStatusStartDate forState:UIControlStateNormal]; [self startLoading]; [collectionStatusXArray removeAllObjects]; [collectionStatusYArray removeAllObjects]; [self clearCollectionStatusData]; [self loadCashData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectDeliveryStatusStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempDeliveryStatusStartDate=date; } andCompletionBlock:^(void){ _deliveryStatusStartDate = _tempDeliveryStatusStartDate; [weakself.btnDeliveryStatusStartDate setTitle:_deliveryStatusStartDate forState:UIControlStateNormal]; [self startLoading]; [self clearDeliveryData]; [self loadDeliveryData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectDeliveryStatusEndDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempDeliveryStatusEndDate=date; } andCompletionBlock:^(void){ _deliveryStatusEndDate = _tempDeliveryStatusEndDate; [weakself.btnDeliveryStatusEndDate setTitle:_deliveryStatusEndDate forState:UIControlStateNormal]; [self startLoading]; [self clearDeliveryData]; [self loadDeliveryData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectCollectionStatusEndDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempCollectionStatusEndDate=date; } andCompletionBlock:^(void){ _collectionStatusEndDate = _tempCollectionStatusEndDate; [weakself.btnCollectionStatusEndDate setTitle:_collectionStatusEndDate forState:UIControlStateNormal]; [self startLoading]; [collectionStatusXArray removeAllObjects]; [collectionStatusYArray removeAllObjects]; [self clearCollectionStatusData]; [self loadCashData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectInstallStatusStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempInstallStatusStartDate=date; } andCompletionBlock:^(void){ _installStatusStartDate = _tempInstallStatusStartDate; [weakself.btnInstallStatusStartDate setTitle:_installStatusStartDate forState:UIControlStateNormal]; [self startLoading]; [self clearInstallData]; [self loadInstallData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectInstallStatusEndDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempInstallStatusEndDate=date; } andCompletionBlock:^(void){ _installStatusEndDate = _tempInstallStatusEndDate; [weakself.btnInstallStatusEndDate setTitle:_installStatusEndDate forState:UIControlStateNormal]; [self startLoading]; [self clearInstallData]; [self loadInstallData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectRepairStatusStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempRepairStatusStartDate=date; } andCompletionBlock:^(void){ _repairStatusStartDate = _tempRepairStatusStartDate; [weakself.btnRepairStatusStartDate setTitle:_repairStatusStartDate forState:UIControlStateNormal]; [self startLoading]; [self clearRepairData]; [self loadRepairData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectRepairStatusEndDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempRepairStatusEndDate=date; } andCompletionBlock:^(void){ _repairStatusEndDate = _tempRepairStatusEndDate; [weakself.btnRepairStatusEndDate setTitle:_repairStatusEndDate forState:UIControlStateNormal]; [self startLoading]; [self clearRepairData]; [self loadRepairData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectOrderStatusStartDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempOrderStatusStartDate=date; } andCompletionBlock:^(void){ _orderStatusStartDate = _tempOrderStatusStartDate; [weakself.btnOrderStatusStartDate setTitle:_orderStatusStartDate forState:UIControlStateNormal]; [self startLoading]; [orderStatusXArray removeAllObjects]; [orderStatusYArray removeAllObjects]; [self clearOrderStatusData]; [self loadOrderStatusData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } -(void)btnSelectOrderStatusEndDate { __weak typeof(self) weakself=self; _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_dealDatePicker configureSelectionBlock:^(NSString *date){ _tempOrderStatusEndDate=date; } andCompletionBlock:^(void){ _orderStatusEndDate = _tempOrderStatusEndDate; [weakself.btnOrderStatusEndDate setTitle:_orderStatusEndDate forState:UIControlStateNormal]; [self clearOrderStatusData]; [self startLoading]; [orderStatusXArray removeAllObjects]; [orderStatusYArray removeAllObjects]; [self loadOrderStatusData]; } andCancelBlock:^(void){ }]; [_dealDatePicker show]; } /** 画单个柱状图 */ -(void)drawSingleBarchart:(NSMutableArray*)barchartArray chartView:(BarChartView*)chart axisValueFormatter:(id)formatter xAxisLabelCount:(NSInteger)count maximumValue:(double)maximumValue minimumValue:(double)minimumValue { chart.chartDescription.enabled = NO; chart.legend.enabled = NO; chart.drawGridBackgroundEnabled = NO; chart.dragEnabled = YES; [chart setScaleEnabled:YES]; chart.pinchZoomEnabled = NO; chart.extraBottomOffset=20; chart.rightAxis.enabled = NO; chart.delegate = self; chart.drawBarShadowEnabled = NO; chart.drawValueAboveBarEnabled = YES; BalloonMarker *marker = [[BalloonMarker alloc] initWithColor: [UIColor colorWithWhite:210/255. alpha:1.0] font: [UIFont systemFontOfSize:12.0] textColor: UIColor.whiteColor insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)]; marker.chartView = chart; marker.minimumSize = CGSizeMake(80.f, 40.f); chart.marker = marker; chart.maxVisibleCount = 60; ChartXAxis *xAxis = chart.xAxis; xAxis.labelPosition = XAxisLabelPositionBottom; xAxis.labelFont = [UIFont systemFontOfSize:10.f]; xAxis.drawGridLinesEnabled = NO; xAxis.granularity = 1.0; // only intervals of 1 day xAxis.labelCount = count; xAxis.labelRotationAngle=20; xAxis.valueFormatter = formatter; ChartYAxis *leftAxis = chart.leftAxis; leftAxis.labelFont = [UIFont systemFontOfSize:10.f]; leftAxis.axisMaximum=maximumValue+100; leftAxis.labelPosition = YAxisLabelPositionOutsideChart; leftAxis.spaceTop = 0.15; if(minimumValue<0) { leftAxis.axisMinimum =minimumValue; } else{ leftAxis.axisMinimum = 0.0; } double start = 0; NSMutableArray *yVals1 = [[NSMutableArray alloc] init]; for (int i = start; i < barchartArray.count; i++) { BarChartDataEntry *dataEntry; dataEntry= [[BarChartDataEntry alloc] initWithX:i y:[[barchartArray objectAtIndex:i]doubleValue] icon: [UIImage imageNamed:@"icon"] ]; [yVals1 addObject:dataEntry]; } BarChartDataSet *set1 = nil; UIColor *blueColor= [UIColor colorWithRed:70/255.0f green:116/255.0f blue:193/255.0f alpha:1]; NSMutableArray *colorArray=[[NSMutableArray alloc]init]; [colorArray addObject:blueColor]; if (chart.data.dataSetCount > 0) { set1 = (BarChartDataSet *)chart.data.dataSets[0]; [set1 replaceEntries: yVals1]; [chart.data notifyDataChanged]; [chart notifyDataSetChanged]; } else { set1 = [[BarChartDataSet alloc] initWithEntries:yVals1 label:@"资金"]; [set1 setColors:colorArray]; set1.drawIconsEnabled = NO; [set1 setDrawValuesEnabled:NO]; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.0f]]; data.barWidth = 0.5f; chart.data = data; } } /** * 异步执行 + 并发队列 * 特点:可以开启多个线程,任务交替(同时)执行。 */ - (void)asyncConcurrent { dispatch_queue_t queue = dispatch_queue_create("com.test.queue", DISPATCH_QUEUE_CONCURRENT); // if([kkRights rangeOfString: FUNCTION_SALES_DATA_SALES_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadSalesStatusData]; }); // } // if([kkRights rangeOfString: FUNCTION_SALES_DATA_COLLECTION_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadCashData]; }); //} // if([kkRights rangeOfString: FUNCTION_SALES_DATA_ORDER_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadOrderStatusData]; }); // } // if([kkRights rangeOfString: FUNCTION_SALES_DATA_SHOPPING_GUIDE_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadShoppingGuideData]; }); // } // if([kkRights rangeOfString: FUNCTION_SALES_DATA_DELIVERY_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadDeliveryData]; }); // } // if([kkRights rangeOfString: FUNCTION_SALES_DATA_INSTALL_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadInstallData]; }); // } // if([kkRights rangeOfString: FUNCTION_SALES_DATA_REPAIR_STATUS_IPHONE].location!=NSNotFound){ dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadRepairData]; }); // } dispatch_async(queue, ^{ // 追加任务 1 [NSThread sleepForTimeInterval:1]; // 模拟耗时操作 [self loadSalesAchievementData]; }); } -(void)loadDeliveryData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisDistributionDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; _deliveryDownManager = [[ASIDownManager alloc] init]; _deliveryDownManager.delegate = self; _deliveryDownManager.onRequestSuccess = @selector(onDeliveryStatusLoadFinish:); _deliveryDownManager.onRequestFail = @selector(onDeliveryStatusLoadFail:); [_deliveryDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadRepairData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisRepairDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; _repairDownManager = [[ASIDownManager alloc] init]; _repairDownManager.delegate = self; _repairDownManager.onRequestSuccess = @selector(onRepairStatusLoadFinish:); _repairDownManager.onRequestFail = @selector(onRepairStatusLoadFail:); [_repairDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadInstallData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisInstallationDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; _installDownManager = [[ASIDownManager alloc] init]; _installDownManager.delegate = self; _installDownManager.onRequestSuccess = @selector(onInstallStatusLoadFinish:); _installDownManager.onRequestFail = @selector(onInstallStatusLoadFail:); [_installDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 加载销售利润数据源 */ -(void)loadSalesStatusData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisSaleDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:typeId forKeyedSubscript:@"TypeID"]; [dict setObject:_salesStatusStartDate forKeyedSubscript:@"AccountDateFrom"]; [dict setObject:_salesStatusEndDate forKeyedSubscript:@"AccountDateTo"]; _salesStatusDownManager = [[ASIDownManager alloc] init]; _salesStatusDownManager.delegate = self; _salesStatusDownManager.onRequestSuccess = @selector(onSalesStatusLoadFinish:); _salesStatusDownManager.onRequestFail = @selector(onSalesStatusLoadFail:); [_salesStatusDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadSalesAchievementData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisAchievementDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:salesAchievementTypeId forKeyedSubscript:@"TypeID"]; [dict setObject:_salesAchievementMonth forKeyedSubscript:@"AccountMonth"]; _salesAchievementDownManager = [[ASIDownManager alloc] init]; _salesAchievementDownManager.delegate = self; _salesAchievementDownManager.onRequestSuccess = @selector(onSalesAchievementLoadFinish:); _salesAchievementDownManager.onRequestFail = @selector(onSalesAchievementLoadFail:); [_salesAchievementDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadOrderStatusData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisOrderData" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:orderStatusTypeId forKeyedSubscript:@"TypeID"]; [dict setObject:_orderStatusStartDate forKeyedSubscript:@"AccountDateFrom"]; [dict setObject:_orderStatusEndDate forKeyedSubscript:@"AccountDateTo"]; _orderStatusDownManager = [[ASIDownManager alloc] init]; _orderStatusDownManager.delegate = self; _orderStatusDownManager.onRequestSuccess = @selector(onOrderStatusLoadFinish:); _orderStatusDownManager.onRequestFail = @selector(onOrderStatusLoadFail:); [_orderStatusDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadShoppingGuideData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisRecordDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_shoppingGuideStartDate forKeyedSubscript:@"AccountDateFrom"]; [dict setObject:_shoppingGuideEndDate forKeyedSubscript:@"AccountDateTo"]; _shoppingGuideDownManager = [[ASIDownManager alloc] init]; _shoppingGuideDownManager.delegate = self; _shoppingGuideDownManager.onRequestSuccess = @selector(onShoppingGuideLoadFinish:); _shoppingGuideDownManager.onRequestFail = @selector(onShoppingGuideLoadFail:); [_shoppingGuideDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } -(void)loadCashData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetSalesStatisticalAnalysisCashDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:cashStatusTypeId forKeyedSubscript:@"TypeID"]; [dict setObject:_collectionStatusStartDate forKeyedSubscript:@"AccountDateFrom"]; [dict setObject:_collectionStatusEndDate forKeyedSubscript:@"AccountDateTo"]; _cashStatusDownManager = [[ASIDownManager alloc] init]; _cashStatusDownManager.delegate = self; _cashStatusDownManager.onRequestSuccess = @selector(onCashStatusLoadFinish:); _cashStatusDownManager.onRequestFail = @selector(onCashStatusLoadFail:); [_cashStatusDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } #pragma mark - 代理函数 - (void)datePickerController:(ITDatePickerController *)datePickerController didSelectedDate:(NSDate *)date dateString:(NSString *)dateString { NSInteger tag = datePickerController.tag; if (datePickerController.tag == 100) { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM"] ; NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init]; [dateFormatter1 setDateFormat:@"yyyyMM"]; //NSDate转NSString _salesAchievementMonth = [dateFormatter1 stringFromDate:date]; [_btnSalesAchievementCustom setTitle: [dateFormatter stringFromDate:date] forState:UIControlStateNormal]; [self clearSalesAchievementData]; [self startLoading]; [self loadSalesAchievementData]; } } -(void)onSalesAchievementLoadFinish:(ASIDownManager *)sender { [self stopLoading]; RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; int status= resultModel.status; if(status==0) { NSDictionary *resultDic=(NSDictionary*)[resultModel result]; NSArray *tableArray= [resultDic objectForKey:@"Table"]; if(tableArray!=nil&&tableArray.count>0) { double totalAmount=0; double totalPlanAmount=0; NSMutableArray *salesAchievementArray=[[NSMutableArray alloc]init]; for(int i=0;i0) { NSDictionary *dic=[resultArray objectAtIndex:0]; int repairNo= [[dic objectForKey:@"RepairNo"]intValue]; int repairOkNo= [[dic objectForKey:@"RepairOkNo"]intValue]; int repairNoOne= [[dic objectForKey:@"RepairNo_One"]intValue]; int repairNoTwo=[[dic objectForKey:@"RepairNo_Two"]intValue]; int repairNoThree=[[dic objectForKey:@"RepairNo_Three"]intValue]; lblNeedRepairCustomerCount.text=[NSString stringWithFormat:@"%d",repairNo]; lblRepairedCustomerCount.text=[NSString stringWithFormat:@"%d",repairOkNo]; lblNextDayNeedRepairCount.text=[NSString stringWithFormat:@"%d",repairNoOne]; lblNextTwoDaysNeedRepairCount.text=[NSString stringWithFormat:@"%d",repairNoTwo]; lblNextThreeDaysNeedRepairCount.text=[NSString stringWithFormat:@"%d",repairNoThree]; double percent=0; if(repairNo==0) { percent=0; } else{ percent= repairOkNo/repairNo*100; } [_repairStatusView progress:percent ]; lblRepairPercent.text=[NSString stringWithFormat:@"%@%.2f%@",@"完成率",percent,@"%"]; } } } -(void)onRepairStatusLoadFail:(ASIDownManager *)sender { [self stopLoading]; } -(void)onDeliveryStatusLoadFinish:(ASIDownManager *)sender { [self stopLoading]; RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; int status= resultModel.status; if(status==0) { NSDictionary *resultDic=(NSDictionary*)[resultModel result]; NSArray *resultArray=[resultDic objectForKey:@"Table"]; if(resultArray!=nil&&resultArray.count>0) { NSDictionary *dic=[resultArray objectAtIndex:0]; int deliveryNo= [[dic objectForKey:@"DeliveryNo"]intValue]; int deliveryOkNo= [[dic objectForKey:@"DeliveryOkNo"]intValue]; int deliveryNoOne= [[dic objectForKey:@"DeliveryNo_One"]intValue]; int deliveryNoTwo=[[dic objectForKey:@"DeliveryNo_Two"]intValue]; int deliveryNoThree=[[dic objectForKey:@"DeliveryNo_Three"]intValue]; lblNeedDeliveryCustomerCount.text=[NSString stringWithFormat:@"%d",deliveryNo]; lblDeliveredCustomerCount.text=[NSString stringWithFormat:@"%d",deliveryOkNo]; lblNextDayNeedDeliveryCount.text=[NSString stringWithFormat:@"%d",deliveryNoOne]; lblNextTwoDaysNeedDeliveryCount.text=[NSString stringWithFormat:@"%d",deliveryNoTwo]; lblNextThreeDaysNeedDeliveryCount.text=[NSString stringWithFormat:@"%d",deliveryNoThree]; double percent=0; if(deliveryNo==0) { percent=0; } else{ percent= deliveryOkNo/deliveryNo*100; } [_deliveryStatusView progress:percent ]; lblDeliveryPercent.text=[NSString stringWithFormat:@"%@%.2f%@",@"完成率",percent,@"%"]; } } } -(void)onDeliveryStatusLoadFail:(ASIDownManager *)sender { [self stopLoading]; } -(void)onInstallStatusLoadFinish:(ASIDownManager *)sender { [self stopLoading]; RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; int status= resultModel.status; if(status==0) { NSDictionary *resultDic=(NSDictionary*)[resultModel result]; if(resultDic!=nil) { NSArray *resultArray=[resultDic objectForKey:@"Table"]; if(resultArray!=nil&&resultArray.count>0) { NSDictionary *dic=[resultArray objectAtIndex:0]; int installNo= [[dic objectForKey:@"InstallationNo"]intValue]; int installOkNo= [[dic objectForKey:@"InstallationOkNo"]intValue]; int installNoOne= [[dic objectForKey:@"InstallationNo_One"]intValue]; int installNoTwo=[[dic objectForKey:@"InstallationNo_Two"]intValue]; int installNoThree=[[dic objectForKey:@"InstallationNo_Three"]intValue]; lblNeedInstallCustomerCount.text=[NSString stringWithFormat:@"%d",installNo]; lblInstalledCustomerCount.text=[NSString stringWithFormat:@"%d",installOkNo]; lblNextDayNeedInstallCount.text=[NSString stringWithFormat:@"%d",installNoOne]; lblNextTwoDaysNeedInstallCount.text=[NSString stringWithFormat:@"%d",installNoTwo]; lblNextThreeDaysNeedInstallCount.text=[NSString stringWithFormat:@"%d",installNoThree]; double percent=0; if(installNo==0) { percent=0; } else{ percent= installOkNo/installNo*100; } [_installStatusView progress:percent]; lblInstallPercent.text=[NSString stringWithFormat:@"%@%.2f%@",@"完成率",percent,@"%"]; } } } } -(void)onInstallStatusLoadFail:(ASIDownManager *)sender { [self stopLoading]; } -(void)onShoppingGuideLoadFinish:(ASIDownManager *)sender { [self stopLoading]; RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; int status= resultModel.status; if(status==0) { NSDictionary *resultDic=(NSDictionary*)[resultModel result]; if(resultDic!=nil) { NSArray *table1Array= [resultDic objectForKey:@"Table1"]; NSArray *tableArray= [resultDic objectForKey:@"Table"]; if(table1Array!=nil&&table1Array.count>0) { NSDictionary *table1Dic=[table1Array objectAtIndex:0]; int num= [[table1Dic objectForKey:@"Num"]intValue]; int okNum= [[table1Dic objectForKey:@"OkNum"]intValue]; double transactionPercent=0; if(num==0) { transactionPercent=0; } else{ transactionPercent= okNum/num*100; } lblFilingCustomerCount.text=[NSString stringWithFormat:@"%d",num]; lblTransactionCustomerCount.text=[NSString stringWithFormat:@"%d",okNum]; [_transactionView progress:transactionPercent ]; } if(tableArray!=nil&&tableArray.count>0) { NSMutableArray *yArray=[[NSMutableArray alloc]init]; for(int i=0;i0) { for(int i=0;i0) { NSDictionary *table1Dic=[table1Array objectAtIndex:0]; int customerReturnNo=[[table1Dic objectForKey:@"CustomerReturnNo"]intValue]; int customerNo=[[table1Dic objectForKey:@"CustomerNo"]intValue]; double amount=[[table1Dic objectForKey:@"Amount"]doubleValue]; double returnAmount=[[table1Dic objectForKey:@"ReturnAmount"]doubleValue]; lblOrderCustomerCount.text=[NSString stringWithFormat:@"%d",customerNo]; lblUnsubscribeCustomerCount.text=[NSString stringWithFormat:@"%d",customerReturnNo]; NSString *amountStr=[NSString stringWithFormat:@"%.2f",amount]; amountStr=[Util thousandSeparatorFormat:amountStr]; lblOrderAmount.text=amountStr; NSString *returnAmountStr=[NSString stringWithFormat:@"%.2f",returnAmount]; returnAmountStr=[Util thousandSeparatorFormat:returnAmountStr]; lblUnsubscribeAmount.text=returnAmountStr; } } } } -(void)onOrderStatusLoadFail:(ASIDownManager *)sender { [self stopLoading]; } -(void)onCashStatusLoadFinish:(ASIDownManager *)sender { [self stopLoading]; RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; int status= resultModel.status; if(status==0) { NSDictionary *resultDic=(NSDictionary*)resultModel.result; if(resultDic!=nil) { NSArray *resultArray=[resultDic objectForKey:@"Table"]; if(resultArray!=nil&&resultArray.count>0) { double totalAmount=0; for(int i=0;i0) { NSDictionary *table1Dic= [table1Array objectAtIndex:0]; int customerNewNo=[[table1Dic objectForKey:@"CustomerNewNo"]intValue]; int customerNo=[[table1Dic objectForKey:@"CustomerNo"]intValue]; lblSalesAddCustomer.text=[NSString stringWithFormat:@"%d",customerNewNo]; lblSalesCustomerCount.text=[NSString stringWithFormat:@"%d",customerNo]; } if(tableArray!=nil&&tableArray.count>0) { double totalAmount=0; for(int i=0;i