httplib_cost_structured.go 12.1 KB
package cost_structured

import (
	"fmt"
	"time"

	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)

//HttpLibCostStructured 成本结构化
type HttpLibCostStructured struct {
	service_gateway.BaseServiceGateway
	baseUrL string
}

func NewHttpLibCostStructured(operator domain.Operator) *HttpLibCostStructured {
	return &HttpLibCostStructured{
		BaseServiceGateway: service_gateway.BaseServiceGateway{
			ConnectTimeout:   100 * time.Second,
			ReadWriteTimeout: 100 * time.Second,
			CompanyId:        operator.CompanyId,
			OrgId:            operator.OrgId,
			InOrgIds:         operator.OrgIds,
			UserId:           operator.UserId,
			UserBaseId:       operator.UserBaseId,
		},
		baseUrL: constant.COST_STRUCTURED,
	}

}

func (gateway HttpLibCostStructured) BaseUrl() string {
	return gateway.baseUrL
}

//批量添加成本管理
func (gateway HttpLibCostStructured) BatchCreateCostManagemant(param BatchAddCostManagemantRequest) (*BatchAddCostManagemantResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/batch-update-cost-managemants")
	method := "post"
	var data BatchAddCostManagemantResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}
type BatchAddCostManagemantRequest struct {
	 *domain.BatchCreateCostManagemant
}
type BatchAddCostManagemantResponse []interface{}

func (gateway HttpLibCostStructured) ListCostManagemant(param ListCostManagemantRequest) (*ListCostManagemantResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/")
	method := "post"
	var data ListCostManagemantResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}







type (
	ListCostManagemantRequest struct {
		// 页码
		PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
		// 页数
		PageSize int `cname:"页数" json:"pageSize,omitempty"`
		// 查询项目(结构)类型
		Types int `cname:"查询项目(结构)类型" json:"types" valid:"Required"`
		// 查询项目id
		ProjectId int64 `cname:"查询项目id" json:"projectId"`
	}
	ListCostManagemantResponse struct {
		Grid struct {
			List  []SearchProductItem `json:"list"`
			Total int                 `json:"total"`
		} `json:"grid"`
	}
	SearchProductItem struct {
		ProductID       int     `json:"productId"`
		ProductCode     string  `json:"productCode"`
		ProductName     string  `json:"productName"`
		ProductCategory string  `json:"productCategory"`
		Unit            string  `json:"unit"`
		UnitWeight      float64 `json:"unitWeight"`
	}
)







/*设备*/



type BatchAddDeviceRequest struct {
	List []*domain.ImportDeviceItem `json:"list"`
}
type BatchAddDeviceResponse []interface{}

/**生产记录**/
//SearchProduct 搜索员工产能统计
func (gateway HttpLibCostStructured) SearchEmployeeProductive(param SearchEmployeeProductiveRequest) (*SearchEmployeeProductiveResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/employee-productive/search")
	method := "post"
	var data SearchEmployeeProductiveResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}

type (
	SearchEmployeeProductiveRequest struct {
		// 页码
		//PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
		// 页数
		//PageSize int `cname:"页数" json:"pageSize,omitempty"`
		// 车间名称
		WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
		// 生产线名称
		LineName string `cname:"生产线名称" json:"lineName,omitempty"`
		// 工段名称
		SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
		// 姓名
		UserName string `cname:"姓名" json:"userName"`
		// 员工类型  1:固定 2:派遣 3.临时
		EmployeeType string `cname:"员工类型  1:固定 2:派遣 3.临时" json:"employeeType"`
		// 开始时间
		BeginTime string `cname:"开始时间" json:"beginTime"`
		// 结束时间
		EndTime string `cname:"结束时间" json:"endTime"`
	}
	SearchEmployeeProductiveResponse struct {
		Grid struct {
			List  []EmployeeProductiveItem `json:"list"`
			Total int                      `json:"total"`
		} `json:"grid"`
	}
	EmployeeProductiveItem struct {
		EmployeeProductRecordID int `json:"employeeProductRecordId"`
		ProductWorker           struct {
			UserID       int    `json:"userId"`
			UserName     string `json:"userName"`
			Avatar       string `json:"avatar"`
			Phone        string `json:"phone"`
			EmployeeType int    `json:"employeeType"`
		} `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            string  `json:"workOn"`
		PlanProductName   string  `json:"planProductName"`
		BatchNumber       string  `json:"batchNumber"`
		ParticipateType   int     `json:"participateType"`
		ProductWeigh      float64 `json:"productWeigh"`
		SecondLevelWeigh  float64 `json:"secondLevelWeigh"`
		CreatedAt         string  `json:"createdAt"`
		OrgName           string  `json:"orgName"`
		AuthFlag          bool    `json:"authFlag"`
		QualificationRate int     `json:"qualificationRate"`
	}
)

//SearchProduct 搜索员工产能统计
func (gateway HttpLibCostStructured) SearchWorkshopProductive(param SearchWorkshopProductiveRequest) (*SearchWorkshopProductiveResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/workshop-productive/search")
	method := "post"
	var data SearchWorkshopProductiveResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}

type (
	SearchWorkshopProductiveRequest struct {
		// 品名
		PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
		// 工段名称
		SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
		// 开始时间
		BeginTime string `cname:"开始时间" json:"beginTime"`
		// 结束时间
		EndTime string `cname:"结束时间" json:"endTime"`
	}
	SearchWorkshopProductiveResponse struct {
		Grid struct {
			List  []WorkshopProductiveItem `json:"list"`
			Total int                      `json:"total"`
		} `json:"grid"`
	}
	WorkshopProductiveItem struct {
		EmployeeProductRecordID int `json:"employeeProductRecordId"`
		ProductWorker           struct {
			UserID       int    `json:"userId"`
			UserName     string `json:"userName"`
			Avatar       string `json:"avatar"`
			Phone        string `json:"phone"`
			EmployeeType int    `json:"employeeType"`
		} `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          string `json:"workOn"`
		PlanProductName string `json:"planProductName"`
		BatchNumber     string `json:"batchNumber"`
		//ParticipateType   int    `json:"participateType"`
		// 投入量
		DevotedProductWeigh float64 `json:"devotedProductWeigh"`
		// 产能
		ProductWeigh float64 `json:"productWeigh"`
		// 二级品产能
		SecondLevelWeigh  float64 `json:"secondLevelWeigh"`
		CreatedAt         string  `json:"createdAt"`
		OrgName           string  `json:"orgName"`
		AuthFlag          bool    `json:"authFlag"`
		QualificationRate int     `json:"qualificationRate"`
	}
)

/*** 考勤记录 ***/
//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibCostStructured) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/employee-attendance-statics/search")
	method := "post"
	var data SearchEmployeeAttendanceStaticsResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}

type (
	SearchEmployeeAttendanceStaticsRequest struct {
		// 车间名称
		WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
		// 生产线名称
		LineName string `cname:"生产线名称" json:"lineName,omitempty"`
		// 工段名称
		SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
		// 姓名
		UserName string `cname:"姓名" json:"userName,omitempty"`
		// 考勤状态 1.未审核 2:已审核 4.自动审核
		AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
		// 开始时间
		BeginTime string `cname:"开始时间" json:"beginTime"`
		// 结束时间
		EndTime string `cname:"结束时间" json:"endTime"`
	}
	SearchEmployeeAttendanceStaticsResponse struct {
		Grid struct {
			List  []SearchEmployeeAttendanceStaticsItem `json:"list"`
			Total int                                   `json:"total"`
		} `json:"grid"`
	}
	SearchEmployeeAttendanceStaticsItem struct {
		ProductAttendanceID int    `json:"productAttendanceId"`
		SignDate            string `json:"signDate"`
		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"`
		ProductWorker       struct {
			UserID       int    `json:"userId"`
			UserName     string `json:"userName"`
			EmployeeType int    `json:"employeeType"`
			Avatar       string `json:"avatar"`
			Phone        string `json:"phone"`
		} `json:"productWorker"`
		AttendanceType              int     `json:"attendanceType"`
		AttendanceStatus            int     `json:"attendanceStatus"`
		AttendanceTypeDescription   string  `json:"attendanceTypeDescription"`
		EmployeeTypeDescription     string  `json:"employeeTypeDescription"`
		AttendanceStatusDescription string  `json:"attendanceStatusDescription"`
		WorkTime                    float64 `json:"workTime"`
		OrgName                     string  `json:"orgName"`
		AuthFlag                    bool    `json:"authFlag"`
	}
)

//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibCostStructured) SearchWorkshopWorkTimeStatics(param SearchWorkshopWorkTimeStaticsRequest) (*SearchWorkshopWorkTimeStaticsResponse, error) {
	url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/workshop-attendance-statics/search")
	method := "post"
	var data SearchWorkshopWorkTimeStaticsResponse
	err := gateway.FastDoRequest(url, method, param, &data)
	return &data, err
}

type (
	SearchWorkshopWorkTimeStaticsRequest struct {
		// 车间名称
		WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
		// 生产线名称
		LineName string `cname:"生产线名称" json:"lineName,omitempty"`
		// 开始时间
		BeginTime string `cname:"开始时间" json:"beginTime"`
		// 结束时间
		EndTime string `cname:"结束时间" json:"endTime"`
	}
	SearchWorkshopWorkTimeStaticsResponse struct {
		Grid struct {
			List  []SearchWorkshopWorkTimeStaticsItem `json:"list"`
			Total int                                 `json:"total"`
		} `json:"grid"`
	}
	SearchWorkshopWorkTimeStaticsItem struct {
		WorkshopWorkTimeRecordID int     `json:"workshopWorkTimeRecordId"`
		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"`
		EftWorkTime              float64 `json:"eftWorkTime"`
		EdWorkTime               int     `json:"edWorkTime"`
		EptWorkTime              int     `json:"eptWorkTime"`
		RecordDate               string  `json:"recordDate"`
		OrgName                  string  `json:"orgName"`
		AuthFlag                 bool    `json:"authFlag"`
	}
)