|
|
|
@ -24,6 +24,10 @@ type (
|
|
|
|
|
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
|
|
|
|
|
Remark string `json:"remark" form:"remark"` // 备注信息
|
|
|
|
|
}
|
|
|
|
|
// workLaunchSupplierForm 供应商信息
|
|
|
|
|
workLaunchSupplierForm struct {
|
|
|
|
|
SupplierID string `json:"supplier_id" form:"supplier_id"`
|
|
|
|
|
}
|
|
|
|
|
// workLaunchMaterialForm 工单发起配件信息
|
|
|
|
|
workLaunchMaterialForm struct {
|
|
|
|
|
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 工单信息
|
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
@ -324,10 +356,13 @@ func (*Work) Detail(c *gin.Context) {
|
|
|
|
|
* @apiHeader {string} x-token token
|
|
|
|
|
* @apiHeader {string} Content-Type=application/json 传输方式
|
|
|
|
|
*
|
|
|
|
|
* @apiParam {Object[]} material 配件信息,内修才需要上传
|
|
|
|
|
* @apiParam {String} material.id 配件ID
|
|
|
|
|
* @apiParam {String} material.supplier_id 供应商ID
|
|
|
|
|
* @apiParam {String} material.number 配件数量
|
|
|
|
|
* @apiParam {Object} within 内修参数信息
|
|
|
|
|
* @apiParam {Object[]} within.material 配件信息,内修才需要上传
|
|
|
|
|
* @apiParam {String} within.material.id 配件ID
|
|
|
|
|
* @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 {String} [title="''"] 工单名称
|
|
|
|
|
* @apiParam {Number} equipment_id 装备名称
|
|
|
|
@ -356,7 +391,12 @@ func (*Work) Detail(c *gin.Context) {
|
|
|
|
|
func (*Work) Launch(c *gin.Context) {
|
|
|
|
|
form := &struct {
|
|
|
|
|
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"`
|
|
|
|
|
}{}
|
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
|
|
@ -365,35 +405,21 @@ func (*Work) Launch(c *gin.Context) {
|
|
|
|
|
}
|
|
|
|
|
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
|
|
|
|
|
|
|
|
|
|
obj := new(IDStringForm)
|
|
|
|
|
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()
|
|
|
|
|
for _, v := range form.Within.Material {
|
|
|
|
|
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{
|
|
|
|
|
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,
|
|
|
|
|
Supplier: &work.InstanceLaunchParamsForSupplier{SupplierID: form.Outside.SupplierInfo()},
|
|
|
|
|
Material: materials,
|
|
|
|
|
Distribution: &work.InstanceLaunchParamsForDistribution{
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
* @apiName WorkDelete
|
|
|
|
|
* @apiGroup Work
|
|
|
|
|