|
|
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"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -175,3 +178,461 @@ func (data ExportCooperationUserData) DataListLen() int { |
|
|
func (data ExportCooperationUserData) TableTitle() []string {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//ExportProductsData 导出产品数据
|
|
|
type ExportProductsData struct {
|
|
|
SourceData []allied_creation_manufacture.SearchProductItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportProductsData)(nil)
|
|
|
|
|
|
func (data ExportProductsData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "productCode", CnName: "产品编号"},
|
|
|
{EnName: "productName", CnName: "*品名"},
|
|
|
{EnName: "unit", CnName: "*规格"},
|
|
|
{EnName: "productCategory", CnName: "*类别"},
|
|
|
{EnName: "unitWeight", CnName: "投入单份重量"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportProductsData) 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 ExportProductsData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "productCode":
|
|
|
return data.SourceData[index].ProductCode
|
|
|
case "productName":
|
|
|
return data.SourceData[index].ProductName
|
|
|
case "unit":
|
|
|
return data.SourceData[index].Unit
|
|
|
case "productCategory":
|
|
|
return data.SourceData[index].ProductCategory
|
|
|
case "unitWeight":
|
|
|
return fmt.Sprintf("%v", data.SourceData[index].UnitWeight)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportProductsData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
//ExportEmployeeAttendanceStaticsData 导出员工产能数据
|
|
|
type ExportEmployeeAttendanceStaticsData struct {
|
|
|
SourceData []allied_creation_manufacture.SearchEmployeeAttendanceStaticsItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportEmployeeAttendanceStaticsData)(nil)
|
|
|
|
|
|
func (data ExportEmployeeAttendanceStaticsData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "signDate", CnName: "日期"},
|
|
|
{EnName: "workshopName", CnName: "车间名称"},
|
|
|
{EnName: "lineName", CnName: "线别"},
|
|
|
{EnName: "sectionName", CnName: "工段"},
|
|
|
{EnName: "userName", CnName: "姓名"},
|
|
|
{EnName: "employeeTypeDescription", CnName: "员工类型"},
|
|
|
{EnName: "attendanceTypeDescription", CnName: "类别"},
|
|
|
{EnName: "workTime", CnName: "工时"},
|
|
|
{EnName: "attendanceStatusDescription", CnName: "状态"},
|
|
|
{EnName: "orgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeAttendanceStaticsData) 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 ExportEmployeeAttendanceStaticsData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "signDate":
|
|
|
return data.SourceData[index].SignDate
|
|
|
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 "employeeTypeDescription":
|
|
|
return data.SourceData[index].EmployeeTypeDescription
|
|
|
case "attendanceTypeDescription":
|
|
|
return data.SourceData[index].AttendanceTypeDescription
|
|
|
case "workTime":
|
|
|
return fmt.Sprintf("%vh", data.SourceData[index].WorkTime)
|
|
|
case "attendanceStatusDescription":
|
|
|
return data.SourceData[index].AttendanceStatusDescription
|
|
|
case "orgName":
|
|
|
return data.SourceData[index].OrgName
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeAttendanceStaticsData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportEmployeeAttendanceStaticsData) TableTitle() []string {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//ExportWorkshopAttendanceStaticsData 导出车间工时统计
|
|
|
type ExportWorkshopAttendanceStaticsData struct {
|
|
|
SourceData []allied_creation_manufacture.SearchWorkshopWorkTimeStaticsItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportWorkshopAttendanceStaticsData)(nil)
|
|
|
|
|
|
func (data ExportWorkshopAttendanceStaticsData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "recordDate", CnName: "日期"},
|
|
|
{EnName: "workshopName", CnName: "车间名称"},
|
|
|
{EnName: "lineName", CnName: "线别"},
|
|
|
{EnName: "sectionName", CnName: "工段"},
|
|
|
{EnName: "eftWorkTime", CnName: "固定工时"},
|
|
|
{EnName: "edWorkTime", CnName: "临时工时"},
|
|
|
{EnName: "epWorkTime", CnName: "派遣工时"},
|
|
|
{EnName: "orgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopAttendanceStaticsData) 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 ExportWorkshopAttendanceStaticsData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "recordDate":
|
|
|
return data.SourceData[index].RecordDate
|
|
|
case "workshopName":
|
|
|
return data.SourceData[index].WorkshopName
|
|
|
case "lineName":
|
|
|
return data.SourceData[index].LineName
|
|
|
case "sectionName":
|
|
|
return data.SourceData[index].SectionName
|
|
|
case "eftWorkTime":
|
|
|
return data.SourceData[index].EftWorkTime
|
|
|
case "edWorkTime":
|
|
|
return data.SourceData[index].EdWorkTime
|
|
|
case "epWorkTime":
|
|
|
return data.SourceData[index].EptWorkTime
|
|
|
case "orgName":
|
|
|
return data.SourceData[index].OrgName
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopAttendanceStaticsData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportWorkshopAttendanceStaticsData) TableTitle() []string {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//ExportWorkshopProductiveData 导出员工产能数据
|
|
|
type ExportSecondLevelData struct {
|
|
|
SourceData []allied_creation_manufacture.SecondLevelRecordItem
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportSecondLevelData)(nil)
|
|
|
|
|
|
func (data ExportSecondLevelData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "workshopName", CnName: "车间名称"},
|
|
|
{EnName: "lineName", CnName: "线别"},
|
|
|
{EnName: "sectionName", CnName: "工段"},
|
|
|
{EnName: "workOn", CnName: "班别"},
|
|
|
{EnName: "userName", CnName: "姓名"},
|
|
|
{EnName: "employeeType", CnName: "员工类型"},
|
|
|
{EnName: "batchNumber", CnName: "批次号"},
|
|
|
{EnName: "planProductName", CnName: "生产品名"},
|
|
|
{EnName: "weightBefore", CnName: "二级品"},
|
|
|
{EnName: "createdAt", CnName: "提报时间"},
|
|
|
{EnName: "orgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportSecondLevelData) 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 ExportSecondLevelData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
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 "workOn":
|
|
|
return domain.WorkOnDescription(data.SourceData[index].WorkOn)
|
|
|
case "employeeType":
|
|
|
return domain.EmployeeTypeDescription(data.SourceData[index].ProductWorker.EmployeeType)
|
|
|
case "batchNumber":
|
|
|
return data.SourceData[index].BatchNumber
|
|
|
case "planProductName":
|
|
|
return data.SourceData[index].PlanProductName
|
|
|
case "weightBefore":
|
|
|
return fmt.Sprintf("%vKg", data.SourceData[index].WeightBefore)
|
|
|
case "createdAt":
|
|
|
return data.SourceData[index].CreatedAt
|
|
|
case "orgName":
|
|
|
return data.SourceData[index].OrgName
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportSecondLevelData) DataListLen() int {
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportSecondLevelData) TableTitle() []string {
|
|
|
return nil
|
|
|
} |
...
|
...
|
|