|
|
@@ -2,6 +2,7 @@ package lims
|
|
|
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/business/devicestatistics"
|
|
|
+ limscustomerposition2 "dashoo.cn/backend/api/business/limscustomerposition"
|
|
|
"dashoo.cn/backend/api/business/organize"
|
|
|
. "dashoo.cn/backend/api/controllers"
|
|
|
"dashoo.cn/business2/permission"
|
|
|
@@ -42,6 +43,7 @@ func (this *DeviceStatisticsController) GetEntityList() {
|
|
|
ethrIds := ""
|
|
|
//unitId := ""
|
|
|
wheret := ""
|
|
|
+ // 100001215 特检 100001219 宇信
|
|
|
if thrId == "100001219" || thrId == "100001215" {
|
|
|
if unitId != "" {
|
|
|
throrg := organizeSvc.GetAllThirdChildByTopId(unitId, "")
|
|
|
@@ -327,7 +329,6 @@ func (this *DeviceStatisticsController) GetDictList() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// @Title 判断是否有权限
|
|
|
// @Description get user by token
|
|
|
// @Success 200 {object}
|
|
|
@@ -346,14 +347,11 @@ func (this *DeviceStatisticsController) GetAuthority() {
|
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
|
dictList["isauth"] = svcPerm.IsAuthorized(this.User.Id, code)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
var datainfo DataInfo
|
|
|
datainfo.Items = &dictList
|
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// @Title
|
|
|
@@ -369,23 +367,22 @@ func (this *DeviceStatisticsController) GetDeviceTotal() {
|
|
|
|
|
|
ids := svc.GetAllChildById("100000304")
|
|
|
where := "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total := svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
-
|
|
|
+ total := svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
where = "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total = svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
+ total = svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
where = "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total = svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
+ total = svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
where = "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total = svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
+ total = svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
where = "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total = svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
+ total = svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
where = "TemplateTypeId=" + templateTypeId + " and DepartmentId IN (" + ids + ")"
|
|
|
- total = svcd.GetDeviceCounts(this.User.AccCode + LimsCheckEquipmentListName, where)
|
|
|
+ total = svcd.GetDeviceCounts(this.User.AccCode+LimsCheckEquipmentListName, where)
|
|
|
|
|
|
var datainfo ErrorDataInfo
|
|
|
datainfo.Item = total
|
|
|
@@ -394,6 +391,547 @@ func (this *DeviceStatisticsController) GetDeviceTotal() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// @Title 合格率
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /getpassrate [get]
|
|
|
+//func (this *DeviceStatisticsController) GetPassRate() {
|
|
|
+// templateTypeId := this.GetString("TemplateTypeId")
|
|
|
+// var passRate devicestatistics.PassRate
|
|
|
+// svc := devicestatistics.GetDeviceStatisticsService(utils.DBE)
|
|
|
+//
|
|
|
+// where := ""
|
|
|
+// whereYno := "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult='×' " + where
|
|
|
+// whereY := "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult='○' " + where
|
|
|
+// if templateTypeId == "187" {
|
|
|
+//
|
|
|
+// } else if templateTypeId == "286" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "181" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "179" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "156" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "183" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "154" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "189" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "141" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// } else if templateTypeId == "173" {
|
|
|
+// totalYearNo := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereYno)
|
|
|
+// totalYear := svc.GetCountsByDate(this.User.AccCode+LimsReportNoBeamPumpingUnitName, whereY)
|
|
|
+// FinishYear := int(totalYearNo) + int(totalYear)
|
|
|
+// if FinishYear != 0 {
|
|
|
+// passRate.PassRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (float64(totalYear)/(float64(totalYearNo)+float64(totalYear)))*100), 64)
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// var datainfo ErrorDataInfo
|
|
|
+// datainfo.Item = total
|
|
|
+// this.Data["json"] = &datainfo
|
|
|
+// this.ServeJSON()
|
|
|
+//
|
|
|
+//}
|
|
|
+
|
|
|
+// @Title 获取列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /listoil [get]
|
|
|
+func (this *DeviceStatisticsController) GetEntityListOil() {
|
|
|
+
|
|
|
+ unitId := this.GetString("unitCheckId")
|
|
|
+ templateTypeId := this.GetString("TemplateTypeId")
|
|
|
+
|
|
|
+ // 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.DeviceStatisticsOil
|
|
|
+ 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"
|
|
|
+
|
|
|
+ organizeSvc := organize.GetOrganizeService(utils.DBE)
|
|
|
+
|
|
|
+ thrId := organizeSvc.GetMyThrUnitDepartmentId(this.User.DepartmentId)
|
|
|
+
|
|
|
+ thrIds := ""
|
|
|
+ ethrIds := ""
|
|
|
+ //unitId := ""
|
|
|
+ wheret := ""
|
|
|
+ if thrId == "100001219" || thrId == "100001215" {
|
|
|
+ if unitId != "" {
|
|
|
+ throrg := organizeSvc.GetAllThirdChildByTopId(unitId, "")
|
|
|
+ if throrg == nil {
|
|
|
+ thrIds = "-1"
|
|
|
+ } else {
|
|
|
+ for _, item := range throrg {
|
|
|
+ thrIds += strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ thrIds = strings.Trim(thrIds, ",")
|
|
|
+ ethrIds = organizeSvc.GetAllChildById(unitId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if unitId != "" {
|
|
|
+ throrg := organizeSvc.GetAllThirdChildByTopId(unitId, "")
|
|
|
+ if throrg == nil {
|
|
|
+ thrIds = "-1"
|
|
|
+ } else {
|
|
|
+ for _, item := range throrg {
|
|
|
+ thrIds += strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ thrIds = strings.Trim(thrIds, ",")
|
|
|
+ ethrIds = organizeSvc.GetAllChildById(unitId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if thrIds != "" {
|
|
|
+ wheret = " and b.TestDepartId in (" + thrIds + ")"
|
|
|
+ }
|
|
|
+ wheree := ""
|
|
|
+ if ethrIds != "" {
|
|
|
+ wheree = " and DepartmentId in (" + ethrIds + ")"
|
|
|
+ }
|
|
|
+
|
|
|
+ where := "(a.CreateOn < DATE_ADD(CURDATE()-DAY(CURDATE())+1,INTERVAL 1 MONTH)) and a.CheckResult != ''" + wheret
|
|
|
+ whereYno := "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult='×' " + wheret
|
|
|
+ whereY := "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult='○' " + wheret
|
|
|
+
|
|
|
+
|
|
|
+ var unitidArr = [][]string{
|
|
|
+ {"100000304","第一采油厂"},{"100000402","第二采油厂"},{"100000506","第三采油厂"},{"100000787","第四采油厂"},{"100000852","第五采油厂"},{"100000952","第六采油厂"},
|
|
|
+ }
|
|
|
+
|
|
|
+ if thrId != "100001219" {
|
|
|
+ totalYearNo := 0
|
|
|
+ totalYear := 0
|
|
|
+ num := 0
|
|
|
+ numEQ := 0
|
|
|
+ numWM := 0
|
|
|
+ numWY := 0
|
|
|
+ whereN := ""
|
|
|
+ if templateTypeId == "187" {
|
|
|
+ // 防雷装置(等电位)
|
|
|
+ for _,unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCustomerpositionName, wherep, &position )
|
|
|
+ positionids := ""
|
|
|
+ for _,item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ var deviceEQ devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ := svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM := svc.GetWaitCountsMonth("187")
|
|
|
+ numWY := svc.GetWaitCountsYear("187")
|
|
|
+ deviceEQ.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceEQ.UnitName = unit[1]
|
|
|
+ deviceEQ.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if templateTypeId == "286" {
|
|
|
+ for _,unit := range unitidArr {
|
|
|
+ // 防雷装置
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCustomerpositionName, wherep, &position )
|
|
|
+ positionids := ""
|
|
|
+ for _,item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ var deviceLPT devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("286")
|
|
|
+ numWY = svc.GetWaitCountsYear("286")
|
|
|
+ deviceLPT.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceLPT.UnitName = unit[1]
|
|
|
+ deviceLPT.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if templateTypeId == "181" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCustomerpositionName, wherep, &position )
|
|
|
+ positionids := ""
|
|
|
+ for _,item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 漏电保护器
|
|
|
+ var deviceLP devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("181")
|
|
|
+ numWY = svc.GetWaitCountsYear("181")
|
|
|
+ deviceLP.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceLP.UnitName = unit[1]
|
|
|
+ deviceLP.TemplateTypeId = 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)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if templateTypeId == "179" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCustomerpositionName, wherep, &position)
|
|
|
+ positionids := ""
|
|
|
+ for _, item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 电气接地
|
|
|
+ var deviceEG devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("179")
|
|
|
+ numWY = svc.GetWaitCountsYear("179")
|
|
|
+ deviceEG.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceEG.UnitName = unit[1]
|
|
|
+ deviceEG.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if thrId != "100001215" {
|
|
|
+ whereYno = "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult LIKE '%不合格%'" + wheret
|
|
|
+ whereY = "(a.CreateOn < DATE_ADD(DATE_SUB(CURDATE(),INTERVAL DAYOFYEAR(NOW())-1 DAY),INTERVAL 1 YEAR)) and a.CheckResult LIKE '%合格%' AND CheckResult NOT LIKE '%不合格%' " + wheret
|
|
|
+ numWY := 0
|
|
|
+ numWM := 0
|
|
|
+ numEQ := 0
|
|
|
+ whereN := ""
|
|
|
+ num := 0
|
|
|
+ totalYear := 0
|
|
|
+ totalYearNo := 0
|
|
|
+ if templateTypeId == "156" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCustomerpositionName, wherep, &position )
|
|
|
+ positionids := ""
|
|
|
+ for _,item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ //阻火器 LimsReportZuhq
|
|
|
+ var deviceZHQ devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("156")
|
|
|
+ numWY = svc.GetWaitCountsYear("156")
|
|
|
+ deviceZHQ.UnitId ,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceZHQ.UnitName = unit[1]
|
|
|
+ deviceZHQ.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if templateTypeId == "183" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCustomerpositionName, wherep, &position)
|
|
|
+ positionids := ""
|
|
|
+ for _, item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 呼吸阀 LimsReportHuxf
|
|
|
+ var deviceHXF devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("183")
|
|
|
+ numWY = svc.GetWaitCountsYear("183")
|
|
|
+ deviceHXF.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceHXF.UnitName = unit[1]
|
|
|
+ deviceHXF.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if templateTypeId == "189" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCustomerpositionName, wherep, &position)
|
|
|
+ positionids := ""
|
|
|
+ for _, item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 空气泡沫产生器 LimsReportAirFoamGenerator
|
|
|
+ var deviceKQPM devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("189")
|
|
|
+ numWY = svc.GetWaitCountsYear("189")
|
|
|
+ deviceKQPM.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceKQPM.UnitName = unit[1]
|
|
|
+ deviceKQPM.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if templateTypeId == "141" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCustomerpositionName, wherep, &position)
|
|
|
+ positionids := ""
|
|
|
+ for _, item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 游梁式抽油机 LimsReportBeamPumpingUnits
|
|
|
+ var deviceYL devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("141")
|
|
|
+ numWY = svc.GetWaitCountsYear("141")
|
|
|
+ deviceYL.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceYL.UnitName = unit[1]
|
|
|
+ deviceYL.TemplateTypeId = 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if templateTypeId == "173" {
|
|
|
+ for _, unit := range unitidArr {
|
|
|
+ var position []limscustomerposition2.LimsCustomerPosition
|
|
|
+ wherep := "PositionTypeId = '1' and CustomerId = " + unit[0]
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCustomerpositionName, wherep, &position)
|
|
|
+ positionids := ""
|
|
|
+ for _, item := range position {
|
|
|
+ positionids = positionids + strconv.Itoa(item.Id) + ","
|
|
|
+ }
|
|
|
+ positionids = strings.Trim(positionids, ",")
|
|
|
+ if positionids != "" {
|
|
|
+ // 无游梁式抽油机 LimsReportNoBeamPumpingUnit
|
|
|
+ var deviceWYL devicestatistics.DeviceStatisticsOil
|
|
|
+ whereYno = whereYno + " and b.CustomerId=" + unit[0]
|
|
|
+ whereY = whereY + " and b.CustomerId=" + unit[0]
|
|
|
+ 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 And PositionCheckId IN (" + positionids + ")" + wheree
|
|
|
+ numEQ = svc.GetCountsByDateEquipment(this.User.AccCode+LimsCheckEquipmentListName, whereN)
|
|
|
+ numWM = svc.GetWaitCountsMonth("173")
|
|
|
+ numWY = svc.GetWaitCountsYear("173")
|
|
|
+ deviceWYL.UnitId,_ = strconv.Atoi(unit[0])
|
|
|
+ deviceWYL.UnitName = unit[1]
|
|
|
+ deviceWYL.TemplateTypeId = 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
|
|
|
+ datainfo.Item = devicelist
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
//获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。
|
|
|
|
|
|
func GetFirstDateOfMonth(d time.Time) time.Time {
|