|
...
|
...
|
@@ -28,7 +28,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
|
planId int
|
|
|
|
err error
|
|
|
|
plan *domain.ProductPlanDispatchRecord
|
|
|
|
datetime time.Time
|
|
|
|
//datetime time.Time
|
|
|
|
)
|
|
|
|
var (
|
|
|
|
deviceRepository, _ = repository.NewDeviceRepository(ptr.transactionContext)
|
|
...
|
...
|
@@ -78,9 +78,9 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
|
|
|
|
|
// 封箱机、串串机需要定位到批次
|
|
|
|
if record.DeviceType == domain.DeviceTypeFengXiangJi || record.DeviceType == domain.DeviceTypeChuanChuanJi {
|
|
|
|
datetime, _ = time.Parse("2006-01-02", deviceRunningData.Date)
|
|
|
|
if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, datetime, deviceRunningData.ProductType); err != nil {
|
|
|
|
log.Logger.Error(err.Error())
|
|
|
|
//datetime, _ = time.Parse("2006-01-02 15:04:05", deviceRunningData.Date)
|
|
|
|
if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, utils.GetZeroTimeWithLocal(deviceRunningData.CollectionTime, time.UTC), deviceRunningData.ProductType); err != nil {
|
|
|
|
log.Logger.Error(err.Error(), map[string]interface{}{"workstation": workStation, "product_code": deviceRunningData.ProductType})
|
|
|
|
} else {
|
|
|
|
planId = plan.PlanDispatchRecordExt.ProductPlanId
|
|
|
|
}
|
|
...
|
...
|
@@ -171,7 +171,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
|
break
|
|
|
|
}
|
|
|
|
data.Count = int(deviceChuanChuanJi.Count)
|
|
|
|
data.ProductType = deviceChuanChuanJi.ProductType1
|
|
|
|
data.ProductType = domain.ProductTypeToProductCode(deviceChuanChuanJi.ProductType)
|
|
|
|
if data.Date, err = formatDate(deviceChuanChuanJi.Year, deviceChuanChuanJi.Month, deviceChuanChuanJi.Day); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
...
|
...
|
@@ -194,7 +194,8 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
|
break
|
|
|
|
}
|
|
|
|
data.Count = int(deviceFengKouJi.Count)
|
|
|
|
data.ProductType = deviceFengKouJi.ProductType1
|
|
|
|
//data.ProductType = deviceFengKouJi.ProductType1
|
|
|
|
data.ProductType = domain.ProductTypeToProductCode(deviceFengKouJi.ProductType)
|
|
|
|
if data.Date, err = formatDate(deviceFengKouJi.Year, deviceFengKouJi.Month, deviceFengKouJi.Day); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
...
|
...
|
@@ -207,7 +208,8 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
|
break
|
|
|
|
}
|
|
|
|
data.Count = int(deviceFengXiangJi.Count)
|
|
|
|
data.ProductType = deviceFengXiangJi.ProductType1
|
|
|
|
//data.ProductType = deviceFengXiangJi.ProductType1
|
|
|
|
data.ProductType = domain.ProductTypeToProductCode(deviceFengXiangJi.ProductType)
|
|
|
|
if data.Date, err = formatDate(deviceFengXiangJi.Year, deviceFengXiangJi.Month, deviceFengXiangJi.Day); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
...
|
...
|
@@ -227,7 +229,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId |
|
|
|
DeviceId: device.DeviceId,
|
|
|
|
DeviceCode: device.DeviceCode,
|
|
|
|
DeviceRunningRecordInfo: data,
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
CreatedAt: data.CollectionTime,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -243,8 +245,8 @@ func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId i |
|
|
|
ProductRecordInfo: &domain.ProductRecordInfo{
|
|
|
|
ProductDate: data.CollectionTime.Local().Format("2006-01-02"),
|
|
|
|
Original: float64(data.Count),
|
|
|
|
Weigh: float64(data.Count) * DefaultCCJUnitQuantity,
|
|
|
|
WeighBefore: float64(data.Count) * DefaultCCJUnitQuantity,
|
|
|
|
Weigh: utils.Round(float64(data.Count)*DefaultCCJUnitQuantity, 1),
|
|
|
|
WeighBefore: utils.Round(float64(data.Count)*DefaultCCJUnitQuantity, 1),
|
|
|
|
ApproveStatus: domain.AttendanceNotApprove,
|
|
|
|
ProductPlanId: plan.PlanDispatchRecordExt.ProductPlanId,
|
|
|
|
PlanProductName: plan.PlanDispatchRecordExt.PlanProductName,
|
...
|
...
|
|