|
@@ -3,6 +3,7 @@ package domainService |
|
@@ -3,6 +3,7 @@ package domainService |
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
5
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
5
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
6
|
+ "github.com/linmadan/egglib-go/utils/xtime"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao"
|
|
@@ -125,6 +126,7 @@ type HourProductiveStatisticsRequest struct { |
|
@@ -125,6 +126,7 @@ type HourProductiveStatisticsRequest struct { |
125
|
CompanyId int `json:"companyId" valid:"Required"`
|
126
|
CompanyId int `json:"companyId" valid:"Required"`
|
126
|
OrgId int `json:"orgId" valid:"Required"`
|
127
|
OrgId int `json:"orgId" valid:"Required"`
|
127
|
WorkshopId int `json:"workshopId" valid:"Required"`
|
128
|
WorkshopId int `json:"workshopId" valid:"Required"`
|
|
|
129
|
+ Date time.Time `json:"date"`
|
128
|
}
|
130
|
}
|
129
|
|
131
|
|
130
|
func NewXYData(xData []string, values interface{}) interface{} {
|
132
|
func NewXYData(xData []string, values interface{}) interface{} {
|
|
@@ -151,7 +153,10 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
|
@@ -151,7 +153,10 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
151
|
Ts string `json:"ts"`
|
153
|
Ts string `json:"ts"`
|
152
|
Total float64 `json:"total"`
|
154
|
Total float64 `json:"total"`
|
153
|
}
|
155
|
}
|
154
|
-
|
156
|
+ var date = time.Now()
|
|
|
157
|
+ if !xtime.IsZero(request.Date) {
|
|
|
158
|
+ date = request.Date
|
|
|
159
|
+ }
|
155
|
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
|
160
|
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
|
156
|
if err != nil || workshop == nil {
|
161
|
if err != nil || workshop == nil {
|
157
|
return nil, nil
|
162
|
return nil, nil
|
|
@@ -163,7 +168,7 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
|
@@ -163,7 +168,7 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
163
|
|
168
|
|
164
|
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
|
169
|
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
|
165
|
var result = make([]*record, 0)
|
170
|
var result = make([]*record, 0)
|
166
|
- if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*24*7), &result); err != nil {
|
171
|
+ if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, date.Add(-time.Hour*24*7), date, &result); err != nil {
|
167
|
log.Logger.Error(err.Error())
|
172
|
log.Logger.Error(err.Error())
|
168
|
continue
|
173
|
continue
|
169
|
}
|
174
|
}
|
|
@@ -207,20 +212,24 @@ func (ptr *PGCommonStatisticsService) ProportionOfSecondLevelStatistics(queryOpt |
|
@@ -207,20 +212,24 @@ func (ptr *PGCommonStatisticsService) ProportionOfSecondLevelStatistics(queryOpt |
207
|
return nil, nil
|
212
|
return nil, nil
|
208
|
}
|
213
|
}
|
209
|
productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext)
|
214
|
productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext)
|
210
|
-
|
215
|
+ var date = time.Now()
|
|
|
216
|
+ if !xtime.IsZero(request.Date) {
|
|
|
217
|
+ date = request.Date
|
|
|
218
|
+ }
|
211
|
var input = []struct {
|
219
|
var input = []struct {
|
212
|
name string
|
220
|
name string
|
213
|
- t time.Time
|
221
|
+ begin time.Time
|
|
|
222
|
+ end time.Time
|
214
|
}{
|
223
|
}{
|
215
|
- {"today", utils.GetZeroTime(time.Now())},
|
|
|
216
|
- {"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
|
|
|
217
|
- {"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
|
224
|
+ {"today", utils.GetZeroTime(date), utils.GetZeroTime(date.AddDate(0, 0, 1))},
|
|
|
225
|
+ {"current_week", utils.GetCurrentWeekFirstDay(date), utils.GetCurrentWeekFirstDay(date.AddDate(0, 0, 7))},
|
|
|
226
|
+ {"current_month", utils.GetCurrentMonthFirstDay(date), utils.GetCurrentMonthFirstDay(date.AddDate(0, 1, 0))},
|
218
|
}
|
227
|
}
|
219
|
|
228
|
|
220
|
var response = make(map[string]interface{})
|
229
|
var response = make(map[string]interface{})
|
221
|
for _, v := range input {
|
230
|
for _, v := range input {
|
222
|
var result = make([]*record, 0)
|
231
|
var result = make([]*record, 0)
|
223
|
- if err := productRecordDao.ProportionOfSecondLevelRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
|
232
|
+ if err := productRecordDao.ProportionOfSecondLevelRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.begin, v.end, &result); err != nil {
|
224
|
log.Logger.Error(err.Error())
|
233
|
log.Logger.Error(err.Error())
|
225
|
return nil, err
|
234
|
return nil, err
|
226
|
}
|
235
|
}
|
|
@@ -252,20 +261,24 @@ func (ptr *PGCommonStatisticsService) WorkshopProductionEfficiencyStatistics(que |
|
@@ -252,20 +261,24 @@ func (ptr *PGCommonStatisticsService) WorkshopProductionEfficiencyStatistics(que |
252
|
return nil, nil
|
261
|
return nil, nil
|
253
|
}
|
262
|
}
|
254
|
productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext)
|
263
|
productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext)
|
255
|
-
|
264
|
+ var date = time.Now()
|
|
|
265
|
+ if !xtime.IsZero(request.Date) {
|
|
|
266
|
+ date = request.Date
|
|
|
267
|
+ }
|
256
|
var input = []struct {
|
268
|
var input = []struct {
|
257
|
name string
|
269
|
name string
|
258
|
- t time.Time
|
270
|
+ begin time.Time
|
|
|
271
|
+ end time.Time
|
259
|
}{
|
272
|
}{
|
260
|
- {"today", utils.GetZeroTime(time.Now())},
|
|
|
261
|
- {"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
|
|
|
262
|
- {"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
|
273
|
+ {"today", utils.GetZeroTime(date), utils.GetZeroTime(date.AddDate(0, 0, 1))},
|
|
|
274
|
+ {"current_week", utils.GetCurrentWeekFirstDay(date), utils.GetCurrentWeekFirstDay(date.AddDate(0, 0, 7))},
|
|
|
275
|
+ {"current_month", utils.GetCurrentMonthFirstDay(date), utils.GetCurrentMonthFirstDay(date.AddDate(0, 1, 0))},
|
263
|
}
|
276
|
}
|
264
|
|
277
|
|
265
|
var response = make(map[string]interface{})
|
278
|
var response = make(map[string]interface{})
|
266
|
for _, v := range input {
|
279
|
for _, v := range input {
|
267
|
var result = record{}
|
280
|
var result = record{}
|
268
|
- if err := productRecordDao.WorkshopProductionEfficiencyStatistics(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
|
281
|
+ if err := productRecordDao.WorkshopProductionEfficiencyStatistics(request.CompanyId, request.OrgId, request.WorkshopId, v.begin, v.end, &result); err != nil {
|
269
|
log.Logger.Error(err.Error())
|
282
|
log.Logger.Error(err.Error())
|
270
|
return nil, err
|
283
|
return nil, err
|
271
|
}
|
284
|
}
|