...
|
...
|
@@ -3,6 +3,7 @@ package domainService |
|
|
import (
|
|
|
"fmt"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"github.com/linmadan/egglib-go/utils/xtime"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao"
|
...
|
...
|
@@ -122,9 +123,10 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[ |
|
|
}
|
|
|
|
|
|
type HourProductiveStatisticsRequest struct {
|
|
|
CompanyId int `json:"companyId" valid:"Required"`
|
|
|
OrgId int `json:"orgId" valid:"Required"`
|
|
|
WorkshopId int `json:"workshopId" valid:"Required"`
|
|
|
CompanyId int `json:"companyId" valid:"Required"`
|
|
|
OrgId int `json:"orgId" valid:"Required"`
|
|
|
WorkshopId int `json:"workshopId" valid:"Required"`
|
|
|
Date time.Time `json:"date"`
|
|
|
}
|
|
|
|
|
|
func NewXYData(xData []string, values interface{}) interface{} {
|
...
|
...
|
@@ -151,7 +153,10 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
|
|
Ts string `json:"ts"`
|
|
|
Total float64 `json:"total"`
|
|
|
}
|
|
|
|
|
|
var date = time.Now()
|
|
|
if !xtime.IsZero(request.Date) {
|
|
|
date = request.Date
|
|
|
}
|
|
|
workshop, err := workshopRepository.FindOne(map[string]interface{}{"workshopId": request.WorkshopId})
|
|
|
if err != nil || workshop == nil {
|
|
|
return nil, nil
|
...
|
...
|
@@ -163,7 +168,7 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map |
|
|
|
|
|
for _, v := range workshop.GetProductLines(domain.NotDeleted) {
|
|
|
var result = make([]*record, 0)
|
|
|
if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*24*7), &result); err != nil {
|
|
|
if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, date.Add(-time.Hour*24*7), date, &result); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -207,20 +212,24 @@ func (ptr *PGCommonStatisticsService) ProportionOfSecondLevelStatistics(queryOpt |
|
|
return nil, nil
|
|
|
}
|
|
|
productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext)
|
|
|
|
|
|
var date = time.Now()
|
|
|
if !xtime.IsZero(request.Date) {
|
|
|
date = request.Date
|
|
|
}
|
|
|
var input = []struct {
|
|
|
name string
|
|
|
t time.Time
|
|
|
name string
|
|
|
begin time.Time
|
|
|
end time.Time
|
|
|
}{
|
|
|
{"today", utils.GetZeroTime(time.Now())},
|
|
|
{"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
|
|
|
{"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
|
|
|
{"today", utils.GetZeroTime(date), utils.GetZeroTime(date.AddDate(0, 0, 1))},
|
|
|
{"current_week", utils.GetCurrentWeekFirstDay(date), utils.GetCurrentWeekFirstDay(date.AddDate(0, 0, 7))},
|
|
|
{"current_month", utils.GetCurrentMonthFirstDay(date), utils.GetCurrentMonthFirstDay(date.AddDate(0, 1, 0))},
|
|
|
}
|
|
|
|
|
|
var response = make(map[string]interface{})
|
|
|
for _, v := range input {
|
|
|
var result = make([]*record, 0)
|
|
|
if err := productRecordDao.ProportionOfSecondLevelRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
|
|
|
if err := productRecordDao.ProportionOfSecondLevelRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.begin, v.end, &result); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -252,20 +261,24 @@ func (ptr *PGCommonStatisticsService) WorkshopProductionEfficiencyStatistics(que |
|
|
return nil, nil
|
|
|
}
|
|
|
productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext)
|
|
|
|
|
|
var date = time.Now()
|
|
|
if !xtime.IsZero(request.Date) {
|
|
|
date = request.Date
|
|
|
}
|
|
|
var input = []struct {
|
|
|
name string
|
|
|
t time.Time
|
|
|
name string
|
|
|
begin time.Time
|
|
|
end time.Time
|
|
|
}{
|
|
|
{"today", utils.GetZeroTime(time.Now())},
|
|
|
{"current_week", utils.GetCurrentWeekFirstDay(time.Now())},
|
|
|
{"current_month", utils.GetCurrentMonthFirstDay(time.Now())},
|
|
|
{"today", utils.GetZeroTime(date), utils.GetZeroTime(date.AddDate(0, 0, 1))},
|
|
|
{"current_week", utils.GetCurrentWeekFirstDay(date), utils.GetCurrentWeekFirstDay(date.AddDate(0, 0, 7))},
|
|
|
{"current_month", utils.GetCurrentMonthFirstDay(date), utils.GetCurrentMonthFirstDay(date.AddDate(0, 1, 0))},
|
|
|
}
|
|
|
|
|
|
var response = make(map[string]interface{})
|
|
|
for _, v := range input {
|
|
|
var result = record{}
|
|
|
if err := productRecordDao.WorkshopProductionEfficiencyStatistics(request.CompanyId, request.OrgId, request.WorkshopId, v.t, &result); err != nil {
|
|
|
if err := productRecordDao.WorkshopProductionEfficiencyStatistics(request.CompanyId, request.OrgId, request.WorkshopId, v.begin, v.end, &result); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
|