product_trouble_controller.go 4.3 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/service"
)

type ProductTroubleController struct {
	beego.BaseController
}

// 创建事故记录
func (c *ProductTroubleController) CreatedProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	createCommand := &command.CreateProductTroubleCommand{}
	Must(c.Unmarshal(createCommand))
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.CreateProductTrouble(operater, createCommand)
	c.Response(data, err)
}

// 更新事故记录
func (c *ProductTroubleController) UpdateProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	createCommand := &command.SaveProductTroubleCommand{}
	Must(c.Unmarshal(createCommand))
	id, _ := c.GetInt(":id")
	createCommand.Id = id
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.SaveProductTrouble(operater, createCommand)
	c.Response(data, err)
}

// 获取事故记录
func (c *ProductTroubleController) GetProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	id, _ := c.GetInt(":id")

	data, err := srv.GetProductTrouble(id)
	c.Response(data, err)
}

// 删除事故记录
func (c *ProductTroubleController) DeleteProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	getQuery := &query.GetProductTroubleQuery{}
	Must(c.Unmarshal(getQuery))
	err := srv.DeleteProductTrouble(int64(getQuery.Id))
	c.Response(nil, err)
}

// 获取事故记录列表
func (c *ProductTroubleController) ListProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	getQuery := query.ListProductTrouble{}
	Must(c.Unmarshal(&getQuery))
	operater := ParseOperateInfo(c.BaseController)
	getQuery.CompanyId = operater.CompanyId
	getQuery.OrgId = operater.OrgId
	total, data, err := srv.ListProductTrouble(&getQuery)
	ResponseGrid(c.BaseController, total, data, err)
}

// 审核事故记录
func (c *ProductTroubleController) ApproveProductTrouble() {
	srv := service.NewProductTroubleService(nil)
	getQuery := &query.GetProductTroubleQuery{}
	Must(c.Unmarshal(getQuery))
	operater := ParseOperateInfo(c.BaseController)
	err := srv.ApproveProductTrouble(operater, int64(getQuery.Id))
	c.Response(nil, err)
}

func (c *ProductTroubleController) ListRewardSummary() {
	srv := service.NewProductTroubleService(nil)
	getQuery := query.ListRewardSummaryQuery{}
	Must(c.Unmarshal(&getQuery))
	operater := ParseOperateInfo(c.BaseController)
	getQuery.CompanyId = operater.CompanyId
	getQuery.OrgId = operater.OrgId
	total, data, err := srv.ListRewardSummary(&getQuery)
	ResponseGrid(c.BaseController, total, data, err)
}

// 功过看板 日榜
func (c *ProductTroubleController) RewardSummaryPublicNoticeDay() {
	srv := service.NewProductTroubleService(nil)
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.RewardSummaryPublicNoticeDay(operater)
	c.Response(data, err)
}

// 功过看板 产效
func (c *ProductTroubleController) RewardSummaryPublicNoticeYield() {
	srv := service.NewProductTroubleService(nil)
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.RewardSummaryPublicNoticeYield(operater)
	c.Response(data, err)
}

// 功过看板 合格率
func (c *ProductTroubleController) RewardSummaryPublicNoticeUpToStandard() {
	srv := service.NewProductTroubleService(nil)
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.RewardSummaryPublicNoticeUpToStandard(operater)
	c.Response(data, err)
}

// 功过看板 异常
func (c *ProductTroubleController) RewardSummaryPublicNoticeAccident() {
	srv := service.NewProductTroubleService(nil)
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.RewardSummaryPublicNoticeAccident(operater)
	c.Response(data, err)
}

// 功过看板 月榜
func (c *ProductTroubleController) RewardSummaryPublicNoticeMonth() {
	srv := service.NewProductTroubleService(nil)
	operater := ParseOperateInfo(c.BaseController)
	data, err := srv.RewardSummaryPublicNoticeMonth(operater)
	c.Response(data, err)
}