feat:完善项目
This commit is contained in:
@ -17,11 +17,13 @@ type (
|
||||
WorkInstanceInfo struct {
|
||||
ID uint64 `json:"-"`
|
||||
Title string `json:"title"`
|
||||
OrderNo string `json:"order_no"`
|
||||
Kind model.WorkInstanceKind `json:"kind"`
|
||||
EquipmentCode string `json:"equipment_code"`
|
||||
EquipmentTitle string `json:"equipment_title"`
|
||||
BreakdownTitle string `json:"breakdown_title"`
|
||||
ScheduleTitle string `json:"schedule_title"`
|
||||
SupplierName string `json:"-"`
|
||||
Priority int `json:"priority"`
|
||||
Distribution string `json:"distribution"`
|
||||
Status int `json:"status"`
|
||||
@ -54,9 +56,10 @@ func (m *WorkInstance) Detail(id uint64) (*WorkInstanceInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
||||
Select("w.id", "w.kind", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
"(SELECT GROUP_CONCAT(s_b.title) FROM ( SELECT id, title FROM sys_breakdown) AS s_b WHERE FIND_IN_SET( s_b.id, w.breakdown )) AS breakdown_title",
|
||||
"s.title AS schedule_title", "w.distribution", "w.status", "w.created_at").
|
||||
"s.title AS schedule_title", "supplier.name AS supplier_name", "w.distribution", "w.status", "w.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON w.schedule = s.id", model.NewWorkSchedule().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS supplier ON w.supplier_id = supplier.id", model.NewManageSupplier().TableName())).
|
||||
Where("w.id = ?", id)
|
||||
|
||||
out := new(WorkInstanceInfo)
|
||||
@ -70,7 +73,7 @@ func (m *WorkInstance) Detail(id uint64) (*WorkInstanceInfo, error) {
|
||||
// Instances 基本信息
|
||||
func (m *WorkInstance) Instances(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
||||
Select("w.id", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
Select("w.id", "w.order_no", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
"(SELECT GROUP_CONCAT(s_b.title) FROM ( SELECT id, title FROM sys_breakdown) AS s_b WHERE FIND_IN_SET( s_b.id, w.breakdown )) AS breakdown_title",
|
||||
"s.title AS schedule_title", "w.status", "u.name AS username", "w.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
|
||||
@ -98,7 +101,7 @@ func (m *WorkInstance) Instances(page, pageSize int, count *int64, where ...*mod
|
||||
// Persons 个人信息
|
||||
func (m *WorkInstance) Persons(uid uint64, page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
||||
Select("w.id", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
Select("w.id", "w.order_no", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
"(SELECT GROUP_CONCAT(s_b.title) FROM ( SELECT id, title FROM sys_breakdown) AS s_b WHERE FIND_IN_SET( s_b.id, w.breakdown )) AS breakdown_title",
|
||||
"s.title AS schedule_title", "w.status", "w.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
|
||||
@ -137,13 +140,14 @@ ELSE "" END`, "s.target",
|
||||
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
||||
Select("w.id", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
Select("w.id", "w.order_no", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
"(SELECT GROUP_CONCAT(s_b.title) FROM (SELECT id, title FROM sys_breakdown) AS s_b WHERE FIND_IN_SET( s_b.id, w.breakdown )) AS breakdown_title",
|
||||
"s.title AS schedule_title", "w.status", "u.name AS username", "w.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON w.schedule = s.id", mWorkSchedule.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON w.uid = u.uuid", model.NewSysUser().TableName())).
|
||||
Where("w.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("w.status = ?", model.WorkInstanceStatusForOngoing).
|
||||
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
||||
|
||||
if len(where) > 0 {
|
||||
@ -175,12 +179,14 @@ ELSE "" END`, "s.target",
|
||||
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
||||
Select("w.id", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
Select("w.id", "w.order_no", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
|
||||
"(SELECT GROUP_CONCAT(s_b.title) FROM (SELECT id, title FROM sys_breakdown) AS s_b WHERE FIND_IN_SET( s_b.id, w.breakdown )) AS breakdown_title",
|
||||
"s.title AS schedule_title", "w.status", "w.created_at").
|
||||
"s.title AS schedule_title", "w.status", "u.name AS username", "w.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON w.schedule = s.id", mWorkSchedule.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON w.uid = u.uuid", model.NewSysUser().TableName())).
|
||||
Where("w.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("w.status = ?", model.WorkInstanceStatusForOngoing).
|
||||
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
||||
|
||||
if len(where) > 0 {
|
||||
|
Reference in New Issue
Block a user