fix:
1. 增加配置 产品类型列表 MANUFACTURE_PRODUCT_TYPE 2. 工时管理状态查询异常修改 3. 考勤统计修改
正在显示
8 个修改的文件
包含
34 行增加
和
26 行删除
| @@ -49,10 +49,10 @@ func (crontabService *CrontabService) initTask() { | @@ -49,10 +49,10 @@ func (crontabService *CrontabService) initTask() { | ||
| 49 | autoFlushDeviceDailyRunningRecordOEE := task.NewTask("定时刷新设备每日运行记录-OEE", "0 */10 * * * *", AutoFlushDeviceDailyRunningRecordOEE) | 49 | autoFlushDeviceDailyRunningRecordOEE := task.NewTask("定时刷新设备每日运行记录-OEE", "0 */10 * * * *", AutoFlushDeviceDailyRunningRecordOEE) |
| 50 | task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecordOEE) | 50 | task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecordOEE) |
| 51 | 51 | ||
| 52 | - autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-15/3 * * *", AutoWorkshopPlanCompletionRecord) | 52 | + autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-17/1 * * *", AutoWorkshopPlanCompletionRecord) |
| 53 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) | 53 | task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) |
| 54 | 54 | ||
| 55 | - autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/3 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次 | 55 | + autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/1 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次 |
| 56 | task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord) | 56 | task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord) |
| 57 | 57 | ||
| 58 | syncProductPlan := task.NewTask("定时同步车间计划", "0 */5 * * * *", SyncProductPlan) | 58 | syncProductPlan := task.NewTask("定时同步车间计划", "0 */5 * * * *", SyncProductPlan) |
| @@ -12,7 +12,7 @@ var ( | @@ -12,7 +12,7 @@ var ( | ||
| 12 | // 生产制造 - 称重系统 - 默认组织 | 12 | // 生产制造 - 称重系统 - 默认组织 |
| 13 | MANUFACTURE_DEFAULT_ORGID = 1 | 13 | MANUFACTURE_DEFAULT_ORGID = 1 |
| 14 | // 产品类型列表 | 14 | // 产品类型列表 |
| 15 | - MANUFACTURE_PRODUCT_TYPE = "0502010004ST,0502010004ST" | 15 | + MANUFACTURE_PRODUCT_TYPE = "0502010004ST,0504010004ST" |
| 16 | 16 | ||
| 17 | MapProductType = make(map[int]string) | 17 | MapProductType = make(map[int]string) |
| 18 | ) | 18 | ) |
| @@ -214,13 +214,13 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string | @@ -214,13 +214,13 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string | ||
| 214 | if com&index > 0 { | 214 | if com&index > 0 { |
| 215 | val |= 2 | 215 | val |= 2 |
| 216 | } | 216 | } |
| 217 | - if val == 1 || val == 0 { | 217 | + if val == 1 { |
| 218 | return 1 //故障 | 218 | return 1 //故障 |
| 219 | } | 219 | } |
| 220 | if val == 3 { | 220 | if val == 3 { |
| 221 | return 2 //正常 | 221 | return 2 //正常 |
| 222 | } | 222 | } |
| 223 | - if val == 2 { | 223 | + if val == 2 || val == 0 { |
| 224 | return 3 //停机 | 224 | return 3 //停机 |
| 225 | } | 225 | } |
| 226 | return 3 // 停机 | 226 | return 3 // 停机 |
| @@ -233,12 +233,12 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string | @@ -233,12 +233,12 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string | ||
| 233 | if hds, ok = d.TimeLineDeviceStatus[fmt.Sprintf("%v", i)]; !ok { | 233 | if hds, ok = d.TimeLineDeviceStatus[fmt.Sprintf("%v", i)]; !ok { |
| 234 | hds = &HourDeviceStatus{Window: DefaultTimeWindow} | 234 | hds = &HourDeviceStatus{Window: DefaultTimeWindow} |
| 235 | } | 235 | } |
| 236 | - if i == 0 { | ||
| 237 | - status = computeStatus(hds.Up, hds.Com, index) // 状态初始化 | ||
| 238 | - } | ||
| 239 | if end >= endTime { | 236 | if end >= endTime { |
| 240 | break | 237 | break |
| 241 | } | 238 | } |
| 239 | + if i == 0 { | ||
| 240 | + status = computeStatus(hds.Up, hds.Com, index) // 状态初始化 | ||
| 241 | + } | ||
| 242 | if hds.Up == 0 && hds.Com == 0 { | 242 | if hds.Up == 0 && hds.Com == 0 { |
| 243 | end += 60 / hds.Window | 243 | end += 60 / hds.Window |
| 244 | continue | 244 | continue |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | -import "time" | 3 | +import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
| 5 | + "time" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | const ( | 8 | const ( |
| 6 | ParticipateNormal = 1 // 正常 | 9 | ParticipateNormal = 1 // 正常 |
| @@ -97,7 +100,7 @@ func (employeeProductRecord *EmployeeProductRecord) UpdateProductWeigh(weigh flo | @@ -97,7 +100,7 @@ func (employeeProductRecord *EmployeeProductRecord) UpdateProductWeigh(weigh flo | ||
| 97 | // 产能 | 100 | // 产能 |
| 98 | func (employeeProductRecord *EmployeeProductRecord) RealProductWeigh() float64 { | 101 | func (employeeProductRecord *EmployeeProductRecord) RealProductWeigh() float64 { |
| 99 | // 产能 = 总投入量 - 本阶段二级品重量 - 其他上级二级品重量 | 102 | // 产能 = 总投入量 - 本阶段二级品重量 - 其他上级二级品重量 |
| 100 | - return employeeProductRecord.ProductWeigh - employeeProductRecord.SecondLevelWeigh - employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh() | 103 | + return utils.Round(employeeProductRecord.ProductWeigh-employeeProductRecord.SecondLevelWeigh-employeeProductRecord.ProductRecordInfo.OtherSecondLevelWeigh(), 1) |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | // 合格率 | 106 | // 合格率 |
| @@ -106,6 +109,6 @@ func (employeeProductRecord *EmployeeProductRecord) QualificationRate() int { | @@ -106,6 +109,6 @@ func (employeeProductRecord *EmployeeProductRecord) QualificationRate() int { | ||
| 106 | if realProductWeigh == 0 { | 109 | if realProductWeigh == 0 { |
| 107 | return 0 | 110 | return 0 |
| 108 | } | 111 | } |
| 109 | - result := int(realProductWeigh * 100 / employeeProductRecord.ProductWeigh) | 112 | + result := int(realProductWeigh * 100 / utils.Round(employeeProductRecord.ProductWeigh, 1)) |
| 110 | return result | 113 | return result |
| 111 | } | 114 | } |
| @@ -25,7 +25,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | @@ -25,7 +25,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | ||
| 25 | record *domain.ProductAttendanceRecord | 25 | record *domain.ProductAttendanceRecord |
| 26 | //workStationId string //具体工位 | 26 | //workStationId string //具体工位 |
| 27 | workStation *domain.WorkStation | 27 | workStation *domain.WorkStation |
| 28 | - attendanceType int = domain.ParticipateNormal | 28 | + attendanceType int = domain.ParticipateSupport |
| 29 | worker *domain.User | 29 | worker *domain.User |
| 30 | org *domain.Org | 30 | org *domain.Org |
| 31 | ) | 31 | ) |
| @@ -59,15 +59,14 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | @@ -59,15 +59,14 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | ||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | groupMembers, groupMembersKeyFunc := FindGroupMembers(productGroupRepository, cid, oid, workStation.WorkStationId) | 61 | groupMembers, groupMembersKeyFunc := FindGroupMembers(productGroupRepository, cid, oid, workStation.WorkStationId) |
| 62 | - if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; !ok { | ||
| 63 | - attendanceType = domain.ParticipateSupport | ||
| 64 | - } else { | 62 | + if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; ok { |
| 63 | + attendanceType = domain.ParticipateNormal | ||
| 65 | groupId = v.GroupId | 64 | groupId = v.GroupId |
| 66 | groupName = v.GroupName | 65 | groupName = v.GroupName |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | beginTime := utils.GetZeroTime(report.ActionTime) | 68 | beginTime := utils.GetZeroTime(report.ActionTime) |
| 70 | - endTime := report.ActionTime | 69 | + endTime := time.Now() |
| 71 | _, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime) | 70 | _, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime) |
| 72 | for i := 0; i < len(records); i++ { | 71 | for i := 0; i < len(records); i++ { |
| 73 | r := records[i] | 72 | r := records[i] |
| @@ -106,6 +105,12 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | @@ -106,6 +105,12 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. | ||
| 106 | log.Logger.Debug(fmt.Sprintf("【考勤汇报】 已存在同一时间段的考勤记录 考勤ID:%v 用户:%v 打卡时间:%v", r.ProductAttendanceId, worker.UserId, report.ActionTime)) | 105 | log.Logger.Debug(fmt.Sprintf("【考勤汇报】 已存在同一时间段的考勤记录 考勤ID:%v 用户:%v 打卡时间:%v", r.ProductAttendanceId, worker.UserId, report.ActionTime)) |
| 107 | return struct{}{}, nil | 106 | return struct{}{}, nil |
| 108 | } | 107 | } |
| 108 | + if r.WorkStation.WorkStationId == workStation.WorkStationId && utils.TimeAfterEqual(r.SignOut.Add(time.Minute*5), report.ActionTime) { | ||
| 109 | + isSignIn = false | ||
| 110 | + record = r | ||
| 111 | + log.Logger.Debug(fmt.Sprintf("【考勤汇报】 已存在同一时间段的考勤记录,小于离岗时间5min 考勤ID:%v 用户:%v 打卡时间:%v", r.ProductAttendanceId, worker.UserId, report.ActionTime)) | ||
| 112 | + break | ||
| 113 | + } | ||
| 109 | continue | 114 | continue |
| 110 | } | 115 | } |
| 111 | // 存在未结束的打卡记录 | 116 | // 存在未结束的打卡记录 |
| @@ -78,8 +78,8 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | @@ -78,8 +78,8 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | ||
| 78 | 78 | ||
| 79 | // 封箱机、串串机需要定位到批次 | 79 | // 封箱机、串串机需要定位到批次 |
| 80 | if record.DeviceType == domain.DeviceTypeFengXiangJi || record.DeviceType == domain.DeviceTypeChuanChuanJi { | 80 | if record.DeviceType == domain.DeviceTypeFengXiangJi || record.DeviceType == domain.DeviceTypeChuanChuanJi { |
| 81 | - //datetime, _ = time.Parse("2006-01-02 15:04:05", deviceRunningData.Date) | ||
| 82 | - if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, utils.GetZeroTimeWithLocal(deviceRunningData.CollectionTime, time.UTC), deviceRunningData.ProductType); err != nil { | 81 | + datetime, _ := time.ParseInLocation("2006-01-02", deviceRunningData.Date, time.Local) |
| 82 | + if plan, err = ptr.findDeviceProductPlan(companyId, orgId, workStation.WorkStationId, utils.GetZeroTimeWithLocal(datetime, time.UTC), deviceRunningData.ProductType); err != nil { | ||
| 83 | log.Logger.Error(err.Error(), map[string]interface{}{"workstation": workStation, "product_code": deviceRunningData.ProductType}) | 83 | log.Logger.Error(err.Error(), map[string]interface{}{"workstation": workStation, "product_code": deviceRunningData.ProductType}) |
| 84 | } else { | 84 | } else { |
| 85 | planId = plan.PlanDispatchRecordExt.ProductPlanId | 85 | planId = plan.PlanDispatchRecordExt.ProductPlanId |
| @@ -91,7 +91,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | @@ -91,7 +91,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | ||
| 91 | if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil { | 91 | if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil { |
| 92 | return nil, err | 92 | return nil, err |
| 93 | } | 93 | } |
| 94 | - // 2.保存设备生产记录 | 94 | + // 2.保存设备生产记录 (统计车间、员工产能) |
| 95 | if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil { | 95 | if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil { |
| 96 | 96 | ||
| 97 | productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan) | 97 | productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan) |
| @@ -169,7 +169,7 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin | @@ -169,7 +169,7 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin | ||
| 169 | query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") | 169 | query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") |
| 170 | query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") | 170 | query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") |
| 171 | query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") | 171 | query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") |
| 172 | - query.SetWhereByQueryOption("attendance_status & ? >0", "attendanceStatus") | 172 | + query.SetWhereByQueryOption("attendance_status = ?", "attendanceStatus") |
| 173 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { | 173 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { |
| 174 | query.Where(`org_id in (?)`, pg.In(v)) | 174 | query.Where(`org_id in (?)`, pg.In(v)) |
| 175 | } | 175 | } |
| @@ -35,7 +35,7 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | @@ -35,7 +35,7 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | ||
| 35 | return | 35 | return |
| 36 | } | 36 | } |
| 37 | for key, item := range payload { | 37 | for key, item := range payload { |
| 38 | - if key == "WorkShop" { | 38 | + if key == "WorkShop" || key == "UpTime" { |
| 39 | continue | 39 | continue |
| 40 | } | 40 | } |
| 41 | mBytes, err := json.Marshal(item) | 41 | mBytes, err := json.Marshal(item) |
| @@ -145,10 +145,10 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | @@ -145,10 +145,10 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | ||
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | //TODO:日志先注释 | 147 | //TODO:日志先注释 |
| 148 | - log.Logger.Info("MQTT", map[string]interface{}{ | ||
| 149 | - "Topic": message.Topic(), | ||
| 150 | - "MessageId": message.MessageID(), | ||
| 151 | - "Message": payload, | ||
| 152 | - }) | 148 | + //log.Logger.Info("MQTT", map[string]interface{}{ |
| 149 | + // "Topic": message.Topic(), | ||
| 150 | + // "MessageId": message.MessageID(), | ||
| 151 | + // "Message": payload, | ||
| 152 | + //}) | ||
| 153 | } | 153 | } |
| 154 | } | 154 | } |
-
请 注册 或 登录 后发表评论