Просмотр исходного кода

外呼任务报表添加合计行

mengjie лет назад: 7
Родитель
Сommit
cead9ee17f

+ 95 - 4
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/CallOutReportController.cs

@@ -451,7 +451,7 @@ namespace CallCenterApi.Interface.Controllers.report
451 451
         {
452 452
             #region 测试用
453 453
             //TaskID = "";
454
-            //quesid = "1";
454
+            //quesid = "50";
455 455
             ////countryid = "524";
456 456
             //sdate = "2018-02-27";
457 457
             //edate = "2018-07-25";
@@ -495,7 +495,9 @@ namespace CallCenterApi.Interface.Controllers.report
495 495
             {
496 496
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
497 497
             }
498
-
498
+            //2018-7-6
499
+            DataRow drtotal = dtnew.NewRow();
500
+            drtotal["乡镇"] = "合计";
499 501
             #region 根据单位和QuestionItemID统计数量
500 502
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
501 503
             {
@@ -508,6 +510,7 @@ namespace CallCenterApi.Interface.Controllers.report
508 510
                     foreach (var iconf in dsc)
509 511
                     {
510 512
                         DataRow dr = dtnew.NewRow();
513
+                        
511 514
                         dr["乡镇"] = iconf.F_Name;
512 515
                         DataSet dsa = DbHelperSQL.Query("select count(F_Expand3) from T_Call_OutAnswers where  DATEDIFF(day,F_OptOn,'" + sdate + "')<=0 and DATEDIFF(day,F_OptOn,'" + edate + "')>=0 and F_Answer='" + iconf.F_Name + "' "+strand+strtaskid  );
513 516
                         DataTable dta = dsa.Tables[0];
@@ -524,6 +527,7 @@ namespace CallCenterApi.Interface.Controllers.report
524 527
                                 {
525 528
                                     var dsk = ansBLL.GetRecordCount(" F_Expand3 IN  (select F_Expand3 from T_Call_OutAnswers where DATEDIFF(day,F_OptOn,'" + sdate + "')<=0 and DATEDIFF(day,F_OptOn,'" + edate + "')>=0 "+strand +strtaskid +" and F_Answer='" + iconf.F_Name + "') and F_QID='" + quesid + "' and F_QIID='" + itemconf.F_ItemId + "'");
526 529
                                     dr[itemconf.F_ItemName] = dsk;
530
+                                    
527 531
                                     totalnum += dsk;
528 532
                                     if (quesid == "1")
529 533
                                     {
@@ -660,12 +664,58 @@ namespace CallCenterApi.Interface.Controllers.report
660 664
                     }
661 665
                 }                
662 666
             }
667
+            if (dsi.Count > 0)
668
+            {
669
+                foreach (var itemconf in dsi)
670
+                {
671
+                    if (quesid == "1")
672
+                    {
673
+                        if (itemconf.F_ItemName != "安全感指数")
674
+                        {
675
+                            drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
676
+                        }
677
+                        else
678
+                        {
679
+                            drtotal[itemconf.F_ItemName] = "";
680
+                        }
681
+                    }
682
+                    else if (quesid == "50")
683
+                    {
684
+                        if (itemconf.F_ItemName != "知晓率" && itemconf.F_ItemName != "参与率")
685
+                        {
686
+                            drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
687
+                        }
688
+                        else
689
+                        {
690
+                            drtotal[itemconf.F_ItemName] = "";
691
+                        }
692
+                    }
693
+                    else
694
+                    {
695
+                        drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
696
+                    }
697
+                }
698
+            }
699
+            if (quesid == "1"|| quesid == "50")
700
+            { drtotal["总数"] = ColumnSum(dtnew, "总数"); }
701
+                
702
+            dtnew.Rows.Add(drtotal);
663 703
             return Success("获取外呼任务报表数据成功", dtnew);
664 704
             #endregion
665 705
 
666 706
         }
667 707
         #endregion
668 708
 
709
+        double ColumnSum(DataTable dt, string ColumnName)
710
+        {
711
+            double d = 0;
712
+            foreach (DataRow row in dt.Rows)
713
+            {
714
+                d += double.Parse(row[ColumnName].ToString());
715
+            }
716
+            return d;
717
+        }
718
+
669 719
         #region 导出外呼任务报表
670 720
         /// <summary>
671 721
         /// 外呼任务报表
@@ -724,7 +774,9 @@ namespace CallCenterApi.Interface.Controllers.report
724 774
             {
725 775
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
726 776
             }
727
-
777
+            //2018-7-6
778
+            DataRow drtotal = dtnew.NewRow();
779
+            drtotal["乡镇"] = "合计";
728 780
             #region 根据单位和QuestionItemID统计数量
729 781
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
730 782
             {
@@ -889,8 +941,47 @@ namespace CallCenterApi.Interface.Controllers.report
889 941
                     }
890 942
                 }
891 943
             }
892
-            
944
+
893 945
             #endregion
946
+
947
+            //2018-7-6
948
+            if (dsi.Count > 0)
949
+            {
950
+                foreach (var itemconf in dsi)
951
+                {
952
+                    if (quesid == "1")
953
+                    {
954
+                        if (itemconf.F_ItemName != "安全感指数")
955
+                        {
956
+                            drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
957
+                        }
958
+                        else
959
+                        {
960
+                            drtotal[itemconf.F_ItemName] = "";
961
+                        }
962
+                    }
963
+                    else if (quesid == "50")
964
+                    {
965
+                        if (itemconf.F_ItemName != "知晓率" && itemconf.F_ItemName != "参与率")
966
+                        {
967
+                            drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
968
+                        }
969
+                        else
970
+                        {
971
+                            drtotal[itemconf.F_ItemName] = "";
972
+                        }
973
+                    }
974
+                    else
975
+                    {
976
+                        drtotal[itemconf.F_ItemName] = ColumnSum(dtnew, itemconf.F_ItemName);
977
+                    }
978
+                }
979
+            }
980
+            if (quesid == "1" || quesid == "50")
981
+            { drtotal["总数"] = ColumnSum(dtnew, "总数"); }
982
+
983
+            dtnew.Rows.Add(drtotal);
984
+
894 985
             //导出dtnew
895 986
             NPOIHelper npoi = new NPOIHelper();
896 987
             string category = "";