|
@@ -369,20 +369,24 @@ func GetCompanyStatisticsList(c *gin.Context) {
|
|
|
TotalSendCount int64 `json:"totalSendCount"`
|
|
|
TotalRecvCount int64 `json:"totalRecvCount"`
|
|
|
TotalFinishedCount int64 `json:"totalFinishedCount"`
|
|
|
+ TotalEngineer int `json:"totalEngineer"`
|
|
|
+ TotalAdmin int `json:"totalAdmin"`
|
|
|
}
|
|
|
res := make([]result, len(companies))
|
|
|
for i, v := range companies {
|
|
|
- totalSendCount, totalRecvCount, totalFinishedCount := GetCompanyStatisticsData(v.ID)
|
|
|
+ totalSendCount, totalRecvCount, totalFinishedCount, totalEngineer, totalAdmin := GetCompanyStatisticsData(v.ID)
|
|
|
res[i].TotalSendCount = totalSendCount
|
|
|
res[i].TotalRecvCount = totalRecvCount
|
|
|
res[i].TotalFinishedCount = totalFinishedCount
|
|
|
+ res[i].TotalEngineer = totalEngineer
|
|
|
+ res[i].TotalAdmin = totalAdmin
|
|
|
v.CertificateUrl = ""
|
|
|
res[i].Company = v
|
|
|
}
|
|
|
response.Success(c, gin.H{"companyList": res}, "查询成功")
|
|
|
}
|
|
|
|
|
|
-func GetCompanyStatisticsData(companyId int) (int64, int64, int64) {
|
|
|
+func GetCompanyStatisticsData(companyId int) (int64, int64, int64, int, int) {
|
|
|
|
|
|
db := common.GetDB()
|
|
|
|
|
@@ -395,7 +399,17 @@ func GetCompanyStatisticsData(companyId int) (int64, int64, int64) {
|
|
|
|
|
|
var totalFinishedCount int64
|
|
|
db.Model(&model.Task{}).Where("company_id = ? and task.state = 2", companyId).Count(&totalFinishedCount)
|
|
|
- return totalSendCount, totalRecvCount, totalFinishedCount
|
|
|
+
|
|
|
+ var totalEngineer int
|
|
|
+ db.Raw("SELECT count(*) FROM company_users left join `user` on company_users.user_id = user.id "+
|
|
|
+ "WHERE company_users.company_id = ? and company_users.state= 1 AND identify = 2", companyId).First(&totalEngineer)
|
|
|
+
|
|
|
+ var totalAdmin int
|
|
|
+ db.Raw("SELECT count(*) FROM company_users left join `user` on company_users.user_id = user.id "+
|
|
|
+ "WHERE company_users.company_id = ? and company_users.state= 1 AND identify = 1", companyId).First(&totalAdmin)
|
|
|
+
|
|
|
+ return totalSendCount, totalRecvCount, totalFinishedCount, totalEngineer, totalAdmin
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func GetCompanyStatistics(c *gin.Context) {
|
|
@@ -407,11 +421,13 @@ func GetCompanyStatistics(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
companyIntId, _ := strconv.Atoi(companyId)
|
|
|
- totalSendCount, totalRecvCount, totalFinishedCount := GetCompanyStatisticsData(companyIntId)
|
|
|
+ totalSendCount, totalRecvCount, totalFinishedCount, totalEngineer, totalAdmin := GetCompanyStatisticsData(companyIntId)
|
|
|
response.Success(c, gin.H{
|
|
|
"company": company,
|
|
|
"totalSendCount": totalSendCount,
|
|
|
"totalRecvCount": totalRecvCount,
|
|
|
"totalFinishedCount": totalFinishedCount,
|
|
|
+ "totalEngineer": totalEngineer,
|
|
|
+ "totalAdmin": totalAdmin,
|
|
|
}, "查询成功")
|
|
|
}
|