feat:完善项目
This commit is contained in:
185
app/api/work.go
185
app/api/work.go
@ -17,8 +17,8 @@ type (
|
||||
workLaunchForm struct {
|
||||
Kind int `json:"kind" form:"kind" binding:"required"` // 类型
|
||||
Title string `json:"title" form:"title"`
|
||||
EquipmentID uint64 `json:"equipment_id" form:"equipment_id" binding:"required"` // 装备ID
|
||||
Breakdowns []uint64 `json:"breakdowns" form:"breakdowns"` // 故障类型
|
||||
EquipmentID string `json:"equipment_id" form:"equipment_id" binding:"required"` // 装备ID
|
||||
Breakdowns []string `json:"breakdowns" form:"breakdowns"` // 故障类型
|
||||
PlateNumber string `json:"plate_number" form:"plate_number"` // 车牌号
|
||||
Priority int `json:"priority" form:"priority" binding:"required"` // 优先级
|
||||
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
|
||||
@ -26,12 +26,15 @@ type (
|
||||
}
|
||||
// workLaunchMaterialForm 工单发起配件信息
|
||||
workLaunchMaterialForm struct {
|
||||
ID string `json:"id" form:"id"`
|
||||
SupplierID string `json:"supplier_id" form:"supplier_id"`
|
||||
Number float64 `json:"number" form:"number"`
|
||||
}
|
||||
// workLaunchDistributionForm 工单发起地址信息
|
||||
workLaunchDistributionForm struct {
|
||||
Name string `json:"name" form:"name" binding:"required"` // 联系人
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"` // 联系方式
|
||||
Address string `json:"address" form:"address" binding:"required"` // 联系地址
|
||||
Name string `json:"name" form:"name"` // 联系人
|
||||
Mobile string `json:"mobile" form:"mobile"` // 联系方式
|
||||
Address string `json:"address" form:"address"` // 联系地址
|
||||
}
|
||||
// scheduleForm 流程信息
|
||||
scheduleForm struct {
|
||||
@ -60,6 +63,7 @@ type (
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:外修,2:内修)
|
||||
* @apiSuccess (200) {String} data.title 标题名称
|
||||
* @apiSuccess (200) {String} data.material_code 装备编码
|
||||
* @apiSuccess (200) {String} data.material_title 装备名称
|
||||
@ -68,7 +72,7 @@ type (
|
||||
* @apiSuccess (200) {Number} data.priority 紧急状态(1:普通,2:紧急,3:非常紧急)
|
||||
* @apiSuccess (200) {Number} data.status 状态(0:进行中,1:已完成)
|
||||
* @apiSuccess (200) {Time} data.created_at 创建时间
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
@ -79,6 +83,7 @@ type (
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "m9Qa2ZaOvE",
|
||||
* "kind": 2,
|
||||
* "title": "刹车盘",
|
||||
* "material_code": "装备编码",
|
||||
* "material_title": "装备名称",
|
||||
@ -121,6 +126,7 @@ func (*Work) Instance(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:外修,2:内修)
|
||||
* @apiSuccess (200) {String} data.title 标题名称
|
||||
* @apiSuccess (200) {String} data.material_code 装备编码
|
||||
* @apiSuccess (200) {String} data.material_title 装备名称
|
||||
@ -140,6 +146,7 @@ func (*Work) Instance(c *gin.Context) {
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "m9Qa2ZaOvE",
|
||||
* "kind": 2,
|
||||
* "title": "刹车盘",
|
||||
* "material_code": "装备编码",
|
||||
* "material_title": "装备名称",
|
||||
@ -182,6 +189,7 @@ func (*Work) Person(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:外修,2:内修)
|
||||
* @apiSuccess (200) {String} data.title 标题名称
|
||||
* @apiSuccess (200) {String} data.material_code 装备编码
|
||||
* @apiSuccess (200) {String} data.material_title 装备名称
|
||||
@ -201,6 +209,7 @@ func (*Work) Person(c *gin.Context) {
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "m9Qa2ZaOvE",
|
||||
* "kind": 2,
|
||||
* "title": "刹车盘",
|
||||
* "material_code": "装备编码",
|
||||
* "material_title": "装备名称",
|
||||
@ -227,6 +236,74 @@ func (*Work) Workbench(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/detail 工单详情信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName WorkDetail
|
||||
* @apiGroup Work
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||
*
|
||||
* @apiParam {String} id 工单ID
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:外修,2:内修)
|
||||
* @apiSuccess (200) {String} data.title 标题名称
|
||||
* @apiSuccess (200) {String} data.material_code 装备编码
|
||||
* @apiSuccess (200) {String} data.material_title 装备名称
|
||||
* @apiSuccess (200) {String} data.breakdown_title 故障信息
|
||||
* @apiSuccess (200) {String} data.schedule_title 流程名称
|
||||
* @apiSuccess (200) {Number} data.priority 紧急状态(1:普通,2:紧急,3:非常紧急)
|
||||
* @apiSuccess (200) {Number} data.status 状态(0:进行中,1:已完成)
|
||||
* @apiSuccess (200) {Time} data.created_at 创建时间
|
||||
* @apiSuccess (200) {Object} data.distribution 配送信息
|
||||
* @apiSuccess (200) {String} data.distribution.name 联系人
|
||||
* @apiSuccess (200) {String} data.distribution.mobile 联系方式
|
||||
* @apiSuccess (200) {String} data.distribution.address 联系地址
|
||||
* @apiSuccess (200) {Object} data.materials 配件信息
|
||||
* @apiSuccess (200) {Float} data.materials.material_number 所需数量
|
||||
* @apiSuccess (200) {String} data.materials.material_code 配件编码
|
||||
* @apiSuccess (200) {String} data.materials.material_title 配件名称
|
||||
* @apiSuccess (200) {Float} data.materials.material_price 配件价格
|
||||
* @apiSuccess (200) {String} data.materials.supplier_name 供应商名称
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": {
|
||||
* "id": "m9Qa2ZaOvE",
|
||||
* "kind": 2,
|
||||
* "title": "刹车盘",
|
||||
* "material_code": "装备编码",
|
||||
* "material_title": "装备名称",
|
||||
* "breakdown_title": "发动机,刹车盘",
|
||||
* "schedule_title": "分管领导审批",
|
||||
* "priority": 1,
|
||||
* "status": 0,
|
||||
* "created_at": "2021-11-05T14:24:07+08:00",
|
||||
* "distribution": [
|
||||
* "name": "",
|
||||
* "mobile": "",
|
||||
* "address": "",
|
||||
* ],
|
||||
* "materials": [
|
||||
* {
|
||||
* "material_number": 0,
|
||||
* "material_code": "2222",
|
||||
* "material_title": "qewqe",
|
||||
* "material_price": 0,
|
||||
* "supplier_name": "测试的"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
func (*Work) Detail(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
@ -238,23 +315,113 @@ func (*Work) Detail(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/launch 工单发起
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName WorkLaunch
|
||||
* @apiGroup Work
|
||||
*
|
||||
* @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 {Number} kind 工单类型
|
||||
* @apiParam {String} [title="''"] 工单名称
|
||||
* @apiParam {Number} equipment_id 装备名称
|
||||
* @apiParam {String[]} breakdowns 故障类型
|
||||
* @apiParam {String} plate_number 车牌号
|
||||
* @apiParam {Number} priority 紧急状态(1:普通,2:紧急,3:非常紧急)
|
||||
* @apiParam {Number} [is_assist=0] 是否需要上级协助(1:是)
|
||||
* @apiParam {String} [remark="''"] 备注信息
|
||||
* @apiParam {Object} distribution 配送信息
|
||||
* @apiParam {String} distribution.name 联系人
|
||||
* @apiParam {String} distribution.mobile 联系方式
|
||||
* @apiParam {String} distribution.address 联系地址
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Work) Launch(c *gin.Context) {
|
||||
form := &struct {
|
||||
workLaunchForm
|
||||
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
||||
Address workLaunchDistributionForm `json:"distribution" form:"distribution"`
|
||||
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
||||
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
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()
|
||||
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
|
||||
ID: id, SupplierID: supplierID, Number: v.Number,
|
||||
})
|
||||
}
|
||||
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch(&work.InstanceLaunchParams{
|
||||
Kind: form.Kind, Title: form.Title, EquipmentID: form.EquipmentID, Breakdowns: form.Breakdowns,
|
||||
Kind: form.Kind, Title: form.Title, EquipmentID: equipmentID, Breakdowns: breakdowns,
|
||||
PlateNumber: form.PlateNumber, Priority: form.Priority, IsAssist: form.IsAssist, Remark: form.Remark,
|
||||
Material: materials,
|
||||
Distribution: &work.InstanceLaunchParamsForDistribution{
|
||||
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
|
||||
},
|
||||
})
|
||||
APIResponse(err)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/examine 工单审核
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName WorkExamine
|
||||
* @apiGroup Work
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||
*
|
||||
* @apiParam {String} id 工单ID
|
||||
* @apiParam {String} status 审核状态
|
||||
* @apiParam {String} remark 备注信息
|
||||
* @apiParam {Number} [is_assist=0] 是否需要上级协助(0:不需要,1:需要)
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Work) Examine(c *gin.Context) {
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
|
Reference in New Issue
Block a user