正在显示
25 个修改的文件
包含
279 行增加
和
20 行删除
| @@ -43,11 +43,14 @@ func (crontabService *CrontabService) initTask() { | @@ -43,11 +43,14 @@ 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 | + autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-15/3 * * *", AutoWorkshopPlanCompletionRecord) |
| 50 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) | 50 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) |
| 51 | + | ||
| 52 | + autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/3 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次 | ||
| 53 | + task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord) | ||
| 51 | } | 54 | } |
| 52 | 55 | ||
| 53 | func (crontabService *CrontabService) StartCrontabTask() { | 56 | func (crontabService *CrontabService) StartCrontabTask() { |
| 1 | +package crontab | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
| 9 | + "time" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +// 定时刷新设备每日运行记录 | ||
| 13 | +func AutoFlushDeviceDailyRunningRecordOEE(ctx context.Context) error { | ||
| 14 | + defer func() { | ||
| 15 | + if r := recover(); r != nil { | ||
| 16 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
| 17 | + } | ||
| 18 | + }() | ||
| 19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 20 | + if err != nil { | ||
| 21 | + return err | ||
| 22 | + } | ||
| 23 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 24 | + return err | ||
| 25 | + } | ||
| 26 | + defer func() { | ||
| 27 | + if err != nil { | ||
| 28 | + log.Logger.Error("【定时刷新设备每日运行记录-OEE】 失败:" + err.Error()) | ||
| 29 | + } | ||
| 30 | + transactionContext.RollbackTransaction() | ||
| 31 | + }() | ||
| 32 | + | ||
| 33 | + log.Logger.Debug("【定时刷新设备每日运行记录-OEE】 启动") | ||
| 34 | + deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | ||
| 35 | + // 获取redis里当天的记录 | ||
| 36 | + span := time.Duration(20) | ||
| 37 | + t := time.Now().Add(-time.Minute * span) | ||
| 38 | + records, err := redis.GetDeviceDailyAllRecord(t) | ||
| 39 | + if err != nil { | ||
| 40 | + log.Logger.Error(err.Error()) | ||
| 41 | + return err | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + for _, v := range records { | ||
| 45 | + //if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | ||
| 46 | + // log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | ||
| 47 | + // continue | ||
| 48 | + //} | ||
| 49 | + | ||
| 50 | + // 更新设备效率 OEE = tu * pu * qu | ||
| 51 | + /* | ||
| 52 | + pu 性能利用 | ||
| 53 | + 设备标准工时, | ||
| 54 | + 没有配置设备标准工时的为100 | ||
| 55 | + */ | ||
| 56 | + //pu :=100 | ||
| 57 | + //if v.DeviceRunningRecordInfo | ||
| 58 | + // 设备数据(标准工时) | ||
| 59 | + | ||
| 60 | + // 工段对应二级品数据 | ||
| 61 | + | ||
| 62 | + v.DeviceRunningRecordInfo.ResetOEE(0, 0) | ||
| 63 | + | ||
| 64 | + if _, err := deviceDailyRunningRecordRepository.Save(v); err != nil { | ||
| 65 | + log.Logger.Error(err.Error()) | ||
| 66 | + continue | ||
| 67 | + } else { | ||
| 68 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 刷新记录 %v", v)) | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
| 73 | + return err | ||
| 74 | + } | ||
| 75 | + return nil | ||
| 76 | +} |
| @@ -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 | // 返回生产线 |
| @@ -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"` // 生产计数:生产统计数量 |
| @@ -79,7 +79,7 @@ type DeviceRunningRecordInfo struct { | @@ -79,7 +79,7 @@ type DeviceRunningRecordInfo struct { | ||
| 79 | // 1. 当前设备实际产出数量/理论数量(理论数量=60*60*12/标准工时) | 79 | // 1. 当前设备实际产出数量/理论数量(理论数量=60*60*12/标准工时) |
| 80 | // 2. 没有数量100% | 80 | // 2. 没有数量100% |
| 81 | PerformanceUtilization float64 `json:"pu"` | 81 | PerformanceUtilization float64 `json:"pu"` |
| 82 | - // 合格率 QualificationUtilization ?设备提交的二级品事串 、 机器上报的是kg | 82 | + // 合格率 QualificationUtilization 设备提交的二级品是kg 、 机器上报的是串 |
| 83 | // 1.按工段的合格率 | 83 | // 1.按工段的合格率 |
| 84 | // 2.默认100% | 84 | // 2.默认100% |
| 85 | QualificationUtilization float64 `json:"qu"` | 85 | QualificationUtilization float64 `json:"qu"` |
| @@ -87,8 +87,10 @@ type DeviceRunningRecordInfo struct { | @@ -87,8 +87,10 @@ type DeviceRunningRecordInfo struct { | ||
| 87 | UpTime float64 `json:"upTime"` | 87 | UpTime float64 `json:"upTime"` |
| 88 | // 生成数量 | 88 | // 生成数量 |
| 89 | Count int `json:"count"` | 89 | Count int `json:"count"` |
| 90 | - // 设备温度 单位:摄氏度 | ||
| 91 | - Temp float64 `json:"temp"` | 90 | + // 设备温度 单位:摄氏度 (前端温度、温度1) |
| 91 | + Temp1 float64 `json:"temp"` | ||
| 92 | + // 设备温度 单位:摄氏度 (后断温度、温度2) | ||
| 93 | + Temp2 float64 `json:"temp1"` | ||
| 92 | 94 | ||
| 93 | // 时间点 | 95 | // 时间点 |
| 94 | //TimeLine []string `json:"timeLine"` | 96 | //TimeLine []string `json:"timeLine"` |
| @@ -103,6 +105,10 @@ type DeviceRunningRecordInfo struct { | @@ -103,6 +105,10 @@ type DeviceRunningRecordInfo struct { | ||
| 103 | DeviceName string `json:"deviceName"` | 105 | DeviceName string `json:"deviceName"` |
| 104 | // 组织名称 | 106 | // 组织名称 |
| 105 | OrgName string `json:"orgName"` | 107 | OrgName string `json:"orgName"` |
| 108 | + | ||
| 109 | + // 额外数据 | ||
| 110 | + // 单位数据 比如:1串/0.1kg weight = count * unitQuantity | ||
| 111 | + UnitQuantity float64 `json:"unitQuantity"` | ||
| 106 | } | 112 | } |
| 107 | 113 | ||
| 108 | func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { | 114 | func NewDeviceRunningRecordInfo() *DeviceRunningRecordInfo { |
| @@ -116,7 +122,8 @@ func (d *DeviceRunningRecordInfo) AddDeviceRunningData(t time.Time, data *Device | @@ -116,7 +122,8 @@ func (d *DeviceRunningRecordInfo) AddDeviceRunningData(t time.Time, data *Device | ||
| 116 | d.Count += data.Count | 122 | d.Count += data.Count |
| 117 | //d.Temp = data.FrontTemp | 123 | //d.Temp = data.FrontTemp |
| 118 | 124 | ||
| 119 | - d.Temp = data.Temp1 | 125 | + d.Temp1 = data.Temp1 |
| 126 | + d.Temp2 = data.Temp2 | ||
| 120 | d.AddTimeLineDeviceStatus(t, data) | 127 | d.AddTimeLineDeviceStatus(t, data) |
| 121 | 128 | ||
| 122 | //d.OEE | 129 | //d.OEE |
| @@ -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 | // 日期 |
| @@ -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") |
| @@ -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 | } |
| @@ -53,7 +53,7 @@ func Start() { | @@ -53,7 +53,7 @@ func Start() { | ||
| 53 | deviceCollection.Values = deviceBaoXianJi | 53 | deviceCollection.Values = deviceBaoXianJi |
| 54 | break | 54 | break |
| 55 | //油炸机 | 55 | //油炸机 |
| 56 | - case domain.DeviceTypeYouZhaJi: | 56 | + case domain.DeviceTypeYouZhaJi1: |
| 57 | deviceYouZhaJi := &domain.DeviceYouZhaJi{} | 57 | deviceYouZhaJi := &domain.DeviceYouZhaJi{} |
| 58 | err = json.Unmarshal(mBytes, deviceYouZhaJi) | 58 | err = json.Unmarshal(mBytes, deviceYouZhaJi) |
| 59 | if err != nil { | 59 | if err != nil { |
| @@ -61,6 +61,15 @@ func Start() { | @@ -61,6 +61,15 @@ func Start() { | ||
| 61 | } | 61 | } |
| 62 | deviceCollection.Values = deviceYouZhaJi | 62 | deviceCollection.Values = deviceYouZhaJi |
| 63 | break | 63 | break |
| 64 | + //油炸机 | ||
| 65 | + case domain.DeviceTypeYouZhaJi2: | ||
| 66 | + deviceYouZhaJi := &domain.DeviceYouZhaJi2{} | ||
| 67 | + err = json.Unmarshal(mBytes, deviceYouZhaJi) | ||
| 68 | + if err != nil { | ||
| 69 | + continue | ||
| 70 | + } | ||
| 71 | + deviceCollection.Values = deviceYouZhaJi | ||
| 72 | + break | ||
| 64 | //串串机 | 73 | //串串机 |
| 65 | case domain.DeviceTypeChuanChuanJi: | 74 | case domain.DeviceTypeChuanChuanJi: |
| 66 | deviceChuanChuanJi := &domain.DeviceChuanChuanJi{} | 75 | deviceChuanChuanJi := &domain.DeviceChuanChuanJi{} |
-
请 注册 或 登录 后发表评论