正在显示
9 个修改的文件
包含
70 行增加
和
11 行删除
@@ -30,7 +30,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | @@ -30,7 +30,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
30 | transactionContext.RollbackTransaction() | 30 | transactionContext.RollbackTransaction() |
31 | }() | 31 | }() |
32 | 32 | ||
33 | - log.Logger.Info("【定时刷新设备每日运行记录】 启动") | 33 | + log.Logger.Debug("【定时刷新设备每日运行记录】 启动") |
34 | deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | 34 | deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) |
35 | // 获取redis里当天的记录 | 35 | // 获取redis里当天的记录 |
36 | span := time.Duration(20) | 36 | span := time.Duration(20) |
@@ -43,7 +43,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | @@ -43,7 +43,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
43 | 43 | ||
44 | for _, v := range records { | 44 | for _, v := range records { |
45 | if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | 45 | if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { |
46 | - log.Logger.Info(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | 46 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) |
47 | continue | 47 | continue |
48 | } | 48 | } |
49 | 49 | ||
@@ -53,7 +53,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | @@ -53,7 +53,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
53 | log.Logger.Error(err.Error()) | 53 | log.Logger.Error(err.Error()) |
54 | continue | 54 | continue |
55 | } else { | 55 | } else { |
56 | - log.Logger.Info(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v)) | 56 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v)) |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 |
@@ -26,7 +26,7 @@ type UpdateDeviceCommand struct { | @@ -26,7 +26,7 @@ type UpdateDeviceCommand struct { | ||
26 | // 工段ID | 26 | // 工段ID |
27 | SectionId int `cname:"工段ID" json:"sectionId"` | 27 | SectionId int `cname:"工段ID" json:"sectionId"` |
28 | // 品牌 | 28 | // 品牌 |
29 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 29 | + Brand string `cname:"品牌" json:"brand"` |
30 | // 设备状态 1:正常 2:封存 3:报废 | 30 | // 设备状态 1:正常 2:封存 3:报废 |
31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
32 | // 风险等级 1:高 2:中 3:低 | 32 | // 风险等级 1:高 2:中 3:低 |
1 | package dto | 1 | package dto |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | ) | 6 | ) |
6 | 7 | ||
@@ -24,7 +25,7 @@ type DeviceDto struct { | @@ -24,7 +25,7 @@ type DeviceDto struct { | ||
24 | // 所属位置 | 25 | // 所属位置 |
25 | *domain.WorkStation | 26 | *domain.WorkStation |
26 | // 生产单个产品的时间(单位:秒) | 27 | // 生产单个产品的时间(单位:秒) |
27 | - UnitProductionSecTime int `json:"unitProductionSecTime"` | 28 | + UnitProductionSecTime string `json:"unitProductionSecTime"` |
28 | 29 | ||
29 | // 组织名称 | 30 | // 组织名称 |
30 | OrgName string `json:"orgName"` | 31 | OrgName string `json:"orgName"` |
@@ -47,7 +48,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | @@ -47,7 +48,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
47 | d.OrgName = m.Ext.OrgName | 48 | d.OrgName = m.Ext.OrgName |
48 | } | 49 | } |
49 | if m.Ext != nil && m.Ext.DeviceExt != nil { | 50 | if m.Ext != nil && m.Ext.DeviceExt != nil { |
50 | - d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime | 51 | + if m.Ext.DeviceExt.UnitProductionSecTime > 0 { |
52 | + d.UnitProductionSecTime = fmt.Sprintf("%v", m.Ext.DeviceExt.UnitProductionSecTime) | ||
53 | + } | ||
51 | } | 54 | } |
52 | return d | 55 | return d |
53 | } | 56 | } |
@@ -71,6 +71,26 @@ func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) { | @@ -71,6 +71,26 @@ func (d *ProductGroupEmployeesDtos) LoadDto(groups ...*domain.ProductGroup) { | ||
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | +func (d *ProductGroupEmployeesDtos) LoadDtoV2(list ...*domain.ProductAttendanceRecord) { | ||
75 | + var mapUser = make(map[int]int) | ||
76 | + for _, v := range list { | ||
77 | + item := &ProductGroupEmployeesDto{} | ||
78 | + item.UserId = v.ProductWorker.UserId | ||
79 | + item.UserName = v.ProductWorker.UserName | ||
80 | + item.ProductGroupId = 0 | ||
81 | + item.GroupName = "" | ||
82 | + if len(item.UserName) > 0 { | ||
83 | + item.UserNamePinyin = converter.ToPinYin(item.UserName, "") | ||
84 | + } | ||
85 | + if _, ok := mapUser[item.UserId]; ok { | ||
86 | + continue | ||
87 | + } else { | ||
88 | + mapUser[item.UserId] = item.UserId | ||
89 | + } | ||
90 | + d.Append(item) | ||
91 | + } | ||
92 | +} | ||
93 | + | ||
74 | func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { | 94 | func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { |
75 | return &ProductGroupEmployeesDtos{ | 95 | return &ProductGroupEmployeesDtos{ |
76 | Result: make([]*ProductGroupEmployeesDto, 0), | 96 | Result: make([]*ProductGroupEmployeesDto, 0), |
@@ -395,9 +395,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -395,9 +395,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
395 | transactionContext.RollbackTransaction() | 395 | transactionContext.RollbackTransaction() |
396 | }() | 396 | }() |
397 | 397 | ||
398 | - //workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
399 | queryOptions := utils.ObjectToMap(cmd) | 398 | queryOptions := utils.ObjectToMap(cmd) |
400 | - //queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "") | ||
401 | 399 | ||
402 | var productGroupRepository domain.ProductGroupRepository | 400 | var productGroupRepository domain.ProductGroupRepository |
403 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) | 401 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) |
@@ -422,6 +420,41 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -422,6 +420,41 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
422 | }, nil | 420 | }, nil |
423 | } | 421 | } |
424 | 422 | ||
423 | +// 返回在当前工段上打卡的所有用户 | ||
424 | +func (productGroupService *ProductGroupService) SearchProductGroupEmployeesV2(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupEmployeesQuery) (int64, interface{}, error) { | ||
425 | + if err := cmd.ValidateQuery(); err != nil { | ||
426 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
427 | + } | ||
428 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
429 | + if err != nil { | ||
430 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
431 | + } | ||
432 | + if err := transactionContext.StartTransaction(); err != nil { | ||
433 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
434 | + } | ||
435 | + defer func() { | ||
436 | + transactionContext.RollbackTransaction() | ||
437 | + }() | ||
438 | + | ||
439 | + queryOptions := utils.ObjectToMap(cmd) | ||
440 | + queryOptions["signBeginTime"] = utils.GetZeroTime(time.Now()) | ||
441 | + var attendanceRecordRepository domain.ProductAttendanceRecordRepository | ||
442 | + attendanceRecordRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
443 | + _, productGroups, err := attendanceRecordRepository.Find(queryOptions) | ||
444 | + if err != nil { | ||
445 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
446 | + } | ||
447 | + var results = dto.NewProductGroupEmployeesDtos() | ||
448 | + results.LoadDtoV2(productGroups...) | ||
449 | + sort.Stable(results) | ||
450 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
451 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
452 | + } | ||
453 | + return int64(len(results.Result)), map[string]interface{}{ | ||
454 | + "employees": results.Result, | ||
455 | + }, nil | ||
456 | +} | ||
457 | + | ||
425 | // 返回生产班组服务列表 | 458 | // 返回生产班组服务列表 |
426 | func (productGroupService *ProductGroupService) GetSignEmployee(cmd *query.GetSignInEmployeeQuery) (interface{}, error) { | 459 | func (productGroupService *ProductGroupService) GetSignEmployee(cmd *query.GetSignInEmployeeQuery) (interface{}, error) { |
427 | if err := cmd.ValidateQuery(); err != nil { | 460 | if err := cmd.ValidateQuery(); err != nil { |
@@ -17,7 +17,7 @@ func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt | @@ -17,7 +17,7 @@ func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt | ||
17 | var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext) | 17 | var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext) |
18 | var attendance *domain.ProductAttendanceRecord | 18 | var attendance *domain.ProductAttendanceRecord |
19 | var err error | 19 | var err error |
20 | - log.Logger.Info("【自动审核考勤记录任务】 启动") | 20 | + log.Logger.Debug("【自动审核考勤记录任务】 启动") |
21 | var user *domain.User = &domain.User{} | 21 | var user *domain.User = &domain.User{} |
22 | userService := NewUserService() | 22 | userService := NewUserService() |
23 | if approveUserId > 0 { | 23 | if approveUserId > 0 { |
@@ -167,7 +167,7 @@ func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, ap | @@ -167,7 +167,7 @@ func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, ap | ||
167 | var productRecordRepository, _ = repository.NewProductRecordRepository(ptr.transactionContext) | 167 | var productRecordRepository, _ = repository.NewProductRecordRepository(ptr.transactionContext) |
168 | var record *domain.ProductRecord | 168 | var record *domain.ProductRecord |
169 | var err error | 169 | var err error |
170 | - log.Logger.Info("【自动审核二级品记录任务】 启动") | 170 | + log.Logger.Debug("【自动审核二级品记录任务】 启动") |
171 | var user *domain.User = &domain.User{} | 171 | var user *domain.User = &domain.User{} |
172 | userService := NewUserService() | 172 | userService := NewUserService() |
173 | if approveUserId > 0 { | 173 | if approveUserId > 0 { |
@@ -166,6 +166,9 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin | @@ -166,6 +166,9 @@ func (repository *ProductAttendanceRecordRepository) Find(queryOptions map[strin | ||
166 | query := sqlbuilder.BuildQuery(tx.Model(&productAttendanceRecordModels), queryOptions) | 166 | query := sqlbuilder.BuildQuery(tx.Model(&productAttendanceRecordModels), queryOptions) |
167 | query.SetWhereByQueryOption("company_id = ?", "companyId") | 167 | query.SetWhereByQueryOption("company_id = ?", "companyId") |
168 | query.SetWhereByQueryOption("org_id = ?", "orgId") | 168 | query.SetWhereByQueryOption("org_id = ?", "orgId") |
169 | + query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") | ||
170 | + query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") | ||
171 | + query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") | ||
169 | query.SetWhereByQueryOption("attendance_status & ? >0", "attendanceStatus") | 172 | query.SetWhereByQueryOption("attendance_status & ? >0", "attendanceStatus") |
170 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { | 173 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { |
171 | query.Where(`org_id in (?)`, pg.In(v)) | 174 | query.Where(`org_id in (?)`, pg.In(v)) |
@@ -86,7 +86,7 @@ func (controller *ProductGroupController) SearchProductGroupEmployees() { | @@ -86,7 +86,7 @@ func (controller *ProductGroupController) SearchProductGroupEmployees() { | ||
86 | operateInfo := ParseOperateInfo(controller.BaseController) | 86 | operateInfo := ParseOperateInfo(controller.BaseController) |
87 | cmd.OrgId = operateInfo.OrgId | 87 | cmd.OrgId = operateInfo.OrgId |
88 | cmd.CompanyId = operateInfo.CompanyId | 88 | cmd.CompanyId = operateInfo.CompanyId |
89 | - _, data, err := productGroupService.SearchProductGroupEmployees(operateInfo, cmd) | 89 | + _, data, err := productGroupService.SearchProductGroupEmployeesV2(operateInfo, cmd) |
90 | controller.Response(data, err) | 90 | controller.Response(data, err) |
91 | } | 91 | } |
92 | 92 |
-
请 注册 或 登录 后发表评论