作者 yangfu

fix: 导入修改

package query
import (
"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"
)
type ManufactureSecondLevelRecordQuery struct {
*allied_creation_manufacture.SearchSecondLevelRecordRequest
//操作人
Operator domain.Operator `json:"-"`
SelectedField []string `json:"selectedField"`
}
... ...
... ... @@ -99,6 +99,25 @@ func (srv ExcelDataService) ExportWorkshopProductive(cmd *query.ManufactureWorks
return ExportWorkshopProductiveData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
}
// ExportSecondLevelRecord 二级废品
func (srv ExcelDataService) ExportSecondLevelRecord(cmd *query.ManufactureSecondLevelRecordQuery) (ExportSecondLevelData, error) {
creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
result, err := creationUserGateway.SearchSecondLevelRecord(allied_creation_manufacture.SearchSecondLevelRecordRequest{
WorkshopName: cmd.WorkshopName,
BatchNumber: cmd.BatchNumber,
UserName: cmd.UserName,
LineName: cmd.LineName,
SectionName: cmd.SectionName,
EmployeeType: cmd.EmployeeType,
BeginTime: cmd.BeginTime,
EndTime: cmd.EndTime,
})
if err != nil {
return ExportSecondLevelData{}, fmt.Errorf("获取二级废品数据失败:%w", err)
}
return ExportSecondLevelData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
}
// ExportEmployeeAttendanceStatics 导出员工工时
func (srv ExcelDataService) ExportEmployeeAttendanceStatics(cmd *query.ManufactureExportEmployeeAttendanceStaticsQuery) (ExportEmployeeAttendanceStaticsData, error) {
creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
... ...
... ... @@ -556,3 +556,83 @@ func (data ExportWorkshopAttendanceStaticsData) DataListLen() int {
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
}
... ...
... ... @@ -82,6 +82,8 @@ const (
ExportManufactureEmployeeProductive = "ExportManufactureEmployeeProductive"
// 导出车间产能统计
ExportManufactureWorkshopProductive = "ExportManufactureWorkshopProductive"
// 报废记录
ExportSecondLevelRecord = "ExportSecondLevelRecord"
// 员工工时
ExportManufactureEmployeeAttendanceStatics = "ExportManufactureEmployeeAttendanceStatics"
... ... @@ -125,3 +127,27 @@ func ParticipateTypeDescription(participateType int) string {
}
return "正常"
}
// 班次
const (
WorkOnFullDay = 1 //全天
WorkOnDay = 2 //白班
WorkOnMidDay = 4 //中班
WorkOnNight = 8 //夜班
)
func WorkOnDescription(workOn int) string {
if workOn&WorkOnFullDay > 0 {
return "全天"
}
if workOn&WorkOnDay > 0 {
return "白班"
}
if workOn&WorkOnMidDay > 0 {
return "中班"
}
if workOn&WorkOnNight > 0 {
return "夜班"
}
return ""
}
... ...
... ... @@ -226,6 +226,75 @@ type (
}
)
//SearchProduct 搜索员工产能统计
func (gateway HttpLibAlliedCreationManufacture) SearchSecondLevelRecord(param SearchSecondLevelRecordRequest) (*SearchSecondLevelRecordResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/second-level-record/search")
method := "post"
var data SearchSecondLevelRecordResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
SearchSecondLevelRecordRequest struct {
// 车间名称
WorkshopName string `cname:"车间名称" json:"workshopName"`
// 批号
BatchNumber string `cname:"批号" json:"batchNumber"`
// 姓名
UserName string `cname:"姓名" json:"userName"`
// 生产记录类型:1:领料 2:退料 4:称重 8:二级品称重
//ProductRecordType int `cname:"生产记录类型:1:领料 2:退料 4:称重 8:二级品称重"`
// 生产线名称
LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType int `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime string `cname:"结束时间" json:"endTime"`
}
SearchSecondLevelRecordResponse struct {
Grid struct {
List []SecondLevelRecordItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
SecondLevelRecordItem struct {
ProductRecordID int `json:"productRecordId"`
ProductWorker struct {
UserID int `json:"userId"`
UserName string `json:"userName"`
EmployeeType int `json:"employeeType"`
Phone string `json:"phone"`
} `json:"productWorker"`
WorkStationID string `json:"workStationId"`
WorkshopID int `json:"workshopId"`
WorkshopName string `json:"workshopName"`
LineID int `json:"lineId"`
LineName string `json:"lineName"`
SectionID int `json:"sectionId"`
SectionName string `json:"sectionName"`
WorkOn int `json:"workOn"`
WeightBefore int `json:"weightBefore"`
WeightAfter int `json:"weightAfter"`
ApproveStatus int `json:"approveStatus"`
ApproveUser struct {
UserID int `json:"userId"`
UserName string `json:"userName"`
} `json:"approveUser"`
ApproveAt string `json:"approveAt"`
PlanProductName string `json:"planProductName"`
BatchNumber string `json:"batchNumber"`
CreatedDate string `json:"createdDate"`
CreatedAt string `json:"createdAt"`
OrgName string `json:"orgName"`
AuthFlag bool `json:"authFlag"`
}
)
/*** 考勤记录 ***/
//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibAlliedCreationManufacture) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
... ...