feat:完善项目

This commit is contained in:
henry
2021-11-19 11:53:20 +08:00
parent 5ff6164295
commit 7efe403bf0
9 changed files with 64 additions and 46 deletions

View File

@ -30,7 +30,7 @@ type (
*model.WorkInstanceInfo
Outside struct {
SupplierName string `json:"supplier_name"`
} `json:"outside" form:"outside"`
} `json:"outside"`
Within struct {
Material []*model.WorkMaterialInfo `json:"material"`
Purchase []*model.WorkPurchaseInfo `json:"purchase"`
@ -218,13 +218,16 @@ func (c *Instance) List(equipmentCode, equipmentTitle string, kind, page, pageSi
}
// 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()
where := make([]*model2.ModelWhere, 0)
if materialID > 0 {
where = append(where, model2.NewWhere("w.material_id", materialID))
if equipmentCode != "" {
where = append(where, model2.NewWhereLike("e.code", equipmentCode))
}
if equipmentTitle != "" {
where = append(where, model2.NewWhereLike("e.title", equipmentTitle))
}
if kind > 0 {
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 工作台
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()
roleIDs := make([]string, 0)
@ -263,8 +266,11 @@ func (c *Instance) Workbench(materialID uint64, kind, page, pageSize int) (*basi
where := make([]*model2.ModelWhere, 0)
if materialID > 0 {
where = append(where, model2.NewWhere("w.material_id", materialID))
if equipmentCode != "" {
where = append(where, model2.NewWhereLike("e.code", equipmentCode))
}
if equipmentTitle != "" {
where = append(where, model2.NewWhereLike("e.title", equipmentTitle))
}
if kind > 0 {
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)
out.CommonIDString = basic.CommonIDString{
ID: mWorkInstance.GetEncodeTenantID(),
ID: mWorkInstance.GetEncodeID(),
}
// 位置信息
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
@ -332,6 +338,7 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
SupplierName string `json:"supplier_name"`
}{SupplierName: out.WorkInstanceInfo.SupplierName}
}
// 工单历史信息
if out.History, err = model.NewWorkProgress().Progress(id); err != nil {
return nil, err
}
@ -368,9 +375,6 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
})
mWorkInstance.Remark = params.Remark
// 工单流程信息
mWorkProgress := model.NewWorkProgress()
if mWorkInstance.Kind == model2.WorkInstanceKindForOutside {
if params.Supplier.SupplierID <= 0 {
return errors.New("操作错误,承修单位不存在")
@ -391,6 +395,9 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
}
mWorkInstance.Schedule = mWorkSchedule.ID
mWorkInstance.Status = model2.WorkInstanceStatusForComplete
// 工单流程信息
mWorkProgress := model.NewWorkProgress()
mWorkProgress.ScheduleID = mWorkInstance.Schedule
// 下一流程
nextWorkSchedule := new(model.WorkScheduleInfo)
@ -402,19 +409,19 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
mWorkInstance.Schedule = nextWorkSchedule.ID
}
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
// 工单信息
if err = model2.Create(mWorkInstance.WorkInstance, tx); err != nil {
return err
}
// 工单历史
mWorkProgress.UID = c.UID
mWorkProgress.WorkID = mWorkInstance.ID
mWorkProgress.ScheduleID = mWorkInstance.Schedule
mWorkProgress.Status = model2.WorkProgressStatusForAgree
mWorkProgress.Remark = "发起工单"
mWorkProgress.Status = model2.WorkProgressStatusForCreate
mWorkProgress.Remark = ""
if err = model2.Create(mWorkProgress.WorkProgress, tx); err != nil {
return err
}
// 内修模块信息
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && params.IsAssist <= 0 {
// 物料信息