作者 Your Name

更新 看板 查询

... ... @@ -120,3 +120,30 @@ func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (map[string
}
return result, nil
}
// RewardSummaryPublicNoticeDay 功过看板 月榜
func (srv ProductTroubleService) RewardSummaryPublicNoticeMonth() (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
rewardSumaryDao, _ := dao.NewRewardSumaryDao(transactionContext.(*pgTransaction.TransactionContext))
sumaryData, err := rewardSumaryDao.SeachRewardSummaryMonth(23, 487, "2022-10")
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := map[string]interface{}{
"list": sumaryData,
}
return result, nil
}
... ...
... ... @@ -146,3 +146,55 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
return result, err
}
// 功过看板-异常
type RewardSummaryMonth struct {
SectionId string `json:"sectionId"` //工段名称
SectionName string `json:"sectionName"` //工段名称
WorkerName string `json:"workerName"` //员工名称
WorkerId string `json:"workerId"` //员工名称
AccidentAmount1 string `json:"accidentAmount1"` //质量事故损失金额
AccidentNum1 string `json:"accidentNum1"` //质量事故次数
AccidentNum3 string `json:"accidentNum3"` //金属异物事故 次数
AccidentNum4 string `json:"accidentNum4"` //非属异物事故 次数
AccidentAmount2 string `json:"accidentAmount2"` //安全事故 损失金额
AccidentNum2 string `json:"accidentNum2"` //安全事故 次数
YieldAvg string `json:"yieldAvg"` //平均产效
YieldMax string `json:"yieldMax"` //产效历史最佳
AmountFine string `json:"amountFine"` //惩,的金额
AmountReward string `json:"amountReward"` //奖,的金额
AmountFinal string `json:"amountFinal"` //最终的 奖惩结果
}
// 功过看板-月榜
func (d *RewardSumaryDao) SeachRewardSummaryMonth(companyId int, orgId int, recordMonth string) ([]RewardSummaryMonth, error) {
sqlStr := `SELECT
work_station->>'sectionId' AS section_id,
work_station->>'sectionName' as section_name,
worker->>'userId' as worker_id,
worker->>'userName' as worker_name,
count(accident_num1) as accident_num1,
count(accident_num2) as accident_num2,
count(accident_num3) as accident_num3,
count(accident_num4) as accident_num4,
count(accident_amount1) as accident_amount1,
count(accident_amount2) as accident_amount2,
'12' as yield_avg,
'13' as yield_max,
'-39' as amount_fine,
'25' as amount_reward,
'-14' as amount_final
FROM manufacture.reward_summary
WHERE company_id=?
and org_id=?
and record_month_str=?
GROUP BY
worker->>'userId' ,
worker->>'userName' ,
work_station->>'sectionId',
work_station->>'sectionName' `
tx := d.transactionContext.PgTx
var result []RewardSummaryMonth
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordMonth)
return result, err
}
... ...
... ... @@ -111,3 +111,10 @@ func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() {
data, err := srv.RewardSummaryPublicNoticeAccident()
c.Response(data, err)
}
// 功过看板 月榜
func (c *ProductTroubleController) RewardSummaryPublicNoticeMonth() {
srv := service.NewProductTroubleService(nil)
data, err := srv.RewardSummaryPublicNoticeMonth()
c.Response(data, err)
}
... ...
... ... @@ -17,5 +17,5 @@ func init() {
web.Router("/reward-summary/public-notice/yield", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeYield")
web.Router("/reward-summary/public-notice/up-to-standard", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeUpToStandard")
web.Router("/reward-summary/public-notice/accident", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeAccident")
web.Router("/reward-summary/public-notice/month", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeMonth")
}
... ...