作者 yangfu

fix: 车间产能统计修改

1 package domain 1 package domain
2 2
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
  4 +
3 type ProductRecordStaticInfo struct { 5 type ProductRecordStaticInfo struct {
4 // 生产日期 6 // 生产日期
5 ProductDate string `json:"productDate"` 7 ProductDate string `json:"productDate"`
@@ -66,5 +68,5 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second @@ -66,5 +68,5 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second
66 info.BestOutputWeight = info.OutputWeight 68 info.BestOutputWeight = info.OutputWeight
67 } 69 }
68 info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh 70 info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh
69 - info.QualificationRate = int(info.OutputWeight / info.InputWeight * 100) 71 + info.QualificationRate = int(utils.Round(info.OutputWeight/info.InputWeight*100, 2))
70 } 72 }
1 package domain 1 package domain
2 2
3 -import "time" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
  5 + "time"
  6 +)
4 7
5 // 员工生产记录 8 // 员工生产记录
6 type WorkshopProductRecord struct { 9 type WorkshopProductRecord struct {
@@ -89,8 +92,12 @@ func (employeeProductRecord *WorkshopProductRecord) QualificationRate() int { @@ -89,8 +92,12 @@ func (employeeProductRecord *WorkshopProductRecord) QualificationRate() int {
89 if realProductWeigh == 0 { 92 if realProductWeigh == 0 {
90 return 0 93 return 0
91 } 94 }
  95 + devoteWeigh := employeeProductRecord.DevotedProductWeigh()
  96 + if devoteWeigh == 0 {
  97 + return 0
  98 + }
92 // 合格率 = 产能重量 / (总投入重量 - 上级损耗重量) 99 // 合格率 = 产能重量 / (总投入重量 - 上级损耗重量)
93 - result := int(realProductWeigh * 100 / (employeeProductRecord.ProductWeigh - employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh())) 100 + result := int(utils.Round(realProductWeigh*100/devoteWeigh, 0))
94 return result 101 return result
95 } 102 }
96 func (employeeProductRecord *WorkshopProductRecord) DevotedProductWeigh() float64 { 103 func (employeeProductRecord *WorkshopProductRecord) DevotedProductWeigh() float64 {
@@ -57,6 +57,7 @@ func TestComputeTimeDuration(t *testing.T) { @@ -57,6 +57,7 @@ func TestComputeTimeDuration(t *testing.T) {
57 const TIME_LAYOUT = "2006-01-02 03:04:05" 57 const TIME_LAYOUT = "2006-01-02 03:04:05"
58 58
59 func TestTimeParse(t *testing.T) { 59 func TestTimeParse(t *testing.T) {
  60 + fmt.Println(int(-1))
60 timeParse() 61 timeParse()
61 } 62 }
62 63