作者 Your Name

Merge branch 'test'

@@ -30,7 +30,7 @@ func (attendanceService *AttendanceService) WorkshopWorkTimeRecordStatics(cmd *c @@ -30,7 +30,7 @@ func (attendanceService *AttendanceService) WorkshopWorkTimeRecordStatics(cmd *c
30 log.Logger.Error(err.Error()) 30 log.Logger.Error(err.Error())
31 return nil, err 31 return nil, err
32 } 32 }
33 - 33 + //TODO 添加功过统计
34 if err := transactionContext.CommitTransaction(); err != nil { 34 if err := transactionContext.CommitTransaction(); err != nil {
35 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 35 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
36 } 36 }
@@ -131,6 +131,9 @@ func (productRecordService *ProductRecordService) SaveProductCapacities(operateI @@ -131,6 +131,9 @@ func (productRecordService *ProductRecordService) SaveProductCapacities(operateI
131 if err != nil { 131 if err != nil {
132 return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error()) 132 return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error())
133 } 133 }
  134 + if param.SaveAndApprove {
  135 + _ = domainService.SendProductRecordStaticsJob(epRecord)
  136 + }
134 if err := transactionContext.CommitTransaction(); err != nil { 137 if err := transactionContext.CommitTransaction(); err != nil {
135 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 138 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
136 } 139 }
@@ -332,6 +335,7 @@ func (productRecordService *ProductRecordService) ApproveProductCapacities(opera @@ -332,6 +335,7 @@ func (productRecordService *ProductRecordService) ApproveProductCapacities(opera
332 if err != nil { 335 if err != nil {
333 return nil, application.ThrowError(application.ARG_ERROR, "保存数据错误,"+err.Error()) 336 return nil, application.ThrowError(application.ARG_ERROR, "保存数据错误,"+err.Error())
334 } 337 }
  338 + _ = domainService.SendProductRecordStaticsJob(recordData)
335 if err := transactionContext.CommitTransaction(); err != nil { 339 if err := transactionContext.CommitTransaction(); err != nil {
336 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 340 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
337 } 341 }
@@ -661,6 +665,9 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat @@ -661,6 +665,9 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat
661 if err != nil { 665 if err != nil {
662 return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error()) 666 return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error())
663 } 667 }
  668 + if param.SaveAndApprove {
  669 + _ = domainService.SendProductRecordStaticsJob(epRecord)
  670 + }
664 productRecordIds = append(productRecordIds, epRecord.ProductRecordId) 671 productRecordIds = append(productRecordIds, epRecord.ProductRecordId)
665 } 672 }
666 if err := transactionContext.CommitTransaction(); err != nil { 673 if err := transactionContext.CommitTransaction(); err != nil {
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "time"
  5 +
4 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao"
8 ) 11 )
9 12
10 //功过看板 展示(员工) 13 //功过看板 展示(员工)
11 14
12 // RewardSummaryPublicNoticeDay 功过看板 日榜 15 // RewardSummaryPublicNoticeDay 功过看板 日榜
13 -func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]interface{}, error) { 16 +func (srv ProductTroubleService) RewardSummaryPublicNoticeDay(operateInfo *domain.OperateInfo) (map[string]interface{}, error) {
14 transactionContext, err := factory.CreateTransactionContext(nil) 17 transactionContext, err := factory.CreateTransactionContext(nil)
15 if err != nil { 18 if err != nil {
16 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 19 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -22,7 +25,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]inte @@ -22,7 +25,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]inte
22 transactionContext.RollbackTransaction() 25 transactionContext.RollbackTransaction()
23 }() 26 }()
24 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) 27 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
25 - sumaryData, err := rewardSumaryDao.SeachRewardSummaryDay(23, 487, "2022-10-29") 28 + nowTime := time.Now().Format("2006-01-02")
  29 + sumaryData, err := rewardSumaryDao.SeachRewardSummaryDay(operateInfo.CompanyId, operateInfo.OrgId, nowTime)
26 if err != nil { 30 if err != nil {
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 31 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 32 }
@@ -31,14 +35,14 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]inte @@ -31,14 +35,14 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]inte
31 } 35 }
32 result := map[string]interface{}{ 36 result := map[string]interface{}{
33 "list": sumaryData, 37 "list": sumaryData,
34 - "recordDay": "2022-10-29", 38 + "recordDay": nowTime,
35 } 39 }
36 40
37 return result, nil 41 return result, nil
38 } 42 }
39 43
40 // RewardSummaryPublicNoticeYield 功过看板 产效 44 // RewardSummaryPublicNoticeYield 功过看板 产效
41 -func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]interface{}, error) { 45 +func (srv ProductTroubleService) RewardSummaryPublicNoticeYield(operateInfo *domain.OperateInfo) (map[string]interface{}, error) {
42 46
43 transactionContext, err := factory.CreateTransactionContext(nil) 47 transactionContext, err := factory.CreateTransactionContext(nil)
44 if err != nil { 48 if err != nil {
@@ -51,7 +55,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]in @@ -51,7 +55,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]in
51 transactionContext.RollbackTransaction() 55 transactionContext.RollbackTransaction()
52 }() 56 }()
53 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) 57 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
54 - sumaryData, err := rewardSumaryDao.SeachRewardSummaryYield(23, 487, "2022-10-29") 58 + nowTime := time.Now().Format("2006-01-02")
  59 + sumaryData, err := rewardSumaryDao.SeachRewardSummaryYield(operateInfo.CompanyId, operateInfo.OrgId, nowTime)
55 if err != nil { 60 if err != nil {
56 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 61 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
57 } 62 }
@@ -67,7 +72,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]in @@ -67,7 +72,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]in
67 } 72 }
68 73
69 // RewardSummaryPublicNoticeUpToStandard 功过看板 合格率 74 // RewardSummaryPublicNoticeUpToStandard 功过看板 合格率
70 -func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[string]interface{}, error) { 75 +func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard(operateInfo *domain.OperateInfo) (map[string]interface{}, error) {
71 76
72 transactionContext, err := factory.CreateTransactionContext(nil) 77 transactionContext, err := factory.CreateTransactionContext(nil)
73 if err != nil { 78 if err != nil {
@@ -80,7 +85,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[st @@ -80,7 +85,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[st
80 transactionContext.RollbackTransaction() 85 transactionContext.RollbackTransaction()
81 }() 86 }()
82 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) 87 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
83 - sumaryData, err := rewardSumaryDao.SeachRewardUpToStandard(23, 487, "2022-10-29") 88 + nowTime := time.Now().Format("2006-01-02")
  89 + sumaryData, err := rewardSumaryDao.SeachRewardUpToStandard(operateInfo.CompanyId, operateInfo.OrgId, nowTime)
84 if err != nil { 90 if err != nil {
85 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 91 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
86 } 92 }
@@ -95,7 +101,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[st @@ -95,7 +101,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[st
95 } 101 }
96 102
97 // RewardSummaryPublicNoticeDay 功过看板 异常 103 // RewardSummaryPublicNoticeDay 功过看板 异常
98 -func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string]interface{}, error) { 104 +func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident(operateInfo *domain.OperateInfo) (map[string]interface{}, error) {
99 105
100 transactionContext, err := factory.CreateTransactionContext(nil) 106 transactionContext, err := factory.CreateTransactionContext(nil)
101 if err != nil { 107 if err != nil {
@@ -108,7 +114,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string @@ -108,7 +114,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string
108 transactionContext.RollbackTransaction() 114 transactionContext.RollbackTransaction()
109 }() 115 }()
110 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) 116 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
111 - sumaryData, err := rewardSumaryDao.SeachRewardAccident(23, 487, "2022-10-29") 117 + nowTime := time.Now().Format("2006-01-02")
  118 + sumaryData, err := rewardSumaryDao.SeachRewardAccident(operateInfo.CompanyId, operateInfo.OrgId, nowTime)
112 if err != nil { 119 if err != nil {
113 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 120 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
114 } 121 }
@@ -122,8 +129,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string @@ -122,8 +129,7 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string
122 } 129 }
123 130
124 // RewardSummaryPublicNoticeDay 功过看板 月榜 131 // RewardSummaryPublicNoticeDay 功过看板 月榜
125 -func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth() (map[string]interface{}, error) {  
126 - 132 +func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth(operateInfo *domain.OperateInfo) (map[string]interface{}, error) {
127 transactionContext, err := factory.CreateTransactionContext(nil) 133 transactionContext, err := factory.CreateTransactionContext(nil)
128 if err != nil { 134 if err != nil {
129 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 135 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -135,7 +141,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth() (map[string]in @@ -135,7 +141,8 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth() (map[string]in
135 transactionContext.RollbackTransaction() 141 transactionContext.RollbackTransaction()
136 }() 142 }()
137 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) 143 rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
138 - sumaryData, err := rewardSumaryDao.SeachRewardSummaryMonth(23, 487, "2022-10") 144 + nowTime := time.Now().Format("2006-01")
  145 + sumaryData, err := rewardSumaryDao.SeachRewardSummaryMonth(operateInfo.CompanyId, operateInfo.OrgId, nowTime)
139 if err != nil { 146 if err != nil {
140 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 147 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
141 } 148 }
@@ -134,7 +134,7 @@ func (c *PGRewardSummaryStaticService) CreateRewardSummaryByEmployeeProductRecor @@ -134,7 +134,7 @@ func (c *PGRewardSummaryStaticService) CreateRewardSummaryByEmployeeProductRecor
134 "sectionId": param.WorkStation.SectionId, 134 "sectionId": param.WorkStation.SectionId,
135 "workshopId": param.WorkStation.WorkshopId, 135 "workshopId": param.WorkStation.WorkshopId,
136 "workerId": param.ProductWorker.UserId, 136 "workerId": param.ProductWorker.UserId,
137 - "recordDateStr": param.CreatedAt.Format("200-01-02"), 137 + "recordDateStr": param.CreatedAt.Format("2006-01-02"),
138 } 138 }
139 139
140 _, summaryList, err := rewardSummaryRepo.Find(condtion) 140 _, summaryList, err := rewardSummaryRepo.Find(condtion)
@@ -137,6 +137,10 @@ func (repo *RewardSummaryRepository) Find(queryOptions map[string]interface{}) ( @@ -137,6 +137,10 @@ func (repo *RewardSummaryRepository) Find(queryOptions map[string]interface{}) (
137 if v, ok := queryOptions["recordDateStr"]; ok { 137 if v, ok := queryOptions["recordDateStr"]; ok {
138 query.Where("record_date_str=?", v) 138 query.Where("record_date_str=?", v)
139 } 139 }
  140 + //用户id
  141 + if v, ok := queryOptions["workerId"]; ok {
  142 + query.Where(`worker->>'userId'='?'`, v)
  143 + }
140 cnt, err := query.SelectAndCount() 144 cnt, err := query.SelectAndCount()
141 if err != nil { 145 if err != nil {
142 return 0, nil, err 146 return 0, nil, err
@@ -87,34 +87,39 @@ func (c *ProductTroubleController) ListRewardSummary() { @@ -87,34 +87,39 @@ func (c *ProductTroubleController) ListRewardSummary() {
87 // 功过看板 日榜 87 // 功过看板 日榜
88 func (c *ProductTroubleController) RewardSummaryPublicNoticeDay() { 88 func (c *ProductTroubleController) RewardSummaryPublicNoticeDay() {
89 srv := service.NewProductTroubleService(nil) 89 srv := service.NewProductTroubleService(nil)
90 - data, err := srv.RewardSummaryPublicNoticeDay() 90 + operater := ParseOperateInfo(c.BaseController)
  91 + data, err := srv.RewardSummaryPublicNoticeDay(operater)
91 c.Response(data, err) 92 c.Response(data, err)
92 } 93 }
93 94
94 // 功过看板 产效 95 // 功过看板 产效
95 func (c *ProductTroubleController) RewardSummaryPublicNoticeYield() { 96 func (c *ProductTroubleController) RewardSummaryPublicNoticeYield() {
96 srv := service.NewProductTroubleService(nil) 97 srv := service.NewProductTroubleService(nil)
97 - data, err := srv.RewardSummaryPublicNoticeYield() 98 + operater := ParseOperateInfo(c.BaseController)
  99 + data, err := srv.RewardSummaryPublicNoticeYield(operater)
98 c.Response(data, err) 100 c.Response(data, err)
99 } 101 }
100 102
101 // 功过看板 合格率 103 // 功过看板 合格率
102 func (c *ProductTroubleController) RewardSummaryPublicNoticeUpToStandard() { 104 func (c *ProductTroubleController) RewardSummaryPublicNoticeUpToStandard() {
103 srv := service.NewProductTroubleService(nil) 105 srv := service.NewProductTroubleService(nil)
104 - data, err := srv.RewardSummaryPublicNoticeUpToStandard() 106 + operater := ParseOperateInfo(c.BaseController)
  107 + data, err := srv.RewardSummaryPublicNoticeUpToStandard(operater)
105 c.Response(data, err) 108 c.Response(data, err)
106 } 109 }
107 110
108 // 功过看板 异常 111 // 功过看板 异常
109 func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() { 112 func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() {
110 srv := service.NewProductTroubleService(nil) 113 srv := service.NewProductTroubleService(nil)
111 - data, err := srv.RewardSummaryPublicNoticeAccident() 114 + operater := ParseOperateInfo(c.BaseController)
  115 + data, err := srv.RewardSummaryPublicNoticeAccident(operater)
112 c.Response(data, err) 116 c.Response(data, err)
113 } 117 }
114 118
115 // 功过看板 月榜 119 // 功过看板 月榜
116 func (c *ProductTroubleController) RewardSummaryPublicNoticeMonth() { 120 func (c *ProductTroubleController) RewardSummaryPublicNoticeMonth() {
117 srv := service.NewProductTroubleService(nil) 121 srv := service.NewProductTroubleService(nil)
118 - data, err := srv.RewardSummaryPublicNoticeMonth() 122 + operater := ParseOperateInfo(c.BaseController)
  123 + data, err := srv.RewardSummaryPublicNoticeMonth(operater)
119 c.Response(data, err) 124 c.Response(data, err)
120 } 125 }