|
|
@@ -1456,8 +1456,282 @@ namespace RMYY_CallCenter_Api.Controllers.CarManage
|
|
1456
|
1456
|
int n = new BLL.T_Car_Operation().Add(oper);
|
|
1457
|
1457
|
return n;
|
|
1458
|
1458
|
}
|
|
|
1459
|
+ /// <summary>
|
|
|
1460
|
+ ///科室维修
|
|
|
1461
|
+ /// </summary>
|
|
|
1462
|
+ /// <param name="starttime"></param>
|
|
|
1463
|
+ /// <param name="endtime"></param>
|
|
|
1464
|
+ /// <param name="type"></param>
|
|
|
1465
|
+ /// <param name="loweltype"></param>
|
|
|
1466
|
+ /// <param name="deptid"></param>
|
|
|
1467
|
+ /// <returns></returns>
|
|
|
1468
|
+
|
|
|
1469
|
+ public ActionResult DeptMaintenance(string starttime, string endtime, int loweltype = 0, int deptid = 0, int isdc = 0)
|
|
|
1470
|
+ {
|
|
|
1471
|
+ string where = "";
|
|
|
1472
|
+ if (!string.IsNullOrEmpty(starttime))
|
|
|
1473
|
+ {
|
|
|
1474
|
+ where += "and F_CreateTime>='" + starttime + "'";
|
|
|
1475
|
+ }
|
|
|
1476
|
+ if (!string.IsNullOrEmpty(endtime))
|
|
|
1477
|
+ {
|
|
|
1478
|
+ where += "and F_CreateTime<='" + endtime + "'";
|
|
|
1479
|
+ }
|
|
|
1480
|
+ if (deptid > 0)
|
|
|
1481
|
+ {
|
|
|
1482
|
+ where += "and [dbo].[GetDeptIdByUserCode](F_DriverCode)='" + deptid + "'";
|
|
|
1483
|
+ }
|
|
|
1484
|
+
|
|
|
1485
|
+ if (loweltype > 0)
|
|
|
1486
|
+ {
|
|
|
1487
|
+ where += $" and F_Type in(select F_GDId from [dbo].[GetValueId]({loweltype}))";
|
|
|
1488
|
+ }
|
|
|
1489
|
+
|
|
|
1490
|
+
|
|
|
1491
|
+ string sql = " select [dbo].[GetYQNameByDeptId]([dbo].[GetDeptIdByUserCode](F_DriverCode)) woname , " +
|
|
|
1492
|
+ " dbo.[GetCompleteDeptNames]([dbo].[GetDeptIdByUserCode](F_DriverCode)) MaintenanceDept," +
|
|
|
1493
|
+ " dbo.GetGongDanNameByID(F_Type) gdtype , " +
|
|
|
1494
|
+ " count(1) total," +
|
|
|
1495
|
+ " sum( case when F_State >= 7 then 1 else 0 end) complete," +
|
|
|
1496
|
+ " sum(case when F_State < 7 then 1 else 0 end) undone,CONVERT(int, (select count(1) from T_Car_Evaluate where" +
|
|
|
1497
|
+ " F_WorkOrderCode in ((stuff((select ',' + T.F_WorkOrderCode FROM T_Car_WorkOrder T WHERE" +
|
|
|
1498
|
+ " dbo.GetGongDanNameByID(a.F_Type) = dbo.GetGongDanNameByID(T.F_Type) and F_Source < 3" +
|
|
|
1499
|
+ " and[dbo].[GetDeptIdByUserCode](a.F_DriverCode) =[dbo].[GetDeptIdByUserCode](T.F_DriverCode)" +
|
|
|
1500
|
+ " for xml path('')),1,1,'')" +
|
|
|
1501
|
+ " )))) score from T_Car_WorkOrder a" + " where F_DriverCode is not null and F_DriverCode!= ''and F_State >= 1" + where
|
|
|
1502
|
+ + " group by[dbo].[GetDeptIdByUserCode] (a.F_DriverCode), dbo.GetGongDanNameByID(F_Type) " +
|
|
|
1503
|
+ " order by[dbo].[GetDeptIdByUserCode] (F_DriverCode)";
|
|
|
1504
|
+ var dataTable = DbHelperSQL.Query(sql ).Tables[0];
|
|
|
1505
|
+
|
|
|
1506
|
+ dataTable.Columns.Add("completerate", typeof(string));
|
|
|
1507
|
+ dataTable.Columns.Add("scorerate", typeof(string));
|
|
1459
|
1508
|
|
|
1460
|
|
- /// <summary>
|
|
|
1509
|
+ int total = 0, complete = 0, undone = 0, score = 0;
|
|
|
1510
|
+ foreach (DataRow row in dataTable.Rows)
|
|
|
1511
|
+ {
|
|
|
1512
|
+ if (row["total"] != null && row["total"].ToString() != "")
|
|
|
1513
|
+ {
|
|
|
1514
|
+ if (int.Parse(row["total"].ToString()) > 0)
|
|
|
1515
|
+ {
|
|
|
1516
|
+ total += int.Parse(row["total"].ToString());
|
|
|
1517
|
+ if (row["complete"] != null && row["complete"].ToString() != "")
|
|
|
1518
|
+ complete += int.Parse(row["complete"].ToString());
|
|
|
1519
|
+ if (row["undone"] != null && row["undone"].ToString() != "")
|
|
|
1520
|
+ undone += int.Parse(row["undone"].ToString());
|
|
|
1521
|
+
|
|
|
1522
|
+ if (row["score"] != null && row["score"].ToString() != "")
|
|
|
1523
|
+ score += int.Parse(row["score"].ToString());
|
|
|
1524
|
+ if (row["complete"] != null && row["complete"].ToString() != "")
|
|
|
1525
|
+ {
|
|
|
1526
|
+ row["completerate"] = string.Format("{0:f2}%", float.Parse(row["complete"].ToString()) / float.Parse(row["total"].ToString()) * 100);
|
|
|
1527
|
+ if (int.Parse(row["complete"].ToString()) > 0)
|
|
|
1528
|
+ {
|
|
|
1529
|
+ if (row["score"] != null && row["score"].ToString() != "")
|
|
|
1530
|
+ {
|
|
|
1531
|
+ row["scorerate"] = string.Format("{0:f2}%", float.Parse(row["score"].ToString()) / float.Parse(row["complete"].ToString()) * 100);
|
|
|
1532
|
+ }
|
|
|
1533
|
+ }
|
|
|
1534
|
+ else
|
|
|
1535
|
+ {
|
|
|
1536
|
+ row["scorerate"] = "0%";
|
|
|
1537
|
+ }
|
|
|
1538
|
+ }
|
|
|
1539
|
+
|
|
|
1540
|
+ }
|
|
|
1541
|
+ else
|
|
|
1542
|
+ {
|
|
|
1543
|
+ row["completerate"] = "0%";
|
|
|
1544
|
+ }
|
|
|
1545
|
+ }
|
|
|
1546
|
+ }
|
|
|
1547
|
+ DataRow drtNew = dataTable.NewRow();
|
|
|
1548
|
+ drtNew["woname"] = "合计";//院区
|
|
|
1549
|
+ drtNew["MaintenanceDept"] = "";//科室
|
|
|
1550
|
+ drtNew["gdtype"] = "";//工单类别
|
|
|
1551
|
+ drtNew["total"] = total;//接单量
|
|
|
1552
|
+ drtNew["complete"] = complete;//完成量
|
|
|
1553
|
+ drtNew["undone"] = undone;//未完成量
|
|
|
1554
|
+ drtNew["score"] = score;//
|
|
|
1555
|
+ if (total > 0)
|
|
|
1556
|
+ {
|
|
|
1557
|
+ drtNew["completerate"] = string.Format("{0:f2}%", ((float)complete / total) * 100);
|
|
|
1558
|
+ }
|
|
|
1559
|
+ else
|
|
|
1560
|
+ {
|
|
|
1561
|
+ drtNew["completerate"] = "0%";//完成率
|
|
|
1562
|
+ }
|
|
|
1563
|
+
|
|
|
1564
|
+
|
|
|
1565
|
+ if (complete > 0)
|
|
|
1566
|
+ {
|
|
|
1567
|
+ drtNew["scorerate"] = string.Format("{0:f2}%", ((float)score / complete) * 100);
|
|
|
1568
|
+ }
|
|
|
1569
|
+ else
|
|
|
1570
|
+ {
|
|
|
1571
|
+ drtNew["scorerate"] = "0%";//态度率
|
|
|
1572
|
+ }
|
|
|
1573
|
+
|
|
|
1574
|
+
|
|
|
1575
|
+ dataTable.Rows.Add(drtNew);
|
|
|
1576
|
+ dataTable = dataTable.DefaultView.ToTable(false, new string[] { "woname", "MaintenanceDept", "gdtype",
|
|
|
1577
|
+ "total", "complete", "undone", "completerate",
|
|
|
1578
|
+ "score", "scorerate"
|
|
|
1579
|
+ });
|
|
|
1580
|
+ if (isdc > 0)
|
|
|
1581
|
+ {
|
|
|
1582
|
+ NPOIHelper npoi = new NPOIHelper();
|
|
|
1583
|
+ if (npoi.CarMaintenance ("车辆调度科室维修情况报表", dataTable) == "")
|
|
|
1584
|
+ {
|
|
|
1585
|
+ return Success("导出成功");
|
|
|
1586
|
+ }
|
|
|
1587
|
+ else
|
|
|
1588
|
+ {
|
|
|
1589
|
+ return Error("导出失败");
|
|
|
1590
|
+ }
|
|
|
1591
|
+ }
|
|
|
1592
|
+ else
|
|
|
1593
|
+ return Success("车辆调度科室维修情况报表数据成功", dataTable);
|
|
|
1594
|
+ }
|
|
|
1595
|
+
|
|
|
1596
|
+
|
|
|
1597
|
+ /// <summary>
|
|
|
1598
|
+ /// 工勤维修
|
|
|
1599
|
+ /// </summary>
|
|
|
1600
|
+ /// <param name="starttime"></param>
|
|
|
1601
|
+ /// <param name="endtime"></param>
|
|
|
1602
|
+ /// <param name="type"></param>
|
|
|
1603
|
+ /// <param name="loweltype"></param>
|
|
|
1604
|
+ /// <param name="deptid"></param>
|
|
|
1605
|
+ /// <returns></returns>
|
|
|
1606
|
+
|
|
|
1607
|
+ public ActionResult WorkMaintenance(string starttime, string endtime, int type = 0, int loweltype = 0, int deptid = 0, int isdc = 0)
|
|
|
1608
|
+ {
|
|
|
1609
|
+ string where = "";
|
|
|
1610
|
+ if (!string.IsNullOrEmpty(starttime))
|
|
|
1611
|
+ {
|
|
|
1612
|
+ where += "and F_CreateTime>='" + starttime + "'";
|
|
|
1613
|
+ }
|
|
|
1614
|
+ if (!string.IsNullOrEmpty(endtime))
|
|
|
1615
|
+ {
|
|
|
1616
|
+ where += "and F_CreateTime<='" + endtime + "'";
|
|
|
1617
|
+ }
|
|
|
1618
|
+ if (deptid > 0)
|
|
|
1619
|
+ {
|
|
|
1620
|
+ where += "and [dbo].[GetDeptIdByUserCode](F_DriverCode)='" + deptid + "'";
|
|
|
1621
|
+ }
|
|
|
1622
|
+
|
|
|
1623
|
+ if (loweltype > 0)
|
|
|
1624
|
+ {
|
|
|
1625
|
+ where += $" and F_Type in(select F_GDId from [dbo].[GetValueId]({loweltype}))";
|
|
|
1626
|
+ }
|
|
|
1627
|
+ string sql = " select [dbo].[GetYQNameByDeptId]([dbo].[GetDeptIdByUserCode](F_DriverCode)) woname , " +
|
|
|
1628
|
+ " dbo.[GetCompleteDeptNames]([dbo].[GetDeptIdByUserCode](F_DriverCode)) MaintenanceDept," +
|
|
|
1629
|
+ " [dbo].[GetUserName] (F_DriverCode) DealUser," +
|
|
|
1630
|
+ " count(1) total, sum( case when F_State>=7 then 1 else 0 end ) complete," +
|
|
|
1631
|
+ " sum(case when F_State<7 then 1 else 0 end) undone," +
|
|
|
1632
|
+ " CONVERT(int , (select count(1) from T_Car_Evaluate where" +
|
|
|
1633
|
+ " F_WorkOrderCode in((stuff((select ','+T.F_WorkOrderCode FROM T_Car_WorkOrder T WHERE" +
|
|
|
1634
|
+ " a.F_DriverCode=T.F_DriverCode and F_Source<3 for xml path('')),1,1,'')" +
|
|
|
1635
|
+ " )))) score from T_Car_WorkOrder a";
|
|
|
1636
|
+
|
|
|
1637
|
+ var dataTable = DbHelperSQL.Query(sql + " where F_DriverCode is not null and F_DriverCode!= '' " +
|
|
|
1638
|
+ "and F_State >= 1" + where
|
|
|
1639
|
+ + " group by dbo.[GetCompleteDeptNames] ([dbo].[GetDeptIdByUserCode] (F_DriverCode)),F_DriverCode " +
|
|
|
1640
|
+ " order by[dbo].[GetDeptIdByUserCode] (F_DriverCode)").Tables[0];
|
|
|
1641
|
+
|
|
|
1642
|
+ dataTable.Columns.Add("completerate", typeof(string));
|
|
|
1643
|
+ dataTable.Columns.Add("scorerate", typeof(string));
|
|
|
1644
|
+
|
|
|
1645
|
+ int total = 0, complete = 0, undone = 0, score = 0;
|
|
|
1646
|
+ foreach (DataRow row in dataTable.Rows)
|
|
|
1647
|
+ {
|
|
|
1648
|
+ if (row["total"] != null && row["total"].ToString() != "")
|
|
|
1649
|
+ {
|
|
|
1650
|
+ if (int.Parse(row["total"].ToString()) > 0)
|
|
|
1651
|
+ {
|
|
|
1652
|
+ total += int.Parse(row["total"].ToString());
|
|
|
1653
|
+ if (row["complete"] != null && row["complete"].ToString() != "")
|
|
|
1654
|
+ complete += int.Parse(row["complete"].ToString());
|
|
|
1655
|
+ if (row["undone"] != null && row["undone"].ToString() != "")
|
|
|
1656
|
+ undone += int.Parse(row["undone"].ToString());
|
|
|
1657
|
+
|
|
|
1658
|
+ if (row["score"] != null && row["score"].ToString() != "")
|
|
|
1659
|
+ score += int.Parse(row["score"].ToString());
|
|
|
1660
|
+ if (row["complete"] != null && row["complete"].ToString() != "")
|
|
|
1661
|
+ {
|
|
|
1662
|
+ row["completerate"] = string.Format("{0:f2}%", float.Parse(row["complete"].ToString()) / float.Parse(row["total"].ToString()) * 100);
|
|
|
1663
|
+ if (int.Parse(row["complete"].ToString()) > 0)
|
|
|
1664
|
+ {
|
|
|
1665
|
+ if (row["score"] != null && row["score"].ToString() != "")
|
|
|
1666
|
+ {
|
|
|
1667
|
+ row["scorerate"] = string.Format("{0:f2}%", float.Parse(row["score"].ToString()) / float.Parse(row["complete"].ToString()) * 100);
|
|
|
1668
|
+ }
|
|
|
1669
|
+ }
|
|
|
1670
|
+ else
|
|
|
1671
|
+ {
|
|
|
1672
|
+ row["scorerate"] = "0%";
|
|
|
1673
|
+ }
|
|
|
1674
|
+ }
|
|
|
1675
|
+
|
|
|
1676
|
+ }
|
|
|
1677
|
+ else
|
|
|
1678
|
+ {
|
|
|
1679
|
+ row["completerate"] = "0%";
|
|
|
1680
|
+ }
|
|
|
1681
|
+ }
|
|
|
1682
|
+ }
|
|
|
1683
|
+ DataRow drtNew = dataTable.NewRow();
|
|
|
1684
|
+ drtNew["woname"] = "合计";//院区
|
|
|
1685
|
+ drtNew["MaintenanceDept"] = "";//科室
|
|
|
1686
|
+ drtNew["DealUser"] = "";//
|
|
|
1687
|
+ drtNew["total"] = total;//接单量
|
|
|
1688
|
+ drtNew["complete"] = complete;//完成量
|
|
|
1689
|
+ drtNew["undone"] = undone;//未完成量
|
|
|
1690
|
+ drtNew["score"] = score;//未完成量
|
|
|
1691
|
+
|
|
|
1692
|
+
|
|
|
1693
|
+ if (total > 0)
|
|
|
1694
|
+ {
|
|
|
1695
|
+ drtNew["completerate"] = string.Format("{0:f2}%", ((float)complete / total) * 100);
|
|
|
1696
|
+ }
|
|
|
1697
|
+ else
|
|
|
1698
|
+ {
|
|
|
1699
|
+ drtNew["completerate"] = "0%";//完成率
|
|
|
1700
|
+ }
|
|
|
1701
|
+
|
|
|
1702
|
+
|
|
|
1703
|
+ if (complete > 0)
|
|
|
1704
|
+ {
|
|
|
1705
|
+ drtNew["scorerate"] = string.Format("{0:f2}%", ((float)score / complete) * 100);
|
|
|
1706
|
+ }
|
|
|
1707
|
+ else
|
|
|
1708
|
+ {
|
|
|
1709
|
+ drtNew["scorerate"] = "0%";//态度率
|
|
|
1710
|
+ }
|
|
|
1711
|
+
|
|
|
1712
|
+
|
|
|
1713
|
+ dataTable.Rows.Add(drtNew);
|
|
|
1714
|
+ dataTable = dataTable.DefaultView.ToTable(false, new string[] { "woname", "MaintenanceDept", "DealUser",
|
|
|
1715
|
+ "total", "complete", "undone", "completerate",
|
|
|
1716
|
+ "score", "scorerate"
|
|
|
1717
|
+ });
|
|
|
1718
|
+ if (isdc > 0)
|
|
|
1719
|
+ {
|
|
|
1720
|
+ NPOIHelper npoi = new NPOIHelper();
|
|
|
1721
|
+ if (npoi.CarMaintenance("车辆调度工勤维修情况报表", dataTable) == "")
|
|
|
1722
|
+ {
|
|
|
1723
|
+ return Success("导出成功");
|
|
|
1724
|
+ }
|
|
|
1725
|
+ else
|
|
|
1726
|
+ {
|
|
|
1727
|
+ return Error("导出失败");
|
|
|
1728
|
+ }
|
|
|
1729
|
+ }
|
|
|
1730
|
+ else
|
|
|
1731
|
+ return Success("车辆调度工勤维修情况报表数据成功", dataTable);
|
|
|
1732
|
+
|
|
|
1733
|
+ }
|
|
|
1734
|
+ /// <summary>
|
|
1461
|
1735
|
/// 添加操作记录
|
|
1462
|
1736
|
/// </summary>
|
|
1463
|
1737
|
/// <param name="message"></param>
|