Explorar el Código

外呼任务报表添加合计行

mengjie %!s(int64=7) %!d(string=hace) años
padre
commit
cead9ee17f

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

451
         {
451
         {
452
             #region 测试用
452
             #region 测试用
453
             //TaskID = "";
453
             //TaskID = "";
454
-            //quesid = "1";
454
+            //quesid = "50";
455
             ////countryid = "524";
455
             ////countryid = "524";
456
             //sdate = "2018-02-27";
456
             //sdate = "2018-02-27";
457
             //edate = "2018-07-25";
457
             //edate = "2018-07-25";
495
             {
495
             {
496
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
496
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
497
             }
497
             }
498
-
498
+            //2018-7-6
499
+            DataRow drtotal = dtnew.NewRow();
500
+            drtotal["乡镇"] = "合计";
499
             #region 根据单位和QuestionItemID统计数量
501
             #region 根据单位和QuestionItemID统计数量
500
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
502
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
501
             {
503
             {
508
                     foreach (var iconf in dsc)
510
                     foreach (var iconf in dsc)
509
                     {
511
                     {
510
                         DataRow dr = dtnew.NewRow();
512
                         DataRow dr = dtnew.NewRow();
513
+                        
511
                         dr["乡镇"] = iconf.F_Name;
514
                         dr["乡镇"] = iconf.F_Name;
512
                         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  );
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
                         DataTable dta = dsa.Tables[0];
516
                         DataTable dta = dsa.Tables[0];
524
                                 {
527
                                 {
525
                                     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 + "'");
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
                                     dr[itemconf.F_ItemName] = dsk;
529
                                     dr[itemconf.F_ItemName] = dsk;
530
+                                    
527
                                     totalnum += dsk;
531
                                     totalnum += dsk;
528
                                     if (quesid == "1")
532
                                     if (quesid == "1")
529
                                     {
533
                                     {
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
             return Success("获取外呼任务报表数据成功", dtnew);
703
             return Success("获取外呼任务报表数据成功", dtnew);
664
             #endregion
704
             #endregion
665
 
705
 
666
         }
706
         }
667
         #endregion
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
         #region 导出外呼任务报表
719
         #region 导出外呼任务报表
670
         /// <summary>
720
         /// <summary>
671
         /// 外呼任务报表
721
         /// 外呼任务报表
724
             {
774
             {
725
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
775
                 strtaskid = " and F_TaskID='" + TaskID + "' ";
726
             }
776
             }
727
-
777
+            //2018-7-6
778
+            DataRow drtotal = dtnew.NewRow();
779
+            drtotal["乡镇"] = "合计";
728
             #region 根据单位和QuestionItemID统计数量
780
             #region 根据单位和QuestionItemID统计数量
729
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
781
             if (string.IsNullOrEmpty(countryid))//countryid == "")//为空时统计全部乡镇信息,否则显示单个乡镇数据
730
             {
782
             {
889
                     }
941
                     }
890
                 }
942
                 }
891
             }
943
             }
892
-            
944
+
893
             #endregion
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
             //导出dtnew
985
             //导出dtnew
895
             NPOIHelper npoi = new NPOIHelper();
986
             NPOIHelper npoi = new NPOIHelper();
896
             string category = "";
987
             string category = "";