...
|
...
|
@@ -16,6 +16,10 @@ const ( |
|
|
ProductSection4 = "包装"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
DefaultCCJUnitQuantity = 0.2 //kg 穿串机默认的换算数量 1串/0.1千克
|
|
|
)
|
|
|
|
|
|
//EmployeeProductStatics 员工产能统计
|
|
|
func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain.ProductRecord) (interface{}, error) {
|
|
|
|
...
|
...
|
@@ -56,7 +60,10 @@ func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain. |
|
|
default:
|
|
|
return nil, nil //ptr.personalProductStatics(productRecord)
|
|
|
}
|
|
|
|
|
|
if planId == 0 {
|
|
|
log.Logger.Debug(fmt.Sprintf("工段:%v product_record 编号:%v 批次为0", productRecord.WorkStation.WorkStationId, productRecord.ProductRecordId))
|
|
|
return nil, nil
|
|
|
}
|
|
|
productPlan, err = productPlanRepository.FindOne(map[string]interface{}{"productPlanId": planId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -66,7 +73,7 @@ func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain. |
|
|
// 1.查询员工 -》 员工打卡记录 工位+打卡日期
|
|
|
// 2.打卡记录的时间区间 在生产记录上报的时间范围内
|
|
|
attendanceRecordDao, _ := dao.NewAttendanceRecordDao(ptr.transactionContext)
|
|
|
_, attendanceRecords, err := attendanceRecordDao.ProductWorkStationAttendanceRecord(cid, oid, productRecord.WorkStation.WorkStationId, productRecord.CreatedAt)
|
|
|
_, attendanceRecords, err := attendanceRecordDao.ProductWorkStationAttendanceRecord(cid, oid, productRecord.WorkStation.WorkStationId, time.Now()) //, productRecord.CreatedAt
|
|
|
if err != nil || len(attendanceRecords) == 0 {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -97,13 +104,15 @@ func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain. |
|
|
yesterdayOutputWeight float64 = 0
|
|
|
bestOutputWeight float64 = 0
|
|
|
)
|
|
|
if record, e := employeeProductRecordDao.WorkerProductRecord(cid, oid, planId, r.ProductWorker.UserId, productRecord.CreatedAt.AddDate(0, 0, -1)); e == nil && record != nil {
|
|
|
yesterdayOutputWeight = record.ProductRecordInfo.OutputWeight
|
|
|
bestOutputWeight = record.ProductRecordInfo.BestOutputWeight
|
|
|
|
|
|
} else {
|
|
|
if record, e := employeeProductRecordDao.WorkerBestOutputRecord(cid, oid, planId, r.ProductWorker.UserId); e == nil && record != nil {
|
|
|
if employeeProductRecord.ProductRecordInfo.BestOutputWeight > 0 {
|
|
|
if record, e := employeeProductRecordDao.WorkerProductRecord(cid, oid, planId, r.ProductWorker.UserId, productRecord.CreatedAt.AddDate(0, 0, -1)); e == nil && record != nil {
|
|
|
yesterdayOutputWeight = record.ProductRecordInfo.OutputWeight
|
|
|
bestOutputWeight = record.ProductRecordInfo.BestOutputWeight
|
|
|
|
|
|
} else {
|
|
|
if record, e := employeeProductRecordDao.WorkerBestOutputRecord(cid, oid, planId, r.ProductWorker.UserId); e == nil && record != nil {
|
|
|
yesterdayOutputWeight = record.ProductRecordInfo.OutputWeight
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -139,7 +148,7 @@ func newEmployeeProductRecord(productRecord *domain.ProductRecord, participateTy |
|
|
Ext: productPlan.Ext,
|
|
|
Version: 1,
|
|
|
ProductRecordInfo: &domain.ProductRecordStaticInfo{
|
|
|
ProductDate: productRecord.CreatedAt.Format("2006-01-02"),
|
|
|
ProductDate: productRecord.CreatedAt.Local().Format("2006-01-02"),
|
|
|
ProductPlanId: productRecord.ProductRecordInfo.ProductPlanId,
|
|
|
PlanProductName: productRecord.ProductRecordInfo.PlanProductName,
|
|
|
BatchNumber: productRecord.ProductRecordInfo.BatchNumber,
|
...
|
...
|
@@ -191,6 +200,7 @@ func FindGroupMembers(productGroupRepository domain.ProductGroupRepository, comp |
|
|
u := groups[i].GroupMembers[j]
|
|
|
u.GroupId = groups[i].ProductGroupId
|
|
|
u.GroupName = groups[i].GroupName
|
|
|
u.WorkOn = groups[i].WorkOn
|
|
|
result[keyFunc(u.UserId)] = u
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -247,10 +257,6 @@ func (ptr *PGProductRecordService) personalProductStatics(productRecord *domain. |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 更新批次的产能 (只有包装要更新批次产能)
|
|
|
//if productPlan.WorkStation.SectionName==ProductSection4{
|
|
|
//
|
|
|
//}
|
|
|
|
|
|
employeeProductRecord.UpdateProductWeigh(productRecord.ProductRecordInfo.Weigh, productRecord.ProductRecordType, productRecord.WorkStation.SectionName, yesterdayOutputWeight, bestOutputWeight)
|
|
|
|
...
|
...
|
@@ -277,7 +283,10 @@ func (ptr *PGProductRecordService) WorkshopProductStatics(productRecord *domain. |
|
|
productPlan *domain.ProductPlan
|
|
|
err error
|
|
|
)
|
|
|
|
|
|
if planId == 0 {
|
|
|
log.Logger.Debug(fmt.Sprintf("工段:%v product_record 编号:%v 批次为0", productRecord.WorkStation.WorkStationId, productRecord.ProductRecordId))
|
|
|
return nil, nil
|
|
|
}
|
|
|
productPlan, err = productPlanRepository.FindOne(map[string]interface{}{"productPlanId": planId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -326,7 +335,7 @@ func newWorkshopProductRecord(productRecord *domain.ProductRecord, productPlan * |
|
|
WorkStation: productRecord.WorkStation,
|
|
|
//WorkOn: productPlan.WorkOn,
|
|
|
//ParticipateType: participateType,
|
|
|
ProductDate: productRecord.CreatedAt.Format("2006-01-02"),
|
|
|
ProductDate: productRecord.CreatedAt.Local().Format("2006-01-02"),
|
|
|
ProductWeigh: 0,
|
|
|
SecondLevelWeigh: 0,
|
|
|
CreatedAt: time.Now(),
|
...
|
...
|
@@ -334,7 +343,7 @@ func newWorkshopProductRecord(productRecord *domain.ProductRecord, productPlan * |
|
|
Ext: productPlan.Ext,
|
|
|
Version: 1,
|
|
|
ProductRecordInfo: &domain.ProductRecordStaticInfo{
|
|
|
ProductDate: productRecord.CreatedAt.Format("2006-01-02"),
|
|
|
ProductDate: productRecord.CreatedAt.Local().Format("2006-01-02"),
|
|
|
ProductPlanId: productRecord.ProductRecordInfo.ProductPlanId,
|
|
|
PlanProductName: productRecord.ProductRecordInfo.PlanProductName,
|
|
|
BatchNumber: productRecord.ProductRecordInfo.BatchNumber,
|
...
|
...
|
|