feat:完善项目
This commit is contained in:
@ -23,6 +23,11 @@ type (
|
||||
basic.CommonIDString
|
||||
*model.WorkInstanceInfo
|
||||
}
|
||||
// InstanceDetailInfo 详细信息
|
||||
InstanceDetailInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.WorkInstanceInfo
|
||||
}
|
||||
// InstanceLaunchParams 发起参数信息
|
||||
InstanceLaunchParams struct {
|
||||
ID uint64
|
||||
@ -88,8 +93,46 @@ func (c *Instance) List(materialID uint64, kind, page, pageSize int) (*basic.Pag
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func (c *Instance) ToDo() {
|
||||
// Person 个人提交的审核信息
|
||||
func (c *Instance) Person(materialID uint64, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mWorkInstance := model.NewWorkInstance()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if materialID > 0 {
|
||||
where = append(where, model2.NewWhere("w.material_id", materialID))
|
||||
}
|
||||
if kind > 0 {
|
||||
where = append(where, model2.NewWhere("w.kind", kind))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mWorkInstance.Persons(c.UID, model2.WorkScheduleKindForRepair, page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InstanceInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mWorkInstance.ID = v.ID
|
||||
|
||||
list = append(list, &InstanceInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: mWorkInstance.GetEncodeID()}, WorkInstanceInfo: v,
|
||||
})
|
||||
}
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Workbench 工作台
|
||||
func (c *Instance) Workbench() {
|
||||
|
||||
}
|
||||
|
||||
func (c *Instance) Detail(id uint64) (interface{}, error) {
|
||||
mWorkInstance := model.NewWorkInstance()
|
||||
mWorkInstance.ID = id
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Launch 发起工单申请
|
||||
@ -129,7 +172,7 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
|
||||
isExist := false
|
||||
|
||||
if isExist, err = mWorkSchedule.FirstSchedule(); err != nil {
|
||||
if isExist, err = mWorkSchedule.FirstSchedule(model2.WorkScheduleKindForRepair); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,无工单流程信息,请先核实数据")
|
||||
@ -157,12 +200,9 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
if err = model2.Create(mWorkProgress.WorkProgress, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 创建维修工单
|
||||
mWorkRepair := model.NewWorkRepair()
|
||||
mWorkRepair.WorkID = mWorkInstance.ID
|
||||
|
||||
if err = model2.Create(mWorkRepair.WorkRepair, tx); err != nil {
|
||||
return err
|
||||
if nextWorkSchedule != nil {
|
||||
// 推送通知
|
||||
go c.publish(nextWorkSchedule.Reviewer)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@ -204,6 +244,7 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
||||
} else if !isAuth {
|
||||
return errors.New("操作错误,无权限审批")
|
||||
}
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 工单流程记录
|
||||
mWorkProgress := model.NewWorkProgress()
|
||||
@ -220,33 +261,42 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
||||
"status": model2.WorkInstanceStatusForComplete, "updated_at": time.Now(),
|
||||
}
|
||||
// 下一流程
|
||||
newNextScheduleInfo := new(model.WorkScheduleInfo)
|
||||
nextScheduleInfo := new(model.WorkScheduleInfo)
|
||||
|
||||
// 拒绝审批,工单直接结束
|
||||
if _status == model2.WorkProgressStatusForRefuse {
|
||||
goto FINISH
|
||||
}
|
||||
// 下一流程信息
|
||||
if newNextScheduleInfo, err = mWorkSchedule.NextSchedule(model2.WorkInstanceAssist(isAssist) == model2.WorkInstanceAssistForYes); err != nil {
|
||||
if nextScheduleInfo, err = mWorkSchedule.NextSchedule(model2.WorkInstanceAssist(isAssist) == model2.WorkInstanceAssistForYes); err != nil {
|
||||
return err
|
||||
}
|
||||
// 无下一流程,工单直接完成
|
||||
if newNextScheduleInfo == nil || newNextScheduleInfo.ID <= 0 {
|
||||
if nextScheduleInfo == nil || nextScheduleInfo.ID <= 0 {
|
||||
goto FINISH
|
||||
}
|
||||
workUpdates["status"] = model2.WorkInstanceStatusForOngoing
|
||||
workUpdates["schedule"] = newNextScheduleInfo.ID
|
||||
workUpdates["schedule"] = nextScheduleInfo.ID
|
||||
|
||||
if newNextScheduleInfo.IsNext {
|
||||
if nextScheduleInfo.IsNextStage {
|
||||
workUpdates["is_assist"] = isAssist
|
||||
}
|
||||
// 推送通知
|
||||
go c.publish(newNextScheduleInfo.Reviewer)
|
||||
|
||||
FINISH:
|
||||
if err = model2.Updates(mWorkInstance.WorkInstance, workUpdates, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 完成,创建维修工单
|
||||
if workUpdates["status"] == model2.WorkInstanceStatusForComplete {
|
||||
// 创建维修工单
|
||||
mWorkRepair := model.NewWorkRepair()
|
||||
mWorkRepair.WorkID = mWorkInstance.ID
|
||||
|
||||
if err = model2.Create(mWorkRepair.WorkRepair, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 推送通知
|
||||
go c.publish(nextScheduleInfo.Reviewer)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
@ -254,8 +304,11 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Instance) Delete() error {
|
||||
return nil
|
||||
// Delete 删除操作
|
||||
func (c *Instance) Delete(id uint64) error {
|
||||
mWorkInstance := model.NewWorkInstance()
|
||||
mWorkInstance.ID = id
|
||||
return model2.Delete(mWorkInstance.WorkInstance)
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
|
Reference in New Issue
Block a user