Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-manufacture into dev
正在显示
34 个修改的文件
包含
355 行增加
和
25 行删除
@@ -5,7 +5,7 @@ go 1.16 | @@ -5,7 +5,7 @@ go 1.16 | ||
5 | require ( | 5 | require ( |
6 | github.com/ajg/form v1.5.1 // indirect | 6 | github.com/ajg/form v1.5.1 // indirect |
7 | github.com/beego/beego/v2 v2.0.1 | 7 | github.com/beego/beego/v2 v2.0.1 |
8 | - github.com/bwmarrin/snowflake v0.3.0 // indirect | 8 | + github.com/bwmarrin/snowflake v0.3.0 |
9 | github.com/eclipse/paho.mqtt.golang v1.3.5 | 9 | github.com/eclipse/paho.mqtt.golang v1.3.5 |
10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | 10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect |
11 | github.com/fatih/structs v1.1.0 // indirect | 11 | github.com/fatih/structs v1.1.0 // indirect |
@@ -20,6 +20,11 @@ import ( | @@ -20,6 +20,11 @@ import ( | ||
20 | ) | 20 | ) |
21 | 21 | ||
22 | func main() { | 22 | func main() { |
23 | + defer func() { | ||
24 | + if r := recover(); r != nil { | ||
25 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
26 | + } | ||
27 | + }() | ||
23 | if constant.ENABLE_KAFKA_LOG { | 28 | if constant.ENABLE_KAFKA_LOG { |
24 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) | 29 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) |
25 | log.Logger.AddHook(w) | 30 | log.Logger.AddHook(w) |
@@ -43,11 +43,17 @@ func (crontabService *CrontabService) initTask() { | @@ -43,11 +43,17 @@ func (crontabService *CrontabService) initTask() { | ||
43 | autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) | 43 | autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) |
44 | task.AddTask("autoApproveRecord", autoApproveRecord) | 44 | task.AddTask("autoApproveRecord", autoApproveRecord) |
45 | 45 | ||
46 | - autoFlushDeviceDailyRunningRecord := task.NewTask("autoFlushDeviceDailyRunningRecord", "0 */1 * * * *", AutoFlushDeviceDailyRunningRecord) | 46 | + autoFlushDeviceDailyRunningRecord := task.NewTask("定时刷新设备每日运行记录", "0 */1 * * * *", AutoFlushDeviceDailyRunningRecord) |
47 | task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecord) | 47 | task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecord) |
48 | 48 | ||
49 | - autoWorkshopPlanCompletionRecord := task.NewTask("autoFlushDeviceDailyRunningRecord", "0 1 1-10/3 * * *", AutoWorkshopPlanCompletionRecord) | 49 | + autoFlushDeviceDailyRunningRecordOEE := task.NewTask("定时刷新设备每日运行记录-OEE", "0 */10 * * * *", AutoFlushDeviceDailyRunningRecordOEE) |
50 | + task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecordOEE) | ||
51 | + | ||
52 | + autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-15/3 * * *", AutoWorkshopPlanCompletionRecord) | ||
50 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) | 53 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) |
54 | + | ||
55 | + autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/3 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次 | ||
56 | + task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord) | ||
51 | } | 57 | } |
52 | 58 | ||
53 | func (crontabService *CrontabService) StartCrontabTask() { | 59 | func (crontabService *CrontabService) StartCrontabTask() { |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
14 | + "time" | ||
15 | +) | ||
16 | + | ||
17 | +// 定时刷新设备每日运行记录 | ||
18 | +func AutoFlushDeviceDailyRunningRecordOEE(ctx context.Context) error { | ||
19 | + defer func() { | ||
20 | + if r := recover(); r != nil { | ||
21 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
22 | + } | ||
23 | + }() | ||
24 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if err := transactionContext.StartTransaction(); err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + defer func() { | ||
32 | + if err != nil { | ||
33 | + log.Logger.Error("【定时刷新设备每日运行记录-OEE】 失败:" + err.Error()) | ||
34 | + } | ||
35 | + transactionContext.RollbackTransaction() | ||
36 | + }() | ||
37 | + | ||
38 | + log.Logger.Debug("【定时刷新设备每日运行记录-OEE】 启动") | ||
39 | + deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | ||
40 | + // 获取redis里当天的记录 | ||
41 | + span := time.Duration(20) | ||
42 | + t := time.Now().Add(-time.Minute * span) | ||
43 | + records, err := redis.GetDeviceDailyAllRecord(t) | ||
44 | + if err != nil { | ||
45 | + log.Logger.Error(err.Error()) | ||
46 | + return err | ||
47 | + } | ||
48 | + total := 24 * 60 * 60 | ||
49 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
50 | + workshopProductRecordDao, _ := dao.NewWorkshopProductRecordDao(transactionContext.(*pg.TransactionContext)) | ||
51 | + | ||
52 | + for _, v := range records { | ||
53 | + //if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | ||
54 | + // log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | ||
55 | + // continue | ||
56 | + //} | ||
57 | + | ||
58 | + var ( | ||
59 | + pu float64 = 100 | ||
60 | + qu float64 = 100 | ||
61 | + ) | ||
62 | + | ||
63 | + // 更新设备效率 OEE = tu * pu * qu | ||
64 | + /* | ||
65 | + pu 性能利用 | ||
66 | + 设备标准工时, | ||
67 | + 没有配置设备标准工时的为100 | ||
68 | + */ | ||
69 | + | ||
70 | + // 只计算串串机 | ||
71 | + if v.DeviceRunningRecordInfo.DeviceType == domain.DeviceTypeChuanChuanJi { | ||
72 | + // 设备数据(标准工时) | ||
73 | + device, err := deviceRepository.FindOne(map[string]interface{}{"deviceId": v.DeviceId}) | ||
74 | + if device != nil && err == nil { | ||
75 | + if device.Ext.DeviceExt != nil { | ||
76 | + pu = utils.Round(float64((v.DeviceRunningRecordInfo.Count*100.0)/(total/device.Ext.DeviceExt.UnitProductionSecTime)), 1) | ||
77 | + } | ||
78 | + } | ||
79 | + // 工段对应二级品数据 | ||
80 | + | ||
81 | + record, err := workshopProductRecordDao.WorkStationProductRecord(v.CompanyId, v.OrgId, v.WorkStation.WorkStationId, t) | ||
82 | + if record != nil && err == nil { | ||
83 | + qu = float64(v.DeviceRunningRecordInfo.Count) * domainService.DefaultCCJUnitQuantity | ||
84 | + qu = utils.Round((qu-record.SecondLevelWeigh)*100/qu, 1) | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | + v.DeviceRunningRecordInfo.ResetOEE(pu, qu) | ||
89 | + | ||
90 | + if _, err := deviceDailyRunningRecordRepository.Save(v); err != nil { | ||
91 | + log.Logger.Error(err.Error()) | ||
92 | + continue | ||
93 | + } | ||
94 | + if err := redis.SaveDeviceDailyRunningRecord(v); err != nil { | ||
95 | + log.Logger.Error(err.Error()) | ||
96 | + continue | ||
97 | + } | ||
98 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 刷新记录 %v", v)) | ||
99 | + } | ||
100 | + | ||
101 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
102 | + return err | ||
103 | + } | ||
104 | + return nil | ||
105 | +} |
@@ -27,12 +27,12 @@ func AutoWorkshopPlanCompletionRecord(ctx context.Context) error { | @@ -27,12 +27,12 @@ func AutoWorkshopPlanCompletionRecord(ctx context.Context) error { | ||
27 | } | 27 | } |
28 | defer func() { | 28 | defer func() { |
29 | if err != nil { | 29 | if err != nil { |
30 | - log.Logger.Error("【定时刷新设备每日运行记录】 失败:" + err.Error()) | 30 | + log.Logger.Error("【定时刷新车间计划备每日运行记录】 失败:" + err.Error()) |
31 | } | 31 | } |
32 | transactionContext.RollbackTransaction() | 32 | transactionContext.RollbackTransaction() |
33 | }() | 33 | }() |
34 | 34 | ||
35 | - log.Logger.Debug("【定时刷新设备每日运行记录】 启动") | 35 | + log.Logger.Debug("【定时刷新车间计划每日运行记录】 启动") |
36 | end := utils.GetZeroTime(time.Now()) | 36 | end := utils.GetZeroTime(time.Now()) |
37 | begin := utils.GetZeroTime(end.Add(-time.Second)) | 37 | begin := utils.GetZeroTime(end.Add(-time.Second)) |
38 | approveAttendanceRecordsService, _ := domainService.NewPGWorkshopPlanCompletionRecordService(transactionContext.(*pgTransaction.TransactionContext)) | 38 | approveAttendanceRecordsService, _ := domainService.NewPGWorkshopPlanCompletionRecordService(transactionContext.(*pgTransaction.TransactionContext)) |
@@ -46,3 +46,39 @@ func AutoWorkshopPlanCompletionRecord(ctx context.Context) error { | @@ -46,3 +46,39 @@ func AutoWorkshopPlanCompletionRecord(ctx context.Context) error { | ||
46 | } | 46 | } |
47 | return nil | 47 | return nil |
48 | } | 48 | } |
49 | + | ||
50 | +// 定时刷新当天车间计划完成纪录 | ||
51 | +func AutoTodayWorkshopPlanCompletionRecord(ctx context.Context) error { | ||
52 | + defer func() { | ||
53 | + if r := recover(); r != nil { | ||
54 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
55 | + } | ||
56 | + }() | ||
57 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
58 | + if err != nil { | ||
59 | + return err | ||
60 | + } | ||
61 | + if err := transactionContext.StartTransaction(); err != nil { | ||
62 | + return err | ||
63 | + } | ||
64 | + defer func() { | ||
65 | + if err != nil { | ||
66 | + log.Logger.Error("【定时刷新车间计划今日运行记录】 失败:" + err.Error()) | ||
67 | + } | ||
68 | + transactionContext.RollbackTransaction() | ||
69 | + }() | ||
70 | + | ||
71 | + log.Logger.Debug("【定时刷新车间计划今日运行记录】 启动") | ||
72 | + begin := utils.GetZeroTime(time.Now()) | ||
73 | + end := time.Now() | ||
74 | + approveAttendanceRecordsService, _ := domainService.NewPGWorkshopPlanCompletionRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
75 | + | ||
76 | + if err = approveAttendanceRecordsService.WorkshopPlanCompletion(begin, end); err != nil { | ||
77 | + return err | ||
78 | + } | ||
79 | + | ||
80 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
81 | + return err | ||
82 | + } | ||
83 | + return nil | ||
84 | +} |
@@ -28,6 +28,8 @@ type SearchDeviceQuery struct { | @@ -28,6 +28,8 @@ type SearchDeviceQuery struct { | ||
28 | DeviceName string `json:"deviceName,omitempty"` | 28 | DeviceName string `json:"deviceName,omitempty"` |
29 | // 设备状态 1:正常 2:封存 3:报废 | 29 | // 设备状态 1:正常 2:封存 3:报废 |
30 | DeviceStatus int `json:"deviceStatus,omitempty"` | 30 | DeviceStatus int `json:"deviceStatus,omitempty"` |
31 | + // 排除的设备列表 | ||
32 | + IncludeDevices []int `cname:"排除的设备列表" json:"includeDevices"` | ||
31 | } | 33 | } |
32 | 34 | ||
33 | func (cmd *SearchDeviceQuery) Valid(validation *validation.Validation) { | 35 | func (cmd *SearchDeviceQuery) Valid(validation *validation.Validation) { |
@@ -363,6 +363,67 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | @@ -363,6 +363,67 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | ||
363 | return count, result, nil | 363 | return count, result, nil |
364 | } | 364 | } |
365 | 365 | ||
366 | +// 返回设备服务列表 | ||
367 | +func (deviceService *DeviceService) SelectorDeviceUnbounded(operateInfo *domain.OperateInfo, listDeviceQuery *query.SearchDeviceQuery) (int64, interface{}, error) { | ||
368 | + if err := listDeviceQuery.ValidateQuery(); err != nil { | ||
369 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
370 | + } | ||
371 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
372 | + if err != nil { | ||
373 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
374 | + } | ||
375 | + if err := transactionContext.StartTransaction(); err != nil { | ||
376 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
377 | + } | ||
378 | + defer func() { | ||
379 | + transactionContext.RollbackTransaction() | ||
380 | + }() | ||
381 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
382 | + count, devices, err := deviceRepository.Find(utils.ObjectToMap(listDeviceQuery)) | ||
383 | + if err != nil { | ||
384 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
385 | + } | ||
386 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
387 | + | ||
388 | + productJobRepository, _, _ := factory.FastPgProductJob(transactionContext, 0) | ||
389 | + _, productJobs, _ := productJobRepository.Find(map[string]interface{}{"companyId": listDeviceQuery.CompanyId}) | ||
390 | + var excludeMap = make(map[int]int) | ||
391 | + var allBoundedDevice = make([]int, 0) | ||
392 | + for i := range productJobs { | ||
393 | + allBoundedDevice = append(allBoundedDevice, productJobs[i].RelatedDevices...) | ||
394 | + } | ||
395 | + for _, v := range allBoundedDevice { | ||
396 | + exclude := false | ||
397 | + for _, j := range listDeviceQuery.IncludeDevices { | ||
398 | + if j == v { | ||
399 | + exclude = true | ||
400 | + } | ||
401 | + } | ||
402 | + if exclude { | ||
403 | + continue | ||
404 | + } | ||
405 | + excludeMap[v] = v | ||
406 | + } | ||
407 | + var result = make([]*dto.DeviceDto, 0) | ||
408 | + for i := range devices { | ||
409 | + item := devices[i] | ||
410 | + newJobDto := &dto.DeviceDto{} | ||
411 | + if _, ok := excludeMap[item.DeviceId]; ok { | ||
412 | + continue | ||
413 | + } | ||
414 | + if item.WorkStation != nil && item.WorkStation.WorkshopId > 0 { | ||
415 | + newJobDto.WorkStation = workshops.FindWorkStationOrNil(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
416 | + } | ||
417 | + newJobDto.LoadDto(item, operateInfo.OrgId) | ||
418 | + result = append(result, newJobDto) | ||
419 | + } | ||
420 | + | ||
421 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
422 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
423 | + } | ||
424 | + return count, result, nil | ||
425 | +} | ||
426 | + | ||
366 | // 批量添加产品服务 | 427 | // 批量添加产品服务 |
367 | func (deviceService *DeviceService) BatchAddProduct(opt *domain.OperateInfo, list []*domain.ImportDeviceItem) ([]interface{}, error) { | 428 | func (deviceService *DeviceService) BatchAddProduct(opt *domain.OperateInfo, list []*domain.ImportDeviceItem) ([]interface{}, error) { |
368 | transactionContext, err := factory.CreateTransactionContext(nil) | 429 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -20,7 +20,7 @@ type UpdateProductCalendarCommand struct { | @@ -20,7 +20,7 @@ type UpdateProductCalendarCommand struct { | ||
20 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 20 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
21 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 21 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
22 | // 日历选择 | 22 | // 日历选择 |
23 | - CalendarSelected []string `cname:"日历选择" json:"calendarSelected" valid:"Required"` | 23 | + CalendarSelected []int `cname:"日历选择" json:"calendarSelected" valid:"Required"` |
24 | // 上岗时间 | 24 | // 上岗时间 |
25 | InWorkAt string `cname:"上岗时间" json:"inWorkAt" valid:"Required"` | 25 | InWorkAt string `cname:"上岗时间" json:"inWorkAt" valid:"Required"` |
26 | // 下岗时间 | 26 | // 下岗时间 |
@@ -23,9 +23,9 @@ type ProductCalendarDto struct { | @@ -23,9 +23,9 @@ type ProductCalendarDto struct { | ||
23 | // 下岗时间 | 23 | // 下岗时间 |
24 | OutWorkAt string `json:"outWorkAt,omitempty"` | 24 | OutWorkAt string `json:"outWorkAt,omitempty"` |
25 | // 休息时间 (单位 h) | 25 | // 休息时间 (单位 h) |
26 | - BreakTime float64 `json:"breakTime,omitempty"` | 26 | + BreakTime float64 `json:"breakTime"` |
27 | // 工时 (单位 h) | 27 | // 工时 (单位 h) |
28 | - WorkTime float64 `json:"workTime,omitempty"` | 28 | + WorkTime float64 `json:"workTime"` |
29 | // 已选择日历 | 29 | // 已选择日历 |
30 | //CalendarSelectedString string `json:"calendarSelectedString,omitempty"` | 30 | //CalendarSelectedString string `json:"calendarSelectedString,omitempty"` |
31 | // 组织名称 | 31 | // 组织名称 |
@@ -302,7 +302,7 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd | @@ -302,7 +302,7 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd | ||
302 | 302 | ||
303 | productCalendar.WorkStation = workStation | 303 | productCalendar.WorkStation = workStation |
304 | productCalendar.WorkOn = cmd.WorkOn | 304 | productCalendar.WorkOn = cmd.WorkOn |
305 | - productCalendar.CalendarSelected = cmd.CalendarSelected | 305 | + productCalendar.CalendarSelected = utils.ToArrayString(cmd.CalendarSelected) |
306 | productCalendar.InWorkAt = cmd.InWorkAt | 306 | productCalendar.InWorkAt = cmd.InWorkAt |
307 | productCalendar.OutWorkAt = cmd.OutWorkAt | 307 | productCalendar.OutWorkAt = cmd.OutWorkAt |
308 | productCalendar.BreakTime = cmd.BreakTime | 308 | productCalendar.BreakTime = cmd.BreakTime |
@@ -57,7 +57,11 @@ func (productLineService *ProductLineService) CreateProductLine(createProductLin | @@ -57,7 +57,11 @@ func (productLineService *ProductLineService) CreateProductLine(createProductLin | ||
57 | if err := transactionContext.CommitTransaction(); err != nil { | 57 | if err := transactionContext.CommitTransaction(); err != nil { |
58 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 58 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
59 | } | 59 | } |
60 | - return createProductLineCommand, nil | 60 | + return map[string]interface{}{ |
61 | + "lineId": newProductLine.LineId, | ||
62 | + "lineName": newProductLine.LineName, | ||
63 | + "workshopId": createProductLineCommand.WorkshopId, | ||
64 | + }, nil | ||
61 | } | 65 | } |
62 | 66 | ||
63 | // 返回生产线 | 67 | // 返回生产线 |
@@ -46,6 +46,7 @@ func (d *ProductLevelTwoRecord) LoadDto(m *domain.ProductRecord, orgId int) *Pro | @@ -46,6 +46,7 @@ func (d *ProductLevelTwoRecord) LoadDto(m *domain.ProductRecord, orgId int) *Pro | ||
46 | d.WeighBefore = m.ProductRecordInfo.WeighBefore | 46 | d.WeighBefore = m.ProductRecordInfo.WeighBefore |
47 | d.WeighAfter = m.ProductRecordInfo.WeighAfter | 47 | d.WeighAfter = m.ProductRecordInfo.WeighAfter |
48 | d.ApproveStatus = m.ProductRecordInfo.ApproveStatus | 48 | d.ApproveStatus = m.ProductRecordInfo.ApproveStatus |
49 | + d.WorkOn = m.ProductRecordInfo.WorkOn | ||
49 | if m.ProductRecordInfo.ApproveAt > 0 { | 50 | if m.ProductRecordInfo.ApproveAt > 0 { |
50 | d.ApproveAt = time.Unix(m.ProductRecordInfo.ApproveAt, 0).Local().Format("2006-01-02 15:04:05") | 51 | d.ApproveAt = time.Unix(m.ProductRecordInfo.ApproveAt, 0).Local().Format("2006-01-02 15:04:05") |
51 | d.ApproveUser = m.ProductRecordInfo.ApproveUser | 52 | d.ApproveUser = m.ProductRecordInfo.ApproveUser |
@@ -55,7 +55,12 @@ func (productSectionService *ProductSectionService) CreateProductSection(createP | @@ -55,7 +55,12 @@ func (productSectionService *ProductSectionService) CreateProductSection(createP | ||
55 | if err := transactionContext.CommitTransaction(); err != nil { | 55 | if err := transactionContext.CommitTransaction(); err != nil { |
56 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 56 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
57 | } | 57 | } |
58 | - return newProductSection, nil | 58 | + return map[string]interface{}{ |
59 | + "workshopId": workshop.WorkshopId, | ||
60 | + "lineId": createProductSectionCommand.LineId, | ||
61 | + "sectionId": newProductSection.SectionId, | ||
62 | + "sectionName": newProductSection.SectionName, | ||
63 | + }, nil | ||
59 | } | 64 | } |
60 | 65 | ||
61 | // 返回工段服务 | 66 | // 返回工段服务 |
@@ -57,7 +57,7 @@ func (workshopService *WorkshopService) CreateWorkshop(operateInfo *domain.Opera | @@ -57,7 +57,7 @@ func (workshopService *WorkshopService) CreateWorkshop(operateInfo *domain.Opera | ||
57 | if item, err := workshopRepository.FindOne(map[string]interface{}{ | 57 | if item, err := workshopRepository.FindOne(map[string]interface{}{ |
58 | "workshopName": createWorkshopCommand.WorkshopName, | 58 | "workshopName": createWorkshopCommand.WorkshopName, |
59 | "companyId": operateInfo.CompanyId, | 59 | "companyId": operateInfo.CompanyId, |
60 | - "orgId": operateInfo.OrgId, | 60 | + //"orgId": operateInfo.OrgId, |
61 | }); err == nil && item != nil && strings.EqualFold(item.WorkshopName, createWorkshopCommand.WorkshopName) { | 61 | }); err == nil && item != nil && strings.EqualFold(item.WorkshopName, createWorkshopCommand.WorkshopName) { |
62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "车间名称已存在") | 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "车间名称已存在") |
63 | } | 63 | } |
@@ -35,6 +35,10 @@ var ( | @@ -35,6 +35,10 @@ var ( | ||
35 | DeviceTypeMianBaoXieJi = "MBXJ" | 35 | DeviceTypeMianBaoXieJi = "MBXJ" |
36 | // 油炸机 | 36 | // 油炸机 |
37 | DeviceTypeYouZhaJi = "YZJ" | 37 | DeviceTypeYouZhaJi = "YZJ" |
38 | + // 油炸机 | ||
39 | + DeviceTypeYouZhaJi1 = "YZJ1" | ||
40 | + // 油炸机 | ||
41 | + DeviceTypeYouZhaJi2 = "YZJ2" | ||
38 | // 串串机 | 42 | // 串串机 |
39 | DeviceTypeChuanChuanJi = "CCJ" | 43 | DeviceTypeChuanChuanJi = "CCJ" |
40 | // 速冻线 | 44 | // 速冻线 |
@@ -17,6 +17,13 @@ type DeviceYouZhaJi struct { | @@ -17,6 +17,13 @@ type DeviceYouZhaJi struct { | ||
17 | TubeTemp float64 `json:"TubeTemp"` // 管路温度:管路当前温度 | 17 | TubeTemp float64 `json:"TubeTemp"` // 管路温度:管路当前温度 |
18 | } | 18 | } |
19 | 19 | ||
20 | +// 油炸机2 | ||
21 | +type DeviceYouZhaJi2 struct { | ||
22 | + Temp1 float64 `json:"Temp1"` // 温度1当前温度 | ||
23 | + Temp2 float64 `json:"Temp2"` // 温度2当前温度 | ||
24 | + Temp3 float64 `json:"Temp3"` // 温度3当前温度 | ||
25 | +} | ||
26 | + | ||
20 | // 串串机 | 27 | // 串串机 |
21 | type DeviceChuanChuanJi struct { | 28 | type DeviceChuanChuanJi struct { |
22 | Count int64 `json:"Count"` // 生产计数:生产统计数量 | 29 | Count int64 `json:"Count"` // 生产计数:生产统计数量 |
@@ -67,6 +67,8 @@ func (deviceDailyRunningRecord *DeviceDailyRunningRecord) String() string { | @@ -67,6 +67,8 @@ func (deviceDailyRunningRecord *DeviceDailyRunningRecord) String() string { | ||
67 | 67 | ||
68 | // 设备运行记录信息 | 68 | // 设备运行记录信息 |
69 | type DeviceRunningRecordInfo struct { | 69 | type DeviceRunningRecordInfo struct { |
70 | + // 设备类型 | ||
71 | + DeviceType string `json:"deviceType"` | ||
70 | // 当前状态 | 72 | // 当前状态 |
71 | // bit0: 运行、停止 | 73 | // bit0: 运行、停止 |
72 | // bit1: 正常、故障 | 74 | // bit1: 正常、故障 |
@@ -79,7 +81,7 @@ type DeviceRunningRecordInfo struct { | @@ -79,7 +81,7 @@ type DeviceRunningRecordInfo struct { | ||
79 | // 1. 当前设备实际产出数量/理论数量(理论数量=60*60*12/标准工时) | 81 | // 1. 当前设备实际产出数量/理论数量(理论数量=60*60*12/标准工时) |
80 | // 2. 没有数量100% | 82 | // 2. 没有数量100% |
81 | PerformanceUtilization float64 `json:"pu"` | 83 | PerformanceUtilization float64 `json:"pu"` |
82 | - // 合格率 QualificationUtilization ?设备提交的二级品事串 、 机器上报的是kg | 84 | + // 合格率 QualificationUtilization 设备提交的二级品是kg 、 机器上报的是串 |
83 | // 1.按工段的合格率 | 85 | // 1.按工段的合格率 |
84 | // 2.默认100% | 86 | // 2.默认100% |
85 | QualificationUtilization float64 `json:"qu"` | 87 | QualificationUtilization float64 `json:"qu"` |
@@ -87,8 +89,10 @@ type DeviceRunningRecordInfo struct { | @@ -87,8 +89,10 @@ type DeviceRunningRecordInfo struct { | ||
87 | UpTime float64 `json:"upTime"` | 89 | UpTime float64 `json:"upTime"` |
88 | // 生成数量 | 90 | // 生成数量 |
89 | Count int `json:"count"` | 91 | Count int `json:"count"` |
90 | - // 设备温度 单位:摄氏度 | ||
91 | - Temp float64 `json:"temp"` | 92 | + // 设备温度 单位:摄氏度 (前端温度、温度1) |
93 | + Temp1 float64 `json:"temp"` | ||
94 | + // 设备温度 单位:摄氏度 (后断温度、温度2) | ||
95 | + Temp2 float64 `json:"temp1"` | ||
92 | 96 | ||
93 | // 时间点 | 97 | // 时间点 |
94 | //TimeLine []string `json:"timeLine"` | 98 | //TimeLine []string `json:"timeLine"` |
@@ -103,6 +107,10 @@ type DeviceRunningRecordInfo struct { | @@ -103,6 +107,10 @@ type DeviceRunningRecordInfo struct { | ||
103 | DeviceName string `json:"deviceName"` | 107 | DeviceName string `json:"deviceName"` |
104 | // 组织名称 | 108 | // 组织名称 |
105 | OrgName string `json:"orgName"` | 109 | OrgName string `json:"orgName"` |
110 | + | ||
111 | + // 额外数据 | ||
112 | + // 单位数据 比如:1串/0.1kg weight = count * unitQuantity | ||
113 | + UnitQuantity float64 `json:"unitQuantity"` | ||
106 | } | 114 | } |
107 | 115 | ||
108 | func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { | 116 | func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { |
@@ -111,12 +119,16 @@ func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { | @@ -111,12 +119,16 @@ func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { | ||
111 | } | 119 | } |
112 | } | 120 | } |
113 | func (d *DeviceRunningRecordInfo) AddDeviceRunningData(t time.Time, data *DeviceRunningData) { | 121 | func (d *DeviceRunningRecordInfo) AddDeviceRunningData(t time.Time, data *DeviceRunningData) { |
122 | + if len(d.DeviceType) == 0 { | ||
123 | + d.DeviceType = data.DeviceType | ||
124 | + } | ||
114 | d.CurrentStatus = data.StartupStatus | (1 << data.ComStatus) | 125 | d.CurrentStatus = data.StartupStatus | (1 << data.ComStatus) |
115 | d.ResetUpTime() | 126 | d.ResetUpTime() |
116 | d.Count += data.Count | 127 | d.Count += data.Count |
117 | //d.Temp = data.FrontTemp | 128 | //d.Temp = data.FrontTemp |
118 | 129 | ||
119 | - d.Temp = data.Temp1 | 130 | + d.Temp1 = data.Temp1 |
131 | + d.Temp2 = data.Temp2 | ||
120 | d.AddTimeLineDeviceStatus(t, data) | 132 | d.AddTimeLineDeviceStatus(t, data) |
121 | 133 | ||
122 | //d.OEE | 134 | //d.OEE |
@@ -156,7 +168,7 @@ func (d *DeviceRunningRecordInfo) ResetUpTime() float64 { | @@ -156,7 +168,7 @@ func (d *DeviceRunningRecordInfo) ResetUpTime() float64 { | ||
156 | func (d *DeviceRunningRecordInfo) ResetOEE(pu, qu float64) float64 { | 168 | func (d *DeviceRunningRecordInfo) ResetOEE(pu, qu float64) float64 { |
157 | d.PerformanceUtilization = pu | 169 | d.PerformanceUtilization = pu |
158 | d.QualificationUtilization = qu | 170 | d.QualificationUtilization = qu |
159 | - d.OEE = (d.TimeUtilization + d.PerformanceUtilization + d.QualificationUtilization) / 3 | 171 | + d.OEE = utils.Round((d.TimeUtilization+d.PerformanceUtilization+d.QualificationUtilization)/3, 1) |
160 | return d.OEE | 172 | return d.OEE |
161 | } | 173 | } |
162 | 174 |
@@ -28,6 +28,8 @@ type DeviceRunningData struct { | @@ -28,6 +28,8 @@ type DeviceRunningData struct { | ||
28 | //FrontTemp float64 `json:"frontTemp"` | 28 | //FrontTemp float64 `json:"frontTemp"` |
29 | // 炸机前段温度:炸机前段当前温度 YZJ2 油炸机 | 29 | // 炸机前段温度:炸机前段当前温度 YZJ2 油炸机 |
30 | Temp1 float64 `json:"temp1"` | 30 | Temp1 float64 `json:"temp1"` |
31 | + // 炸机前段温度:炸机前段当前温度 YZJ2 油炸机 | ||
32 | + Temp2 float64 `json:"temp2"` | ||
31 | // 当前产品种类(产品编号) | 33 | // 当前产品种类(产品编号) |
32 | ProductType string `json:"productType"` | 34 | ProductType string `json:"productType"` |
33 | // 日期 | 35 | // 日期 |
@@ -34,4 +34,6 @@ type ProductRecordInfo struct { | @@ -34,4 +34,6 @@ type ProductRecordInfo struct { | ||
34 | 34 | ||
35 | // 生产小组ID | 35 | // 生产小组ID |
36 | ProductGroupId int `json:"productGroupId,omitempty"` | 36 | ProductGroupId int `json:"productGroupId,omitempty"` |
37 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
38 | + WorkOn int `json:"workOn,omitempty"` | ||
37 | } | 39 | } |
@@ -33,6 +33,8 @@ type UserInfo struct { | @@ -33,6 +33,8 @@ type UserInfo struct { | ||
33 | Email string `json:"email,omitempty"` | 33 | Email string `json:"email,omitempty"` |
34 | UserName string `json:"userName,omitempty"` | 34 | UserName string `json:"userName,omitempty"` |
35 | Avatar string `json:"avatar,omitempty"` | 35 | Avatar string `json:"avatar,omitempty"` |
36 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
37 | + EmployeeType int `json:"employeeType,omitempty"` | ||
36 | } | 38 | } |
37 | 39 | ||
38 | // Company 公司信息 | 40 | // Company 公司信息 |
@@ -79,6 +79,14 @@ func (dao *WorkshopPlanCompletionRecordDao) Save(record *models.WorkshopPlanComp | @@ -79,6 +79,14 @@ func (dao *WorkshopPlanCompletionRecordDao) Save(record *models.WorkshopPlanComp | ||
79 | return nil | 79 | return nil |
80 | } | 80 | } |
81 | 81 | ||
82 | +func (dao *WorkshopPlanCompletionRecordDao) Update(record *models.WorkshopPlanCompletionRecord) error { | ||
83 | + tx := dao.transactionContext.PgTx | ||
84 | + if _, err := tx.Model(record).WherePK().Update(); err != nil { | ||
85 | + return err | ||
86 | + } | ||
87 | + return nil | ||
88 | +} | ||
89 | + | ||
82 | func NewWorkshopPlanCompletionRecordDao(transactionContext *pgTransaction.TransactionContext) (*WorkshopPlanCompletionRecordDao, error) { | 90 | func NewWorkshopPlanCompletionRecordDao(transactionContext *pgTransaction.TransactionContext) (*WorkshopPlanCompletionRecordDao, error) { |
83 | if transactionContext == nil { | 91 | if transactionContext == nil { |
84 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 92 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
@@ -48,6 +48,29 @@ func (dao *WorkshopProductRecordDao) WorkshopProductRecord(companyId, orgId, pla | @@ -48,6 +48,29 @@ func (dao *WorkshopProductRecordDao) WorkshopProductRecord(companyId, orgId, pla | ||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | +// 车间对应工段的生产记录 (生产日期) | ||
52 | +func (dao *WorkshopProductRecordDao) WorkStationProductRecord(companyId, orgId int, workStationId string, productTime time.Time) (*domain.WorkshopProductRecord, error) { | ||
53 | + tx := dao.transactionContext.PgTx | ||
54 | + employeeProductRecordModel := new(models.WorkshopProductRecord) | ||
55 | + query := sqlbuilder.BuildQuery(tx.Model(employeeProductRecordModel), map[string]interface{}{}) | ||
56 | + query.Where("company_id = ?", companyId) | ||
57 | + query.Where("org_id = ?", orgId) | ||
58 | + query.Where("product_date = ?", productTime.Local().Format("2006-01-02")) | ||
59 | + query.Where("work_station ->>'workStationId' = ?", workStationId) | ||
60 | + if err := query.First(); err != nil { | ||
61 | + if err.Error() == "pg: no rows in result set" { | ||
62 | + return nil, domain.ErrorNotFound | ||
63 | + } else { | ||
64 | + return nil, err | ||
65 | + } | ||
66 | + } | ||
67 | + if employeeProductRecordModel.WorkshopProductRecordId == 0 { | ||
68 | + return nil, domain.ErrorNotFound | ||
69 | + } else { | ||
70 | + return transform.TransformToWorkshopProductRecordDomainModelFromPgModels(employeeProductRecordModel) | ||
71 | + } | ||
72 | +} | ||
73 | + | ||
51 | func (dao *WorkshopProductRecordDao) SearchWorkshopProductRecord(queryOptions map[string]interface{}) (int64, []*domain.WorkshopProductRecord, error) { | 74 | func (dao *WorkshopProductRecordDao) SearchWorkshopProductRecord(queryOptions map[string]interface{}) (int64, []*domain.WorkshopProductRecord, error) { |
52 | tx := dao.transactionContext.PgTx | 75 | tx := dao.transactionContext.PgTx |
53 | var employeeProductRecordModels []*models.WorkshopProductRecord | 76 | var employeeProductRecordModels []*models.WorkshopProductRecord |
@@ -59,7 +59,7 @@ func (svr *UserService) ToUser(from *models.User) *domain.User { | @@ -59,7 +59,7 @@ func (svr *UserService) ToUser(from *models.User) *domain.User { | ||
59 | user := &domain.User{ | 59 | user := &domain.User{ |
60 | UserId: from.UserId, | 60 | UserId: from.UserId, |
61 | UserName: from.UserInfo.UserName, | 61 | UserName: from.UserInfo.UserName, |
62 | - EmployeeType: from.EmployeeType, | 62 | + EmployeeType: from.UserInfo.EmployeeType, |
63 | IcCardNumber: from.IcCardNumber, | 63 | IcCardNumber: from.IcCardNumber, |
64 | Avatar: from.UserInfo.Avatar, | 64 | Avatar: from.UserInfo.Avatar, |
65 | Phone: from.UserInfo.Phone, | 65 | Phone: from.UserInfo.Phone, |
@@ -152,7 +152,7 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | @@ -152,7 +152,7 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | ||
152 | var values []interface{} = make([]interface{}, 0) | 152 | var values []interface{} = make([]interface{}, 0) |
153 | for _, r := range result { | 153 | for _, r := range result { |
154 | xData = append(xData, r.Ts) | 154 | xData = append(xData, r.Ts) |
155 | - values = append(values, r.Total) | 155 | + values = append(values, utils.Round(r.Total*DefaultCCJUnitQuantity, 1)) |
156 | } | 156 | } |
157 | if len(tmpXData) == 0 { | 157 | if len(tmpXData) == 0 { |
158 | tmpXData = xData | 158 | tmpXData = xData |
@@ -123,6 +123,7 @@ func (ptr *PGProductRecordService) SubmitProductRecord(productRecordType int, qu | @@ -123,6 +123,7 @@ func (ptr *PGProductRecordService) SubmitProductRecord(productRecordType int, qu | ||
123 | BatchNumber: plan.BatchNumber, | 123 | BatchNumber: plan.BatchNumber, |
124 | PlanProductName: plan.PlanProductName, | 124 | PlanProductName: plan.PlanProductName, |
125 | ProductGroupId: request.ProductGroupId, | 125 | ProductGroupId: request.ProductGroupId, |
126 | + WorkOn: plan.WorkOn, | ||
126 | }, | 127 | }, |
127 | Ext: domain.NewExt(org.OrgName), | 128 | Ext: domain.NewExt(org.OrgName), |
128 | } | 129 | } |
@@ -152,6 +152,17 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev | @@ -152,6 +152,17 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev | ||
152 | break | 152 | break |
153 | } | 153 | } |
154 | data.Temp1 = deviceYouZhaJi.FrontTemp | 154 | data.Temp1 = deviceYouZhaJi.FrontTemp |
155 | + data.Temp2 = deviceYouZhaJi.BackTemp | ||
156 | + break | ||
157 | + //油炸机 | ||
158 | + case domain.DeviceTypeYouZhaJi2: | ||
159 | + deviceYouZhaJi := &domain.DeviceYouZhaJi2{} | ||
160 | + err = json.Unmarshal(mBytes, deviceYouZhaJi) | ||
161 | + if err != nil { | ||
162 | + break | ||
163 | + } | ||
164 | + data.Temp1 = deviceYouZhaJi.Temp1 | ||
165 | + data.Temp2 = deviceYouZhaJi.Temp2 | ||
155 | break | 166 | break |
156 | //串串机 | 167 | //串串机 |
157 | case domain.DeviceTypeChuanChuanJi: | 168 | case domain.DeviceTypeChuanChuanJi: |
@@ -77,6 +77,13 @@ func (ptr *PGWorkshopPlanCompletionRecordService) WorkshopPlanCompletion(begin t | @@ -77,6 +77,13 @@ func (ptr *PGWorkshopPlanCompletionRecordService) WorkshopPlanCompletion(begin t | ||
77 | if err := workshopProductRecordDao.Save(record); err != nil { | 77 | if err := workshopProductRecordDao.Save(record); err != nil { |
78 | return err | 78 | return err |
79 | } | 79 | } |
80 | + } else if record != nil { | ||
81 | + record.Plan = totalPlan | ||
82 | + record.Real = totalReal | ||
83 | + record.Rate = completionRate | ||
84 | + if err := workshopProductRecordDao.Update(record); err != nil { | ||
85 | + return err | ||
86 | + } | ||
80 | } | 87 | } |
81 | } | 88 | } |
82 | 89 |
@@ -164,7 +164,7 @@ func (repository *DeviceRepository) Find(queryOptions map[string]interface{}) (i | @@ -164,7 +164,7 @@ func (repository *DeviceRepository) Find(queryOptions map[string]interface{}) (i | ||
164 | var deviceModels []*models.Device | 164 | var deviceModels []*models.Device |
165 | devices := make([]*domain.Device, 0) | 165 | devices := make([]*domain.Device, 0) |
166 | query := sqlbuilder.BuildQuery(tx.Model(&deviceModels), queryOptions) | 166 | query := sqlbuilder.BuildQuery(tx.Model(&deviceModels), queryOptions) |
167 | - query.SetOffsetAndLimit(20) | 167 | + query.SetOffsetAndLimit(domain.MaxQueryRow) |
168 | query.SetOrderDirect("device_id", "DESC") | 168 | query.SetOrderDirect("device_id", "DESC") |
169 | query.SetWhereByQueryOption("company_id = ?", "companyId") | 169 | query.SetWhereByQueryOption("company_id = ?", "companyId") |
170 | query.SetWhereByQueryOption("org_id = ?", "orgId") | 170 | query.SetWhereByQueryOption("org_id = ?", "orgId") |
@@ -109,7 +109,7 @@ func (repository *DeviceRunningRecordRepository) FindOne(queryOptions map[string | @@ -109,7 +109,7 @@ func (repository *DeviceRunningRecordRepository) FindOne(queryOptions map[string | ||
109 | query.SetWhereByQueryOption("device_running_record.device_running_record_id = ?", "deviceRunningRecordId") | 109 | query.SetWhereByQueryOption("device_running_record.device_running_record_id = ?", "deviceRunningRecordId") |
110 | if err := query.First(); err != nil { | 110 | if err := query.First(); err != nil { |
111 | if err.Error() == "pg: no rows in result set" { | 111 | if err.Error() == "pg: no rows in result set" { |
112 | - return nil, fmt.Errorf("没有此资源") | 112 | + return nil, domain.ErrorNotFound |
113 | } else { | 113 | } else { |
114 | return nil, err | 114 | return nil, err |
115 | } | 115 | } |
@@ -174,7 +174,7 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | @@ -174,7 +174,7 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | ||
174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) | 174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) |
175 | query.SetWhereByQueryOption("company_id = ?", "companyId") | 175 | query.SetWhereByQueryOption("company_id = ?", "companyId") |
176 | query.SetWhereByQueryOption("org_id = ?", "orgId") | 176 | query.SetWhereByQueryOption("org_id = ?", "orgId") |
177 | - query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") | 177 | + query.SetWhereByQueryOption("workshop->>'workshopId'='?'", "workshopId") |
178 | if v, ok := queryOptions["batchNumber"]; ok && len(v.(string)) > 0 { | 178 | if v, ok := queryOptions["batchNumber"]; ok && len(v.(string)) > 0 { |
179 | query.Where(fmt.Sprintf(`batch_number like '%%%v%%'`, v)) | 179 | query.Where(fmt.Sprintf(`batch_number like '%%%v%%'`, v)) |
180 | } | 180 | } |
@@ -29,6 +29,10 @@ func init() { | @@ -29,6 +29,10 @@ func init() { | ||
29 | //https支持 | 29 | //https支持 |
30 | web.BConfig.Listen.EnableHTTPS = true | 30 | web.BConfig.Listen.EnableHTTPS = true |
31 | web.BConfig.Listen.HTTPSPort = 443 | 31 | web.BConfig.Listen.HTTPSPort = 443 |
32 | + | ||
33 | + //进程内监控 | ||
34 | + web.BConfig.Listen.EnableAdmin = true | ||
35 | + web.BConfig.Listen.AdminPort = 8088 | ||
32 | if os.Getenv("HTTPS_PORT") != "" { | 36 | if os.Getenv("HTTPS_PORT") != "" { |
33 | portStr := os.Getenv("HTTPS_PORT") | 37 | portStr := os.Getenv("HTTPS_PORT") |
34 | if port, err := strconv.Atoi(portStr); err == nil { | 38 | if port, err := strconv.Atoi(portStr); err == nil { |
@@ -80,6 +80,18 @@ func (controller *DeviceController) SearchDevice() { | @@ -80,6 +80,18 @@ func (controller *DeviceController) SearchDevice() { | ||
80 | ResponseGrid(controller.BaseController, total, data, err) | 80 | ResponseGrid(controller.BaseController, total, data, err) |
81 | } | 81 | } |
82 | 82 | ||
83 | +func (controller *DeviceController) SelectorDeviceUnbounded() { | ||
84 | + deviceService := service.NewDeviceService(nil) | ||
85 | + cmd := &query.SearchDeviceQuery{} | ||
86 | + Must(controller.Unmarshal(cmd)) | ||
87 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
88 | + //cmd.OrgId = operateInfo.OrgId | ||
89 | + cmd.CompanyId = operateInfo.CompanyId | ||
90 | + cmd.InOrgIds = operateInfo.OrgIds | ||
91 | + total, data, err := deviceService.SelectorDeviceUnbounded(ParseOperateInfo(controller.BaseController), cmd) | ||
92 | + ResponseGrid(controller.BaseController, total, data, err) | ||
93 | +} | ||
94 | + | ||
83 | func (controller *DeviceController) BatchAddDevice() { | 95 | func (controller *DeviceController) BatchAddDevice() { |
84 | productService := service.NewDeviceService(nil) | 96 | productService := service.NewDeviceService(nil) |
85 | cmd := &struct { | 97 | cmd := &struct { |
@@ -13,11 +13,12 @@ func init() { | @@ -13,11 +13,12 @@ func init() { | ||
13 | web.Router("/devices/batch-remove", &controllers.DeviceController{}, "Post:BatchRemoveDevice") | 13 | web.Router("/devices/batch-remove", &controllers.DeviceController{}, "Post:BatchRemoveDevice") |
14 | web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice") | 14 | web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice") |
15 | web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice") | 15 | web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice") |
16 | + web.Router("/devices/search-unbounded", &controllers.DeviceController{}, "Post:SelectorDeviceUnbounded") | ||
16 | web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice") | 17 | web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice") |
17 | 18 | ||
18 | //考勤机 | 19 | //考勤机 |
19 | web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Post:PostCdata") | 20 | web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Post:PostCdata") |
20 | web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Get:GetCdata") | 21 | web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Get:GetCdata") |
21 | web.Router("/zkteco/iclock/getrequest", &controllers.DeviceZKTecoController{}, "Get:GetRequest") | 22 | web.Router("/zkteco/iclock/getrequest", &controllers.DeviceZKTecoController{}, "Get:GetRequest") |
22 | - web.Router("/zkteco/iclock/ping",&controllers.DeviceZKTecoController{},"Get:Ping") | 23 | + web.Router("/zkteco/iclock/ping", &controllers.DeviceZKTecoController{}, "Get:Ping") |
23 | } | 24 | } |
@@ -57,7 +57,7 @@ func Start() { | @@ -57,7 +57,7 @@ func Start() { | ||
57 | deviceCollection.Values = tool_funs.SimpleStructToMap(deviceBaoXianJi) | 57 | deviceCollection.Values = tool_funs.SimpleStructToMap(deviceBaoXianJi) |
58 | break | 58 | break |
59 | //油炸机 | 59 | //油炸机 |
60 | - case domain.DeviceTypeYouZhaJi: | 60 | + case domain.DeviceTypeYouZhaJi1: |
61 | deviceYouZhaJi := &domain.DeviceYouZhaJi{} | 61 | deviceYouZhaJi := &domain.DeviceYouZhaJi{} |
62 | err = json.Unmarshal(mBytes, deviceYouZhaJi) | 62 | err = json.Unmarshal(mBytes, deviceYouZhaJi) |
63 | if err != nil { | 63 | if err != nil { |
@@ -65,6 +65,15 @@ func Start() { | @@ -65,6 +65,15 @@ func Start() { | ||
65 | } | 65 | } |
66 | deviceCollection.Values = tool_funs.SimpleStructToMap(deviceYouZhaJi) | 66 | deviceCollection.Values = tool_funs.SimpleStructToMap(deviceYouZhaJi) |
67 | break | 67 | break |
68 | + //油炸机 | ||
69 | + case domain.DeviceTypeYouZhaJi2: | ||
70 | + deviceYouZhaJi2 := &domain.DeviceYouZhaJi2{} | ||
71 | + err = json.Unmarshal(mBytes, deviceYouZhaJi2) | ||
72 | + if err != nil { | ||
73 | + continue | ||
74 | + } | ||
75 | + deviceCollection.Values = tool_funs.SimpleStructToMap(deviceYouZhaJi2) | ||
76 | + break | ||
68 | //串串机 | 77 | //串串机 |
69 | case domain.DeviceTypeChuanChuanJi: | 78 | case domain.DeviceTypeChuanChuanJi: |
70 | deviceChuanChuanJi := &domain.DeviceChuanChuanJi{} | 79 | deviceChuanChuanJi := &domain.DeviceChuanChuanJi{} |
@@ -155,4 +164,4 @@ func Start() { | @@ -155,4 +164,4 @@ func Start() { | ||
155 | } | 164 | } |
156 | } | 165 | } |
157 | }) | 166 | }) |
158 | -} | ||
167 | +} |
-
请 注册 或 登录 后发表评论