|
@@ -116,13 +116,14 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
@@ -116,13 +116,14 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
116
|
return nil, nil
|
116
|
return nil, nil
|
|
117
|
}
|
117
|
}
|
|
118
|
|
118
|
|
|
|
|
119
|
+// 设备运行数据
|
|
119
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.DeviceCollection) (*domain.DeviceRunningData, error) {
|
120
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.DeviceCollection) (*domain.DeviceRunningData, error) {
|
|
120
|
var err error
|
121
|
var err error
|
|
121
|
var unitQuantity float64 = DefaultCCJUnitQuantity // 单位数量
|
122
|
var unitQuantity float64 = DefaultCCJUnitQuantity // 单位数量
|
|
122
|
var data = &domain.DeviceRunningData{
|
123
|
var data = &domain.DeviceRunningData{
|
|
123
|
DeviceCollectionId: record.DeviceCollectionId,
|
124
|
DeviceCollectionId: record.DeviceCollectionId,
|
|
124
|
WorkShopName: record.WorkShopName,
|
125
|
WorkShopName: record.WorkShopName,
|
|
125
|
- CollectionTime: record.CollectionTime,
|
126
|
+ CollectionTime: record.CollectionTime.Local(),
|
|
126
|
DeviceCode: record.DeviceSn,
|
127
|
DeviceCode: record.DeviceSn,
|
|
127
|
DeviceType: record.DeviceType,
|
128
|
DeviceType: record.DeviceType,
|
|
128
|
StartupStatus: int(record.StartupStatus),
|
129
|
StartupStatus: int(record.StartupStatus),
|
|
@@ -234,6 +235,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
@@ -234,6 +235,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
234
|
return data, nil
|
235
|
return data, nil
|
|
235
|
}
|
236
|
}
|
|
236
|
|
237
|
|
|
|
|
238
|
+// 设备运行记录
|
|
237
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData) (*domain.DeviceRunningRecord, error) {
|
239
|
func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData) (*domain.DeviceRunningRecord, error) {
|
|
238
|
return &domain.DeviceRunningRecord{
|
240
|
return &domain.DeviceRunningRecord{
|
|
239
|
CompanyId: companyId,
|
241
|
CompanyId: companyId,
|
|
@@ -242,10 +244,11 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId |
|
@@ -242,10 +244,11 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningRecord(companyId, orgId |
|
242
|
DeviceId: device.DeviceId,
|
244
|
DeviceId: device.DeviceId,
|
|
243
|
DeviceCode: device.DeviceCode,
|
245
|
DeviceCode: device.DeviceCode,
|
|
244
|
DeviceRunningRecordInfo: data,
|
246
|
DeviceRunningRecordInfo: data,
|
|
245
|
- CreatedAt: data.CollectionTime,
|
247
|
+ CreatedAt: data.CollectionTime.Local(),
|
|
246
|
}, nil
|
248
|
}, nil
|
|
247
|
}
|
249
|
}
|
|
248
|
|
250
|
|
|
|
|
251
|
+// 生产记录
|
|
249
|
func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData, plan *domain.ProductPlanDispatchRecord) (*domain.ProductRecord, error) {
|
252
|
func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId int, workStation *domain.WorkStation, device *domain.Device, data *domain.DeviceRunningData, plan *domain.ProductPlanDispatchRecord) (*domain.ProductRecord, error) {
|
|
250
|
result := &domain.ProductRecord{
|
253
|
result := &domain.ProductRecord{
|
|
251
|
CompanyId: companyId,
|
254
|
CompanyId: companyId,
|
|
@@ -253,7 +256,7 @@ func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId i |
|
@@ -253,7 +256,7 @@ func (ptr *PGWorkshopDataConsumeService) newProductRecord(companyId int, orgId i |
|
253
|
WorkStation: workStation,
|
256
|
WorkStation: workStation,
|
|
254
|
ProductRecordType: domain.RecordTypeWeigh,
|
257
|
ProductRecordType: domain.RecordTypeWeigh,
|
|
255
|
ProductWorker: &domain.User{},
|
258
|
ProductWorker: &domain.User{},
|
|
256
|
- CreatedAt: data.CollectionTime,
|
259
|
+ CreatedAt: data.CollectionTime.Local(),
|
|
257
|
UpdatedAt: time.Now(),
|
260
|
UpdatedAt: time.Now(),
|
|
258
|
ProductRecordInfo: &domain.ProductRecordInfo{
|
261
|
ProductRecordInfo: &domain.ProductRecordInfo{
|
|
259
|
ProductDate: data.CollectionTime.Local().Format("2006-01-02"),
|
262
|
ProductDate: data.CollectionTime.Local().Format("2006-01-02"),
|
|
@@ -303,9 +306,9 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId, |
|
@@ -303,9 +306,9 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId, |
|
303
|
WorkStation: workStation,
|
306
|
WorkStation: workStation,
|
|
304
|
DeviceId: device.DeviceId,
|
307
|
DeviceId: device.DeviceId,
|
|
305
|
DeviceCode: device.DeviceCode,
|
308
|
DeviceCode: device.DeviceCode,
|
|
306
|
- ProductDate: utils.GetZeroTime(data.CollectionTime),
|
309
|
+ ProductDate: utils.GetZeroTime(data.CollectionTime.Local()),
|
|
307
|
DeviceRunningRecordInfo: recordInfo,
|
310
|
DeviceRunningRecordInfo: recordInfo,
|
|
308
|
- CreatedAt: data.CollectionTime,
|
311
|
+ CreatedAt: data.CollectionTime.Local(),
|
|
309
|
UpdatedAt: time.Now(),
|
312
|
UpdatedAt: time.Now(),
|
|
310
|
}
|
313
|
}
|
|
311
|
record.RedisKey = redis.DeviceDailyRunningRecordKeyByTimeStr(record.DeviceRunningRecordInfo.ProductDate, record.DeviceCode)
|
314
|
record.RedisKey = redis.DeviceDailyRunningRecordKeyByTimeStr(record.DeviceRunningRecordInfo.ProductDate, record.DeviceCode)
|