feat:完善项目
This commit is contained in:
@ -602,6 +602,51 @@ func (*Work) Schedule(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/schedule/basic 工单基本流程信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName WorkScheduleBasic
|
||||
* @apiGroup Work
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id Id
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id 流程ID
|
||||
* @apiSuccess (200) {Number} data.kind 流程类型(1;维修工单)
|
||||
* @apiSuccess (200) {String} data.title 流程名称
|
||||
* @apiSuccess (200) {String} data.title 流程详细名称
|
||||
* @apiSuccess (200) {Number} data.stage 阶段
|
||||
* @apiSuccess (200) {Number} data.step 步骤
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": {
|
||||
* "id": "A9GVg5JZdr",
|
||||
* "title": "发起工单",
|
||||
* "kind": 1,
|
||||
* "stage": 1,
|
||||
* "step": 2
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
func (*Work) ScheduleBasic(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := work.NewSchedule()(getSession()(c).(*service.Session)).Basic(form.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/schedule/edit 工单流程信息修改
|
||||
* @apiVersion 1.0.0
|
||||
|
@ -3,7 +3,10 @@ package common
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
"ArmedPolice/config"
|
||||
"ArmedPolice/lib"
|
||||
"ArmedPolice/serve/orm"
|
||||
"ArmedPolice/utils"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type synchronized struct {
|
||||
@ -36,13 +39,22 @@ func initModel() {
|
||||
}
|
||||
function(
|
||||
&synchronized{iModel: model.NewSysTenant()},
|
||||
&synchronized{iModel: model.NewSysConfig()},
|
||||
&synchronized{iModel: model.NewSysConfig(), iValues: func() interface{} {
|
||||
values := make([]*model.SysConfig, 0)
|
||||
lib.LoadConfig("./json/sys_config.json", &values)
|
||||
fmt.Println(utils.AnyToJSON(values))
|
||||
return values
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()},
|
||||
&synchronized{iModel: model.NewSysUser(), iValues: func() interface{} {
|
||||
return &model.SysUser{Account: "admin", Name: "超级管理员", Mobile: "13888888888", Password: "123456",
|
||||
IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"}
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysRole()}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
|
||||
&synchronized{iModel: model.NewSysRole(), iValues: func() interface{} {
|
||||
values := make([]*model.SysRole, 0)
|
||||
lib.LoadConfig("./json/sys_role.json", &values)
|
||||
return values
|
||||
}}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
|
||||
&synchronized{iModel: model.NewSysUserRole()},
|
||||
// 日志管理
|
||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||
@ -55,7 +67,11 @@ func initModel() {
|
||||
&synchronized{iModel: model.NewManageMaterial()}, &synchronized{iModel: model.NewManageMaterialSupplier()},
|
||||
&synchronized{iModel: model.NewManageMaterialPurchase()}, &synchronized{iModel: model.NewManageMaterialWarehouse()},
|
||||
&synchronized{iModel: model.NewWorkInstance()}, &synchronized{iModel: model.NewWorkMaterial()}, &synchronized{iModel: model.NewWorkProgress()},
|
||||
&synchronized{iModel: model.NewWorkSchedule()}, &synchronized{iModel: model.NewWorkPurchase()},
|
||||
&synchronized{iModel: model.NewWorkSchedule(), iValues: func() interface{} {
|
||||
values := make([]*model.WorkSchedule, 0)
|
||||
lib.LoadConfig("./json/work_schedule.json", &values)
|
||||
return values
|
||||
}}, &synchronized{iModel: model.NewWorkPurchase()},
|
||||
&synchronized{iModel: model.NewWorkRepair()}, &synchronized{iModel: model.NewWorkRepairDetail()},
|
||||
)
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ type (
|
||||
InstanceDetailInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.WorkInstanceInfo
|
||||
Outside struct {
|
||||
EquipmentID string `json:"equipment_id"`
|
||||
ScheduleID string `json:"schedule_id"`
|
||||
Outside struct {
|
||||
SupplierName string `json:"supplier_name"`
|
||||
} `json:"outside"`
|
||||
Within struct {
|
||||
@ -311,6 +313,8 @@ func (c *Instance) Detail(id uint64) (*InstanceDetailInfo, error) {
|
||||
out.CommonIDString = basic.CommonIDString{
|
||||
ID: mWorkInstance.GetEncodeID(),
|
||||
}
|
||||
out.EquipmentID = (&model2.Model{ID: out.WorkInstanceInfo.EquipmentID}).GetEncodeID()
|
||||
out.ScheduleID = (&model2.Model{ID: out.WorkInstanceInfo.ScheduleID}).GetEncodeID()
|
||||
// 位置信息
|
||||
mWorkInstance.Distribution = out.WorkInstanceInfo.Distribution
|
||||
|
||||
|
@ -20,6 +20,11 @@ type (
|
||||
Title string `json:"title"`
|
||||
Schedules []*ScheduleDetailInfo `json:"schedules"`
|
||||
}
|
||||
// ScheduleBasicInfo 流程基本信息
|
||||
ScheduleBasicInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.WorkSchedule
|
||||
}
|
||||
// ScheduleDetailInfo 流程详细信息
|
||||
ScheduleDetailInfo struct {
|
||||
basic.CommonIDString
|
||||
@ -79,6 +84,21 @@ func (c *Schedule) List() ([]*ScheduleInfo, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Basic 基本信息
|
||||
func (c *Schedule) Basic(id uint64) (*ScheduleBasicInfo, error) {
|
||||
mWorkSchedule := model.NewWorkSchedule()
|
||||
mWorkSchedule.ID = id
|
||||
if isExist, err := model2.FirstField(mWorkSchedule.WorkSchedule, []string{"id", "kind", "title", "stage", "step"}); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,流程信息不存在或已被删除")
|
||||
}
|
||||
return &ScheduleBasicInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: mWorkSchedule.GetEncodeID()},
|
||||
WorkSchedule: mWorkSchedule,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Schedule) Form(params *ScheduleParams) error {
|
||||
if params.ID > 0 {
|
||||
|
@ -19,9 +19,11 @@ type (
|
||||
Title string `json:"title"`
|
||||
OrderNo string `json:"order_no"`
|
||||
Kind model.WorkInstanceKind `json:"kind"`
|
||||
EquipmentID uint64 `json:"-"`
|
||||
EquipmentCode string `json:"equipment_code"`
|
||||
EquipmentTitle string `json:"equipment_title"`
|
||||
BreakdownTitle string `json:"breakdown_title"`
|
||||
ScheduleID uint64 `json:"-"`
|
||||
ScheduleTitle string `json:"schedule_title"`
|
||||
SupplierName string `json:"-"`
|
||||
Priority int `json:"priority"`
|
||||
@ -56,9 +58,9 @@ func (m *WorkbenchCondition) roleInfo() string {
|
||||
// Detail 详细信息
|
||||
func (m *WorkInstance) Detail(id uint64) (*WorkInstanceInfo, error) {
|
||||
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", "w.equipment_id", "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",
|
||||
"s.title AS schedule_title", "supplier.name AS supplier_name", "w.distribution", "w.plate_number", "w.remark", "w.status", "w.created_at").
|
||||
"w.schedule AS schedule_id", "s.title AS schedule_title", "supplier.name AS supplier_name", "w.distribution", "w.plate_number", "w.remark", "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 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())).
|
||||
|
@ -12,23 +12,27 @@ type WorkMaterial struct {
|
||||
|
||||
// WorkMaterialInfo 器材信息
|
||||
type WorkMaterialInfo struct {
|
||||
ID uint64 `json:"-"`
|
||||
MaterialNumber float64 `json:"material_number"`
|
||||
MaterialCode string `json:"material_code"`
|
||||
MaterialTitle string `json:"material_title"`
|
||||
MaterialPrice float64 `json:"material_price"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
ID uint64 `json:"-"`
|
||||
MaterialNumber float64 `json:"material_number"`
|
||||
MaterialCode string `json:"material_code"`
|
||||
MaterialTitle string `json:"material_title"`
|
||||
MaterialPrice float64 `json:"material_price"`
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
}
|
||||
|
||||
// Materials 器材信息
|
||||
func (m *WorkMaterial) Materials(workID uint64) ([]*WorkMaterialInfo, error) {
|
||||
mManageSupplier := model.NewManageSupplier()
|
||||
|
||||
out := make([]*WorkMaterialInfo, 0)
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" w").
|
||||
Select("w.id", "w.material_number", "m.code AS material_code", "m.title AS material_title",
|
||||
"m.price AS material_price", "s.name AS supplier_name").
|
||||
"m.price AS material_price", "m_s.name AS manufacturer_name", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON w.material_id = m.id", model.NewManageMaterial().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON w.material_supplier_id = s.id", model.NewManageSupplier().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON w.material_supplier_id = s.id", mManageSupplier.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m_s ON m.manufacturer_id = m_s.id", mManageSupplier.TableName())).
|
||||
Where("w.work_id = ?", workID)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
|
@ -13,7 +13,7 @@ type WorkPurchase struct {
|
||||
type WorkPurchaseInfo struct {
|
||||
*model.WorkPurchase
|
||||
Price float64 `json:"price"`
|
||||
Number float64 `json:"number"`
|
||||
MaterialNumber float64 `json:"material_number"`
|
||||
MaterialCode string `json:"material_code"`
|
||||
MaterialTitle string `json:"material_title"`
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
@ -25,8 +25,8 @@ func (m *WorkPurchase) Purchases(workID uint64) ([]*WorkPurchaseInfo, error) {
|
||||
mManageSupplier := model.NewManageSupplier()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "m_p.price", "m_p.number", "m.code AS material_code", "m.title AS material_title",
|
||||
"m_s.name AS manufacturer_name", "s.name AS supplier_id").
|
||||
Select("p.id", "m_p.price", "m_p.number AS material_number", "m.code AS material_code", "m.title AS material_title",
|
||||
"m_s.name AS manufacturer_name", "s.name AS supplier_id", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m_p ON p.material_purchase_id = m_p.id", model.NewManageMaterialPurchase().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON m_p.material_id = m.id", model.NewManageMaterial().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m_p.supplier_id = s.id", mManageSupplier.TableName())).
|
||||
|
Reference in New Issue
Block a user