feat:完善项目
This commit is contained in:
@ -135,7 +135,7 @@ func (*User) Select(c *gin.Context) {
|
|||||||
* "link": "",
|
* "link": "",
|
||||||
* "component": "",
|
* "component": "",
|
||||||
* "icon": "",
|
* "icon": "",
|
||||||
* "parent_id": "0",
|
* "parent_id": "",
|
||||||
* "checked": true,
|
* "checked": true,
|
||||||
* "checked": [],
|
* "checked": [],
|
||||||
* }
|
* }
|
||||||
@ -476,7 +476,7 @@ func (*User) Frozen(c *gin.Context) {
|
|||||||
* {
|
* {
|
||||||
* "id": "EgmJ4Ga7LQ",
|
* "id": "EgmJ4Ga7LQ",
|
||||||
* "name": "分管领导",
|
* "name": "分管领导",
|
||||||
* "parent_id": "0",
|
* "parent_id": "",
|
||||||
* "checked": true,
|
* "checked": true,
|
||||||
* "children": [
|
* "children": [
|
||||||
* {
|
* {
|
||||||
|
@ -200,15 +200,16 @@ func (*Work) Instance(c *gin.Context) {
|
|||||||
*/
|
*/
|
||||||
func (*Work) Person(c *gin.Context) {
|
func (*Work) Person(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
MaterialID uint64 `json:"material_id" form:"material_id"`
|
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
|
||||||
Kind int `json:"kind" form:"kind"`
|
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
|
||||||
|
Kind int `json:"kind" form:"kind"`
|
||||||
PageForm
|
PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := bind(form)(c); err != nil {
|
if err := bind(form)(c); err != nil {
|
||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Person(form.MaterialID, form.Kind, form.Page, form.PageSize)
|
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Person(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
|
||||||
APIResponse(err, data)(c)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,15 +264,16 @@ func (*Work) Person(c *gin.Context) {
|
|||||||
*/
|
*/
|
||||||
func (*Work) Workbench(c *gin.Context) {
|
func (*Work) Workbench(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
MaterialID uint64 `json:"material_id" form:"material_id"`
|
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
|
||||||
Kind int `json:"kind" form:"kind"`
|
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
|
||||||
|
Kind int `json:"kind" form:"kind"`
|
||||||
PageForm
|
PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := bind(form)(c); err != nil {
|
if err := bind(form)(c); err != nil {
|
||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Workbench(form.MaterialID, form.Kind, form.Page, form.PageSize)
|
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Workbench(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
|
||||||
APIResponse(err, data)(c)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ type WorkProgress struct {
|
|||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||||
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"-"`
|
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"-"`
|
||||||
ScheduleID uint64 `gorm:"column:schedule_id;type:int(11);default:0;comment:工单流程ID" json:"-"`
|
ScheduleID uint64 `gorm:"column:schedule_id;type:int(11);default:0;comment:工单流程ID" json:"-"`
|
||||||
Status WorkProgressStatus `gorm:"column:status;type:tinyint(1);default:1;comment:状态" json:"-"`
|
Status WorkProgressStatus `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"-"`
|
||||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
@ -18,8 +18,10 @@ type WorkProgressStatus int
|
|||||||
const (
|
const (
|
||||||
// WorkProgressStatusForRefuse 拒绝
|
// WorkProgressStatusForRefuse 拒绝
|
||||||
WorkProgressStatusForRefuse WorkProgressStatus = iota - 1
|
WorkProgressStatusForRefuse WorkProgressStatus = iota - 1
|
||||||
|
// WorkProgressStatusForCreate 新建
|
||||||
|
WorkProgressStatusForCreate
|
||||||
// WorkProgressStatusForAgree 同意
|
// WorkProgressStatusForAgree 同意
|
||||||
WorkProgressStatusForAgree WorkProgressStatus = iota
|
WorkProgressStatusForAgree
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *WorkProgress) TableName() string {
|
func (m *WorkProgress) TableName() string {
|
||||||
|
18
app/common/model/work_purchase.go
Normal file
18
app/common/model/work_purchase.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// WorkPurchase 工单采购数据模型
|
||||||
|
type WorkPurchase struct {
|
||||||
|
Model
|
||||||
|
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"-"`
|
||||||
|
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *WorkPurchase) TableName() string {
|
||||||
|
return "work_purchase"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWorkPurchase() *WorkPurchase {
|
||||||
|
return &WorkPurchase{}
|
||||||
|
}
|
@ -64,15 +64,11 @@ func (c *Equipment) tree(iModel model2.IModel, src []*model2.ManageEquipment, pa
|
|||||||
|
|
||||||
for _, v := range src {
|
for _, v := range src {
|
||||||
if v.ParentID == parentID {
|
if v.ParentID == parentID {
|
||||||
parentID := ""
|
iModel.SetID(v.ParentID)
|
||||||
|
|
||||||
if v.ParentID > 0 {
|
|
||||||
iModel.SetID(v.ParentID)
|
|
||||||
parentID = iModel.GetEncodeID()
|
|
||||||
}
|
|
||||||
out = append(out, &EquipmentInfo{
|
out = append(out, &EquipmentInfo{
|
||||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||||
ParentID: parentID,
|
ParentID: iModel.GetEncodeID(),
|
||||||
Code: v.Code,
|
Code: v.Code,
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
Image: v.Analysis(config.SettingInfo.Domain),
|
Image: v.Analysis(config.SettingInfo.Domain),
|
||||||
|
@ -44,15 +44,11 @@ func (c *Instance) tree(iModel model2.IModel, src []*model2.SysMenu, parentID ui
|
|||||||
|
|
||||||
for _, v := range src {
|
for _, v := range src {
|
||||||
if v.ParentID == parentID {
|
if v.ParentID == parentID {
|
||||||
parentID := "0"
|
iModel.SetID(v.ParentID)
|
||||||
|
|
||||||
if v.ParentID > 0 {
|
|
||||||
iModel.SetID(v.ParentID)
|
|
||||||
parentID = iModel.GetEncodeID()
|
|
||||||
}
|
|
||||||
out = append(out, &InstanceInfo{
|
out = append(out, &InstanceInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
ParentID: parentID,
|
ParentID: iModel.GetEncodeID(),
|
||||||
SysMenu: v,
|
SysMenu: v,
|
||||||
Children: c.tree(iModel, src, v.ID),
|
Children: c.tree(iModel, src, v.ID),
|
||||||
})
|
})
|
||||||
@ -70,16 +66,11 @@ func TreeIdentity(iModel model2.IModel, src []*model.SysMenuScene, parentID uint
|
|||||||
iModel.SetID(v.ID)
|
iModel.SetID(v.ID)
|
||||||
id := iModel.GetEncodeID()
|
id := iModel.GetEncodeID()
|
||||||
|
|
||||||
_parentID := "0"
|
iModel.SetID(v.ParentID)
|
||||||
|
|
||||||
if v.ParentID > 0 {
|
|
||||||
iModel.SetID(v.ParentID)
|
|
||||||
_parentID = iModel.GetEncodeID()
|
|
||||||
}
|
|
||||||
out = append(out, &InstanceIdentityInfo{
|
out = append(out, &InstanceIdentityInfo{
|
||||||
ID: id,
|
ID: id,
|
||||||
SysMenuBasic: v.SysMenuBasic,
|
SysMenuBasic: v.SysMenuBasic,
|
||||||
ParentID: _parentID,
|
ParentID: iModel.GetEncodeID(),
|
||||||
Checked: v.SceneID > 0,
|
Checked: v.SceneID > 0,
|
||||||
Children: TreeIdentity(iModel, src, v.ID),
|
Children: TreeIdentity(iModel, src, v.ID),
|
||||||
})
|
})
|
||||||
|
@ -31,7 +31,7 @@ func (c *Role) tree(iModel model2.IModel, src []*model.SysRoleUserInfo, parentID
|
|||||||
iModel.SetID(v.ID)
|
iModel.SetID(v.ID)
|
||||||
id := iModel.GetEncodeID()
|
id := iModel.GetEncodeID()
|
||||||
|
|
||||||
_parentID := "0"
|
_parentID := ""
|
||||||
|
|
||||||
if v.ParentID > 0 {
|
if v.ParentID > 0 {
|
||||||
iModel.SetID(v.ID)
|
iModel.SetID(v.ID)
|
||||||
|
@ -30,7 +30,7 @@ type (
|
|||||||
*model.WorkInstanceInfo
|
*model.WorkInstanceInfo
|
||||||
Outside struct {
|
Outside struct {
|
||||||
SupplierName string `json:"supplier_name"`
|
SupplierName string `json:"supplier_name"`
|
||||||
} `json:"outside" form:"outside"`
|
} `json:"outside"`
|
||||||
Within struct {
|
Within struct {
|
||||||
Material []*model.WorkMaterialInfo `json:"material"`
|
Material []*model.WorkMaterialInfo `json:"material"`
|
||||||
Purchase []*model.WorkPurchaseInfo `json:"purchase"`
|
Purchase []*model.WorkPurchaseInfo `json:"purchase"`
|
||||||
@ -218,13 +218,16 @@ func (c *Instance) List(equipmentCode, equipmentTitle string, kind, page, pageSi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Person 个人提交的审核信息
|
// Person 个人提交的审核信息
|
||||||
func (c *Instance) Person(materialID uint64, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
func (c *Instance) Person(equipmentCode, equipmentTitle string, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||||
mWorkInstance := model.NewWorkInstance()
|
mWorkInstance := model.NewWorkInstance()
|
||||||
|
|
||||||
where := make([]*model2.ModelWhere, 0)
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
if materialID > 0 {
|
if equipmentCode != "" {
|
||||||
where = append(where, model2.NewWhere("w.material_id", materialID))
|
where = append(where, model2.NewWhereLike("e.code", equipmentCode))
|
||||||
|
}
|
||||||
|
if equipmentTitle != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("e.title", equipmentTitle))
|
||||||
}
|
}
|
||||||
if kind > 0 {
|
if kind > 0 {
|
||||||
where = append(where, model2.NewWhere("w.kind", kind))
|
where = append(where, model2.NewWhere("w.kind", kind))
|
||||||
@ -249,7 +252,7 @@ func (c *Instance) Person(materialID uint64, kind, page, pageSize int) (*basic.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Workbench 工作台
|
// Workbench 工作台
|
||||||
func (c *Instance) Workbench(materialID uint64, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
func (c *Instance) Workbench(equipmentCode, equipmentTitle string, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||||
// 查询用户角色信息
|
// 查询用户角色信息
|
||||||
mSysUserRole := model.NewSysUserRole()
|
mSysUserRole := model.NewSysUserRole()
|
||||||
roleIDs := make([]string, 0)
|
roleIDs := make([]string, 0)
|
||||||
@ -263,8 +266,11 @@ func (c *Instance) Workbench(materialID uint64, kind, page, pageSize int) (*basi
|
|||||||
|
|
||||||
where := make([]*model2.ModelWhere, 0)
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
if materialID > 0 {
|
if equipmentCode != "" {
|
||||||
where = append(where, model2.NewWhere("w.material_id", materialID))
|
where = append(where, model2.NewWhereLike("e.code", equipmentCode))
|
||||||
|
}
|
||||||
|
if equipmentTitle != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("e.title", equipmentTitle))
|
||||||
}
|
}
|
||||||
if kind > 0 {
|
if kind > 0 {
|
||||||
where = append(where, model2.NewWhere("w.kind", kind))
|
where = append(where, model2.NewWhere("w.kind", kind))
|
||||||
@ -303,7 +309,7 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
|||||||
}
|
}
|
||||||
mWorkInstance.SetID(out.WorkInstanceInfo.ID)
|
mWorkInstance.SetID(out.WorkInstanceInfo.ID)
|
||||||
out.CommonIDString = basic.CommonIDString{
|
out.CommonIDString = basic.CommonIDString{
|
||||||
ID: mWorkInstance.GetEncodeTenantID(),
|
ID: mWorkInstance.GetEncodeID(),
|
||||||
}
|
}
|
||||||
// 位置信息
|
// 位置信息
|
||||||
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
|
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
|
||||||
@ -332,6 +338,7 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
|||||||
SupplierName string `json:"supplier_name"`
|
SupplierName string `json:"supplier_name"`
|
||||||
}{SupplierName: out.WorkInstanceInfo.SupplierName}
|
}{SupplierName: out.WorkInstanceInfo.SupplierName}
|
||||||
}
|
}
|
||||||
|
// 工单历史信息
|
||||||
if out.History, err = model.NewWorkProgress().Progress(id); err != nil {
|
if out.History, err = model.NewWorkProgress().Progress(id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -368,9 +375,6 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
})
|
})
|
||||||
mWorkInstance.Remark = params.Remark
|
mWorkInstance.Remark = params.Remark
|
||||||
|
|
||||||
// 工单流程信息
|
|
||||||
mWorkProgress := model.NewWorkProgress()
|
|
||||||
|
|
||||||
if mWorkInstance.Kind == model2.WorkInstanceKindForOutside {
|
if mWorkInstance.Kind == model2.WorkInstanceKindForOutside {
|
||||||
if params.Supplier.SupplierID <= 0 {
|
if params.Supplier.SupplierID <= 0 {
|
||||||
return errors.New("操作错误,承修单位不存在")
|
return errors.New("操作错误,承修单位不存在")
|
||||||
@ -391,6 +395,9 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
}
|
}
|
||||||
mWorkInstance.Schedule = mWorkSchedule.ID
|
mWorkInstance.Schedule = mWorkSchedule.ID
|
||||||
mWorkInstance.Status = model2.WorkInstanceStatusForComplete
|
mWorkInstance.Status = model2.WorkInstanceStatusForComplete
|
||||||
|
// 工单流程信息
|
||||||
|
mWorkProgress := model.NewWorkProgress()
|
||||||
|
mWorkProgress.ScheduleID = mWorkInstance.Schedule
|
||||||
// 下一流程
|
// 下一流程
|
||||||
nextWorkSchedule := new(model.WorkScheduleInfo)
|
nextWorkSchedule := new(model.WorkScheduleInfo)
|
||||||
|
|
||||||
@ -402,19 +409,19 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
mWorkInstance.Schedule = nextWorkSchedule.ID
|
mWorkInstance.Schedule = nextWorkSchedule.ID
|
||||||
}
|
}
|
||||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
|
// 工单信息
|
||||||
if err = model2.Create(mWorkInstance.WorkInstance, tx); err != nil {
|
if err = model2.Create(mWorkInstance.WorkInstance, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// 工单历史
|
||||||
mWorkProgress.UID = c.UID
|
mWorkProgress.UID = c.UID
|
||||||
mWorkProgress.WorkID = mWorkInstance.ID
|
mWorkProgress.WorkID = mWorkInstance.ID
|
||||||
mWorkProgress.ScheduleID = mWorkInstance.Schedule
|
mWorkProgress.Status = model2.WorkProgressStatusForCreate
|
||||||
mWorkProgress.Status = model2.WorkProgressStatusForAgree
|
mWorkProgress.Remark = ""
|
||||||
mWorkProgress.Remark = "发起工单"
|
|
||||||
|
|
||||||
if err = model2.Create(mWorkProgress.WorkProgress, tx); err != nil {
|
if err = model2.Create(mWorkProgress.WorkProgress, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内修模块信息
|
// 内修模块信息
|
||||||
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && params.IsAssist <= 0 {
|
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && params.IsAssist <= 0 {
|
||||||
// 物料信息
|
// 物料信息
|
||||||
|
@ -26,6 +26,8 @@ type (
|
|||||||
SupplierName string `json:"-"`
|
SupplierName string `json:"-"`
|
||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
Distribution string `json:"distribution"`
|
Distribution string `json:"distribution"`
|
||||||
|
PlateNumber string `json:"plate_number"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
@ -56,7 +58,7 @@ func (m *WorkInstance) Detail(id uint64) (*WorkInstanceInfo, error) {
|
|||||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
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("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",
|
"(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", "supplier.name AS supplier_name", "w.distribution", "w.status", "w.created_at").
|
"s.title AS schedule_title", "supplier.name AS supplier_name", "w.distribution", "w.plate_number", "w.remark", "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 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 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())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS supplier ON w.supplier_id = supplier.id", model.NewManageSupplier().TableName())).
|
||||||
|
Reference in New Issue
Block a user