productJobDto.go 2.1 KB
package dto

import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"

type ProductJobDto struct {
	// 工位ID
	ProductJobId int `json:"productJobId,omitempty"`
	// 工位名称
	JobName string `json:"jobName,omitempty"`
	// 工序名称
	ProcessName string `json:"processName,omitempty"`
	//// 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID)
	//WorkStationId string `json:"workStationId,omitempty"`
	//// 车间ID
	//WorkshopId int `json:"workshopId,omitempty"`
	//// 车间名称
	//WorkshopName string `json:"workshopName,omitempty"`
	//// 生产线ID
	//LineId int `json:"lineId,omitempty"`
	//// 生产线名称
	//LineName string `json:"lineName,omitempty"`
	//// 工段ID
	//SectionId int `json:"sectionId,omitempty"`
	//// 工段名称
	//SectionName string `json:"sectionName,omitempty"`
	//// 负责人 (用户对象)
	//Principal *domain.User `json:"principal,omitempty"`
	*domain.WorkStation
	// 组织名称
	//OrgName string `json:"orgName"`
	// 权限标识 (当前登录组织匹配为true,否则false)
	//AuthFlag bool `json:"authFlag"`
	// 关联设备列表
	RelatedDevices []int `json:"relatedDevices,omitempty"`
	// 关联设备列表
	RelatedDeviceList []DeviceDto `json:"relatedDevicesList,omitempty"`
}

type DeviceDto struct {
	// 设备Id
	DeviceId int `json:"deviceId,omitempty"`
	// 设备编号
	DeviceCode string `json:"deviceCode,omitempty"`
	// 设备名称
	DeviceName string `json:"deviceName,omitempty"`
}

func (d *ProductJobDto) LoadDto(job *domain.ProductJob, orgId int) {
	d.ProductJobId = job.ProductJobId
	d.JobName = job.JobName
	d.ProcessName = job.ProcessName
	d.WorkStation = job.WorkStation
	d.RelatedDevices = job.RelatedDevices
	//d.AuthFlag = domain.CheckOrgAuth(orgId, job.OrgId)
	//if job.Ext != nil {
	//	d.OrgName = job.Ext.OrgName
	//}
}

func (d *ProductJobDto) WithRelatedDevicesList(devices []*domain.Device) *ProductJobDto {
	for i := range devices {
		d.RelatedDeviceList = append(d.RelatedDeviceList, DeviceDto{
			DeviceName: devices[i].DeviceName,
			DeviceId:   devices[i].DeviceId,
			DeviceCode: devices[i].DeviceCode,
		})
	}
	return d
}