正在显示
4 个修改的文件
包含
87 行增加
和
1 行删除
@@ -120,3 +120,30 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string | @@ -120,3 +120,30 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string | ||
120 | } | 120 | } |
121 | return result, nil | 121 | return result, nil |
122 | } | 122 | } |
123 | + | ||
124 | +// RewardSummaryPublicNoticeDay 功过看板 月榜 | ||
125 | +func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth() (map[string]interface{}, error) { | ||
126 | + | ||
127 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
128 | + if err != nil { | ||
129 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
130 | + } | ||
131 | + if err := transactionContext.StartTransaction(); err != nil { | ||
132 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
133 | + } | ||
134 | + defer func() { | ||
135 | + transactionContext.RollbackTransaction() | ||
136 | + }() | ||
137 | + rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
138 | + sumaryData, err := rewardSumaryDao.SeachRewardSummaryMonth(23, 487, "2022-10") | ||
139 | + if err != nil { | ||
140 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
141 | + } | ||
142 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
143 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
144 | + } | ||
145 | + result := map[string]interface{}{ | ||
146 | + "list": sumaryData, | ||
147 | + } | ||
148 | + return result, nil | ||
149 | +} |
@@ -146,3 +146,55 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa | @@ -146,3 +146,55 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa | ||
146 | _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) | 146 | _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate) |
147 | return result, err | 147 | return result, err |
148 | } | 148 | } |
149 | + | ||
150 | +// 功过看板-异常 | ||
151 | +type RewardSummaryMonth struct { | ||
152 | + SectionId string `json:"sectionId"` //工段名称 | ||
153 | + SectionName string `json:"sectionName"` //工段名称 | ||
154 | + WorkerName string `json:"workerName"` //员工名称 | ||
155 | + WorkerId string `json:"workerId"` //员工名称 | ||
156 | + AccidentAmount1 string `json:"accidentAmount1"` //质量事故损失金额 | ||
157 | + AccidentNum1 string `json:"accidentNum1"` //质量事故次数 | ||
158 | + AccidentNum3 string `json:"accidentNum3"` //金属异物事故 次数 | ||
159 | + AccidentNum4 string `json:"accidentNum4"` //非属异物事故 次数 | ||
160 | + AccidentAmount2 string `json:"accidentAmount2"` //安全事故 损失金额 | ||
161 | + AccidentNum2 string `json:"accidentNum2"` //安全事故 次数 | ||
162 | + YieldAvg string `json:"yieldAvg"` //平均产效 | ||
163 | + YieldMax string `json:"yieldMax"` //产效历史最佳 | ||
164 | + AmountFine string `json:"amountFine"` //惩,的金额 | ||
165 | + AmountReward string `json:"amountReward"` //奖,的金额 | ||
166 | + AmountFinal string `json:"amountFinal"` //最终的 奖惩结果 | ||
167 | +} | ||
168 | + | ||
169 | +// 功过看板-月榜 | ||
170 | +func (d *RewardSumaryDao) SeachRewardSummaryMonth(companyId int, orgId int, recordMonth string) ([]RewardSummaryMonth, error) { | ||
171 | + sqlStr := `SELECT | ||
172 | +work_station->>'sectionId' AS section_id, | ||
173 | +work_station->>'sectionName' as section_name, | ||
174 | +worker->>'userId' as worker_id, | ||
175 | +worker->>'userName' as worker_name, | ||
176 | +count(accident_num1) as accident_num1, | ||
177 | +count(accident_num2) as accident_num2, | ||
178 | +count(accident_num3) as accident_num3, | ||
179 | +count(accident_num4) as accident_num4, | ||
180 | +count(accident_amount1) as accident_amount1, | ||
181 | +count(accident_amount2) as accident_amount2, | ||
182 | +'12' as yield_avg, | ||
183 | +'13' as yield_max, | ||
184 | +'-39' as amount_fine, | ||
185 | +'25' as amount_reward, | ||
186 | +'-14' as amount_final | ||
187 | + FROM manufacture.reward_summary | ||
188 | + WHERE company_id=? | ||
189 | + and org_id=? | ||
190 | + and record_month_str=? | ||
191 | +GROUP BY | ||
192 | +worker->>'userId' , | ||
193 | +worker->>'userName' , | ||
194 | +work_station->>'sectionId', | ||
195 | +work_station->>'sectionName' ` | ||
196 | + tx := d.transactionContext.PgTx | ||
197 | + var result []RewardSummaryMonth | ||
198 | + _, err := tx.Query(&result, sqlStr, companyId, orgId, recordMonth) | ||
199 | + return result, err | ||
200 | +} |
@@ -111,3 +111,10 @@ func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() { | @@ -111,3 +111,10 @@ func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() { | ||
111 | data, err := srv.RewardSummaryPublicNoticeAccident() | 111 | data, err := srv.RewardSummaryPublicNoticeAccident() |
112 | c.Response(data, err) | 112 | c.Response(data, err) |
113 | } | 113 | } |
114 | + | ||
115 | +// 功过看板 月榜 | ||
116 | +func (c *ProductTroubleController) RewardSummaryPublicNoticeMonth() { | ||
117 | + srv := service.NewProductTroubleService(nil) | ||
118 | + data, err := srv.RewardSummaryPublicNoticeMonth() | ||
119 | + c.Response(data, err) | ||
120 | +} |
@@ -17,5 +17,5 @@ func init() { | @@ -17,5 +17,5 @@ func init() { | ||
17 | web.Router("/reward-summary/public-notice/yield", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeYield") | 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") | 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") | 19 | web.Router("/reward-summary/public-notice/accident", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeAccident") |
20 | - | 20 | + web.Router("/reward-summary/public-notice/month", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeMonth") |
21 | } | 21 | } |
-
请 注册 或 登录 后发表评论