作者 Your Name

更新

... ... @@ -6,6 +6,7 @@ type RewardSummaryList struct {
WorkshopName string `json:"workshopName"` //车间名称
LineName string `json:"lineName"` //线别名称
SectionName string `json:"sectionName"` //工段
WorkerName string `json:"workerName"` //员工名字
Yield string `json:"yield"` //产效
UpToStandard string `json:"upToStandard"` //合格率
Accident1 string `json:"accident1"` //质量事故
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao"
)
//功过看板 展示(员工)
// RewardSummaryPublicNoticeDay 功过看板 日榜
func (srv ProductTroubleService) RewardSummaryPublicNoticeDay() (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.SeachRewardSummaryDay(23, 467, "2022-10-29")
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,
"recordDay": "2022-10-29",
}
return result, nil
}
// RewardSummaryPublicNoticeYield 功过看板 产效
func (srv ProductTroubleService) RewardSummaryPublicNoticeYield() (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.SeachRewardSummaryYield(23, 467, "2022-10-29")
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
}
// RewardSummaryPublicNoticeUpToStandard 功过看板 合格率
func (srv ProductTroubleService) RewardSummaryPublicNoticeUpToStandard() (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.SeachRewardUpToStandard(23, 467, "2022-10-29")
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
}
// RewardSummaryPublicNoticeDay 功过看板 异常
func (srv ProductTroubleService) RewardSummaryPublicNoticeAccident() (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.SeachRewardUpToStandard(23, 467, "2022-10-29")
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
}
... ...
... ... @@ -531,6 +531,7 @@ func (srv ProductTroubleService) ListRewardSummary(param *query.ListRewardSummar
WorkshopName: v.WorkStation.WorkshopName,
LineName: v.WorkStation.LineName,
SectionName: v.WorkStation.SectionName,
WorkerName: v.Worker.UserName,
Yield: fmt.Sprintf("%.2f", v.Yield),
UpToStandard: fmt.Sprintf("%.2f%%", v.UpToStandard),
Accident1: fmt.Sprintf("%d次%.2f元", v.AccidentNum1, v.AccidentAmount1),
... ...
... ... @@ -12,6 +12,11 @@ import (
type CommonStatisticsService struct {
}
func NewCommonStatisticsService(options map[string]interface{}) *CommonStatisticsService {
newProductSectionService := &CommonStatisticsService{}
return newProductSectionService
}
// CommonStatisticsService 通用的统计服务
func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonStatisticsQuery) (interface{}, error) {
if err := cmd.ValidateQuery(); err != nil {
... ... @@ -39,8 +44,3 @@ func (svr *CommonStatisticsService) CommonStatisticsService(cmd *query.CommonSta
}
return response, nil
}
func NewCommonStatisticsService(options map[string]interface{}) *CommonStatisticsService {
newProductSectionService := &CommonStatisticsService{}
return newProductSectionService
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type RewardSumaryDao struct {
transactionContext *pgTransaction.TransactionContext
}
func NewRewardSumaryDao(transactionContext *pgTransaction.TransactionContext) (*RewardSumaryDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &RewardSumaryDao{
transactionContext: transactionContext,
}, nil
}
}
// 功过看板-日榜
type RewardSummaryDay struct {
Id int `json:"id"` //id
RecordDateStr string `json:"record_date_str"`
SectionName string `json:"sectionName"` //工段名称
WorkerName string `json:"workerName"` //员工名称
SummaryResult string `json:"summaryResult"` //奖惩结果
YieldResult string `json:"yieldResult"` //产效功过结果
UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果
AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果
AccidentResul2 string `json:"accidentResul2"` //安全事故功过结果
AccidentResul3 string `json:"accidentResul3"` //异物 功过结果
}
// 功过看板-日榜
func (d *RewardSumaryDao) SeachRewardSummaryDay(companyId int, orgId int, recordDate string) ([]RewardSummaryDay, error) {
sqlStr := `SELECT
"id",record_date_str,
work_station->>'sectionName',
worker->>'userName' as worker_name,
summary_result,
yield_result,
up_to_standard_result,
accident_result1,
accident_result2,
accident_result3
FROM "reward_summary"
WHERE company_id=?
and org_id=?
and record_date_str=?`
tx := d.transactionContext.PgTx
var result []RewardSummaryDay
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
return result, err
}
// 功过看板-产效
type RewardSummaryYield struct {
RecordDateStr string `json:"record_date_str"`
SectionName string `json:"sectionName"` //工段名称
WorkerName string `json:"workerName"` //员工名称
Yield string `json:"yield"` //产效
YieldResult string `json:"yieldResult"` //产效功过结果
YieldMax string `json:"yildMax"` //产效历史最佳
}
// 功过看板-产效
func (d *RewardSumaryDao) SeachRewardSummaryYield(companyId int, orgId int, recordDate string) ([]RewardSummaryYield, error) {
sqlStr := `SELECT
record_date_str,
work_station->>'sectionName',
worker->>'userName' as worker_name,
yield_result,
yield,
"24" as yield_max
FROM "reward_summary"
WHERE company_id=?
and org_id=?
and record_date_str=?`
tx := d.transactionContext.PgTx
var result []RewardSummaryYield
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
return result, err
}
// 功过看板-合格率
type RewardSummaryUpToStandard struct {
RecordDateStr string `json:"record_date_str"`
SectionName string `json:"sectionName"` //工段名称
WorkerName string `json:"workerName"` //员工名称
UpToStandard string `json:"upToStandard"` //合格率
UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果
UpToStandardMax string `json:"upToStandardMax"` //合格率历史最佳
}
// 功过看板-合格率
func (d *RewardSumaryDao) SeachRewardUpToStandard(companyId int, orgId int, recordDate string) ([]RewardSummaryUpToStandard, error) {
sqlStr := `SELECT
"id",record_date_str,
work_station->>'sectionName',
worker->>'userName' as worker_name,
up_to_standard_result,
up_to_standard,
'90' as up_to_standard_max
FROM "reward_summary"
WHERE company_id=23
and org_id=487
and record_date_str='2022-10-29'`
tx := d.transactionContext.PgTx
var result []RewardSummaryUpToStandard
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
return result, err
}
// 功过看板-异常
type RewardAccident struct {
RecordDateStr string `json:"record_date_str"`
SectionName string `json:"sectionName"` //工段名称
WorkerName string `json:"workerName"` //员工名称
SummaryResult string `json:"summaryResult"` //奖惩结果
YieldResult string `json:"yieldResult"` //产效功过结果
UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果
AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果
AccidentResul2 string `json:"accidentResul2"` //安全事故功过结果
AccidentResul3 string `json:"accidentResul3"` //异物 功过结果
}
// 功过看板-异常
func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDate string) ([]RewardAccident, error) {
sqlStr := `SELECT
"id",record_date_str,
work_station->>'sectionName',
worker->>'userName' as worker_name,
up_to_standard_result,
up_to_standard,
'90' as up_to_standard_max
FROM "reward_summary"
WHERE company_id=?
and org_id=?
and record_date_str=?`
tx := d.transactionContext.PgTx
var result []RewardAccident
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
return result, err
}
... ...
... ... @@ -13,7 +13,8 @@ type RewardSummary struct {
CompanyId int ``
OrgId int ``
RecordDate time.Time //日期
RecordDateStr string //
RecordDateStr string //日期 ;2006-01-02
RecordMonthStr string //月份 :200601
WorkStation domain.WorkStation // 工作位置
Worker domain.User //员工
UpToStandard float64 //合格率
... ...
... ... @@ -83,3 +83,31 @@ func (c *ProductTroubleController) ListRewardSummary() {
total, data, err := srv.ListRewardSummary(&getQuery)
ResponseGrid(c.BaseController, total, data, err)
}
// 功过看板 日榜
func (c *ProductTroubleController) RewardSummaryPublicNoticeDay() {
srv := service.NewProductTroubleService(nil)
data, err := srv.RewardSummaryPublicNoticeDay()
c.Response(data, err)
}
// 功过看板 产效
func (c *ProductTroubleController) RewardSummaryPublicNoticeYield() {
srv := service.NewProductTroubleService(nil)
data, err := srv.RewardSummaryPublicNoticeYield()
c.Response(data, err)
}
// 功过看板 合格率
func (c *ProductTroubleController) RewardSummaryPublicNoticeUpToStandard() {
srv := service.NewProductTroubleService(nil)
data, err := srv.RewardSummaryPublicNoticeUpToStandard()
c.Response(data, err)
}
// 功过看板 异常
func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() {
srv := service.NewProductTroubleService(nil)
data, err := srv.RewardSummaryPublicNoticeAccident()
c.Response(data, err)
}
... ...
... ... @@ -13,4 +13,9 @@ func init() {
web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble")
web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble")
web.Router("/product_trouble/reward_summary/seach", &controllers.ProductTroubleController{}, "Post:ListRewardSummary")
web.Router("/reward-summary/public-notice/day", &controllers.ProductTroubleController{}, "Get:RewardSummaryPublicNoticeDay")
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")
}
... ...