Files
ArmedPolice/app/api/work.go

743 lines
24 KiB
Go
Raw Normal View History

2021-11-04 17:48:12 +08:00
package api
2021-11-05 15:27:04 +08:00
import (
"ArmedPolice/app/controller/work"
"ArmedPolice/app/service"
"github.com/gin-gonic/gin"
)
2021-11-04 17:48:12 +08:00
/**
* @apiDefine Work 工单管理
*/
2021-11-05 15:27:04 +08:00
type Work struct{}
2021-11-08 17:42:23 +08:00
type (
// workLaunchForm 工单发起基本信息
workLaunchForm struct {
Kind int `json:"kind" form:"kind" binding:"required"` // 类型
Title string `json:"title" form:"title"`
2021-11-11 14:05:52 +08:00
EquipmentID string `json:"equipment_id" form:"equipment_id" binding:"required"` // 装备ID
Breakdowns []string `json:"breakdowns" form:"breakdowns"` // 故障类型
2021-11-08 17:42:23 +08:00
PlateNumber string `json:"plate_number" form:"plate_number"` // 车牌号
Priority int `json:"priority" form:"priority" binding:"required"` // 优先级
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
Remark string `json:"remark" form:"remark"` // 备注信息
}
2021-11-18 09:51:39 +08:00
// workLaunchSupplierForm 供应商信息
workLaunchSupplierForm struct {
SupplierID string `json:"supplier_id" form:"supplier_id"`
}
2021-11-08 17:42:23 +08:00
// workLaunchMaterialForm 工单发起配件信息
workLaunchMaterialForm struct {
2021-11-11 14:05:52 +08:00
ID string `json:"id" form:"id"`
SupplierID string `json:"supplier_id" form:"supplier_id"`
Number float64 `json:"number" form:"number"`
2021-11-08 17:42:23 +08:00
}
2021-11-18 18:28:34 +08:00
// workLaunchPurchaseForm 工单发起配件信息
workLaunchPurchaseForm struct {
workLaunchMaterialForm
Price float64 `json:"price" form:"price"`
}
2021-11-08 17:42:23 +08:00
// workLaunchDistributionForm 工单发起地址信息
workLaunchDistributionForm struct {
2021-11-11 14:05:52 +08:00
Name string `json:"name" form:"name"` // 联系人
Mobile string `json:"mobile" form:"mobile"` // 联系方式
Address string `json:"address" form:"address"` // 联系地址
2021-11-08 17:42:23 +08:00
}
2021-11-10 11:26:40 +08:00
// scheduleForm 流程信息
scheduleForm struct {
Title string `json:"title" form:"title" binding:"required"`
Stage int `json:"stage" form:"stage"`
Step int `json:"step" form:"step"`
Target int `json:"target" form:"target" binding:"required"`
TargetValue []string `json:"target_value" form:"target_value" binding:"required"`
IsCountersign int `json:"is_countersign" form:"is_countersign"`
}
2021-11-08 17:42:23 +08:00
)
2021-11-08 15:52:46 +08:00
2021-11-18 09:51:39 +08:00
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()
}
2021-11-05 15:27:04 +08:00
/**
* @api {post} /api/v1/work/list 工单信息
* @apiVersion 1.0.0
* @apiName WorkList
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
2021-11-19 09:24:15 +08:00
* @apiParam {String} [equipment_code="''"] 装备编码
* @apiParam {String} [equipment_title="''"] 装备名称
2021-11-05 15:27:04 +08:00
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {Object} data 数据信息
2021-11-05 15:27:04 +08:00
* @apiSuccess (200) {String} data.id ID
2021-11-11 14:05:52 +08:00
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
2021-11-05 15:27:04 +08:00
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {String} data.schedule_title 流程名称
2021-11-05 15:27:04 +08:00
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
2021-11-11 14:05:52 +08:00
* @apiSuccess (200) {String} code 成功响应状态码!
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {String} msg 成功提示
2021-11-05 15:27:04 +08:00
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
2021-11-11 14:05:52 +08:00
* "kind": 2,
2021-11-05 15:27:04 +08:00
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
2021-11-10 11:26:40 +08:00
* "schedule_title": "分管领导审批",
2021-11-05 15:27:04 +08:00
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
func (*Work) Instance(c *gin.Context) {
form := &struct {
2021-11-19 09:24:15 +08:00
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
Kind int `json:"kind" form:"kind"`
2021-11-05 15:27:04 +08:00
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
2021-11-19 09:24:15 +08:00
data, err := work.NewInstance()(getSession()(c).(*service.Session)).List(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
2021-11-05 15:27:04 +08:00
APIResponse(err, data)(c)
}
2021-11-09 18:38:57 +08:00
/**
* @api {post} /api/v1/work/person 个人申请信息
* @apiVersion 1.0.0
* @apiName WorkPerson
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} [material_id=0] 装备ID
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {Object} data 数据信息
2021-11-09 18:38:57 +08:00
* @apiSuccess (200) {String} data.id ID
2021-11-11 14:05:52 +08:00
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
2021-11-09 18:38:57 +08:00
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {String} data.schedule_title 流程名称
2021-11-09 18:38:57 +08:00
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
2021-11-10 11:26:40 +08:00
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
2021-11-09 18:38:57 +08:00
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
2021-11-11 14:05:52 +08:00
* "kind": 2,
2021-11-09 18:38:57 +08:00
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
2021-11-10 11:26:40 +08:00
* "schedule_title": "分管领导审批",
2021-11-09 18:38:57 +08:00
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
2021-11-09 14:08:02 +08:00
func (*Work) Person(c *gin.Context) {
form := &struct {
MaterialID uint64 `json:"material_id" form:"material_id"`
Kind int `json:"kind" form:"kind"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Person(form.MaterialID, form.Kind, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
2021-11-10 11:26:40 +08:00
/**
* @api {post} /api/v1/work/workbench 个人待办事项
* @apiVersion 1.0.0
* @apiName WorkWorkbench
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} [material_id=0] 装备ID
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
2021-11-11 14:05:52 +08:00
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
2021-11-10 11:26:40 +08:00
* @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) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
2021-11-11 14:05:52 +08:00
* "kind": 2,
2021-11-10 11:26:40 +08:00
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
* "schedule_title": "分管领导审批",
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
2021-11-09 18:38:57 +08:00
func (*Work) Workbench(c *gin.Context) {
form := &struct {
MaterialID uint64 `json:"material_id" form:"material_id"`
Kind int `json:"kind" form:"kind"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Workbench(form.MaterialID, form.Kind, form.Page, form.PageSize)
APIResponse(err, data)(c)
2021-11-05 18:07:32 +08:00
}
2021-11-11 14:05:52 +08:00
/**
* @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": "测试的"
* }
* ]
* }
* }
*/
2021-11-09 14:08:02 +08:00
func (*Work) Detail(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Detail(form.Convert())
APIResponse(err, data)(c)
}
2021-11-11 14:05:52 +08:00
/**
* @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 传输方式
*
2021-11-18 09:51:39 +08:00
* @apiParam {Object} within 内修参数信息
2021-11-18 18:28:34 +08:00
* @apiParam {Object[]} within.material 配件信息
2021-11-18 09:51:39 +08:00
* @apiParam {String} within.material.id 配件ID
* @apiParam {String} within.material.supplier_id 供应商ID
2021-11-18 18:28:34 +08:00
* @apiParam {Float} within.material.number 配件数量
* @apiParam {Object[]} within.purchase 采购信息
* @apiParam {String} within.purchase.id 配件ID
* @apiParam {String} within.purchase.supplier_id 供应商ID
* @apiParam {Float} within.purchase.number 采购数量
* @apiParam {Float} within.purchase.Price 采购价格
2021-11-18 09:51:39 +08:00
* @apiParam {Object} outside 外修参数信息
* @apiParam {String} outside.supplier_id 配件ID
2021-11-11 14:05:52 +08:00
* @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
* }
*/
2021-11-05 15:27:04 +08:00
func (*Work) Launch(c *gin.Context) {
2021-11-08 15:52:46 +08:00
form := &struct {
2021-11-08 17:42:23 +08:00
workLaunchForm
2021-11-18 09:51:39 +08:00
Outside struct {
workLaunchSupplierForm
} `json:"outside" form:"outside"`
Within struct {
Material []*workLaunchMaterialForm `json:"material" form:"material"`
2021-11-18 18:28:34 +08:00
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
2021-11-18 09:51:39 +08:00
} `json:"within" form:"within"`
2021-11-11 14:05:52 +08:00
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
2021-11-08 15:52:46 +08:00
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
2021-11-11 14:05:52 +08:00
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
2021-11-18 09:51:39 +08:00
for _, v := range form.Within.Material {
2021-11-11 14:05:52 +08:00
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
2021-11-18 09:51:39 +08:00
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number,
2021-11-11 14:05:52 +08:00
})
}
2021-11-18 18:28:34 +08:00
purchase := make([]*work.InstanceLaunchParamsForPurchase, 0)
for _, v := range form.Within.Purchase {
purchase = append(purchase, &work.InstanceLaunchParamsForPurchase{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number, Price: v.Price,
})
}
2021-11-08 17:42:23 +08:00
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch(&work.InstanceLaunchParams{
2021-11-18 09:51:39 +08:00
Kind: form.Kind, Title: form.Title, EquipmentID: form.EquipmentInfo(), Breakdowns: form.BreakdownInfo(),
2021-11-08 17:42:23 +08:00
PlateNumber: form.PlateNumber, Priority: form.Priority, IsAssist: form.IsAssist, Remark: form.Remark,
2021-11-18 09:51:39 +08:00
Supplier: &work.InstanceLaunchParamsForSupplier{SupplierID: form.Outside.SupplierInfo()},
2021-11-18 18:28:34 +08:00
Material: materials, Purchase: purchase,
2021-11-11 14:05:52 +08:00
Distribution: &work.InstanceLaunchParamsForDistribution{
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
},
2021-11-08 17:42:23 +08:00
})
2021-11-18 09:51:39 +08:00
APIResponse(err)(c)
2021-11-05 15:27:04 +08:00
}
2021-11-11 14:05:52 +08:00
/**
* @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 传输方式
*
2021-11-18 18:28:34 +08:00
* @apiParam {Object} within 内修参数信息
* @apiParam {Object[]} within.material 配件信息
* @apiParam {String} within.material.id 配件ID
* @apiParam {String} within.material.supplier_id 供应商ID
* @apiParam {Float} within.material.number 配件数量
* @apiParam {Object[]} within.purchase 采购信息
* @apiParam {String} within.purchase.id 配件ID
* @apiParam {String} within.purchase.supplier_id 供应商ID
* @apiParam {Float} within.purchase.number 采购数量
* @apiParam {Float} within.purchase.Price 采购价格
2021-11-11 14:05:52 +08:00
* @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
* }
*/
2021-11-05 15:27:04 +08:00
func (*Work) Examine(c *gin.Context) {
2021-11-05 18:07:32 +08:00
form := &struct {
IDStringForm
Status int `json:"status" form:"status" binding:"required"`
Remark string `json:"remark" form:"remark"`
IsAssist int `json:"is_assist" form:"is_assist"`
2021-11-18 18:28:34 +08:00
Within struct {
Material []*workLaunchMaterialForm `json:"material" form:"material"`
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
} `json:"within" form:"within"`
2021-11-05 18:07:32 +08:00
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
2021-11-18 18:28:34 +08:00
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
for _, v := range form.Within.Material {
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number,
})
}
purchase := make([]*work.InstanceLaunchParamsForPurchase, 0)
for _, v := range form.Within.Purchase {
purchase = append(purchase, &work.InstanceLaunchParamsForPurchase{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number, Price: v.Price,
})
}
err := work.NewInstance()(getSession()(c).(*service.Session)).Examine(form.Convert(), form.Status, form.Remark,
form.IsAssist, &work.InstanceExamineParams{Material: materials, Purchase: purchase})
2021-11-18 09:51:39 +08:00
APIResponse(err)(c)
2021-11-05 15:27:04 +08:00
}
2021-11-09 14:08:02 +08:00
2021-11-10 15:09:31 +08:00
/**
2021-11-18 09:51:39 +08:00
* @api {post} /api/v1/work/delete 工单信息删除
2021-11-10 15:09:31 +08:00
* @apiVersion 1.0.0
* @apiName WorkDelete
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id Id
*
* @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
* }
*/
2021-11-09 14:08:02 +08:00
func (*Work) Delete(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewInstance()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}
2021-11-10 11:26:40 +08:00
/**
* @api {get} /api/v1/work/schedule 工单流程信息
* @apiVersion 1.0.0
* @apiName WorkSchedule
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Number} data.kind 流程类型1维修工单
* @apiSuccess (200) {String} data.title 流程名称
* @apiSuccess (200) {Object} data.schedules 流程信息
* @apiSuccess (200) {String} data.schedules.id 流程详细ID
* @apiSuccess (200) {String} data.schedules.title 流程详细名称
* @apiSuccess (200) {Number} data.schedules.stage 阶段
* @apiSuccess (200) {Number} data.schedules.step 步骤
* @apiSuccess (200) {Number} data.schedules.target 触发对象1个人2角色
* @apiSuccess (200) {String} data.schedules.target_value 触发对象信息
* @apiSuccess (200) {String} data.schedules.target_value_title 触发对象具体信息
* @apiSuccess (200) {Number} data.schedules.is_countersign 是否会签01暂不需要此字段
* @apiSuccess (200) {Time} data.schedules.created_at 创建时间
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "kind": "m9Qa2ZaOvE",
* "title": "刹车盘",
* "schedules": [
* {
* "id": "A9GVg5JZdr",
* "title": "发起工单",
* "stage": 1,
* "step": 2,
* "target": 2,
* "target_value": "9",
* "target_value_title": "区域修理队",
* "is_countersign": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* ]
* }
* }
* ]
* }
*/
2021-11-09 14:08:02 +08:00
func (*Work) Schedule(c *gin.Context) {
data, err := work.NewSchedule()(getSession()(c).(*service.Session)).List()
APIResponse(err, data)(c)
}
2021-11-10 11:26:40 +08:00
/**
2021-11-10 15:09:31 +08:00
* @api {post} /api/v1/work/schedule/edit 工单流程信息修改
2021-11-10 11:26:40 +08:00
* @apiVersion 1.0.0
2021-11-10 15:09:31 +08:00
* @apiName WorkScheduleEdit
2021-11-10 11:26:40 +08:00
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id Id
* @apiParam {String} title 名称
* @apiParam {Number} target 触发对象
* @apiParam {Array.String} target_value 触发对象具体信息
*
* @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) ScheduleEdit(c *gin.Context) {
form := &struct {
IDStringForm
scheduleForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewSchedule()(getSession()(c).(*service.Session)).Form(&work.ScheduleParams{
ID: form.Convert(), Title: form.Title, Stage: form.Stage, Step: form.Step,
Target: form.Target, IsCountersign: form.IsCountersign, TargetValue: form.TargetValue,
})
APIResponse(err)(c)
}
/**
2021-11-10 15:09:31 +08:00
* @api {post} /api/v1/work/schedule/delete 工单流程信息删除
2021-11-10 11:26:40 +08:00
* @apiVersion 1.0.0
2021-11-10 15:09:31 +08:00
* @apiName WorkScheduleDelete
2021-11-10 11:26:40 +08:00
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id Id
*
* @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) ScheduleDelete(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewSchedule()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}
2021-11-11 17:10:43 +08:00
func (*Work) Repair(c *gin.Context) {
form := &struct {
OrderNo string `json:"order_no" form:"order_no"`
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewRepair()(getSession()(c).(*service.Session)).List(form.OrderNo, form.EquipmentCode, form.EquipmentTitle,
form.Page, form.PageSize)
APIResponse(err, data)(c)
}
func (*Work) RepairDetail(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewRepair()(getSession()(c).(*service.Session)).Detail(form.Convert())
APIResponse(err, data)(c)
}
func (*Work) RepairBegin(c *gin.Context) {
form := &struct {
IDStringForm
Remark string `json:"remark" form:"remark"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Begin(form.Convert(), form.Remark)
APIResponse(err)(c)
}
func (*Work) RepairFinish(c *gin.Context) {
form := &struct {
IDStringForm
ImageForm
Remark string `json:"remark" form:"remark"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Finish(form.Convert(), form.Image, form.Remark)
APIResponse(err)(c)
}
func (*Work) RepairEvaluate(c *gin.Context) {
form := &struct {
IDStringForm
Score float64 `json:"score" form:"score" binding:"required"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Evaluate(form.Convert(), form.Score)
APIResponse(err)(c)
}