作者 yangfu

chore: 工时统计算法更新、代码优化

@@ -59,22 +59,13 @@ func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId i @@ -59,22 +59,13 @@ func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId i
59 d.WorkTimeAfter = m.WorkTimeAfter 59 d.WorkTimeAfter = m.WorkTimeAfter
60 d.AttendanceStatus = m.AttendanceStatus 60 d.AttendanceStatus = m.AttendanceStatus
61 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) 61 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
62 - if m.Ext != nil {  
63 - d.OrgName = m.Ext.OrgName  
64 - //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt  
65 - //if  
66 - if m.Ext.AttendanceExt != nil {  
67 - if m.Ext.AttendanceExt.ApproveUserId > 0 {  
68 - d.ApproveUser = &domain.User{  
69 - UserId: m.Ext.AttendanceExt.ApproveUserId,  
70 - UserName: m.Ext.AttendanceExt.ApproveUserName,  
71 - }  
72 - }  
73 - if m.Ext.AttendanceExt.ApproveAt > 0 {  
74 - t := time.Unix(m.Ext.AttendanceExt.ApproveAt, 0)  
75 - d.ApproveAt = t.Local().Format("2006-01-02 15:04:05")  
76 - }  
77 - d.GroupName = m.Ext.AttendanceExt.GroupName 62 + d.OrgName = m.Ext.OrgName
  63 + d.ApproveUser = m.ApproveUser()
  64 + d.GroupName = m.GroupName()
  65 + if m.Ext != nil && m.Ext.AttendanceExt != nil {
  66 + if m.Ext.AttendanceExt.ApproveAt > 0 {
  67 + t := time.Unix(m.Ext.AttendanceExt.ApproveAt, 0)
  68 + d.ApproveAt = t.Local().Format("2006-01-02 15:04:05")
78 } 69 }
79 } 70 }
80 return d 71 return d
@@ -51,12 +51,7 @@ func (d *EmployeeAttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, @@ -51,12 +51,7 @@ func (d *EmployeeAttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord,
51 d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType) 51 d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType)
52 d.AttendanceStatusDescription = domain.AttendanceStatusDescription(m.AttendanceStatus) 52 d.AttendanceStatusDescription = domain.AttendanceStatusDescription(m.AttendanceStatus)
53 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) 53 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
54 - if m.Ext != nil {  
55 - d.OrgName = m.Ext.OrgName  
56 - //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt  
57 - if m.Ext.AttendanceExt != nil {  
58 - d.GroupName = m.Ext.AttendanceExt.GroupName  
59 - }  
60 - } 54 + d.OrgName = m.Ext.OrgName
  55 + d.GroupName = m.GroupName()
61 return d 56 return d
62 } 57 }
@@ -34,9 +34,6 @@ func (d *WorkshopWorkTimeRecordDto) LoadDto(m *domain.WorkshopWorkTimeRecord, or @@ -34,9 +34,6 @@ func (d *WorkshopWorkTimeRecordDto) LoadDto(m *domain.WorkshopWorkTimeRecord, or
34 d.WorkStation = m.WorkStation 34 d.WorkStation = m.WorkStation
35 d.RecordDate = m.RecordDate.Local().Format("2006-01-02") 35 d.RecordDate = m.RecordDate.Local().Format("2006-01-02")
36 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) 36 d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
37 - if m.Ext != nil {  
38 - d.OrgName = m.Ext.OrgName  
39 - //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt  
40 - } 37 + d.OrgName = m.Ext.OrgName
41 return d 38 return d
42 } 39 }
@@ -119,7 +119,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain @@ -119,7 +119,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain
119 ProductGroupId: productGroup.ProductGroupId, 119 ProductGroupId: productGroup.ProductGroupId,
120 }), 120 }),
121 } 121 }
122 - newAttendance.WorkTimeBefore = newAttendance.ComputeWorkTimeBefore() 122 + newAttendance.WorkTimeBefore = newAttendance.ComputeWorkTimeBefore(nil)
123 var attendanceRepository domain.ProductAttendanceRecordRepository 123 var attendanceRepository domain.ProductAttendanceRecordRepository
124 124
125 attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) 125 attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0)
@@ -2,6 +2,7 @@ package domain @@ -2,6 +2,7 @@ package domain
2 2
3 import ( 3 import (
4 "errors" 4 "errors"
  5 + "github.com/linmadan/egglib-go/utils/xtime"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
6 "time" 7 "time"
7 ) 8 )
@@ -65,7 +66,7 @@ func (productAttendanceRecord *ProductAttendanceRecord) Update(data map[string]i @@ -65,7 +66,7 @@ func (productAttendanceRecord *ProductAttendanceRecord) Update(data map[string]i
65 } 66 }
66 67
67 // 计算审核前工时 68 // 计算审核前工时
68 -func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore() float64 { 69 +func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore(productCalendar *ProductCalendar) float64 {
69 if productAttendanceRecord.SignIn.IsZero() { 70 if productAttendanceRecord.SignIn.IsZero() {
70 return 0 71 return 0
71 } 72 }
@@ -75,7 +76,32 @@ func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore() @@ -75,7 +76,32 @@ func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore()
75 if !productAttendanceRecord.SignOut.After(productAttendanceRecord.SignIn) { 76 if !productAttendanceRecord.SignOut.After(productAttendanceRecord.SignIn) {
76 return 0 77 return 0
77 } 78 }
78 - return utils.Round(productAttendanceRecord.SignOut.Sub(productAttendanceRecord.SignIn).Hours(), 1) 79 + wt := utils.Round(productAttendanceRecord.SignOut.Sub(productAttendanceRecord.SignIn).Hours(), 1)
  80 + if productCalendar == nil {
  81 + return wt
  82 + }
  83 + wt = wt - productCalendar.BreakTime
  84 + if wt < 0 {
  85 + return 0
  86 + }
  87 + return wt
  88 +}
  89 +
  90 +func (productAttendanceRecord *ProductAttendanceRecord) SetProductTimeByProductCalendar(productCalendar *ProductCalendar) error {
  91 + now := xtime.New(productAttendanceRecord.SignIn)
  92 + productAttendanceRecord.Ext.AttendanceExt.ProductTime = now.BeginningOfDay().Unix()
  93 + if productCalendar == nil {
  94 + return nil
  95 + }
  96 + overDay, err := productCalendar.CheckOverDay(productAttendanceRecord.SignIn)
  97 + if err != nil {
  98 + return nil
  99 + }
  100 + newNow := now.BeginningOfDay().Add(-time.Hour * 24)
  101 + if overDay && productCalendar.MatchCalendarSelected(newNow) {
  102 + productAttendanceRecord.Ext.AttendanceExt.ProductTime = newNow.Unix()
  103 + }
  104 + return nil
79 } 105 }
80 106
81 func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *User, workTimeAfter float64, status int) error { 107 func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *User, workTimeAfter float64, status int) error {
@@ -94,3 +120,40 @@ func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *Use @@ -94,3 +120,40 @@ func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *Use
94 } 120 }
95 return nil 121 return nil
96 } 122 }
  123 +
  124 +func (productAttendanceRecord *ProductAttendanceRecord) ProductTime() time.Time {
  125 + attendanceExt := productAttendanceRecord.Ext.AttendanceExt
  126 + if attendanceExt != nil && attendanceExt.ProductTime > 0 {
  127 + t := time.Unix(attendanceExt.ProductTime, 0)
  128 + if !t.IsZero() {
  129 + return t
  130 + }
  131 + }
  132 + return productAttendanceRecord.SignIn
  133 +}
  134 +
  135 +func (productAttendanceRecord *ProductAttendanceRecord) GroupName() string {
  136 + if productAttendanceRecord.Ext != nil {
  137 + return ""
  138 + }
  139 + if productAttendanceRecord.Ext.AttendanceExt != nil {
  140 + return ""
  141 + }
  142 + return productAttendanceRecord.Ext.AttendanceExt.GroupName
  143 +}
  144 +
  145 +func (productAttendanceRecord *ProductAttendanceRecord) ApproveUser() *User {
  146 + if productAttendanceRecord.Ext != nil {
  147 + return nil
  148 + }
  149 + if productAttendanceRecord.Ext.AttendanceExt != nil {
  150 + return nil
  151 + }
  152 + if productAttendanceRecord.Ext.AttendanceExt.ApproveUserId == 0 {
  153 + return nil
  154 + }
  155 + return &User{
  156 + UserId: productAttendanceRecord.Ext.AttendanceExt.ApproveUserId,
  157 + UserName: productAttendanceRecord.Ext.AttendanceExt.ApproveUserName,
  158 + }
  159 +}
@@ -6,6 +6,8 @@ type ProductAttendanceRecordExt struct { @@ -6,6 +6,8 @@ type ProductAttendanceRecordExt struct {
6 ProductGroupId int `json:"productGroupId,omitempty"` 6 ProductGroupId int `json:"productGroupId,omitempty"`
7 // 班组名称 7 // 班组名称
8 GroupName string `json:"groupName,omitempty"` 8 GroupName string `json:"groupName,omitempty"`
  9 + // 生产日期
  10 + ProductTime int64 `json:"productTime,omitempty"`
9 // 审核人Id 11 // 审核人Id
10 ApproveUserId int `json:"approveUserId,omitempty"` 12 ApproveUserId int `json:"approveUserId,omitempty"`
11 // 审核人名称 13 // 审核人名称
@@ -2,6 +2,8 @@ package domain @@ -2,6 +2,8 @@ package domain
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
  5 + "strconv"
  6 + "strings"
5 "time" 7 "time"
6 ) 8 )
7 9
@@ -73,3 +75,66 @@ func (productCalendar *ProductCalendar) ResetWorkTime(v float64) error { @@ -73,3 +75,66 @@ func (productCalendar *ProductCalendar) ResetWorkTime(v float64) error {
73 productCalendar.WorkTime = td.Hours() - productCalendar.BreakTime 75 productCalendar.WorkTime = td.Hours() - productCalendar.BreakTime
74 return nil 76 return nil
75 } 77 }
  78 +
  79 +func (productCalendar *ProductCalendar) MatchCalendarSelected(t time.Time) bool {
  80 + weekdays := productCalendar.CalendarSelectedToWeekDays()
  81 + for _, v := range weekdays {
  82 + if v == t.Weekday() {
  83 + return true
  84 + }
  85 + }
  86 + return false
  87 +}
  88 +
  89 +func (productCalendar *ProductCalendar) CalendarSelectedToWeekDays() []time.Weekday {
  90 + weekdays := make([]time.Weekday, 0)
  91 + for _, v := range productCalendar.CalendarSelected {
  92 + switch v {
  93 + case "7": //周日
  94 + weekdays = append(weekdays, time.Sunday)
  95 + break
  96 + case "1": //"周一":
  97 + weekdays = append(weekdays, time.Monday)
  98 + break
  99 + case "2": //"周二":
  100 + weekdays = append(weekdays, time.Tuesday)
  101 + break
  102 + case "3": //"周三":
  103 + weekdays = append(weekdays, time.Wednesday)
  104 + break
  105 + case "4": //"周四":
  106 + weekdays = append(weekdays, time.Thursday)
  107 + break
  108 + case "5": //"周五":
  109 + weekdays = append(weekdays, time.Friday)
  110 + break
  111 + case "6": //"周六":
  112 + weekdays = append(weekdays, time.Saturday)
  113 + break
  114 + }
  115 + }
  116 + return weekdays
  117 +}
  118 +
  119 +// 检查时间是否跨天
  120 +func (productCalendar *ProductCalendar) CheckOverDay(t time.Time) (bool, error) {
  121 + th := t.Hour()
  122 + inHour, parseInHourErr := strconv.Atoi(strings.Split(productCalendar.InWorkAt, ":")[0])
  123 + if parseInHourErr != nil {
  124 + return false, parseInHourErr
  125 + }
  126 + outHour, parseOutHourErr := strconv.Atoi(strings.Split(productCalendar.OutWorkAt, ":")[0])
  127 + if parseOutHourErr != nil {
  128 + return false, parseOutHourErr
  129 + }
  130 + if inHour < outHour {
  131 + return false, nil // eg: 7:00 17:00 t 9:00
  132 + }
  133 + if th >= inHour && th < 24 {
  134 + return false, nil // eg: 7:00 24:00 t 20:00
  135 + }
  136 + if th >= 0 && th < outHour {
  137 + return true, nil
  138 + }
  139 + return false, nil
  140 +}
@@ -168,6 +168,23 @@ func FindGroupMembers(productGroupRepository domain.ProductGroupRepository, comp @@ -168,6 +168,23 @@ func FindGroupMembers(productGroupRepository domain.ProductGroupRepository, comp
168 return result, keyFunc 168 return result, keyFunc
169 } 169 }
170 170
  171 +// 查询组成员属于的分组
  172 +func FindMemberBelongToProductGroup(productGroupRepository domain.ProductGroupRepository, companyId, orgId int, workStationId string, member *domain.User) (*domain.ProductGroup, error) {
  173 + _, groups, err := productGroupRepository.Find(map[string]interface{}{"companyId": companyId, "orgId": orgId, "workStationId": workStationId})
  174 + if err != nil {
  175 + return nil, err
  176 + }
  177 + for i := range groups {
  178 + for j := range groups[i].GroupMembers {
  179 + u := groups[i].GroupMembers[j]
  180 + if u.UserId == member.UserId {
  181 + return groups[i], nil
  182 + }
  183 + }
  184 + }
  185 + return nil, nil
  186 +}
  187 +
171 // 个人生产记录统计 188 // 个人生产记录统计
172 func (ptr *PGProductRecordService) personalProductStatics(productPlan *domain.ProductPlan, productRecord *domain.ProductRecord) (interface{}, error) { 189 func (ptr *PGProductRecordService) personalProductStatics(productPlan *domain.ProductPlan, productRecord *domain.ProductRecord) (interface{}, error) {
173 var ( 190 var (
@@ -21,13 +21,14 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. @@ -21,13 +21,14 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
21 var ( 21 var (
22 attendanceRecordDao, _ = dao.NewAttendanceRecordDao(ptr.transactionContext) 22 attendanceRecordDao, _ = dao.NewAttendanceRecordDao(ptr.transactionContext)
23 attendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext) 23 attendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext)
  24 + productGroupRepository, _ = repository.NewProductGroupRepository(ptr.transactionContext)
  25 + productCalendarRepository, _ = repository.NewProductCalendarRepository(ptr.transactionContext)
24 isSignIn = true 26 isSignIn = true
25 record *domain.ProductAttendanceRecord 27 record *domain.ProductAttendanceRecord
26 - //workStationId string //具体工位  
27 - workStation *domain.WorkStation  
28 - attendanceType int = domain.ParticipateSupport  
29 - worker *domain.User  
30 - org *domain.Org 28 + workStation *domain.WorkStation
  29 + attendanceType int = domain.ParticipateSupport
  30 + worker *domain.User
  31 + org *domain.Org
31 ) 32 )
32 33
33 if err := report.Valid(); err != nil { 34 if err := report.Valid(); err != nil {
@@ -35,11 +36,10 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. @@ -35,11 +36,10 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
35 } 36 }
36 37
37 var ( 38 var (
38 - device *domain.Device  
39 - err error  
40 - productGroupRepository, _ = repository.NewProductGroupRepository(ptr.transactionContext)  
41 - groupId = 0  
42 - groupName = "" 39 + device *domain.Device
  40 + err error
  41 + groupId = 0
  42 + groupName = ""
43 ) 43 )
44 deviceRepository, _ := dao.NewDeviceDao(ptr.transactionContext) 44 deviceRepository, _ := dao.NewDeviceDao(ptr.transactionContext)
45 if device, err = deviceRepository.FindDeviceByDeviceCode(cid, oid, report.Sn); err != nil { 45 if device, err = deviceRepository.FindDeviceByDeviceCode(cid, oid, report.Sn); err != nil {
@@ -58,15 +58,17 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. @@ -58,15 +58,17 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
58 return nil, err 58 return nil, err
59 } 59 }
60 60
61 - groupMembers, groupMembersKeyFunc := FindGroupMembers(productGroupRepository, cid, oid, workStation.WorkStationId)  
62 - if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; ok { 61 + var productCalendar *domain.ProductCalendar
  62 + productGroup, _ := FindMemberBelongToProductGroup(productGroupRepository, cid, oid, workStation.WorkStationId, worker)
  63 + if productGroup != nil {
63 attendanceType = domain.ParticipateNormal 64 attendanceType = domain.ParticipateNormal
64 - groupId = v.GroupId  
65 - groupName = v.GroupName 65 + groupId = productGroup.ProductGroupId
  66 + groupName = productGroup.GroupName
  67 + productCalendar, _ = productCalendarRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "workStationId": workStation.WorkStationId})
66 } 68 }
67 69
68 - beginTime := utils.GetZeroTime(report.ActionTime)  
69 - endTime := time.Now() 70 + beginTime := report.ActionTime.Add(-time.Hour * 13)
  71 + endTime := report.ActionTime
70 _, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime) 72 _, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime)
71 for i := 0; i < len(records); i++ { 73 for i := 0; i < len(records); i++ {
72 r := records[i] 74 r := records[i]
@@ -76,7 +78,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. @@ -76,7 +78,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
76 if !utils.TimeIsZero(r.SignIn) && utils.TimeIsZero(r.SignOut) { 78 if !utils.TimeIsZero(r.SignIn) && utils.TimeIsZero(r.SignOut) {
77 if utils.TimeAfterEqual(report.ActionTime, r.SignIn) { 79 if utils.TimeAfterEqual(report.ActionTime, r.SignIn) {
78 r.SignOut = report.ActionTime 80 r.SignOut = report.ActionTime
79 - r.WorkTimeBefore = r.ComputeWorkTimeBefore() 81 + r.WorkTimeBefore = r.ComputeWorkTimeBefore(productCalendar)
80 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 在其他工段打卡 下线当前工段:%v 签退 %v", worker.UserName, worker.UserId, r.WorkStation.SectionName, report)) 82 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 在其他工段打卡 下线当前工段:%v 签退 %v", worker.UserName, worker.UserId, r.WorkStation.SectionName, report))
81 if _, err = attendanceRecordRepository.Save(r); err != nil { 83 if _, err = attendanceRecordRepository.Save(r); err != nil {
82 return nil, err 84 return nil, err
@@ -148,10 +150,11 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. @@ -148,10 +150,11 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain.
148 ProductGroupId: groupId, 150 ProductGroupId: groupId,
149 }), 151 }),
150 } 152 }
  153 + record.SetProductTimeByProductCalendar(productCalendar)
151 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签到 %v", worker.UserName, worker.UserId, report)) 154 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签到 %v", worker.UserName, worker.UserId, report))
152 } else { 155 } else {
153 record.SignOut = report.ActionTime 156 record.SignOut = report.ActionTime
154 - record.WorkTimeBefore = record.ComputeWorkTimeBefore() 157 + record.WorkTimeBefore = record.ComputeWorkTimeBefore(productCalendar)
155 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签退 %v", worker.UserName, worker.UserId, report)) 158 log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签退 %v", worker.UserName, worker.UserId, report))
156 } 159 }
157 160
@@ -31,7 +31,7 @@ func (ptr *PGWorkshopWorkTimeStaticService) WorkshopWorkTimeStatic(productRecord @@ -31,7 +31,7 @@ func (ptr *PGWorkshopWorkTimeStaticService) WorkshopWorkTimeStatic(productRecord
31 CompanyId: productRecord.CompanyId, 31 CompanyId: productRecord.CompanyId,
32 OrgId: productRecord.OrgId, 32 OrgId: productRecord.OrgId,
33 Ext: productRecord.Ext, 33 Ext: productRecord.Ext,
34 - RecordDate: utils.GetZeroTime(productRecord.SignIn), 34 + RecordDate: utils.GetZeroTime(productRecord.ProductTime()), // utils.GetZeroTime(productRecord.SignIn),
35 WorkshopWorkTimeRecordInfo: &domain.WorkshopWorkTimeRecordInfo{}, 35 WorkshopWorkTimeRecordInfo: &domain.WorkshopWorkTimeRecordInfo{},
36 } 36 }
37 } 37 }
@@ -6,7 +6,6 @@ import ( @@ -6,7 +6,6 @@ import (
6 "github.com/go-redis/redis" 6 "github.com/go-redis/redis"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
9 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"  
10 "time" 9 "time"
11 ) 10 )
12 11
@@ -15,7 +14,7 @@ func GetDeviceDailyRunningRecord(t time.Time, deviceCode string) (*domain.Device @@ -15,7 +14,7 @@ func GetDeviceDailyRunningRecord(t time.Time, deviceCode string) (*domain.Device
15 client := GetRedis() 14 client := GetRedis()
16 key := DeviceDailyRunningRecordKey(t, deviceCode) 15 key := DeviceDailyRunningRecordKey(t, deviceCode)
17 record, err := getDeviceDailyRunningRecord(client, key) 16 record, err := getDeviceDailyRunningRecord(client, key)
18 - log.Logger.Debug(fmt.Sprintf("Redis Device:%v GET Key:%v Value:%v", deviceCode, key, record)) 17 + //log.Logger.Debug(fmt.Sprintf("Redis Device:%v GET Key:%v Value:%v", deviceCode, key, record))
19 return record, err 18 return record, err
20 } 19 }
21 20
@@ -50,7 +49,7 @@ func SaveDeviceDailyRunningRecordByKey(key string, record *domain.DeviceDailyRun @@ -50,7 +49,7 @@ func SaveDeviceDailyRunningRecordByKey(key string, record *domain.DeviceDailyRun
50 if err != nil { 49 if err != nil {
51 return err 50 return err
52 } 51 }
53 - log.Logger.Debug(fmt.Sprintf("Redis Device:%v SET Key:%v Value:%v", record.DeviceCode, key, record)) 52 + //log.Logger.Debug(fmt.Sprintf("Redis Device:%v SET Key:%v Value:%v", record.DeviceCode, key, record))
54 result := client.Set(key, recordData, time.Hour*24*5) 53 result := client.Set(key, recordData, time.Hour*24*5)
55 _, err = result.Result() 54 _, err = result.Result()
56 return err 55 return err
@@ -133,6 +133,9 @@ func (repository *ProductCalendarRepository) FindOne(queryOptions map[string]int @@ -133,6 +133,9 @@ func (repository *ProductCalendarRepository) FindOne(queryOptions map[string]int
133 tx := repository.transactionContext.PgTx 133 tx := repository.transactionContext.PgTx
134 productCalendarModel := new(models.ProductCalendar) 134 productCalendarModel := new(models.ProductCalendar)
135 query := sqlbuilder.BuildQuery(tx.Model(productCalendarModel), queryOptions) 135 query := sqlbuilder.BuildQuery(tx.Model(productCalendarModel), queryOptions)
  136 + query.SetWhereByQueryOption("company_id = ?", "companyId")
  137 + query.SetWhereByQueryOption("org_id = ?", "orgId")
  138 + query.SetWhereByQueryOption("work_station->>'workStationId'=?", "workStationId")
136 query.SetWhereByQueryOption("product_calendar.product_calendar_id = ?", "productCalendarId") 139 query.SetWhereByQueryOption("product_calendar.product_calendar_id = ?", "productCalendarId")
137 if v, ok := queryOptions["includeDeleted"]; ok && v.(bool) { 140 if v, ok := queryOptions["includeDeleted"]; ok && v.(bool) {
138 query.AllWithDeleted() 141 query.AllWithDeleted()
@@ -123,6 +123,8 @@ func (repository *ProductGroupRepository) FindOne(queryOptions map[string]interf @@ -123,6 +123,8 @@ func (repository *ProductGroupRepository) FindOne(queryOptions map[string]interf
123 tx := repository.transactionContext.PgTx 123 tx := repository.transactionContext.PgTx
124 productGroupModel := new(models.ProductGroup) 124 productGroupModel := new(models.ProductGroup)
125 query := sqlbuilder.BuildQuery(tx.Model(productGroupModel), queryOptions) 125 query := sqlbuilder.BuildQuery(tx.Model(productGroupModel), queryOptions)
  126 + query.SetWhereByQueryOption("company_id = ?", "companyId")
  127 + query.SetWhereByQueryOption("org_id = ?", "orgId")
126 query.SetWhereByQueryOption("product_group.product_group_id = ?", "productGroupId") 128 query.SetWhereByQueryOption("product_group.product_group_id = ?", "productGroupId")
127 query.SetWhereByQueryOption("group_name=?", "groupName") 129 query.SetWhereByQueryOption("group_name=?", "groupName")
128 query.SetWhereByQueryOption("work_station->>'workStationId'=?", "workStationId") 130 query.SetWhereByQueryOption("work_station->>'workStationId'=?", "workStationId")