|
|
@ -20,8 +20,6 @@ import ( |
|
|
|
"LAPP_ACURA_MOM_BACKEND/utils" |
|
|
|
"container/list" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
@ -309,7 +307,6 @@ func (impl *CustOrderServiceImplement) Dashboard(user *global.User, workLineId s |
|
|
|
//图例001
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
DashboardData.DashboardDataPic1, err1 = impl.SelectPic1(user, dayModel, workLineId) |
|
|
|
fmt.Println("DashboardData.DashboardDataPic1:", DashboardData.DashboardDataPic1) |
|
|
|
wg.Done() // 操作完成,减少一个计数
|
|
|
|
}(&wg) |
|
|
|
//图例002
|
|
|
@ -827,7 +824,11 @@ func (impl *CustOrderServiceImplement) SelectTeamTemPo(user *global.User, dayMod |
|
|
|
for _, v := range workLineLi { |
|
|
|
workLineIds = append(workLineIds, v.WorkLineid) |
|
|
|
} |
|
|
|
timeModelList := impl.InitDayModelList(dayModel, startDayTime) |
|
|
|
now := time.Now() |
|
|
|
todayStart := now.Format(grmi.DateOutFormat) + " 00:00:00" |
|
|
|
todayStartTime, _ := time.ParseInLocation(grmi.DateTimeOutFormat, todayStart, utils.TimezoneLocation) |
|
|
|
|
|
|
|
timeModelList := impl.InitDayModelList(dayModel, todayStartTime) |
|
|
|
//计算当班平均节拍
|
|
|
|
switch WorkShift { |
|
|
|
case 1: |
|
|
@ -844,7 +845,7 @@ func (impl *CustOrderServiceImplement) SelectTeamTemPo(user *global.User, dayMod |
|
|
|
} |
|
|
|
countPack := len(packData) |
|
|
|
|
|
|
|
packTimes := impl.GetUsefulTime(time.Now(), WorkShift1StartTime, timeModelList) |
|
|
|
packTimes := impl.GetUsefulTime(WorkShift1StartTime, time.Now(), timeModelList) |
|
|
|
if countPack > 0 { |
|
|
|
TeamTemPoNumber = utils.Decimal(float64(packTimes)/float64(countPack), 2) |
|
|
|
PerTeamTemPoNumber = utils.Decimal(float64(countPack)/float64(num), 4) |
|
|
@ -868,7 +869,7 @@ func (impl *CustOrderServiceImplement) SelectTeamTemPo(user *global.User, dayMod |
|
|
|
} |
|
|
|
countPack := len(packData) |
|
|
|
|
|
|
|
packTimes := impl.GetUsefulTime(time.Now(), WorkShift2StartTime, timeModelList) |
|
|
|
packTimes := impl.GetUsefulTime(WorkShift2StartTime, time.Now(), timeModelList) |
|
|
|
if countPack > 0 { |
|
|
|
TeamTemPoNumber = utils.Decimal(float64(packTimes)/float64(countPack), 2) |
|
|
|
PerTeamTemPoNumber = utils.Decimal(float64(countPack)/float64(num), 4) |
|
|
@ -891,7 +892,7 @@ func (impl *CustOrderServiceImplement) SelectTeamTemPo(user *global.User, dayMod |
|
|
|
return 0, 0, err |
|
|
|
} |
|
|
|
countPack := len(packData) |
|
|
|
packTimes := impl.GetUsefulTime(time.Now(), WorkShift3StartTime, timeModelList) |
|
|
|
packTimes := impl.GetUsefulTime(WorkShift3StartTime, time.Now(), timeModelList) |
|
|
|
if countPack > 0 { |
|
|
|
TeamTemPoNumber = utils.Decimal(float64(packTimes)/float64(countPack), 2) |
|
|
|
PerTeamTemPoNumber = utils.Decimal(float64(countPack)/float64(num), 4) |
|
|
@ -995,9 +996,9 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
usefulPackOrderLi = append(usefulPackOrderLi, packOrder) |
|
|
|
} |
|
|
|
} |
|
|
|
sort.Slice(usefulPackOrderLi, func(i, j int) bool { |
|
|
|
return usefulPackOrderLi[i].CloseTime.Restore().Unix() < usefulPackOrderLi[j].CloseTime.Restore().Unix() |
|
|
|
}) |
|
|
|
//sort.Slice(usefulPackOrderLi, func(i, j int) bool {
|
|
|
|
// return usefulPackOrderLi[i].CloseTime.Restore().Unix() < usefulPackOrderLi[j].CloseTime.Restore().Unix()
|
|
|
|
//})
|
|
|
|
custOrderMap := make(map[string]model.CustOrder) |
|
|
|
displayHourMap := make(map[int]interface{}) |
|
|
|
displayHourLi := make([]int, 0, 24) |
|
|
@ -1080,7 +1081,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
for _, data := range hourData { |
|
|
|
productDataLi = append(productDataLi, data) |
|
|
|
} |
|
|
|
impl.QuickSortProductData(productDataLi) |
|
|
|
//impl.QuickSortProductData(productDataLi)
|
|
|
|
currentTime := todayStartTime.Add(time.Hour * time.Duration(hour)) |
|
|
|
var hourAllUsedTime int |
|
|
|
for _, productFamilyProductData := range productDataLi { |
|
|
@ -1172,6 +1173,7 @@ func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHou |
|
|
|
//now, _ := time.ParseInLocation(grmi.DateTimeOutFormat, "2022-04-28 23:00:00", utils.TimezoneLocation)
|
|
|
|
endTime := now.Format(grmi.DateOutFormat) + " 23:59:59" |
|
|
|
todayStart := now.Format(grmi.DateOutFormat) + " 00:00:00" |
|
|
|
todayStartTime, _ := time.ParseInLocation(grmi.DateTimeOutFormat, todayStart, utils.TimezoneLocation) |
|
|
|
packDao := jitDal.NewPackOrderDAO(session, user.PlantNr, user.UserId) |
|
|
|
//图例003
|
|
|
|
DashboardData3 := model.PerDashboardData{} |
|
|
@ -1189,7 +1191,7 @@ func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHou |
|
|
|
workLineIds = append(workLineIds, v.WorkLineid) |
|
|
|
} |
|
|
|
|
|
|
|
timeModelList := impl.InitDayModelList(dayModel, startDayTime) |
|
|
|
timeModelList := impl.InitDayModelList(dayModel, todayStartTime) |
|
|
|
|
|
|
|
packOrderLi, err := packOrderDao.SelectClosedPackOrder(todayStart, endTime, workLineIds) |
|
|
|
if err != nil { |
|
|
@ -1216,9 +1218,7 @@ func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHou |
|
|
|
usefulPackOrderLi = append(usefulPackOrderLi, packOrder) |
|
|
|
} |
|
|
|
} |
|
|
|
sort.Slice(usefulPackOrderLi, func(i, j int) bool { |
|
|
|
return usefulPackOrderLi[i].CloseTime.Restore().Unix() < usefulPackOrderLi[j].CloseTime.Restore().Unix() |
|
|
|
}) |
|
|
|
|
|
|
|
custOrderMap := make(map[string]model.CustOrder) |
|
|
|
displayHourMap := make(map[int]interface{}) |
|
|
|
displayHourProductMap := make(map[int][]model.HourProductData) |
|
|
@ -1288,7 +1288,7 @@ func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHou |
|
|
|
jphMap := make(map[string]float64) |
|
|
|
|
|
|
|
for hour := 0; hour < 24; hour++ { |
|
|
|
key := utils.TimeFormat(startDayTime.Add(time.Duration(hour)*time.Hour), "yyyy-MM-dd HH:00") |
|
|
|
key := utils.TimeFormat(todayStartTime.Add(time.Duration(hour)*time.Hour), "yyyy-MM-dd HH:00") |
|
|
|
hourData, exist := displayHourProductMap[hour] |
|
|
|
if !exist { |
|
|
|
continue |
|
|
@ -1298,15 +1298,14 @@ func (impl *CustOrderServiceImplement) SelectPic3(user *global.User, DayModelHou |
|
|
|
for _, data := range hourData { |
|
|
|
productDataLi = append(productDataLi, data) |
|
|
|
} |
|
|
|
impl.QuickSortProductData(productDataLi) |
|
|
|
currentTime := startDayTime.Add(time.Hour * time.Duration(hour)) |
|
|
|
currentTime := todayStartTime.Add(time.Hour * time.Duration(hour)) |
|
|
|
var hourAllUsedTime int |
|
|
|
for _, productFamilyProductData := range productDataLi { |
|
|
|
usedTime := impl.GetUsefulTime(currentTime, productFamilyProductData.LastDoneTime, timeModelList) |
|
|
|
currentTime = productFamilyProductData.LastDoneTime |
|
|
|
hourAllUsedTime += usedTime |
|
|
|
} |
|
|
|
currentTime = startDayTime.Add(time.Hour * time.Duration(hour)) |
|
|
|
currentTime = todayStartTime.Add(time.Hour * time.Duration(hour)) |
|
|
|
for _, productFamilyProductData := range productDataLi { |
|
|
|
usedTime := impl.GetUsefulTime(currentTime, productFamilyProductData.LastDoneTime, timeModelList) |
|
|
|
currentTime = productFamilyProductData.LastDoneTime |
|
|
|