...
|
...
|
@@ -116,13 +116,14 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
// 设备运行数据
|
|
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.DeviceCollection) (*domain.DeviceRunningData, error) {
|
|
|
var err error
|
|
|
var unitQuantity float64 = DefaultCCJUnitQuantity // 单位数量
|
|
|
var data = &domain.DeviceRunningData{
|
|
|
DeviceCollectionId: record.DeviceCollectionId,
|
|
|
WorkShopName: record.WorkShopName,
|
|
|
CollectionTime: record.CollectionTime,
|
|
|
CollectionTime: record.CollectionTime.Local(),
|
|
|
DeviceCode: record.DeviceSn,
|
|
|
DeviceType: record.DeviceType,
|
|
|
StartupStatus: int(record.StartupStatus),
|
...
|
...
|
@@ -234,6 +235,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
return data, nil
|
|
|
}
|
|
|
|
|
|
// 设备运行记录
|
|
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData) (*domain.DeviceRunningRecord, error) {
|
|
|
return &domain.DeviceRunningRecord{
|
|
|
CompanyId: companyId,
|
...
|
...
|
@@ -242,10 +244,11 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId |
|
|
DeviceId: device.DeviceId,
|
|
|
DeviceCode: device.DeviceCode,
|
|
|
DeviceRunningRecordInfo: data,
|
|
|
CreatedAt: data.CollectionTime,
|
|
|
CreatedAt: data.CollectionTime.Local(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 生产记录
|
|
|
func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData, plan *domain.ProductPlanDispatchRecord) (*domain.ProductRecord, error) {
|
|
|
result := &domain.ProductRecord{
|
|
|
CompanyId: companyId,
|
...
|
...
|
@@ -253,7 +256,7 @@ func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId i |
|
|
WorkStation: workStation,
|
|
|
ProductRecordType: domain.RecordTypeWeigh,
|
|
|
ProductWorker: &domain.User{},
|
|
|
CreatedAt: data.CollectionTime,
|
|
|
CreatedAt: data.CollectionTime.Local(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
ProductRecordInfo: &domain.ProductRecordInfo{
|
|
|
ProductDate: data.CollectionTime.Local().Format("2006-01-02"),
|
...
|
...
|
@@ -303,9 +306,9 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId, |
|
|
WorkStation: workStation,
|
|
|
DeviceId: device.DeviceId,
|
|
|
DeviceCode: device.DeviceCode,
|
|
|
ProductDate: utils.GetZeroTime(data.CollectionTime),
|
|
|
ProductDate: utils.GetZeroTime(data.CollectionTime.Local()),
|
|
|
DeviceRunningRecordInfo: recordInfo,
|
|
|
CreatedAt: data.CollectionTime,
|
|
|
CreatedAt: data.CollectionTime.Local(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
}
|
|
|
record.RedisKey = redis.DeviceDailyRunningRecordKeyByTimeStr(record.DeviceRunningRecordInfo.ProductDate, record.DeviceCode)
|
...
|
...
|
|