|
@@ -45,6 +45,19 @@ func Calculate(varietyId int, sysUserId int, sysUserName string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 产生的数据的结束日期
|
|
|
+ var lastDate time.Time
|
|
|
+ {
|
|
|
+ currDate := time.Now()
|
|
|
+ currHour := currDate.Hour()
|
|
|
+ if currHour < 22 {
|
|
|
+ lastDate, _ = time.ParseInLocation(utils.FormatDate, currDate.Format(utils.FormatDate), time.Local)
|
|
|
+ } else {
|
|
|
+ lastDate, _ = time.ParseInLocation(utils.FormatDate, currDate.AddDate(0, 0, 1).Format(utils.FormatDate), time.Local)
|
|
|
+ }
|
|
|
+ lastDate = lastDate.AddDate(1, 0, 0) //业务需要计算的数据日期往当前日期后面加上一年
|
|
|
+ }
|
|
|
+
|
|
|
// 维修数据的开始日期和结束日期
|
|
|
var startDate, endDate time.Time
|
|
|
//所有设备在该日期的减产数
|
|
@@ -60,7 +73,13 @@ func Calculate(varietyId int, sysUserId int, sysUserName string) (err error) {
|
|
|
endDate = plantInfo.ResumptionDate
|
|
|
}
|
|
|
|
|
|
- for tmpDate := plantInfo.MaintenanceDate; !tmpDate.After(plantInfo.ResumptionDate); tmpDate = tmpDate.AddDate(0, 0, 1) {
|
|
|
+ // 结束检修日期
|
|
|
+ resumptionDate := plantInfo.ResumptionDate
|
|
|
+ if plantInfo.IsStop == 1 { // 如果是停产了,那么结束日期就是到 产生的数据的结束日期
|
|
|
+ resumptionDate = lastDate
|
|
|
+ }
|
|
|
+
|
|
|
+ for tmpDate := plantInfo.MaintenanceDate; !tmpDate.After(resumptionDate); tmpDate = tmpDate.AddDate(0, 0, 1) {
|
|
|
dataList, ok := maintenanceDataMap[tmpDate]
|
|
|
if !ok {
|
|
|
dataList = make([]float64, 0)
|
|
@@ -70,18 +89,6 @@ func Calculate(varietyId int, sysUserId int, sysUserName string) (err error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 产生的数据的结束日期
|
|
|
- var lastDate time.Time
|
|
|
-
|
|
|
- currDate := time.Now()
|
|
|
- currHour := currDate.Hour()
|
|
|
- if currHour < 22 {
|
|
|
- lastDate, _ = time.ParseInLocation(utils.FormatDate, currDate.Format(utils.FormatDate), time.Local)
|
|
|
- } else {
|
|
|
- lastDate, _ = time.ParseInLocation(utils.FormatDate, currDate.AddDate(0, 0, 1).Format(utils.FormatDate), time.Local)
|
|
|
- }
|
|
|
- lastDate = lastDate.AddDate(1, 0, 0) //业务需要计算的数据日期往当前日期后面加上一年
|
|
|
-
|
|
|
// 计算出数据
|
|
|
dataMap := make(map[time.Time]float64)
|
|
|
for tmpDate := startDate; !tmpDate.After(lastDate); tmpDate = tmpDate.AddDate(0, 0, 1) {
|