...
|
...
|
@@ -3,6 +3,7 @@ package service |
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/linmadan/egglib-go/utils/excel"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
|
|
)
|
...
|
...
|
@@ -239,3 +240,171 @@ func (data ExportProductsData) DataListLen() int { |
|
|
func (data ExportProductsData) TableTitle() []string {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//ExportEmployeeProductiveData 导出员工产能数据
|
|
|
type ExportEmployeeProductiveData struct {
|
|
|
SourceData []allied_creation_manufacture.EmployeeProductiveItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportEmployeeProductiveData)(nil)
|
|
|
|
|
|
func (data ExportEmployeeProductiveData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "createdAt", CnName: "日期"},
|
|
|
{EnName: "workshopName", CnName: "车间名称"},
|
|
|
{EnName: "lineName", CnName: "线别"},
|
|
|
{EnName: "sectionName", CnName: "工段"},
|
|
|
{EnName: "workOn", CnName: "班别"},
|
|
|
{EnName: "userName", CnName: "姓名"},
|
|
|
{EnName: "employeeType", CnName: "员工类型"},
|
|
|
{EnName: "participateType", CnName: "类别"},
|
|
|
{EnName: "planProductName", CnName: "品名"},
|
|
|
{EnName: "productWeigh", CnName: "产能"},
|
|
|
{EnName: "secondLevelWeigh", CnName: "二级品"},
|
|
|
{EnName: "qualificationRate", CnName: "合格率"},
|
|
|
{EnName: "orgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeProductiveData) DataFieldList() []excel.DataField {
|
|
|
fields := []excel.DataField{}
|
|
|
allFields := data.AllFields()
|
|
|
for _, value2 := range allFields {
|
|
|
if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
continue
|
|
|
}
|
|
|
for _, value3 := range data.SelectedField {
|
|
|
if value2.EnName == value3 {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return fields
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeProductiveData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "createdAt":
|
|
|
return data.SourceData[index].CreatedAt
|
|
|
case "workshopName":
|
|
|
return data.SourceData[index].WorkshopName
|
|
|
case "lineName":
|
|
|
return data.SourceData[index].LineName
|
|
|
case "sectionName":
|
|
|
return data.SourceData[index].SectionName
|
|
|
case "workOn":
|
|
|
return data.SourceData[index].WorkOn
|
|
|
case "userName":
|
|
|
return data.SourceData[index].ProductWorker.UserName
|
|
|
case "employeeType":
|
|
|
return domain.EmployeeTypeDescription(data.SourceData[index].ProductWorker.EmployeeType)
|
|
|
case "participateType":
|
|
|
return domain.ParticipateTypeDescription(data.SourceData[index].ParticipateType)
|
|
|
case "planProductName":
|
|
|
return data.SourceData[index].PlanProductName
|
|
|
case "productWeigh":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].ProductWeigh)
|
|
|
case "secondLevelWeigh":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].SecondLevelWeigh)
|
|
|
case "qualificationRate":
|
|
|
return fmt.Sprintf("%v%%", data.SourceData[index].QualificationRate)
|
|
|
case "orgName":
|
|
|
return data.SourceData[index].OrgName
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeProductiveData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeProductiveData) TableTitle() []string {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//ExportWorkshopProductiveData 导出员工产能数据
|
|
|
type ExportWorkshopProductiveData struct {
|
|
|
SourceData []allied_creation_manufacture.WorkshopProductiveItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportWorkshopProductiveData)(nil)
|
|
|
|
|
|
func (data ExportWorkshopProductiveData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "createdAt", CnName: "日期"},
|
|
|
{EnName: "batchNumber", CnName: "批次号"},
|
|
|
{EnName: "workshopName", CnName: "车间名称"},
|
|
|
{EnName: "lineName", CnName: "线别"},
|
|
|
{EnName: "sectionName", CnName: "工段"},
|
|
|
{EnName: "planProductName", CnName: "品名"},
|
|
|
{EnName: "devotedProductWeigh", CnName: "投入量"},
|
|
|
{EnName: "productWeigh", CnName: "产出量"},
|
|
|
{EnName: "secondLevelWeigh", CnName: "二级品"},
|
|
|
{EnName: "qualificationRate", CnName: "出品率"},
|
|
|
{EnName: "orgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopProductiveData) DataFieldList() []excel.DataField {
|
|
|
fields := []excel.DataField{}
|
|
|
allFields := data.AllFields()
|
|
|
for _, value2 := range allFields {
|
|
|
if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
continue
|
|
|
}
|
|
|
for _, value3 := range data.SelectedField {
|
|
|
if value2.EnName == value3 {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return fields
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopProductiveData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "createdAt":
|
|
|
return data.SourceData[index].CreatedAt
|
|
|
case "batchNumber":
|
|
|
return data.SourceData[index].BatchNumber
|
|
|
case "workshopName":
|
|
|
return data.SourceData[index].WorkshopName
|
|
|
case "lineName":
|
|
|
return data.SourceData[index].LineName
|
|
|
case "sectionName":
|
|
|
return data.SourceData[index].SectionName
|
|
|
case "userName":
|
|
|
return data.SourceData[index].ProductWorker.UserName
|
|
|
case "planProductName":
|
|
|
return data.SourceData[index].PlanProductName
|
|
|
case "devotedProductWeigh":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].DevotedProductWeigh)
|
|
|
case "productWeigh":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].ProductWeigh)
|
|
|
case "secondLevelWeigh":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].SecondLevelWeigh)
|
|
|
case "qualificationRate":
|
|
|
return fmt.Sprintf("%v%%", data.SourceData[index].QualificationRate)
|
|
|
case "orgName":
|
|
|
return data.SourceData[index].OrgName
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopProductiveData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopProductiveData) TableTitle() []string {
|
|
|
return nil
|
|
|
} |
...
|
...
|
|