|
|
@ -3103,7 +3103,7 @@ func (impl *CustOrderServiceImplement) SelectTeamTemPo(user *global.User, dayMod |
|
|
|
} |
|
|
|
|
|
|
|
//图例1
|
|
|
|
func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *baseModel.DayModel, workLineId string) (result *model.CutLine1, err error) { |
|
|
|
func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *baseModel.DayModel, workLineId string) (result model.CutLine1, err error) { |
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
@ -3133,7 +3133,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
custOrderLi, err := custOrderDao.SelectRunningCustOrder(workLineId) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询正在生产的客户订单失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询正在生产的客户订单失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
var currentMeter int |
|
|
@ -3143,23 +3143,23 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
custOrder := custOrderLi[0] |
|
|
|
productFamily, err := productFamilyDao.SelectOne(custOrder.ProductFamilyId) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询派生数据失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询派生数据失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
if productFamily == nil { |
|
|
|
return nil, grmi.NewBusinessError("客户订单派生不存在, 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
return result, grmi.NewBusinessError("客户订单派生不存在, 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
} |
|
|
|
if productFamily.Jph == 0 { |
|
|
|
return nil, grmi.NewBusinessError("派生JPH为0 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
return result, grmi.NewBusinessError("派生JPH为0 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
} |
|
|
|
currentMeter = int(float64(3600) / productFamily.Jph) |
|
|
|
productFamilyMeterMap[custOrder.ProductFamilyId] = float64(3600) / productFamily.Jph |
|
|
|
productFamilyMap[custOrder.ProductFamilyId] = productFamily |
|
|
|
productLi, err := productFamilyRelateDao.SelectProductByFamilyId(custOrder.ProjectId, custOrder.ProductFamilyId) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询派生下总成数据失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询派生下总成数据失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
if len(productLi) == 0 { |
|
|
|
return nil, grmi.NewBusinessError("派生下未关联需要生产的座椅总成, 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
return result, grmi.NewBusinessError("派生下未关联需要生产的座椅总成, 派生ID:" + custOrder.ProductFamilyId) |
|
|
|
} |
|
|
|
productFamilyRelateMap[custOrder.ProductFamilyId] = make(map[string]interface{}, len(productLi)) |
|
|
|
for _, product := range productLi { |
|
|
@ -3172,7 +3172,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
// 2. 实际结束时间为空 实际开始时间 < 当前时间 状态 > 26 && != 98
|
|
|
|
custOrderDataLi, err := custOrderDao.SelectProduceOrder(todayStart, endTime, workLineId) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询客户订单失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询客户订单失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
|
|
|
|
productFamilyAccomplishMap := make(map[int]map[string]model.HourProductData) |
|
|
@ -3182,20 +3182,20 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
if !exist { |
|
|
|
productFamily, err = productFamilyDao.SelectOne(productFamilyId) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询派生数据失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询派生数据失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
if productFamily == nil { |
|
|
|
return nil, grmi.NewBusinessError("客户订单中派生不存在, 派生Id:" + productFamilyId + ", 客户订单Id:" + custOrderData.CustOrder.CustOrderId) |
|
|
|
return result, grmi.NewBusinessError("客户订单中派生不存在, 派生Id:" + productFamilyId + ", 客户订单Id:" + custOrderData.CustOrder.CustOrderId) |
|
|
|
} |
|
|
|
if productFamily.Jph == 0 { |
|
|
|
return nil, grmi.NewBusinessError("派生JPH为0 派生ID:" + productFamilyId) |
|
|
|
return result, grmi.NewBusinessError("派生JPH为0 派生ID:" + productFamilyId) |
|
|
|
} |
|
|
|
productLi, err := productFamilyRelateDao.SelectProductByFamilyId(custOrderData.CustOrder.ProjectId, productFamilyId) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询派生下总成数据失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询派生下总成数据失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
if len(productLi) == 0 { |
|
|
|
return nil, grmi.NewBusinessError("派生下未关联需要生产的座椅总成, 派生ID:" + productFamilyId) |
|
|
|
return result, grmi.NewBusinessError("派生下未关联需要生产的座椅总成, 派生ID:" + productFamilyId) |
|
|
|
} |
|
|
|
productFamilyRelateMap[productFamilyId] = make(map[string]interface{}, len(productLi)) |
|
|
|
for _, product := range productLi { |
|
|
@ -3207,7 +3207,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
// 查询客户订单下的工单
|
|
|
|
serialOrderDataLi, err := serialOrderDao.SelectByCustOrderIdForDashboard(custOrderData.CustOrder.CustOrderId, todayStart, endTime) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewBusinessError("查询客户订单下工单失败, 错误:" + err.Error()) |
|
|
|
return result, grmi.NewBusinessError("查询客户订单下工单失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
// 记录生产每个台套下面的工单数量
|
|
|
|
syncKeyMap := make(map[string][]omModel.SerialOrder) |
|
|
@ -3275,7 +3275,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
for hour, _ := range productFamilyAccomplishMap { |
|
|
|
displayHourLi = append(displayHourLi, strconv.Itoa(hour)+"时") |
|
|
|
} |
|
|
|
result = &model.CutLine1{ |
|
|
|
result = model.CutLine1{ |
|
|
|
TimeLi: displayHourLi, |
|
|
|
Standard: 1.0, |
|
|
|
ProductFamilyMeter: currentMeter, |
|
|
@ -3304,7 +3304,10 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
usedTime := impl.GetUsefulTime(currentTime, productFamilyProductData.LastDoneTime, timeModelList) |
|
|
|
currentTime = productFamilyProductData.LastDoneTime |
|
|
|
meter := productFamilyMeterMap[productFamilyProductData.ProductFamilyId] |
|
|
|
percent := meter / (float64(usedTime) / float64(productFamilyProductData.Qty)) * (float64(usedTime) / float64(hourAllUsedTime)) |
|
|
|
var percent float64 |
|
|
|
if productFamilyProductData.Qty != 0 && usedTime != 0 && hourAllUsedTime != 0 { |
|
|
|
percent = meter / (float64(usedTime) / float64(productFamilyProductData.Qty)) * (float64(usedTime) / float64(hourAllUsedTime)) |
|
|
|
} |
|
|
|
hourPercent += percent |
|
|
|
} |
|
|
|
result.ProduceData = append(result.ProduceData, hourPercent) |
|
|
@ -3312,6 +3315,7 @@ func (impl *CustOrderServiceImplement) SelectPic1(user *global.User, dayModel *b |
|
|
|
return result, nil |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (impl *CustOrderServiceImplement) GetUsefulTime(start, end time.Time, timeLine *list.List) int { |
|
|
|
var duration int |
|
|
|
for element := timeLine.Front(); element != nil; element = element.Next() { |
|
|
|