Ver código fonte

设备统计

lining 6 anos atrás
pai
commit
05a4352c73

+ 42 - 0
src/dashoo.cn/backend/api/business/devicestatistics/devicestatisticsService.go

@@ -36,3 +36,45 @@ func (s *DeviceStatisticsService) GetCountsByDate(tablename, where string) (tota
 	return int(total1)
 }
 
+//本月待检
+func (s *DeviceStatisticsService) GetWaitCountsMonth(Id string) (total int) {
+	var resultsSlice []map[string][]byte
+	var total1 int64
+	sql := `SELECT COUNT(*) FROM s5OVELimsCheckEquipmentList a WHERE a.TemplateTypeId=`+Id  +` AND 
+           CASE WHEN a.CycleUnit ='年' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle YEAR) < DATE_ADD(CURDATE()-DAY(CURDATE())+1,INTERVAL 1 MONTH)
+           WHEN a.CycleUnit ='月' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle MONTH) < DATE_ADD(CURDATE()-DAY(CURDATE())+1,INTERVAL 1 MONTH)
+			WHEN a.CycleUnit ='天' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle DAY) < DATE_ADD(CURDATE()-DAY(CURDATE())+1,INTERVAL 1 MONTH)
+			ELSE FALSE
+			END`
+
+	resultsSlice, _ = s.DBE.Query(sql)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total1, _ = strconv.ParseInt(string(value), 10, 64)
+			break
+		}
+	}
+	return int(total1)
+}
+
+func (s *DeviceStatisticsService) GetWaitCountsYear(Id string) (total int) {
+	var resultsSlice []map[string][]byte
+	var total1 int64
+	sql := `SELECT COUNT(*) FROM s5OVELimsCheckEquipmentList a WHERE a.TemplateTypeId=`+Id  +` AND 
+           CASE WHEN a.CycleUnit ='年' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle YEAR) < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)
+           WHEN a.CycleUnit ='月' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle MONTH) < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)
+			WHEN a.CycleUnit ='天' THEN DATE_ADD(a.LastCheckDate , INTERVAL a.Cycle DAY) < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)
+			ELSE FALSE
+			END`
+
+	resultsSlice, _ = s.DBE.Query(sql)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total1, _ = strconv.ParseInt(string(value), 10, 64)
+			break
+		}
+	}
+	return int(total1)
+}

+ 221 - 169
src/dashoo.cn/backend/api/controllers/lims/devicestatistics.go

@@ -2,7 +2,9 @@ package lims
 
 import (
 	"dashoo.cn/backend/api/business/devicestatistics"
+	"dashoo.cn/backend/api/business/organize"
 	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/business2/permission"
 	"dashoo.cn/utils"
 	"fmt"
 	"strconv"
@@ -20,179 +22,229 @@ type DeviceStatisticsController struct {
 // @Success 200 {object}
 // @router /list [get]
 func (this *DeviceStatisticsController) GetEntityList() {
+
+	svcPerm := permission.GetPermissionService(utils.DBE)
+	isauth := svcPerm.IsAuthorized(this.User.Id, "Administrator")
+	organizeSvc := organize.GetOrganizeService(utils.DBE)
+	thrunitId := organizeSvc.GetMyThrUnitDepartmentId(this.User.DepartmentId)
+
 	var devicelist []devicestatistics.DeviceStatistics
 	svc := devicestatistics.GetDeviceStatisticsService(utils.DBE)
-	fromdate := GetFirstDateOfMonth(time.Now()).Format("2006-01-02 15:04:05")
-	todate := GetLastDateOfMonth(time.Now()).Format("2006-01-02") + " 23:59:59"
-
-	where := "(CreateOn BETWEEN '" + fromdate + "' AND '" + todate + "') and CheckResult != ''"
-	fromdateyear := strconv.Itoa(time.Now().Year()) + "-01-01 00:00:00"
-	todateyear := strconv.Itoa(time.Now().Year()) + "-12-31 23:59:59"
-	whereYno := "(CreateOn BETWEEN '" + fromdateyear + "' AND '" + todateyear + "') and CheckResult='×'"
-	whereY := "(CreateOn BETWEEN '" + fromdateyear + "' AND '" + todateyear + "') and CheckResult='○'"
-
-	//  防雷装置(等电位)
-	var deviceEQ devicestatistics.DeviceStatistics
-	totalYearNo := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, whereYno)
-	totalYear := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, whereY)
-	num := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, where)
-	whereN := "TemplateTypeId=187"
-	numEQ := svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceEQ.DeviceName = "防雷装置(等电位)"
-	deviceEQ.DeviceQty = int(numEQ)
-	deviceEQ.FinishMonth = int(num)
-	deviceEQ.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceEQ.FinishYear != 0 {
-		deviceEQ.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceEQ)
-
-	//  防雷装置
-	var deviceLPT devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, where)
-	whereN ="TemplateTypeId=286"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceLPT.DeviceName = "防雷装置"
-	deviceLPT.DeviceQty = numEQ
-	deviceLPT.FinishMonth = int(num)
-	deviceLPT.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceLPT.FinishYear != 0 {
-		deviceLPT.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceLPT)
-
-	//  漏电保护器
-	var deviceLP devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, where)
-	whereN ="TemplateTypeId=181"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceLP.DeviceName = "漏电保护器"
-	deviceLP.DeviceQty = numEQ
-	deviceLP.FinishMonth = int(num)
-	deviceLP.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceLP.FinishYear != 0 {
-		deviceLP.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceLP)
-
-	//  电气接地
-	var deviceEG devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, where)
-	whereN ="TemplateTypeId=179"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceEG.DeviceName = "电气接地"
-	deviceEG.DeviceQty = numEQ
-	deviceEG.FinishMonth = int(num)
-	deviceEG.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceEG.FinishYear != 0 {
-		deviceEG.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceEG)
-
-	whereYno = "(CreateOn BETWEEN '" + fromdateyear + "' AND '" + todateyear + "') and CheckResult LIKE '%不合格%' "
-	whereY = "(CreateOn BETWEEN '" + fromdateyear + "' AND '" + todateyear + "') and CheckResult LIKE '%合格%'"
-	//阻火器 LimsReportZuhq
-	var deviceZHQ devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, where)
-	whereN ="TemplateTypeId=156"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceZHQ.DeviceName = "阻火器"
-	deviceZHQ.DeviceQty = numEQ
-	deviceZHQ.FinishMonth = int(num)
-	deviceZHQ.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceZHQ.FinishYear != 0 {
-		deviceZHQ.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceZHQ)
-
-	// 呼吸阀 LimsReportHuxf
-	var deviceHXF devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, where)
-	whereN ="TemplateTypeId=183"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceHXF.DeviceName = "呼吸阀"
-	deviceHXF.DeviceQty = numEQ
-	deviceHXF.FinishMonth = int(num)
-	deviceHXF.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceHXF.FinishYear != 0 {
-		deviceHXF.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceHXF)
-
-	// 液压安全阀 LimsReportYeyaqf
-	var deviceYYF devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, where)
-	whereN ="TemplateTypeId=154"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceYYF.DeviceName = "液压安全阀"
-	deviceYYF.DeviceQty = numEQ
-	deviceYYF.FinishMonth = int(num)
-	deviceYYF.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceYYF.FinishYear != 0 {
-		deviceYYF.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceYYF)
-
-	// 空气泡沫产生器 LimsReportAirFoamGenerator
-	var deviceKQPM devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, where)
-	whereN ="TemplateTypeId=189"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceKQPM.DeviceName = "空气泡沫产生器"
-	deviceKQPM.DeviceQty = numEQ
-	deviceKQPM.FinishMonth = int(num)
-	deviceKQPM.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceKQPM.FinishYear != 0 {
-		deviceKQPM.PassRate,_ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo) + float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceKQPM)
-
-	// 游梁式抽油机 LimsReportBeamPumpingUnits
-	var deviceYL devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, where)
-	whereN ="TemplateTypeId=141"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceYL.DeviceName = "游梁式抽油机"
-	deviceYL.DeviceQty = numEQ
-	deviceYL.FinishMonth = int(num)
-	deviceYL.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceYL.FinishYear != 0 {
-		deviceYL.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
-	}
-	devicelist = append(devicelist, deviceYL)
-
-	// 无游梁式抽油机 LimsReportNoBeamPumpingUnit
-	var deviceWYL devicestatistics.DeviceStatistics
-	totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, whereYno)
-	totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, whereY)
-	num = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, where)
-	whereN ="TemplateTypeId=173"
-	numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
-	deviceWYL.DeviceName = "无游梁式抽油机"
-	deviceWYL.DeviceQty = numEQ
-	deviceWYL.FinishMonth = int(num)
-	deviceWYL.FinishYear = int(totalYearNo) + int(totalYear)
-	if deviceWYL.FinishYear != 0 {
-		deviceWYL.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+	//fromdate := GetFirstDateOfMonth(time.Now()).Format("2006-01-02 15:04:05")
+	//todate := GetLastDateOfMonth(time.Now()).Format("2006-01-02") + " 23:59:59"
+
+	where := "(CreateOn < DATE_ADD(CURDATE()-DAY(CURDATE())+1,INTERVAL 1 MONTH)) and CheckResult != ''"
+	//fromdateyear := strconv.Itoa(time.Now().Year()) + "-01-01 00:00:00"
+	//todateyear := strconv.Itoa(time.Now().Year()) + "-12-31 23:59:59"
+	whereYno := "(CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and CheckResult='×'"
+	whereY := "(CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and CheckResult='○'"
+
+	if isauth || thrunitId == "100001215" {
+		//  防雷装置(等电位)
+		var deviceEQ devicestatistics.DeviceStatistics
+		totalYearNo := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, whereYno)
+		totalYear := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, whereY)
+		num := svc.GetCountsByDate(this.User.AccCode + LimsReportEquipotentName, where)
+		whereN := "TemplateTypeId=187"
+		numEQ := svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM :=svc.GetWaitCountsMonth("187")
+		numWY :=svc.GetWaitCountsYear("187")
+		deviceEQ.DeviceName = "防雷装置(等电位)"
+		deviceEQ.DeviceQty = int(numEQ)
+		deviceEQ.WaitYear = int(numWY)
+		deviceEQ.WaitMonth = int(numWM)
+		deviceEQ.FinishMonth = int(num)
+		deviceEQ.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceEQ.FinishYear != 0 {
+			deviceEQ.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceEQ)
+
+		//  防雷装置
+		var deviceLPT devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportLightProtectName, where)
+		whereN ="TemplateTypeId=286"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("286")
+		numWY =svc.GetWaitCountsYear("286")
+		deviceLPT.DeviceName = "防雷装置"
+		deviceLPT.DeviceQty = numEQ
+		deviceLPT.WaitYear = int(numWY)
+		deviceLPT.WaitMonth = int(numWM)
+		deviceLPT.FinishMonth = int(num)
+		deviceLPT.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceLPT.FinishYear != 0 {
+			deviceLPT.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceLPT)
+
+		//  漏电保护器
+		var deviceLP devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportLeakProtectName, where)
+		whereN ="TemplateTypeId=181"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("181")
+		numWY =svc.GetWaitCountsYear("181")
+		deviceLP.DeviceName = "漏电保护器"
+		deviceLP.DeviceQty = numEQ
+		deviceLP.WaitYear = int(numWY)
+		deviceLP.WaitMonth = int(numWM)
+		deviceLP.FinishMonth = int(num)
+		deviceLP.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceLP.FinishYear != 0 {
+			deviceLP.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceLP)
+
+		//  电气接地
+		var deviceEG devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportElecGroundName, where)
+		whereN ="TemplateTypeId=179"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("179")
+		numWY =svc.GetWaitCountsYear("179")
+		deviceEG.DeviceName = "电气接地"
+		deviceEG.DeviceQty = numEQ
+		deviceEG.WaitYear = int(numWY)
+		deviceEG.WaitMonth = int(numWM)
+		deviceEG.FinishMonth = int(num)
+		deviceEG.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceEG.FinishYear != 0 {
+			deviceEG.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceEG)
 	}
-	devicelist = append(devicelist, deviceWYL)
 
+	if isauth || thrunitId == "100001219" {
+		whereYno = "(CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and CheckResult LIKE '%不合格%' "
+		whereY = "(CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and CheckResult LIKE '%合格%' AND CheckResult NOT LIKE '%不合格%'"
+		//阻火器 LimsReportZuhq
+		var deviceZHQ devicestatistics.DeviceStatistics
+		totalYearNo := svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, whereYno)
+		totalYear := svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, whereY)
+		num := svc.GetCountsByDate(this.User.AccCode + LimsReportZuhqName, where)
+		whereN :="TemplateTypeId=156"
+		numEQ := svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM :=svc.GetWaitCountsMonth("156")
+		numWY :=svc.GetWaitCountsYear("156")
+		deviceZHQ.DeviceName = "阻火器"
+		deviceZHQ.DeviceQty = numEQ
+		deviceZHQ.WaitYear = int(numWY)
+		deviceZHQ.WaitMonth = int(numWM)
+		deviceZHQ.FinishMonth = int(num)
+		deviceZHQ.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceZHQ.FinishYear != 0 {
+			deviceZHQ.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceZHQ)
+
+		// 呼吸阀 LimsReportHuxf
+		var deviceHXF devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportHuxfName, where)
+		whereN ="TemplateTypeId=183"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("183")
+		numWY =svc.GetWaitCountsYear("183")
+		deviceHXF.DeviceName = "呼吸阀"
+		deviceHXF.DeviceQty = numEQ
+		deviceHXF.WaitYear = int(numWY)
+		deviceHXF.WaitMonth = int(numWM)
+		deviceHXF.FinishMonth = int(num)
+		deviceHXF.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceHXF.FinishYear != 0 {
+			deviceHXF.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceHXF)
+
+		// 液压安全阀 LimsReportYeyaqf
+		var deviceYYF devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportYeyaqfName, where)
+		whereN ="TemplateTypeId=154"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("154")
+		numWY =svc.GetWaitCountsYear("154")
+		deviceYYF.DeviceName = "液压安全阀"
+		deviceYYF.DeviceQty = numEQ
+		deviceYYF.WaitYear = int(numWY)
+		deviceYYF.WaitMonth = int(numWM)
+		deviceYYF.FinishMonth = int(num)
+		deviceYYF.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceYYF.FinishYear != 0 {
+			deviceYYF.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceYYF)
+
+		// 空气泡沫产生器 LimsReportAirFoamGenerator
+		var deviceKQPM devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportKqpmName, where)
+		whereN ="TemplateTypeId=189"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("189")
+		numWY =svc.GetWaitCountsYear("189")
+		deviceKQPM.DeviceName = "空气泡沫产生器"
+		deviceKQPM.DeviceQty = numEQ
+		deviceKQPM.WaitYear = int(numWY)
+		deviceKQPM.WaitMonth = int(numWM)
+		deviceKQPM.FinishMonth = int(num)
+		deviceKQPM.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceKQPM.FinishYear != 0 {
+			deviceKQPM.PassRate,_ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo) + float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceKQPM)
+
+		// 游梁式抽油机 LimsReportBeamPumpingUnits
+		var deviceYL devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportBeamPumpingUnitName, where)
+		whereN ="TemplateTypeId=141"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("141")
+		numWY =svc.GetWaitCountsYear("141")
+		deviceYL.DeviceName = "游梁式抽油机"
+		deviceYL.DeviceQty = numEQ
+		deviceYL.WaitYear = int(numWY)
+		deviceYL.WaitMonth = int(numWM)
+		deviceYL.FinishMonth = int(num)
+		deviceYL.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceYL.FinishYear != 0 {
+			deviceYL.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceYL)
+
+		// 无游梁式抽油机 LimsReportNoBeamPumpingUnit
+		var deviceWYL devicestatistics.DeviceStatistics
+		totalYearNo = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, whereYno)
+		totalYear = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, whereY)
+		num = svc.GetCountsByDate(this.User.AccCode + LimsReportNoBeamPumpingUnitName, where)
+		whereN ="TemplateTypeId=173"
+		numEQ = svc.GetCountsByDate(this.User.AccCode + LimsCheckEquipmentListName, whereN)
+		numWM =svc.GetWaitCountsMonth("173")
+		numWY =svc.GetWaitCountsYear("173")
+		deviceWYL.DeviceName = "无游梁式抽油机"
+		deviceWYL.DeviceQty = numEQ
+		deviceWYL.WaitYear = int(numWY)
+		deviceWYL.WaitMonth = int(numWM)
+		deviceWYL.FinishMonth = int(num)
+		deviceWYL.FinishYear = int(totalYearNo) + int(totalYear)
+		if deviceWYL.FinishYear != 0 {
+			deviceWYL.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
+		}
+		devicelist = append(devicelist, deviceWYL)
+
+	}
 
 
 	var datainfo ErrorDataInfo

+ 94 - 73
src/dashoo.cn/frontend_web/src/pages/lims/secondcenter/towLevelCenter.vue

@@ -1,35 +1,35 @@
 <template>
   <div style="width: 100%; overflow-y: auto">
-    <el-card class="box-card" style="height: 70px">
-      <el-form :inline="true" :model="formSearch" class="demo-form-inline">
-        <el-form-item label="日期">
-          <el-date-picker
-            v-model="formSearch.daterange"
-            type="daterange"
-            align="right"
-            unlink-panels
-            range-separator="至"
-            start-placeholder="开始日期"
-            end-placeholder="结束日期">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="检测地点">
-          <el-select v-model="formSearch.checkPosition" placeholder="检测地点">
-            <el-option label="区域一" value="shanghai"></el-option>
-            <el-option label="区域二" value="beijing"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="设备选择">
-          <el-select v-model="formSearch.equipments" multiple placeholder="设备选择">
-            <el-option label="设备一" value="shanghai"></el-option>
-            <el-option label="设备二" value="beijing"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item>
-          <el-button type="primary" @click="onSubmit">查询</el-button>
-        </el-form-item>
-      </el-form>
-    </el-card>
+    <!--<el-card class="box-card" style="height: 70px">-->
+      <!--<el-form :inline="true" :model="formSearch" class="demo-form-inline">-->
+        <!--<el-form-item label="日期">-->
+          <!--<el-date-picker-->
+            <!--v-model="formSearch.daterange"-->
+            <!--type="daterange"-->
+            <!--align="right"-->
+            <!--unlink-panels-->
+            <!--range-separator="至"-->
+            <!--start-placeholder="开始日期"-->
+            <!--end-placeholder="结束日期">-->
+          <!--</el-date-picker>-->
+        <!--</el-form-item>-->
+        <!--<el-form-item label="检测地点">-->
+          <!--<el-select v-model="formSearch.checkPosition" placeholder="检测地点">-->
+            <!--<el-option label="区域一" value="shanghai"></el-option>-->
+            <!--<el-option label="区域二" value="beijing"></el-option>-->
+          <!--</el-select>-->
+        <!--</el-form-item>-->
+        <!--<el-form-item label="设备选择">-->
+          <!--<el-select v-model="formSearch.equipments" multiple placeholder="设备选择">-->
+            <!--<el-option label="设备一" value="shanghai"></el-option>-->
+            <!--<el-option label="设备二" value="beijing"></el-option>-->
+          <!--</el-select>-->
+        <!--</el-form-item>-->
+        <!--<el-form-item>-->
+          <!--<el-button type="primary" @click="onSubmit">查询</el-button>-->
+        <!--</el-form-item>-->
+      <!--</el-form>-->
+    <!--</el-card>-->
 
     <el-card class="box-card">
       <el-table :data="tableData" style="width: 100%" stripe>
@@ -37,13 +37,13 @@
 
         <el-table-column prop="DeviceQty" label="设备总量" ></el-table-column>
 
-        <el-table-column label="本月待检"></el-table-column>
+        <el-table-column prop="WaitMonth" label="本月待检"></el-table-column>
 
         <el-table-column prop="FinishMonth" label="本月检测" ></el-table-column>
 
-        <el-table-column label="全年待检"></el-table-column>
+        <el-table-column prop="WaitYear" label="全年待检"></el-table-column>
 
-        <el-table-column label="全年已检"></el-table-column>
+        <el-table-column prop="FinishYear" label="全年已检"></el-table-column>
 
         <el-table-column prop="FinishYear" label="全年检测"></el-table-column>
 
@@ -100,12 +100,21 @@
         <legend style="color:#436EEE"></legend>
         <i class="icon icon-database"> 图表展示</i>
       </div>
-      <v-chart :forceFit="true" :height="height" :data="chartData" :scale="scale">
+      <v-chart :forceFit="true" :height="height" :data="tableData" :scale="scale">
         <v-tooltip />
-        <v-axis />
-        <v-bar position="year*sales" />
-        <!--<v-line position="year*value" />
-        <v-point position="year*value" shape="circle" />-->
+        <v-legend
+          :custom="legendCustom"
+          :allow-all-canceled="legendAllowAllCanceled"
+          :items="legendItems"
+        />
+        <v-axis
+          data-key="people"
+          :grid="axisGrid"
+          :label="axisLabel"
+        />
+        <v-bar position="DeviceName*WaitYear" color="#3182bd" />
+        <v-smooth-line position="DeviceName*FinishYear" color="#fdae6b" :size="gemoSize" />
+        <v-point shape="circle" position="DeviceName*FinishYear" color="#fdae6b" :size="gemoSize" />
       </v-chart>
     </el-card>
 
@@ -117,42 +126,25 @@
 <script>
   import api from '@/api/lims/secondcenter'
 
-  const chartData = [
-    { year: '1951 年', sales: 38 },
-    { year: '1952 年', sales: 52 },
-    { year: '1956 年', sales: 61 },
-    { year: '1957 年', sales: 145 },
-    { year: '1958 年', sales: 48 },
-    { year: '1959 年', sales: 38 },
-    { year: '1960 年', sales: 38 },
-    { year: '1962 年', sales: 38 }
+  const data = [
+    { time: '10:10', call: 4, waiting: 2, people: 2 },
+    { time: '10:15', call: 2, waiting: 6, people: 3 },
+    { time: '10:20', call: 13, waiting: 2, people: 5 },
+    { time: '10:25', call: 9, waiting: 9, people: 1 },
+    { time: '10:30', call: 5, waiting: 2, people: 3 },
+    { time: '10:35', call: 8, waiting: 2, people: 1 },
+    { time: '10:40', call: 13, waiting: 1, people: 2 }
   ]
 
   const scale = [{
-    dataKey: 'sales',
-    tickInterval: 20
-  }]
-
-  const lineData = [
-    { year: '1991', value: 3 },
-    { year: '1992', value: 4 },
-    { year: '1993', value: 3.5 },
-    { year: '1994', value: 5 },
-    { year: '1995', value: 4.9 },
-    { year: '1996', value: 6 },
-    { year: '1997', value: 7 },
-    { year: '1998', value: 9 },
-    { year: '1999', value: 13 }
-  ]
-
-  const lineScale = [{
-    dataKey: 'value',
+    dataKey: 'DeviceQty',
+    min: 0
+  }, {
+    dataKey: 'FinishYear',
+    min: 0
+  }, {
+    dataKey: 'WaitYear',
     min: 0
-  },
-  {
-    dataKey: 'year',
-    min: 0,
-    max: 1
   }]
 
   export default {
@@ -164,11 +156,40 @@
           equipments: []
         },
 
-        chartData,
+        data,
         scale,
-        lineData,
-        lineScale,
         height: 400,
+
+        axisLabel: {
+          textStyle: {
+            fill: '#fdae6b'
+          }
+        },
+        axisGrid: null,
+
+        gemoSize: 3,
+
+        legendCustom: true,
+        legendAllowAllCanceled: true,
+        legendItems: [
+          {
+            value: '全年待检',
+            marker: {
+              symbol: 'square',
+              fill: '#3182bd',
+              radius: 5}
+          },
+          {
+            value: '全年已检',
+            marker:
+              {symbol: 'hyphen',
+                stroke: '#fdae6b',
+                radius: 5,
+                lineWidth: 3
+              }
+          }
+        ],
+
         tableData: []
       }
     },