feat:完善项目

This commit is contained in:
henry
2021-11-08 17:42:23 +08:00
parent 1cc95fb5ca
commit 08083d26d3
7 changed files with 315 additions and 125 deletions

View File

@ -15,8 +15,8 @@ type WorkInstance struct {
type WorkInstanceInfo struct {
ID uint64 `json:"-"`
Title string `json:"title"`
MaterialCode string `json:"material_code"`
MaterialTitle string `json:"material_title"`
EquipmentCode string `json:"equipment_code"`
EquipmentTitle string `json:"equipment_title"`
BreakdownTitle string `json:"breakdown_title"`
Priority int `json:"priority"`
Status int `json:"status"`
@ -26,9 +26,9 @@ type WorkInstanceInfo struct {
// 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", "m.code AS material_code", "m.title AS material_title", "w.priority",
Select("w.id", "w.title", "e.code AS equipment_code", "e.title AS equipment_title", "w.priority",
"GROUP_CONCAT(b.title) AS breakdown_title", "w.status", "w.created_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON w.material_id = m.id", model.NewManageMaterial().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON w.equipment_id = e.id", model.NewManageEquipment().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS b ON FIND_IN_SET(b.id, w.breakdown)", model.NewSysBreakdown().TableName())).
Where("w.is_deleted = ?", model.DeleteStatusForNot).
Group("w.id")

11
app/model/work_repair.go Normal file
View File

@ -0,0 +1,11 @@
package model
import "ArmedPolice/app/common/model"
type WorkRepair struct {
*model.WorkRepair
}
func NewWorkRepair() *WorkRepair {
return &WorkRepair{model.NewWorkRepair()}
}

View File

@ -2,7 +2,9 @@ package model
import (
"ArmedPolice/app/common/model"
"ArmedPolice/serve/orm"
"fmt"
"gorm.io/gorm"
)
type WorkSchedule struct {
@ -47,6 +49,21 @@ func (m *WorkSchedule) ValidateAuth(uid uint64) (bool, error) {
return false, nil
}
// FirstSchedule 第一个流程
func (m *WorkSchedule) FirstSchedule() (bool, error) {
db := orm.GetDB().Table(m.TableName()).Select("id", "title", "stage", "step").
Where("is_deleted = ?", model.DeleteStatusForNot).
Order("stage " + model.OrderModeToAsc).Order("step " + model.OrderModeToAsc)
if err := db.First(m.WorkSchedule).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return false, nil
}
return false, err
}
return true, nil
}
// NextSchedule 下一流程
func (m *WorkSchedule) NextSchedule(isAssets bool) (*WorkScheduleInfo, error) {
next := NewWorkSchedule()