|
|
@ -2930,7 +2930,6 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, ) (result * |
|
|
|
now, _ := time.ParseInLocation(grmi.DateTimeOutFormat, "2022-03-20 23:00:00", utils.TimezoneLocation) |
|
|
|
endTime := now.Format(grmi.DateTimeOutFormat) |
|
|
|
todayStart := now.Format(grmi.DateOutFormat) + " 00:00:00" |
|
|
|
fmt.Println("endTime:", endTime) |
|
|
|
dateTimeLi := make([]int, 0, now.Hour()) |
|
|
|
todayStartTime, _ := time.ParseInLocation(grmi.DateTimeOutFormat, todayStart, utils.TimezoneLocation) |
|
|
|
var num int |
|
|
@ -3039,22 +3038,51 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, ) (result * |
|
|
|
for _, num = range dateTimeLi { |
|
|
|
result.TimeLi = append(result.TimeLi, strconv.Itoa(num) + "时") |
|
|
|
} |
|
|
|
for _, num = range dateTimeLi { |
|
|
|
hourProduceData := make([]model.ProductFamilyProduce, 0) |
|
|
|
for productFamilyId, accomplishTimeMap := range productFamilyAccomplishMap { |
|
|
|
for productFamilyId, accomplishTimeMap := range productFamilyAccomplishMap { |
|
|
|
percentData := model.ProductFamilyProduce{ |
|
|
|
ProductFamilyId: productFamilyId, |
|
|
|
} |
|
|
|
for _, num = range dateTimeLi { |
|
|
|
qty, exist := accomplishTimeMap[num] |
|
|
|
if exist { |
|
|
|
meter := productFamilyMeterMap[productFamilyId] |
|
|
|
percent := (float64(3600/qty)) / float64(meter) / 100 |
|
|
|
productFamilyProduceData := model.ProductFamilyProduce{ |
|
|
|
ProductFamilyId: productFamilyId, |
|
|
|
Percent: fmt.Sprintf("%.2f", percent), |
|
|
|
} |
|
|
|
hourProduceData = append(hourProduceData, productFamilyProduceData) |
|
|
|
percentData.PercentLi = append(percentData.PercentLi, fmt.Sprintf("%.2f", percent)) |
|
|
|
} else { |
|
|
|
percentData.PercentLi = append(percentData.PercentLi, "0.00") |
|
|
|
} |
|
|
|
} |
|
|
|
result.ProduceData = append(result.ProduceData, percentData) |
|
|
|
|
|
|
|
} |
|
|
|
displayIndexLi := make([]int, 0) |
|
|
|
for index, _ := range dateTimeLi { |
|
|
|
var zeroSign = true |
|
|
|
for _, productData := range result.ProduceData { |
|
|
|
if productData.PercentLi[index] != "0.00" { |
|
|
|
zeroSign = false |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
result.ProduceData = append(result.ProduceData, hourProduceData) |
|
|
|
if !zeroSign { |
|
|
|
displayIndexLi = append(displayIndexLi, index) |
|
|
|
} |
|
|
|
} |
|
|
|
displayTimeLi := make([]string, 0) |
|
|
|
displayProductData := make([]model.ProductFamilyProduce, 0, len(result.ProduceData)) |
|
|
|
for _, productData := range result.ProduceData { |
|
|
|
displayProductData = append(displayProductData, model.ProductFamilyProduce{ |
|
|
|
ProductFamilyId: productData.ProductFamilyId, |
|
|
|
}) |
|
|
|
} |
|
|
|
for _, index := range displayIndexLi { |
|
|
|
displayTimeLi = append(displayTimeLi, result.TimeLi[index]) |
|
|
|
for productIndex, productData := range result.ProduceData { |
|
|
|
displayProductData[productIndex].PercentLi = append(displayProductData[productIndex].PercentLi, productData.PercentLi[index]) |
|
|
|
} |
|
|
|
} |
|
|
|
result.TimeLi = displayTimeLi |
|
|
|
result.ProduceData = displayProductData |
|
|
|
|
|
|
|
return result, nil |
|
|
|
|
|
|
|