Exemplo n.º 1
0
        /// <summary>
        /// P23医疗照顾相关感染指标月统计表
        /// </summary>
        /// <param name="doc"></param>
        private void P23Operation(WordDocument doc)
        {
            DateTime now = DateTime.Now;

            doc.ReplaceText("year", now.Year.ToString());
            doc.ReplaceText("month", now.Month.ToString());
            IReportManageService reportManageService = IOCContainer.Instance.Resolve <IReportManageService>();
            decimal total = reportManageService.GetResidentTotal(now);

            if (total == 0)
            {
                doc.ReplaceText("UTotal", "0");
                doc.ReplaceText("STotal", "0");
                doc.ReplaceText("CTotal", "0");
                doc.ReplaceText("NTotal", "0");
                doc.ReplaceText("RTotal", "0");
                doc.ReplaceText("N0", "0");
                doc.ReplaceText("N1", "0");
                doc.ReplaceText("N2", "0");
                doc.ReplaceText("N3", "0");
                doc.ReplaceText("N4", "0");
                doc.ReplaceText("N5", "0");
                doc.ReplaceText("R0", "0");
                doc.ReplaceText("R1", "0");
                doc.ReplaceText("R2", "0");
                doc.ReplaceText("R3", "0");
                doc.ReplaceText("R4", "0");
                doc.ReplaceText("R5", "0");
                return;
            }
            doc.ReplaceText("CTotal", total.ToString("#0"));

            var     list   = reportManageService.GetInfection(now);
            decimal nTotal = list.Sum(o => o.Total);

            if (nTotal == 0)
            {
                doc.ReplaceText("NTotal", "0");
                doc.ReplaceText("RTotal", "0");
            }
            else
            {
                doc.ReplaceText("NTotal", nTotal.ToString("#0"));
                doc.ReplaceText("RTotal", (nTotal / total * 100).ToString("#0.0"));
            }
            decimal sTotal = reportManageService.GetUsedPipeTotal(now);
            decimal uTotal = total - sTotal;

            doc.ReplaceText("STotal", sTotal.ToString("#0"));
            doc.ReplaceText("UTotal", uTotal.ToString("#0"));
            var keys = new[] { "001", "002", "003", "004", "005" };

            for (int i = 0; i < 5; i++)
            {
                if (nTotal == 0)
                {
                    doc.ReplaceText("N" + i, "0");
                    doc.ReplaceText("R" + i, "0");
                    continue;
                }
                var obj = list.FirstOrDefault(o => o.Type == keys[i]);
                if (obj != null)
                {
                    if (i == 2)
                    {
                        doc.ReplaceText("N" + i, obj.Total.ToString());
                        doc.ReplaceText("R" + i, sTotal != 0 ? (obj.Total / sTotal * 100).ToString("#0.0") : "0");
                    }
                    else if (i == 3)
                    {
                        doc.ReplaceText("N" + i, obj.Total.ToString());
                        doc.ReplaceText("R" + i, uTotal != 0 ? (obj.Total / uTotal * 100).ToString("#0.0") : "0");
                    }
                    else
                    {
                        doc.ReplaceText("N" + i, obj.Total.ToString());
                        doc.ReplaceText("R" + i, (obj.Total / total * 100).ToString("#0.0"));
                    }
                }
                else
                {
                    doc.ReplaceText("N" + i, "0");
                    doc.ReplaceText("R" + i, "0");
                }
            }

            var n5 = list.Where(o => o.Type == "003" || o.Type == "004").Sum(o => o.Total);

            doc.ReplaceText("N5", n5.ToString());
            doc.ReplaceText("R5", n5 != 0 ? (n5 / total * 100).ToString("#0.0") : "0");
        }