feat:完善项目
This commit is contained in:
@ -43,7 +43,7 @@ func bind(req interface{}) ApiHandle {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorF("Request URL【%s】Params Bind Error:%v", c.Request.URL, err)
|
logger.ErrorF("Request URL【%s】Params Bind Error:%v", c.Request.URL, err)
|
||||||
return errors.New("参数异常/缺失")
|
return errors.New("参数异常/缺失:" + err.Error())
|
||||||
}
|
}
|
||||||
c.Set("params", utils.AnyToJSON(req))
|
c.Set("params", utils.AnyToJSON(req))
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -125,6 +125,11 @@ func (*Config) Breakdown(c *gin.Context) {
|
|||||||
APIResponse(err, data)(c)
|
APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Config) BreakdownSelect(c *gin.Context) {
|
||||||
|
data, err := config.NewBreakdown()(getSession()(c).(*service.Session)).Select()
|
||||||
|
APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /api/v1/config/breakdown/add 故障信息添加
|
* @api {post} /api/v1/config/breakdown/add 故障信息添加
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
|
|||||||
@ -52,7 +52,7 @@ func (*Websocket) Publish(c *gin.Context) {
|
|||||||
key := c.Query("key")
|
key := c.Query("key")
|
||||||
service.HubMessage.EmitHandle(&service.HubEmit{
|
service.HubMessage.EmitHandle(&service.HubEmit{
|
||||||
ID: key,
|
ID: key,
|
||||||
Msg: handle.NewWorkNotice("你有一条待办事项"),
|
Msg: handle.NewWorkNotice("你有一条待办事项", nil),
|
||||||
})
|
})
|
||||||
APISuccess()(c)
|
APISuccess()(c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,10 @@ type (
|
|||||||
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
|
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
|
||||||
Remark string `json:"remark" form:"remark"` // 备注信息
|
Remark string `json:"remark" form:"remark"` // 备注信息
|
||||||
}
|
}
|
||||||
|
// workLaunchSupplierForm 供应商信息
|
||||||
|
workLaunchSupplierForm struct {
|
||||||
|
SupplierID string `json:"supplier_id" form:"supplier_id"`
|
||||||
|
}
|
||||||
// workLaunchMaterialForm 工单发起配件信息
|
// workLaunchMaterialForm 工单发起配件信息
|
||||||
workLaunchMaterialForm struct {
|
workLaunchMaterialForm struct {
|
||||||
ID string `json:"id" form:"id"`
|
ID string `json:"id" form:"id"`
|
||||||
@ -47,6 +51,34 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (this *workLaunchForm) EquipmentInfo() uint64 {
|
||||||
|
return (&IDStringForm{ID: this.EquipmentID}).Convert()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *workLaunchForm) BreakdownInfo() []uint64 {
|
||||||
|
out := make([]uint64, 0)
|
||||||
|
|
||||||
|
obj := new(IDStringForm)
|
||||||
|
|
||||||
|
for _, v := range this.Breakdowns {
|
||||||
|
obj.ID = v
|
||||||
|
out = append(out, obj.Convert())
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *workLaunchSupplierForm) SupplierInfo() uint64 {
|
||||||
|
return (&IDStringForm{ID: this.SupplierID}).Convert()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *workLaunchMaterialForm) IDInfo() uint64 {
|
||||||
|
return (&IDStringForm{ID: this.ID}).Convert()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *workLaunchMaterialForm) SupplierInfo() uint64 {
|
||||||
|
return (&IDStringForm{ID: this.SupplierID}).Convert()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /api/v1/work/list 工单信息
|
* @api {post} /api/v1/work/list 工单信息
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
@ -324,10 +356,13 @@ func (*Work) Detail(c *gin.Context) {
|
|||||||
* @apiHeader {string} x-token token
|
* @apiHeader {string} x-token token
|
||||||
* @apiHeader {string} Content-Type=application/json 传输方式
|
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||||
*
|
*
|
||||||
* @apiParam {Object[]} material 配件信息,内修才需要上传
|
* @apiParam {Object} within 内修参数信息
|
||||||
* @apiParam {String} material.id 配件ID
|
* @apiParam {Object[]} within.material 配件信息,内修才需要上传
|
||||||
* @apiParam {String} material.supplier_id 供应商ID
|
* @apiParam {String} within.material.id 配件ID
|
||||||
* @apiParam {String} material.number 配件数量
|
* @apiParam {String} within.material.supplier_id 供应商ID
|
||||||
|
* @apiParam {Number} within.material.number 配件数量
|
||||||
|
* @apiParam {Object} outside 外修参数信息
|
||||||
|
* @apiParam {String} outside.supplier_id 配件ID
|
||||||
* @apiParam {Number} kind 工单类型
|
* @apiParam {Number} kind 工单类型
|
||||||
* @apiParam {String} [title="''"] 工单名称
|
* @apiParam {String} [title="''"] 工单名称
|
||||||
* @apiParam {Number} equipment_id 装备名称
|
* @apiParam {Number} equipment_id 装备名称
|
||||||
@ -356,7 +391,12 @@ func (*Work) Detail(c *gin.Context) {
|
|||||||
func (*Work) Launch(c *gin.Context) {
|
func (*Work) Launch(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
workLaunchForm
|
workLaunchForm
|
||||||
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
Outside struct {
|
||||||
|
workLaunchSupplierForm
|
||||||
|
} `json:"outside" form:"outside"`
|
||||||
|
Within struct {
|
||||||
|
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
||||||
|
} `json:"within" form:"within"`
|
||||||
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
|
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
|
||||||
}{}
|
}{}
|
||||||
if err := bind(form)(c); err != nil {
|
if err := bind(form)(c); err != nil {
|
||||||
@ -365,35 +405,21 @@ func (*Work) Launch(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
|
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
|
||||||
|
|
||||||
obj := new(IDStringForm)
|
for _, v := range form.Within.Material {
|
||||||
obj.ID = form.EquipmentID
|
|
||||||
equipmentID := obj.Convert()
|
|
||||||
|
|
||||||
breakdowns := make([]uint64, 0)
|
|
||||||
for _, v := range form.Breakdowns {
|
|
||||||
obj.ID = v
|
|
||||||
breakdowns = append(breakdowns, obj.Convert())
|
|
||||||
}
|
|
||||||
for _, v := range form.Material {
|
|
||||||
// 器材ID
|
|
||||||
obj.ID = v.ID
|
|
||||||
id := obj.Convert()
|
|
||||||
// 供应商ID
|
|
||||||
obj.ID = v.SupplierID
|
|
||||||
supplierID := obj.Convert()
|
|
||||||
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
|
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
|
||||||
ID: id, SupplierID: supplierID, Number: v.Number,
|
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch(&work.InstanceLaunchParams{
|
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch(&work.InstanceLaunchParams{
|
||||||
Kind: form.Kind, Title: form.Title, EquipmentID: equipmentID, Breakdowns: breakdowns,
|
Kind: form.Kind, Title: form.Title, EquipmentID: form.EquipmentInfo(), Breakdowns: form.BreakdownInfo(),
|
||||||
PlateNumber: form.PlateNumber, Priority: form.Priority, IsAssist: form.IsAssist, Remark: form.Remark,
|
PlateNumber: form.PlateNumber, Priority: form.Priority, IsAssist: form.IsAssist, Remark: form.Remark,
|
||||||
|
Supplier: &work.InstanceLaunchParamsForSupplier{SupplierID: form.Outside.SupplierInfo()},
|
||||||
Material: materials,
|
Material: materials,
|
||||||
Distribution: &work.InstanceLaunchParamsForDistribution{
|
Distribution: &work.InstanceLaunchParamsForDistribution{
|
||||||
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
|
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -434,11 +460,11 @@ func (*Work) Examine(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := work.NewInstance()(getSession()(c).(*service.Session)).Examine(form.Convert(), form.Status, form.Remark, form.IsAssist)
|
err := work.NewInstance()(getSession()(c).(*service.Session)).Examine(form.Convert(), form.Status, form.Remark, form.IsAssist)
|
||||||
APIResponse(err)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /api/v1/work/delete 工单流程信息删除
|
* @api {post} /api/v1/work/delete 工单信息删除
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiName WorkDelete
|
* @apiName WorkDelete
|
||||||
* @apiGroup Work
|
* @apiGroup Work
|
||||||
|
|||||||
@ -19,6 +19,7 @@ type WorkInstance struct {
|
|||||||
Priority WorkInstancePriority `gorm:"column:priority;type:tinyint(1);default:1;comment:工单优先级" json:"priority"`
|
Priority WorkInstancePriority `gorm:"column:priority;type:tinyint(1);default:1;comment:工单优先级" json:"priority"`
|
||||||
Schedule uint64 `gorm:"column:schedule;type:int(11);default:1;comment:工单进度" json:"schedule"`
|
Schedule uint64 `gorm:"column:schedule;type:int(11);default:1;comment:工单进度" json:"schedule"`
|
||||||
IsAssist WorkInstanceAssist `gorm:"column:is_assist;type:tinyint(1);default:0;comment:协助状态" json:"is_assist"` // 当前阶段协助状态,确认是否需要下一阶段协助
|
IsAssist WorkInstanceAssist `gorm:"column:is_assist;type:tinyint(1);default:0;comment:协助状态" json:"is_assist"` // 当前阶段协助状态,确认是否需要下一阶段协助
|
||||||
|
SupplierID uint64 `gorm:"column:supplier_id;type:int(11);default:0;comment:供应商ID(外修:维修单位ID)" json:"supplier_id"`
|
||||||
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"`
|
||||||
Distribution string `gorm:"column:distribution;type:varchar(255);default:null;comment:配送信息" json:"-"`
|
Distribution string `gorm:"column:distribution;type:varchar(255);default:null;comment:配送信息" json:"-"`
|
||||||
Status WorkInstanceStatus `gorm:"column:status;type:tinyint(1);default:0;comment:工单状态" json:"status"`
|
Status WorkInstanceStatus `gorm:"column:status;type:tinyint(1);default:0;comment:工单状态" json:"status"`
|
||||||
|
|||||||
@ -19,7 +19,7 @@ const (
|
|||||||
// WorkProgressStatusForRefuse 拒绝
|
// WorkProgressStatusForRefuse 拒绝
|
||||||
WorkProgressStatusForRefuse WorkProgressStatus = iota - 1
|
WorkProgressStatusForRefuse WorkProgressStatus = iota - 1
|
||||||
// WorkProgressStatusForAgree 同意
|
// WorkProgressStatusForAgree 同意
|
||||||
WorkProgressStatusForAgree
|
WorkProgressStatusForAgree WorkProgressStatus = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *WorkProgress) TableName() string {
|
func (m *WorkProgress) TableName() string {
|
||||||
|
|||||||
@ -44,6 +44,26 @@ func (c *Breakdown) List(title string, page, pageSize int) (*basic.PageDataRespo
|
|||||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Select 查询信息
|
||||||
|
func (c *Breakdown) Select() ([]*BreakdownInfo, error) {
|
||||||
|
mSysBreakdown := model.NewSysBreakdown()
|
||||||
|
|
||||||
|
out := make([]*model2.SysBreakdown, 0)
|
||||||
|
|
||||||
|
if err := model2.ScanFields(mSysBreakdown.SysBreakdown, &out, []string{"id", "title"}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*BreakdownInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &BreakdownInfo{
|
||||||
|
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||||
|
SysBreakdown: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Form 数据处理
|
// Form 数据处理
|
||||||
func (c *Breakdown) Form(id uint64, title, remark string) error {
|
func (c *Breakdown) Form(id uint64, title, remark string) error {
|
||||||
mSysBreakdown := model.NewSysBreakdown()
|
mSysBreakdown := model.NewSysBreakdown()
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"ArmedPolice/app/model"
|
"ArmedPolice/app/model"
|
||||||
"ArmedPolice/app/service"
|
"ArmedPolice/app/service"
|
||||||
"ArmedPolice/serve/orm"
|
"ArmedPolice/serve/orm"
|
||||||
|
"ArmedPolice/utils"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,12 +59,14 @@ func (c *EquipmentMaterial) Bind(params *EquipmentMaterialBindParams) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
materialIDs := utils.ArrayUnique(params.MaterialIDs)
|
||||||
|
|
||||||
list := make([]*model2.ManageEquipmentMaterial, 0)
|
list := make([]*model2.ManageEquipmentMaterial, 0)
|
||||||
|
|
||||||
for _, v := range params.MaterialIDs {
|
for _, v := range materialIDs {
|
||||||
list = append(list, &model2.ManageEquipmentMaterial{
|
list = append(list, &model2.ManageEquipmentMaterial{
|
||||||
EquipmentID: params.EquipmentID,
|
EquipmentID: params.EquipmentID,
|
||||||
MaterialID: v,
|
MaterialID: v.(uint64),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
|
|||||||
@ -28,8 +28,14 @@ type (
|
|||||||
InstanceDetailInfo struct {
|
InstanceDetailInfo struct {
|
||||||
basic.CommonIDString
|
basic.CommonIDString
|
||||||
*model.WorkInstanceInfo
|
*model.WorkInstanceInfo
|
||||||
|
Outside struct {
|
||||||
|
SupplierName string `json:"supplier_name"`
|
||||||
|
} `json:"outside" form:"outside"`
|
||||||
|
Within struct {
|
||||||
|
Material []*model.WorkMaterialInfo `json:"material"`
|
||||||
|
} `json:"within"`
|
||||||
Distribution *model2.WorkInstanceDistribution `json:"distribution"`
|
Distribution *model2.WorkInstanceDistribution `json:"distribution"`
|
||||||
Materials []*model.WorkMaterialInfo `json:"materials"`
|
History []*model.WorkProgressInfo `json:"history"`
|
||||||
}
|
}
|
||||||
// InstanceLaunchParams 发起参数信息
|
// InstanceLaunchParams 发起参数信息
|
||||||
InstanceLaunchParams struct {
|
InstanceLaunchParams struct {
|
||||||
@ -41,9 +47,14 @@ type (
|
|||||||
PlateNumber string // 车牌号
|
PlateNumber string // 车牌号
|
||||||
Priority, IsAssist int // 优先级,是否需要上级审批
|
Priority, IsAssist int // 优先级,是否需要上级审批
|
||||||
Remark string // 备注信息
|
Remark string // 备注信息
|
||||||
|
Supplier *InstanceLaunchParamsForSupplier
|
||||||
Material []*InstanceLaunchParamsForMaterial
|
Material []*InstanceLaunchParamsForMaterial
|
||||||
Distribution *InstanceLaunchParamsForDistribution
|
Distribution *InstanceLaunchParamsForDistribution
|
||||||
}
|
}
|
||||||
|
// InstanceLaunchParamsForSupplier 供应商信息
|
||||||
|
InstanceLaunchParamsForSupplier struct {
|
||||||
|
SupplierID uint64 `json:"supplier_id"`
|
||||||
|
}
|
||||||
// InstanceLaunchParamsForMaterial 配件信息
|
// InstanceLaunchParamsForMaterial 配件信息
|
||||||
InstanceLaunchParamsForMaterial struct {
|
InstanceLaunchParamsForMaterial struct {
|
||||||
ID uint64 // 器材ID
|
ID uint64 // 器材ID
|
||||||
@ -56,14 +67,18 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Instance) publish(reviewer []string) {
|
func (c *Instance) publish(kind int, reviewer []string) {
|
||||||
|
msg := &service.HubEmit{
|
||||||
|
Msg: handle.NewWorkNotice("你有一条待办事项", &struct {
|
||||||
|
Kind int `json:"kind"`
|
||||||
|
}{
|
||||||
|
Kind: kind,
|
||||||
|
}),
|
||||||
|
}
|
||||||
utils.TryCatch(func() {
|
utils.TryCatch(func() {
|
||||||
for _, v := range reviewer {
|
for _, v := range reviewer {
|
||||||
// Socket通知
|
msg.ID = v
|
||||||
service.HubMessage.EmitHandle(&service.HubEmit{
|
service.HubMessage.EmitHandle(msg)
|
||||||
ID: v,
|
|
||||||
Msg: handle.NewWorkNotice("你有一条待办事项"),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -183,14 +198,31 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
|||||||
if out.WorkInstanceInfo, err = mWorkInstance.Detail(id); err != nil {
|
if out.WorkInstanceInfo, err = mWorkInstance.Detail(id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
mWorkInstance.SetID(out.WorkInstanceInfo.ID)
|
||||||
|
out.CommonIDString = basic.CommonIDString{
|
||||||
|
ID: mWorkInstance.GetEncodeTenantID(),
|
||||||
|
}
|
||||||
// 位置信息
|
// 位置信息
|
||||||
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
|
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
|
||||||
|
|
||||||
out.Distribution = mWorkInstance.GetDistributionAttribute()
|
out.Distribution = mWorkInstance.GetDistributionAttribute()
|
||||||
// 内修才有数据
|
// 内修才有数据
|
||||||
if out.WorkInstanceInfo.Kind == model2.WorkInstanceKindForWithin {
|
if out.WorkInstanceInfo.Kind == model2.WorkInstanceKindForWithin {
|
||||||
if out.Materials, err = model.NewWorkMaterial().Materials(id); err != nil {
|
materials := make([]*model.WorkMaterialInfo, 0)
|
||||||
|
|
||||||
|
if materials, err = model.NewWorkMaterial().Materials(id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
out.Within = struct {
|
||||||
|
Material []*model.WorkMaterialInfo `json:"material"`
|
||||||
|
}{Material: materials}
|
||||||
|
} else if out.WorkInstanceInfo.Kind == model2.WorkInstanceKindForOutside {
|
||||||
|
out.Outside = struct {
|
||||||
|
SupplierName string `json:"supplier_name"`
|
||||||
|
}{SupplierName: out.WorkInstanceInfo.SupplierName}
|
||||||
|
}
|
||||||
|
if out.History, err = model.NewWorkProgress().Progress(id); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
@ -212,6 +244,7 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
// 工单信息
|
// 工单信息
|
||||||
mWorkInstance := model.NewWorkInstance()
|
mWorkInstance := model.NewWorkInstance()
|
||||||
mWorkInstance.UID = c.UID
|
mWorkInstance.UID = c.UID
|
||||||
|
mWorkInstance.OrderNo = lib.OrderNo()
|
||||||
mWorkInstance.Kind = model2.WorkInstanceKind(params.Kind)
|
mWorkInstance.Kind = model2.WorkInstanceKind(params.Kind)
|
||||||
mWorkInstance.Title = params.Title
|
mWorkInstance.Title = params.Title
|
||||||
mWorkInstance.EquipmentID = params.EquipmentID
|
mWorkInstance.EquipmentID = params.EquipmentID
|
||||||
@ -229,8 +262,13 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
// 工单器材信息
|
// 工单器材信息
|
||||||
workMaterials := make([]*model2.WorkMaterial, 0)
|
workMaterials := make([]*model2.WorkMaterial, 0)
|
||||||
|
|
||||||
// 内修模块,同步器材库存信息
|
if mWorkInstance.Kind == model2.WorkInstanceKindForOutside {
|
||||||
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin {
|
if params.Supplier.SupplierID <= 0 {
|
||||||
|
return errors.New("操作错误,承修单位不存在")
|
||||||
|
}
|
||||||
|
mWorkInstance.SupplierID = params.Supplier.SupplierID
|
||||||
|
// 内修模块,同步器材库存信息
|
||||||
|
} else if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && params.IsAssist <= 0 {
|
||||||
for _, v := range params.Material {
|
for _, v := range params.Material {
|
||||||
if v.ID <= 0 || v.SupplierID <= 0 || v.Number <= 0 {
|
if v.ID <= 0 || v.SupplierID <= 0 || v.Number <= 0 {
|
||||||
return errors.New("操作错误,器材参数不完全")
|
return errors.New("操作错误,器材参数不完全")
|
||||||
@ -279,8 +317,9 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
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 && len(workMaterials) > 0 {
|
// 处理库存信息
|
||||||
|
if len(workMaterials) > 0 {
|
||||||
mManageMaterialSupplier := model.NewManageMaterialSupplier()
|
mManageMaterialSupplier := model.NewManageMaterialSupplier()
|
||||||
|
|
||||||
for _, v := range workMaterials {
|
for _, v := range workMaterials {
|
||||||
@ -288,7 +327,10 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
|
|
||||||
if err = model2.UpdatesWhere(mManageMaterialSupplier.ManageMaterialSupplier, map[string]interface{}{
|
if err = model2.UpdatesWhere(mManageMaterialSupplier.ManageMaterialSupplier, map[string]interface{}{
|
||||||
"frozen_stock": gorm.Expr("frozen_stock + ?", v.MaterialNumber), "updated_at": now,
|
"frozen_stock": gorm.Expr("frozen_stock + ?", v.MaterialNumber), "updated_at": now,
|
||||||
}, nil, tx); err != nil {
|
}, []*model2.ModelWhere{
|
||||||
|
model2.NewWhere("material_id", v.MaterialID),
|
||||||
|
model2.NewWhere("supplier_id", v.MaterialSupplierID),
|
||||||
|
}, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +342,7 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
|||||||
}
|
}
|
||||||
if nextWorkSchedule != nil {
|
if nextWorkSchedule != nil {
|
||||||
// 推送通知
|
// 推送通知
|
||||||
go c.publish(nextWorkSchedule.Reviewer)
|
go c.publish(params.Kind, nextWorkSchedule.Reviewer)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -316,7 +358,7 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
|||||||
mWorkInstance := model.NewWorkInstance()
|
mWorkInstance := model.NewWorkInstance()
|
||||||
mWorkInstance.ID = id
|
mWorkInstance.ID = id
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mWorkInstance.WorkInstance, []string{"id", "schedule", "status"})
|
isExist, err := model2.FirstField(mWorkInstance.WorkInstance, []string{"id", "kind", "schedule", "status"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -397,7 +439,9 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 推送通知
|
// 推送通知
|
||||||
go c.publish(nextScheduleInfo.Reviewer)
|
if nextScheduleInfo != nil {
|
||||||
|
go c.publish(int(mWorkInstance.Kind), nextScheduleInfo.Reviewer)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -4,7 +4,8 @@ import "encoding/json"
|
|||||||
|
|
||||||
type WorkNotice struct {
|
type WorkNotice struct {
|
||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix"`
|
||||||
Message interface{} `json:"message"`
|
Data interface{} `json:"data"`
|
||||||
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *WorkNotice) ToBytes() []byte {
|
func (this *WorkNotice) ToBytes() []byte {
|
||||||
@ -12,9 +13,10 @@ func (this *WorkNotice) ToBytes() []byte {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWorkNotice(msg interface{}) *WorkNotice {
|
func NewWorkNotice(msg string, data interface{}) *WorkNotice {
|
||||||
return &WorkNotice{
|
return &WorkNotice{
|
||||||
Prefix: "work",
|
Prefix: "work",
|
||||||
Message: msg,
|
Message: msg,
|
||||||
|
Data: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ func (m *SysUser) Users(page, pageSize int, count *int64, where ...*model.ModelW
|
|||||||
mSysTenant := model.NewSysTenant()
|
mSysTenant := model.NewSysTenant()
|
||||||
|
|
||||||
db := orm.GetDB().Table(m.TableName()+" As u").Select("u.id", "u.uuid", "account", "u.name", "u.avatar",
|
db := orm.GetDB().Table(m.TableName()+" As u").Select("u.id", "u.uuid", "account", "u.name", "u.avatar",
|
||||||
"u.mobile", "u.email", "u.gender", "u.status", "t.name AS tenant_name", "u.created_at").
|
"u.mobile", "u.email", "u.gender", "u.status", "t.name AS tenant_name", "u.remark", "u.created_at").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON u.tenant_id = t.id", mSysTenant.TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON u.tenant_id = t.id", mSysTenant.TableName())).
|
||||||
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,13 @@ type (
|
|||||||
WorkInstanceInfo struct {
|
WorkInstanceInfo struct {
|
||||||
ID uint64 `json:"-"`
|
ID uint64 `json:"-"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
OrderNo string `json:"order_no"`
|
||||||
Kind model.WorkInstanceKind `json:"kind"`
|
Kind model.WorkInstanceKind `json:"kind"`
|
||||||
EquipmentCode string `json:"equipment_code"`
|
EquipmentCode string `json:"equipment_code"`
|
||||||
EquipmentTitle string `json:"equipment_title"`
|
EquipmentTitle string `json:"equipment_title"`
|
||||||
BreakdownTitle string `json:"breakdown_title"`
|
BreakdownTitle string `json:"breakdown_title"`
|
||||||
ScheduleTitle string `json:"schedule_title"`
|
ScheduleTitle string `json:"schedule_title"`
|
||||||
|
SupplierName string `json:"-"`
|
||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
Distribution string `json:"distribution"`
|
Distribution string `json:"distribution"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
@ -54,9 +56,10 @@ 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", "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 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())).
|
||||||
Where("w.id = ?", id)
|
Where("w.id = ?", id)
|
||||||
|
|
||||||
out := new(WorkInstanceInfo)
|
out := new(WorkInstanceInfo)
|
||||||
@ -70,7 +73,7 @@ func (m *WorkInstance) Detail(id uint64) (*WorkInstanceInfo, error) {
|
|||||||
// Instances 基本信息
|
// Instances 基本信息
|
||||||
func (m *WorkInstance) Instances(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
func (m *WorkInstance) Instances(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
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",
|
"(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").
|
"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 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 个人信息
|
// Persons 个人信息
|
||||||
func (m *WorkInstance) Persons(uid uint64, page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
func (m *WorkInstance) Persons(uid uint64, page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*WorkInstanceInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
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",
|
"(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", "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())).
|
||||||
@ -137,13 +140,14 @@ ELSE "" END`, "s.target",
|
|||||||
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
||||||
|
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
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",
|
"(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").
|
"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 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 s ON w.schedule = s.id", mWorkSchedule.TableName())).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON w.uid = u.uuid", model.NewSysUser().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.is_deleted = ?", model.DeleteStatusForNot).
|
||||||
|
Where("w.status = ?", model.WorkInstanceStatusForOngoing).
|
||||||
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
@ -175,12 +179,14 @@ ELSE "" END`, "s.target",
|
|||||||
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
mWorkSchedule.TableName(), model.WorkScheduleTargetForRole, condition.roleInfo())
|
||||||
|
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS w").
|
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",
|
"(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 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 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.is_deleted = ?", model.DeleteStatusForNot).
|
||||||
|
Where("w.status = ?", model.WorkInstanceStatusForOngoing).
|
||||||
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
Where(fmt.Sprintf("FIND_IN_SET(w.schedule, %s)", _condition))
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
|
|||||||
@ -1,11 +1,40 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "ArmedPolice/app/common/model"
|
import (
|
||||||
|
"ArmedPolice/app/common/model"
|
||||||
|
"ArmedPolice/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type WorkProgress struct {
|
type WorkProgress struct {
|
||||||
*model.WorkProgress
|
*model.WorkProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WorkProgressInfo struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
ScheduleTitle string `json:"schedule_title"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *WorkProgress) Progress(workID uint64) ([]*WorkProgressInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||||
|
Select("p.id", "s.title AS schedule_title", "u.name AS username", "p.status", "p.remark", "p.created_at").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON p.schedule_id = s.id", model.NewWorkSchedule().TableName())).
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON p.uid = u.uuid", model.NewSysUser().TableName())).
|
||||||
|
Where("p.work_id = ?", workID).
|
||||||
|
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
out := make([]*WorkProgressInfo, 0)
|
||||||
|
|
||||||
|
err := db.Order("p.id " + model.OrderModeToDesc).Scan(&out).Error
|
||||||
|
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
func NewWorkProgress() *WorkProgress {
|
func NewWorkProgress() *WorkProgress {
|
||||||
return &WorkProgress{model.NewWorkProgress()}
|
return &WorkProgress{model.NewWorkProgress()}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ func (m *WorkSchedule) ValidateAuth(uid uint64) (bool, error) {
|
|||||||
|
|
||||||
// FirstSchedule 第一个流程
|
// FirstSchedule 第一个流程
|
||||||
func (m *WorkSchedule) FirstSchedule(kind model.WorkScheduleKind) (bool, error) {
|
func (m *WorkSchedule) FirstSchedule(kind model.WorkScheduleKind) (bool, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()).Select("id", "title", "stage", "step").
|
db := orm.GetDB().Table(m.TableName()).Select("id", "kind", "title", "stage", "step").
|
||||||
Where("kind = ?", kind).
|
Where("kind = ?", kind).
|
||||||
Where("is_deleted = ?", model.DeleteStatusForNot).
|
Where("is_deleted = ?", model.DeleteStatusForNot).
|
||||||
Order("stage " + model.OrderModeToAsc).Order("step " + model.OrderModeToAsc)
|
Order("stage " + model.OrderModeToAsc).Order("step " + model.OrderModeToAsc)
|
||||||
|
|||||||
@ -85,8 +85,10 @@ func (this *Router) registerAPI() {
|
|||||||
configV1.POST("/edit", _api.Edit)
|
configV1.POST("/edit", _api.Edit)
|
||||||
configV1.GET("/area", _api.Area)
|
configV1.GET("/area", _api.Area)
|
||||||
configV1.POST("/breakdown", _api.Breakdown)
|
configV1.POST("/breakdown", _api.Breakdown)
|
||||||
|
configV1.GET("/breakdown/select", _api.BreakdownSelect)
|
||||||
configV1.POST("/breakdown/add", _api.BreakdownAdd)
|
configV1.POST("/breakdown/add", _api.BreakdownAdd)
|
||||||
configV1.POST("/breakdown/edit", _api.BreakdownEdit)
|
configV1.POST("/breakdown/edit", _api.BreakdownEdit)
|
||||||
|
configV1.POST("/breakdown/delete", _api.BreakdownDelete)
|
||||||
}
|
}
|
||||||
// Tenant 租户单位管理
|
// Tenant 租户单位管理
|
||||||
tenantV1 := v1.Group("/tenant")
|
tenantV1 := v1.Group("/tenant")
|
||||||
|
|||||||
Reference in New Issue
Block a user