作者 yangfu

fix: 车间产能统计修改

... ... @@ -2,7 +2,6 @@ package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
)
type EmployeeProductRecordDto struct {
... ... @@ -32,7 +31,7 @@ type EmployeeProductRecordDto struct {
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
// 合格率 百分比
QualificationRate int `json:"qualificationRate"`
QualificationRate float64 `json:"qualificationRate"`
// 考勤类型 1.正常 2.支援
ParticipateTypeDescription string `json:"participateTypeDescription"`
// 员工类型描述 1:固定 2:派遣 3.临时
... ... @@ -50,9 +49,9 @@ func (d *EmployeeProductRecordDto) LoadDto(m *domain.EmployeeProductRecord, orgI
d.PlanProductName = m.ProductRecordInfo.PlanProductName
d.BatchNumber = m.ProductRecordInfo.BatchNumber
d.ParticipateType = m.ParticipateType
d.ProductWeigh = utils.Round(m.RealProductWeigh(), 1)
d.SecondLevelWeigh = utils.Round(m.SecondLevelWeigh, 1)
d.QualificationRate = m.QualificationRate()
d.ProductWeigh = m.ProductRecordInfo.OutputWeight // utils.Round(m.RealProductWeigh(), 1)
d.SecondLevelWeigh = m.ProductRecordInfo.SecondLevelWeight // utils.Round(m.SecondLevelWeigh, 1)
d.QualificationRate = m.ProductRecordInfo.QualificationRate //m.QualificationRate()
d.CreatedAt = m.CreatedAt.Local().Format("2006-01-02")
d.ParticipateTypeDescription = domain.ParticipateTypeDescription(m.ParticipateType)
d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType)
... ...
... ... @@ -2,7 +2,6 @@ package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
)
type WorkshopProductRecordDto struct {
... ... @@ -32,7 +31,7 @@ type WorkshopProductRecordDto struct {
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
// 合格率 百分比
QualificationRate int `json:"qualificationRate"`
QualificationRate float64 `json:"qualificationRate"`
}
func (d *WorkshopProductRecordDto) LoadDto(m *domain.WorkshopProductRecord, orgId int) *WorkshopProductRecordDto {
... ... @@ -42,10 +41,10 @@ func (d *WorkshopProductRecordDto) LoadDto(m *domain.WorkshopProductRecord, orgI
d.PlanProductName = m.ProductRecordInfo.PlanProductName
d.BatchNumber = m.ProductRecordInfo.BatchNumber
//d.ParticipateType = m.ParticipateType
d.DevotedProductWeigh = utils.Round(m.DevotedProductWeigh(), 1)
d.ProductWeigh = utils.Round(m.RealProductWeigh(), 1)
d.SecondLevelWeigh = utils.Round(m.SecondLevelWeigh, 1)
d.QualificationRate = m.QualificationRate()
d.DevotedProductWeigh = m.ProductRecordInfo.InputWeight //utils.Round(m.DevotedProductWeigh(), 1)
d.ProductWeigh = m.ProductRecordInfo.OutputWeight //utils.Round(m.RealProductWeigh(), 1)
d.SecondLevelWeigh = m.ProductRecordInfo.SecondLevelWeight //utils.Round(m.SecondLevelWeigh, 1)
d.QualificationRate = m.ProductRecordInfo.QualificationRate //m.QualificationRate()
d.CreatedAt = m.ProductDate
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
... ...
... ... @@ -25,7 +25,7 @@ type ProductRecordStaticInfo struct {
// 历史最好产出量
BestOutputWeight float64 `json:"bestOutputWeight"`
// 合格率
QualificationRate int `json:"qualificationRate"`
QualificationRate float64 `json:"qualificationRate"`
// 其他工段二级品的重量合计
TotalOtherSecondLevelWeigh float64 `json:"totalOtherSecondLevelWeigh"`
... ... @@ -38,7 +38,7 @@ func (info *ProductRecordStaticInfo) OtherSecondLevelWeigh() float64 {
for _, v := range info.OtherSectionSecondLevelWeigh {
result += v
}
return result
return utils.Round(result, 1)
}
// AddSectionWeight 添加工段的二级品
... ... @@ -57,9 +57,9 @@ func (info *ProductRecordStaticInfo) AddSectionWeight(section string, weight flo
// bestWeight 最佳产能
func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, secondWeight float64, yesterdayWeight float64, bestWeight float64) {
totalOtherSecondLevelWeigh := info.OtherSecondLevelWeigh()
info.InputWeight = productWeight - totalOtherSecondLevelWeigh
info.OutputWeight = info.InputWeight - secondWeight
info.SecondLevelWeight = secondWeight
info.InputWeight = utils.Round(productWeight-totalOtherSecondLevelWeigh, 1)
info.OutputWeight = utils.Round(info.InputWeight-secondWeight, 1)
info.SecondLevelWeight = utils.Round(secondWeight, 1)
if info.YesterdayOutputWeight == 0 && info.BestOutputWeight == 0 {
info.YesterdayOutputWeight = yesterdayWeight
info.BestOutputWeight = bestWeight
... ... @@ -68,5 +68,5 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second
info.BestOutputWeight = info.OutputWeight
}
info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh
info.QualificationRate = int(utils.Round(info.OutputWeight/info.InputWeight*100, 2))
info.QualificationRate = utils.Round(info.OutputWeight*100.0/info.InputWeight, 0)
}
... ...
... ... @@ -87,7 +87,7 @@ func (employeeProductRecord *WorkshopProductRecord) RealProductWeigh() float64 {
}
// 合格率
func (employeeProductRecord *WorkshopProductRecord) QualificationRate() int {
func (employeeProductRecord *WorkshopProductRecord) QualificationRate() float64 {
realProductWeigh := employeeProductRecord.RealProductWeigh()
if realProductWeigh == 0 {
return 0
... ... @@ -97,8 +97,7 @@ func (employeeProductRecord *WorkshopProductRecord) QualificationRate() int {
return 0
}
// 合格率 = 产能重量 / (总投入重量 - 上级损耗重量)
result := int(utils.Round(realProductWeigh*100/devoteWeigh, 0))
return result
return utils.Round(realProductWeigh*100/devoteWeigh, 0)
}
func (employeeProductRecord *WorkshopProductRecord) DevotedProductWeigh() float64 {
result := employeeProductRecord.ProductWeigh - employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh()
... ...