正在显示
8 个修改的文件
包含
312 行增加
和
6 行删除
@@ -6,6 +6,7 @@ type RewardSummaryList struct { | @@ -6,6 +6,7 @@ type RewardSummaryList struct { | ||
6 | WorkshopName string `json:"workshopName"` //车间名称 | 6 | WorkshopName string `json:"workshopName"` //车间名称 |
7 | LineName string `json:"lineName"` //线别名称 | 7 | LineName string `json:"lineName"` //线别名称 |
8 | SectionName string `json:"sectionName"` //工段 | 8 | SectionName string `json:"sectionName"` //工段 |
9 | + WorkerName string `json:"workerName"` //员工名字 | ||
9 | Yield string `json:"yield"` //产效 | 10 | Yield string `json:"yield"` //产效 |
10 | UpToStandard string `json:"upToStandard"` //合格率 | 11 | UpToStandard string `json:"upToStandard"` //合格率 |
11 | Accident1 string `json:"accident1"` //质量事故 | 12 | Accident1 string `json:"accident1"` //质量事故 |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
8 | +) | ||
9 | + | ||
10 | +//功过看板 展示(员工) | ||
11 | + | ||
12 | +// RewardSummaryPublicNoticeDay 功过看板 日榜 | ||
13 | +func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (map[string]interface{}, error) { | ||
14 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
15 | + if err != nil { | ||
16 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
17 | + } | ||
18 | + if err := transactionContext.StartTransaction(); err != nil { | ||
19 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
20 | + } | ||
21 | + defer func() { | ||
22 | + transactionContext.RollbackTransaction() | ||
23 | + }() | ||
24 | + rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
25 | + sumaryData, err := rewardSumaryDao.SeachRewardSummaryDay(23, 467, "2022-10-29") | ||
26 | + if err != nil { | ||
27 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
28 | + } | ||
29 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
30 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
31 | + } | ||
32 | + result := map[string]interface{}{ | ||
33 | + "list": sumaryData, | ||
34 | + "recordDay": "2022-10-29", | ||
35 | + } | ||
36 | + | ||
37 | + return result, nil | ||
38 | +} | ||
39 | + | ||
40 | +// RewardSummaryPublicNoticeYield 功过看板 产效 | ||
41 | +func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (map[string]interface{}, error) { | ||
42 | + | ||
43 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
44 | + if err != nil { | ||
45 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
46 | + } | ||
47 | + if err := transactionContext.StartTransaction(); err != nil { | ||
48 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
49 | + } | ||
50 | + defer func() { | ||
51 | + transactionContext.RollbackTransaction() | ||
52 | + }() | ||
53 | + rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
54 | + sumaryData, err := rewardSumaryDao.SeachRewardSummaryYield(23, 467, "2022-10-29") | ||
55 | + if err != nil { | ||
56 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
57 | + } | ||
58 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
59 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
60 | + } | ||
61 | + result := map[string]interface{}{ | ||
62 | + "list": sumaryData, | ||
63 | + } | ||
64 | + | ||
65 | + return result, nil | ||
66 | + | ||
67 | +} | ||
68 | + | ||
69 | +// RewardSummaryPublicNoticeUpToStandard 功过看板 合格率 | ||
70 | +func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (map[string]interface{}, error) { | ||
71 | + | ||
72 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
73 | + if err != nil { | ||
74 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
75 | + } | ||
76 | + if err := transactionContext.StartTransaction(); err != nil { | ||
77 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
78 | + } | ||
79 | + defer func() { | ||
80 | + transactionContext.RollbackTransaction() | ||
81 | + }() | ||
82 | + rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
83 | + sumaryData, err := rewardSumaryDao.SeachRewardUpToStandard(23, 467, "2022-10-29") | ||
84 | + if err != nil { | ||
85 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
86 | + } | ||
87 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
88 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
89 | + } | ||
90 | + result := map[string]interface{}{ | ||
91 | + "list": sumaryData, | ||
92 | + } | ||
93 | + | ||
94 | + return result, nil | ||
95 | +} | ||
96 | + | ||
97 | +// RewardSummaryPublicNoticeDay 功过看板 异常 | ||
98 | +func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string]interface{}, error) { | ||
99 | + | ||
100 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
101 | + if err != nil { | ||
102 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
103 | + } | ||
104 | + if err := transactionContext.StartTransaction(); err != nil { | ||
105 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
106 | + } | ||
107 | + defer func() { | ||
108 | + transactionContext.RollbackTransaction() | ||
109 | + }() | ||
110 | + rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
111 | + sumaryData, err := rewardSumaryDao.SeachRewardUpToStandard(23, 467, "2022-10-29") | ||
112 | + if err != nil { | ||
113 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
114 | + } | ||
115 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
116 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
117 | + } | ||
118 | + result := map[string]interface{}{ | ||
119 | + "list": sumaryData, | ||
120 | + } | ||
121 | + return result, nil | ||
122 | +} |
@@ -531,6 +531,7 @@ func (srv ProductTroubleService) ListRewardSummary(param *query.ListRewardSummar | @@ -531,6 +531,7 @@ func (srv ProductTroubleService) ListRewardSummary(param *query.ListRewardSummar | ||
531 | WorkshopName: v.WorkStation.WorkshopName, | 531 | WorkshopName: v.WorkStation.WorkshopName, |
532 | LineName: v.WorkStation.LineName, | 532 | LineName: v.WorkStation.LineName, |
533 | SectionName: v.WorkStation.SectionName, | 533 | SectionName: v.WorkStation.SectionName, |
534 | + WorkerName: v.Worker.UserName, | ||
534 | Yield: fmt.Sprintf("%.2f", v.Yield), | 535 | Yield: fmt.Sprintf("%.2f", v.Yield), |
535 | UpToStandard: fmt.Sprintf("%.2f%%", v.UpToStandard), | 536 | UpToStandard: fmt.Sprintf("%.2f%%", v.UpToStandard), |
536 | Accident1: fmt.Sprintf("%d次%.2f元", v.AccidentNum1, v.AccidentAmount1), | 537 | Accident1: fmt.Sprintf("%d次%.2f元", v.AccidentNum1, v.AccidentAmount1), |
@@ -12,6 +12,11 @@ import ( | @@ -12,6 +12,11 @@ import ( | ||
12 | type CommonStatisticsService struct { | 12 | type CommonStatisticsService struct { |
13 | } | 13 | } |
14 | 14 | ||
15 | +func NewCommonStatisticsService(options map[string]interface{}) *CommonStatisticsService { | ||
16 | + newProductSectionService := &CommonStatisticsService{} | ||
17 | + return newProductSectionService | ||
18 | +} | ||
19 | + | ||
15 | // CommonStatisticsService 通用的统计服务 | 20 | // CommonStatisticsService 通用的统计服务 |
16 | func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonStatisticsQuery) (interface{}, error) { | 21 | func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonStatisticsQuery) (interface{}, error) { |
17 | if err := cmd.ValidateQuery(); err != nil { | 22 | if err := cmd.ValidateQuery(); err != nil { |
@@ -39,8 +44,3 @@ func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonSta | @@ -39,8 +44,3 @@ func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonSta | ||
39 | } | 44 | } |
40 | return response, nil | 45 | return response, nil |
41 | } | 46 | } |
42 | - | ||
43 | -func NewCommonStatisticsService(options map[string]interface{}) *CommonStatisticsService { | ||
44 | - newProductSectionService := &CommonStatisticsService{} | ||
45 | - return newProductSectionService | ||
46 | -} |
pkg/infrastructure/dao/reward_summary_dao.go
0 → 100644
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | +) | ||
8 | + | ||
9 | +type RewardSumaryDao struct { | ||
10 | + transactionContext *pgTransaction.TransactionContext | ||
11 | +} | ||
12 | + | ||
13 | +func NewRewardSumaryDao(transactionContext *pgTransaction.TransactionContext) (*RewardSumaryDao, error) { | ||
14 | + if transactionContext == nil { | ||
15 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
16 | + } else { | ||
17 | + return &RewardSumaryDao{ | ||
18 | + transactionContext: transactionContext, | ||
19 | + }, nil | ||
20 | + } | ||
21 | +} | ||
22 | + | ||
23 | +// 功过看板-日榜 | ||
24 | +type RewardSummaryDay struct { | ||
25 | + Id int `json:"id"` //id | ||
26 | + RecordDateStr string `json:"record_date_str"` | ||
27 | + SectionName string `json:"sectionName"` //工段名称 | ||
28 | + WorkerName string `json:"workerName"` //员工名称 | ||
29 | + SummaryResult string `json:"summaryResult"` //奖惩结果 | ||
30 | + YieldResult string `json:"yieldResult"` //产效功过结果 | ||
31 | + UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果 | ||
32 | + AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果 | ||
33 | + AccidentResul2 string `json:"accidentResul2"` //安全事故功过结果 | ||
34 | + AccidentResul3 string `json:"accidentResul3"` //异物 功过结果 | ||
35 | +} | ||
36 | + | ||
37 | +// 功过看板-日榜 | ||
38 | +func (d *RewardSumaryDao) SeachRewardSummaryDay(companyId int, orgId int, recordDate string) ([]RewardSummaryDay, error) { | ||
39 | + sqlStr := `SELECT | ||
40 | + "id",record_date_str, | ||
41 | + work_station->>'sectionName', | ||
42 | + worker->>'userName' as worker_name, | ||
43 | + summary_result, | ||
44 | + yield_result, | ||
45 | + up_to_standard_result, | ||
46 | + accident_result1, | ||
47 | + accident_result2, | ||
48 | + accident_result3 | ||
49 | + FROM "reward_summary" | ||
50 | + WHERE company_id=? | ||
51 | + and org_id=? | ||
52 | + and record_date_str=?` | ||
53 | + tx := d.transactionContext.PgTx | ||
54 | + var result []RewardSummaryDay | ||
55 | + _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) | ||
56 | + return result, err | ||
57 | +} | ||
58 | + | ||
59 | +// 功过看板-产效 | ||
60 | +type RewardSummaryYield struct { | ||
61 | + RecordDateStr string `json:"record_date_str"` | ||
62 | + SectionName string `json:"sectionName"` //工段名称 | ||
63 | + WorkerName string `json:"workerName"` //员工名称 | ||
64 | + Yield string `json:"yield"` //产效 | ||
65 | + YieldResult string `json:"yieldResult"` //产效功过结果 | ||
66 | + YieldMax string `json:"yildMax"` //产效历史最佳 | ||
67 | +} | ||
68 | + | ||
69 | +// 功过看板-产效 | ||
70 | +func (d *RewardSumaryDao) SeachRewardSummaryYield(companyId int, orgId int, recordDate string) ([]RewardSummaryYield, error) { | ||
71 | + sqlStr := `SELECT | ||
72 | + record_date_str, | ||
73 | + work_station->>'sectionName', | ||
74 | + worker->>'userName' as worker_name, | ||
75 | + yield_result, | ||
76 | + yield, | ||
77 | + "24" as yield_max | ||
78 | + FROM "reward_summary" | ||
79 | + WHERE company_id=? | ||
80 | + and org_id=? | ||
81 | + and record_date_str=?` | ||
82 | + tx := d.transactionContext.PgTx | ||
83 | + var result []RewardSummaryYield | ||
84 | + _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) | ||
85 | + return result, err | ||
86 | + | ||
87 | +} | ||
88 | + | ||
89 | +// 功过看板-合格率 | ||
90 | +type RewardSummaryUpToStandard struct { | ||
91 | + RecordDateStr string `json:"record_date_str"` | ||
92 | + SectionName string `json:"sectionName"` //工段名称 | ||
93 | + WorkerName string `json:"workerName"` //员工名称 | ||
94 | + UpToStandard string `json:"upToStandard"` //合格率 | ||
95 | + UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果 | ||
96 | + UpToStandardMax string `json:"upToStandardMax"` //合格率历史最佳 | ||
97 | +} | ||
98 | + | ||
99 | +// 功过看板-合格率 | ||
100 | +func (d *RewardSumaryDao) SeachRewardUpToStandard(companyId int, orgId int, recordDate string) ([]RewardSummaryUpToStandard, error) { | ||
101 | + sqlStr := `SELECT | ||
102 | + "id",record_date_str, | ||
103 | + work_station->>'sectionName', | ||
104 | + worker->>'userName' as worker_name, | ||
105 | + up_to_standard_result, | ||
106 | + up_to_standard, | ||
107 | + '90' as up_to_standard_max | ||
108 | + FROM "reward_summary" | ||
109 | + WHERE company_id=23 | ||
110 | + and org_id=487 | ||
111 | + and record_date_str='2022-10-29'` | ||
112 | + tx := d.transactionContext.PgTx | ||
113 | + var result []RewardSummaryUpToStandard | ||
114 | + _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) | ||
115 | + return result, err | ||
116 | +} | ||
117 | + | ||
118 | +// 功过看板-异常 | ||
119 | +type RewardAccident struct { | ||
120 | + RecordDateStr string `json:"record_date_str"` | ||
121 | + SectionName string `json:"sectionName"` //工段名称 | ||
122 | + WorkerName string `json:"workerName"` //员工名称 | ||
123 | + SummaryResult string `json:"summaryResult"` //奖惩结果 | ||
124 | + YieldResult string `json:"yieldResult"` //产效功过结果 | ||
125 | + UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果 | ||
126 | + AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果 | ||
127 | + AccidentResul2 string `json:"accidentResul2"` //安全事故功过结果 | ||
128 | + AccidentResul3 string `json:"accidentResul3"` //异物 功过结果 | ||
129 | +} | ||
130 | + | ||
131 | +// 功过看板-异常 | ||
132 | +func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDate string) ([]RewardAccident, error) { | ||
133 | + sqlStr := `SELECT | ||
134 | + "id",record_date_str, | ||
135 | + work_station->>'sectionName', | ||
136 | + worker->>'userName' as worker_name, | ||
137 | + up_to_standard_result, | ||
138 | + up_to_standard, | ||
139 | + '90' as up_to_standard_max | ||
140 | + FROM "reward_summary" | ||
141 | + WHERE company_id=? | ||
142 | + and org_id=? | ||
143 | + and record_date_str=?` | ||
144 | + tx := d.transactionContext.PgTx | ||
145 | + var result []RewardAccident | ||
146 | + _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) | ||
147 | + return result, err | ||
148 | +} |
@@ -13,7 +13,8 @@ type RewardSummary struct { | @@ -13,7 +13,8 @@ type RewardSummary struct { | ||
13 | CompanyId int `` | 13 | CompanyId int `` |
14 | OrgId int `` | 14 | OrgId int `` |
15 | RecordDate time.Time //日期 | 15 | RecordDate time.Time //日期 |
16 | - RecordDateStr string // | 16 | + RecordDateStr string //日期 ;2006-01-02 |
17 | + RecordMonthStr string //月份 :200601 | ||
17 | WorkStation domain.WorkStation // 工作位置 | 18 | WorkStation domain.WorkStation // 工作位置 |
18 | Worker domain.User //员工 | 19 | Worker domain.User //员工 |
19 | UpToStandard float64 //合格率 | 20 | UpToStandard float64 //合格率 |
@@ -83,3 +83,31 @@ func (c *ProductTroubleController) ListRewardSummary() { | @@ -83,3 +83,31 @@ func (c *ProductTroubleController) ListRewardSummary() { | ||
83 | total, data, err := srv.ListRewardSummary(&getQuery) | 83 | total, data, err := srv.ListRewardSummary(&getQuery) |
84 | ResponseGrid(c.BaseController, total, data, err) | 84 | ResponseGrid(c.BaseController, total, data, err) |
85 | } | 85 | } |
86 | + | ||
87 | +// 功过看板 日榜 | ||
88 | +func (c *ProductTroubleController) RewardSummaryPublicNoticeDay() { | ||
89 | + srv := service.NewProductTroubleService(nil) | ||
90 | + data, err := srv.RewardSummaryPublicNoticeDay() | ||
91 | + c.Response(data, err) | ||
92 | +} | ||
93 | + | ||
94 | +// 功过看板 产效 | ||
95 | +func (c *ProductTroubleController) RewardSummaryPublicNoticeYield() { | ||
96 | + srv := service.NewProductTroubleService(nil) | ||
97 | + data, err := srv.RewardSummaryPublicNoticeYield() | ||
98 | + c.Response(data, err) | ||
99 | +} | ||
100 | + | ||
101 | +// 功过看板 合格率 | ||
102 | +func (c *ProductTroubleController) RewardSummaryPublicNoticeUpToStandard() { | ||
103 | + srv := service.NewProductTroubleService(nil) | ||
104 | + data, err := srv.RewardSummaryPublicNoticeUpToStandard() | ||
105 | + c.Response(data, err) | ||
106 | +} | ||
107 | + | ||
108 | +// 功过看板 异常 | ||
109 | +func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() { | ||
110 | + srv := service.NewProductTroubleService(nil) | ||
111 | + data, err := srv.RewardSummaryPublicNoticeAccident() | ||
112 | + c.Response(data, err) | ||
113 | +} |
@@ -13,4 +13,9 @@ func init() { | @@ -13,4 +13,9 @@ func init() { | ||
13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") | 13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") |
14 | web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble") | 14 | web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble") |
15 | web.Router("/product_trouble/reward_summary/seach", &controllers.ProductTroubleController{}, "Post:ListRewardSummary") | 15 | web.Router("/product_trouble/reward_summary/seach", &controllers.ProductTroubleController{}, "Post:ListRewardSummary") |
16 | + web.Router("/reward-summary/public-notice/day", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeDay") | ||
17 | + web.Router("/reward-summary/public-notice/yield", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeYield") | ||
18 | + web.Router("/reward-summary/public-notice/up-to-standard", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeUpToStandard") | ||
19 | + web.Router("/reward-summary/public-notice/accident", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeAccident") | ||
20 | + | ||
16 | } | 21 | } |
-
请 注册 或 登录 后发表评论