feat:完善项目
This commit is contained in:
@ -122,6 +122,11 @@ func (*Manage) Equipment(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) EquipmentTree(c *gin.Context) {
|
||||
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).Tree()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/manage/equipment/select 装备Select信息
|
||||
* @apiVersion 1.0.0
|
||||
|
@ -34,6 +34,11 @@ type (
|
||||
SupplierID string `json:"supplier_id" form:"supplier_id"`
|
||||
Number float64 `json:"number" form:"number"`
|
||||
}
|
||||
// workLaunchPurchaseForm 工单发起配件信息
|
||||
workLaunchPurchaseForm struct {
|
||||
workLaunchMaterialForm
|
||||
Price float64 `json:"price" form:"price"`
|
||||
}
|
||||
// workLaunchDistributionForm 工单发起地址信息
|
||||
workLaunchDistributionForm struct {
|
||||
Name string `json:"name" form:"name"` // 联系人
|
||||
@ -357,10 +362,15 @@ func (*Work) Detail(c *gin.Context) {
|
||||
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||
*
|
||||
* @apiParam {Object} within 内修参数信息
|
||||
* @apiParam {Object[]} within.material 配件信息,内修才需要上传
|
||||
* @apiParam {Object[]} within.material 配件信息
|
||||
* @apiParam {String} within.material.id 配件ID
|
||||
* @apiParam {String} within.material.supplier_id 供应商ID
|
||||
* @apiParam {Number} within.material.number 配件数量
|
||||
* @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 采购价格
|
||||
* @apiParam {Object} outside 外修参数信息
|
||||
* @apiParam {String} outside.supplier_id 配件ID
|
||||
* @apiParam {Number} kind 工单类型
|
||||
@ -396,6 +406,7 @@ func (*Work) Launch(c *gin.Context) {
|
||||
} `json:"outside" form:"outside"`
|
||||
Within struct {
|
||||
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
||||
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
|
||||
} `json:"within" form:"within"`
|
||||
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
|
||||
}{}
|
||||
@ -410,11 +421,18 @@ func (*Work) Launch(c *gin.Context) {
|
||||
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)).Launch(&work.InstanceLaunchParams{
|
||||
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,
|
||||
Material: materials, Purchase: purchase,
|
||||
Distribution: &work.InstanceLaunchParamsForDistribution{
|
||||
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
|
||||
},
|
||||
@ -431,6 +449,16 @@ func (*Work) Launch(c *gin.Context) {
|
||||
* @apiHeader {string} x-token token
|
||||
* @apiHeader {string} Content-Type=application/json 传输方式
|
||||
*
|
||||
* @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 采购价格
|
||||
* @apiParam {String} id 工单ID
|
||||
* @apiParam {String} status 审核状态
|
||||
* @apiParam {String} remark 备注信息
|
||||
@ -454,12 +482,31 @@ func (*Work) Examine(c *gin.Context) {
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
IsAssist int `json:"is_assist" form:"is_assist"`
|
||||
Within struct {
|
||||
Material []*workLaunchMaterialForm `json:"material" form:"material"`
|
||||
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
|
||||
} `json:"within" form:"within"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := work.NewInstance()(getSession()(c).(*service.Session)).Examine(form.Convert(), form.Status, form.Remark, form.IsAssist)
|
||||
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})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,13 @@ package model
|
||||
// ManageMaterialPurchase 维修器材采购数据明细
|
||||
type ManageMaterialPurchase struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(30);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialSupplierID uint64 `gorm:"column:material_supplier_id;type:int(6);default:0;comment:器材ID" json:"-"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:采购单价" json:"price"`
|
||||
Number int `gorm:"column:number;type:int(8);default:0;comment:采购数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:采购备注" json:"remark"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(30);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialID uint64 `gorm:"column:material_id;type:int(6);default:0;comment:器材ID" json:"-"`
|
||||
SupplierID uint64 `gorm:"column:supplier_id;type:int(6);default:0;comment:供应商ID" json:"-"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:采购单价" json:"price"`
|
||||
Number float64 `gorm:"column:number;type:decimal(10,2);default:0;comment:采购数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:采购备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package model
|
||||
// ManageMaterialWarehouse 维修器材采购入库明细
|
||||
type ManageMaterialWarehouse struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"material_purchase_id"`
|
||||
Number int `gorm:"column:number;type:int(8);default:0;comment:入库数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:入库备注" json:"remark"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"material_purchase_id"`
|
||||
Number float64 `gorm:"column:number;type:decimal(10,2);default:0;comment:入库数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:入库备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -113,6 +113,25 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Tree 树状列表
|
||||
func (c *Equipment) Tree() ([]*EquipmentInfo, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("parent_id", model2.OrderModeToAsc),
|
||||
},
|
||||
}
|
||||
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "parent_id", "code", "title"},
|
||||
where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.tree(mManageEquipment.ManageEquipment, out, 0), nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Equipment) Select(parentID uint64) ([]*EquipmentBasic, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
@ -19,6 +19,7 @@ type (
|
||||
EquipmentMaterialInfo struct {
|
||||
*model.ManageMaterialBasic
|
||||
basic.CommonIDString
|
||||
MaterialID string `json:"material_id"`
|
||||
}
|
||||
EquipmentMaterialBindParams struct {
|
||||
EquipmentID uint64
|
||||
@ -43,6 +44,7 @@ func (c *EquipmentMaterial) List(equipmentID uint64) ([]*EquipmentMaterialInfo,
|
||||
list = append(list, &EquipmentMaterialInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageEquipmentMaterial.GetEncodeID()},
|
||||
ManageMaterialBasic: v,
|
||||
MaterialID: (&model2.Model{ID: v.MaterialID}).GetEncodeID(),
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
|
@ -20,6 +20,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *MaterialPurchase) List(orderNo, supplierName, materialTitle string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
|
||||
@ -53,11 +54,12 @@ func (c *MaterialPurchase) List(orderNo, supplierName, materialTitle string, pag
|
||||
}
|
||||
|
||||
// Launch 采购发起
|
||||
func (c *MaterialPurchase) Launch(materialSupplierID uint64, price float64, number int, remark string) error {
|
||||
func (c *MaterialPurchase) Launch(materialID, supplierID uint64, price, number float64, remark string) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
mManageMaterialPurchase.UID = c.UID
|
||||
mManageMaterialPurchase.OrderNo = lib.OrderNo()
|
||||
mManageMaterialPurchase.MaterialSupplierID = materialSupplierID
|
||||
mManageMaterialPurchase.MaterialID = materialID
|
||||
mManageMaterialPurchase.SupplierID = supplierID
|
||||
mManageMaterialPurchase.Price = price
|
||||
mManageMaterialPurchase.Number = number
|
||||
mManageMaterialPurchase.Remark = remark
|
||||
|
@ -16,6 +16,7 @@ type (
|
||||
MaterialSupplerBasic struct {
|
||||
basic.CommonIDString
|
||||
*model.ManageMaterialSupplierBasic
|
||||
Stock float64 `json:"stock"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -36,9 +37,15 @@ func (c *MaterialSuppler) Select(materialID uint64) ([]*MaterialSupplerBasic, er
|
||||
for _, v := range out {
|
||||
mManageMaterSupplier.SetID(v.ID)
|
||||
|
||||
stock := v.Stock - v.FrozenStock
|
||||
|
||||
if stock < 0 {
|
||||
stock = 0
|
||||
}
|
||||
list = append(list, &MaterialSupplerBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageMaterSupplier.GetEncodeID()},
|
||||
ManageMaterialSupplierBasic: v,
|
||||
Stock: stock,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
|
@ -19,7 +19,7 @@ func (c *MaterialWarehouse) List() (*basic.PageDataResponse, error) {
|
||||
}
|
||||
|
||||
// Launch 入库发起
|
||||
func (c *MaterialWarehouse) Launch(materialPurchaseID uint64, number int, remark string) error {
|
||||
func (c *MaterialWarehouse) Launch(materialPurchaseID uint64, number float64, remark string) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
mManageMaterialPurchase.ID = materialPurchaseID
|
||||
|
||||
|
@ -49,6 +49,7 @@ type (
|
||||
Remark string // 备注信息
|
||||
Supplier *InstanceLaunchParamsForSupplier
|
||||
Material []*InstanceLaunchParamsForMaterial
|
||||
Purchase []*InstanceLaunchParamsForPurchase
|
||||
Distribution *InstanceLaunchParamsForDistribution
|
||||
}
|
||||
// InstanceLaunchParamsForSupplier 供应商信息
|
||||
@ -61,10 +62,22 @@ type (
|
||||
SupplierID uint64 // 供应商ID
|
||||
Number float64 // 需要数量
|
||||
}
|
||||
// InstanceLaunchParamsForPurchase 采购信息
|
||||
InstanceLaunchParamsForPurchase struct {
|
||||
ID uint64 // 器材ID
|
||||
SupplierID uint64 // 供应商ID
|
||||
Price float64 // 采购单价
|
||||
Number float64 // 采购数量
|
||||
}
|
||||
// InstanceLaunchParamsForDistribution 配送信息
|
||||
InstanceLaunchParamsForDistribution struct {
|
||||
Name, Mobile, Address string
|
||||
}
|
||||
// InstanceExamineParams 审核参数信息
|
||||
InstanceExamineParams struct {
|
||||
Material []*InstanceLaunchParamsForMaterial
|
||||
Purchase []*InstanceLaunchParamsForPurchase
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) publish(kind int, reviewer []string) {
|
||||
@ -83,6 +96,70 @@ func (c *Instance) publish(kind int, reviewer []string) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Instance) material(tx *gorm.DB, material []*InstanceLaunchParamsForMaterial, workID uint64) error {
|
||||
// 工单器材信息
|
||||
workMaterials := make([]*model2.WorkMaterial, 0)
|
||||
|
||||
for _, v := range material {
|
||||
if v.ID <= 0 || v.SupplierID <= 0 || v.Number <= 0 {
|
||||
return errors.New("操作错误,器材参数不完全")
|
||||
}
|
||||
workMaterials = append(workMaterials, &model2.WorkMaterial{
|
||||
MaterialID: v.ID, MaterialSupplierID: v.SupplierID, MaterialNumber: v.Number,
|
||||
})
|
||||
}
|
||||
// 处理库存信息
|
||||
if len(workMaterials) > 0 {
|
||||
mManageMaterialSupplier := model.NewManageMaterialSupplier()
|
||||
|
||||
now := time.Now()
|
||||
|
||||
for _, v := range workMaterials {
|
||||
v.WorkID = workID
|
||||
|
||||
if err := model2.UpdatesWhere(mManageMaterialSupplier.ManageMaterialSupplier, map[string]interface{}{
|
||||
"frozen_stock": gorm.Expr("frozen_stock + ?", v.MaterialNumber), "updated_at": now,
|
||||
}, []*model2.ModelWhere{
|
||||
model2.NewWhere("material_id", v.MaterialID),
|
||||
model2.NewWhere("supplier_id", v.MaterialSupplierID),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
mWorkMaterial := model.NewWorkMaterial()
|
||||
|
||||
if err := model2.Creates(mWorkMaterial.WorkMaterial, &workMaterials, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/// purchase 采购操作
|
||||
func (c *Instance) purchase(tx *gorm.DB, purchase []*InstanceLaunchParamsForPurchase) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
|
||||
_purchase := make([]*model2.ManageMaterialPurchase, 0)
|
||||
|
||||
for _, v := range purchase {
|
||||
_purchase = append(_purchase, &model2.ManageMaterialPurchase{
|
||||
UID: c.UID,
|
||||
OrderNo: lib.OrderNo(),
|
||||
MaterialID: v.ID,
|
||||
SupplierID: v.SupplierID,
|
||||
Price: v.Price,
|
||||
Number: v.Number,
|
||||
Remark: "工单采购",
|
||||
})
|
||||
}
|
||||
if len(_purchase) > 0 {
|
||||
if err := model2.Creates(mManageMaterialPurchase.ManageMaterialPurchase, _purchase, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *Instance) List(materialID uint64, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mWorkInstance := model.NewWorkInstance()
|
||||
@ -259,24 +336,12 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
|
||||
// 工单流程信息
|
||||
mWorkProgress := model.NewWorkProgress()
|
||||
// 工单器材信息
|
||||
workMaterials := make([]*model2.WorkMaterial, 0)
|
||||
|
||||
if mWorkInstance.Kind == model2.WorkInstanceKindForOutside {
|
||||
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 {
|
||||
if v.ID <= 0 || v.SupplierID <= 0 || v.Number <= 0 {
|
||||
return errors.New("操作错误,器材参数不完全")
|
||||
}
|
||||
workMaterials = append(workMaterials, &model2.WorkMaterial{
|
||||
MaterialID: v.ID, MaterialSupplierID: v.SupplierID, MaterialNumber: v.Number,
|
||||
})
|
||||
}
|
||||
}
|
||||
// 查询工单进度流程
|
||||
// TODO:工单流程
|
||||
@ -302,8 +367,6 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
mWorkInstance.Status = model2.WorkInstanceStatusForOngoing
|
||||
mWorkInstance.Schedule = nextWorkSchedule.ID
|
||||
}
|
||||
now := time.Now()
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Create(mWorkInstance.WorkInstance, tx); err != nil {
|
||||
return err
|
||||
@ -318,25 +381,14 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 处理库存信息
|
||||
if len(workMaterials) > 0 {
|
||||
mManageMaterialSupplier := model.NewManageMaterialSupplier()
|
||||
|
||||
for _, v := range workMaterials {
|
||||
v.WorkID = mWorkInstance.ID
|
||||
|
||||
if err = model2.UpdatesWhere(mManageMaterialSupplier.ManageMaterialSupplier, map[string]interface{}{
|
||||
"frozen_stock": gorm.Expr("frozen_stock + ?", v.MaterialNumber), "updated_at": now,
|
||||
}, []*model2.ModelWhere{
|
||||
model2.NewWhere("material_id", v.MaterialID),
|
||||
model2.NewWhere("supplier_id", v.MaterialSupplierID),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 内修模块信息
|
||||
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && params.IsAssist <= 0 {
|
||||
// 物料信息
|
||||
if err = c.material(tx, params.Material, mWorkInstance.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
mWorkMaterial := model.NewWorkMaterial()
|
||||
|
||||
if err = model2.Creates(mWorkMaterial.WorkMaterial, &workMaterials, tx); err != nil {
|
||||
// 采购信息
|
||||
if err = c.purchase(tx, params.Purchase); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -349,7 +401,7 @@ func (c *Instance) Launch(params *InstanceLaunchParams) error {
|
||||
}
|
||||
|
||||
// Examine 审核操作
|
||||
func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) error {
|
||||
func (c *Instance) Examine(id uint64, status int, remark string, isAssist int, params *InstanceExamineParams) error {
|
||||
_status := model2.WorkProgressStatus(status)
|
||||
|
||||
if _status != model2.WorkProgressStatusForAgree && _status != model2.WorkProgressStatusForRefuse {
|
||||
@ -384,8 +436,7 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
||||
} else if !isAuth {
|
||||
return errors.New("操作错误,无权限审批")
|
||||
}
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 工单流程记录
|
||||
mWorkProgress := model.NewWorkProgress()
|
||||
mWorkProgress.UID = c.UID
|
||||
@ -438,15 +489,23 @@ func (c *Instance) Examine(id uint64, status int, remark string, isAssist int) e
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 处理器材信息
|
||||
if mWorkInstance.Kind == model2.WorkInstanceKindForWithin && isAssist <= 0 {
|
||||
// 物料信息
|
||||
if err = c.material(tx, params.Material, id); err != nil {
|
||||
return err
|
||||
}
|
||||
// 采购信息
|
||||
if err = c.purchase(tx, params.Purchase); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 推送通知
|
||||
if nextScheduleInfo != nil {
|
||||
go c.publish(int(mWorkInstance.Kind), nextScheduleInfo.Reviewer)
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
|
@ -13,7 +13,7 @@ type ManageEquipmentMaterial struct {
|
||||
// Materials 器材信息
|
||||
func (m *ManageEquipmentMaterial) Materials(equipmentID uint64) ([]*ManageMaterialBasic, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.id", "m.code", "m.title", "m.unit", "s.name AS manufacturer_name").
|
||||
Select("e.id", "e.material_id", "m.code", "m.title", "m.price", "m.unit", "s.name AS manufacturer_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON e.material_id = m.id", model.NewManageMaterial().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m.manufacturer_id = s.id", model.NewManageSupplier().TableName())).
|
||||
Where("e.equipment_id = ? AND e.is_deleted = ?", equipmentID, model.DeleteStatusForNot)
|
||||
|
@ -17,6 +17,7 @@ type (
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Price float64 `json:"price"`
|
||||
MaterialID uint64 `json:"material_id"`
|
||||
ManufacturerName string `json:"manufacturer_name"`
|
||||
}
|
||||
ManageMaterialInfo struct {
|
||||
|
@ -43,5 +43,5 @@ func (m *ManageMaterialPurchase) Purchases(page, pageSize int, count *int64, whe
|
||||
}
|
||||
|
||||
func NewManageMaterialPurchase() *ManageMaterialPurchase {
|
||||
return &ManageMaterialPurchase{}
|
||||
return &ManageMaterialPurchase{model.NewManageMaterialPurchase()}
|
||||
}
|
@ -10,15 +10,18 @@ type ManageMaterialSupplier struct {
|
||||
*model.ManageMaterialSupplier
|
||||
}
|
||||
|
||||
// ManageMaterialSupplierBasic 基本信息
|
||||
type ManageMaterialSupplierBasic struct {
|
||||
ID uint64 `json:"id"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
ID uint64 `json:"-"`
|
||||
Stock float64 `json:"-"`
|
||||
FrozenStock float64 `json:"-"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
}
|
||||
|
||||
// Basic 基本信息
|
||||
func (m *ManageMaterialSupplier) Basic(where ...*model.ModelWhere) ([]*ManageMaterialSupplierBasic, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" m_s").
|
||||
Select("m_s.id", "s.name AS supplier_name").
|
||||
Select("m_s.id", "m_s.stock", "m_s.frozen_stock", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m_s.supplier_id = s.id", model.NewManageSupplier().TableName())).
|
||||
Where("m_s.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
@ -7,5 +7,5 @@ type ManageMaterialWarehouse struct {
|
||||
}
|
||||
|
||||
func NewManageMaterialWarehouse() *ManageMaterialWarehouse {
|
||||
return &ManageMaterialWarehouse{}
|
||||
return &ManageMaterialWarehouse{model.NewManageMaterialWarehouse()}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ArmedPolice.exe main.go
|
@ -35,11 +35,13 @@ engine:
|
||||
mysql:
|
||||
# host: 47.96.31.6
|
||||
host: 192.168.0.188
|
||||
# host: 127.0.0.1
|
||||
port: 3306
|
||||
user: appuser
|
||||
password: ABCabc01!
|
||||
# password: ABCabc01
|
||||
db_name: armed_police
|
||||
parameters: charset=utf8mb4,utf8&parseTime=True&loc=Asia%2FShanghai
|
||||
parameters: charset=utf8mb4,utf8&parseTime=True&loc=Local
|
||||
# SQLITE 配置
|
||||
sqlite:
|
||||
path: data
|
||||
|
@ -36,7 +36,7 @@
|
||||
{
|
||||
"name": "ArmedPoliceServer-Window",
|
||||
"format": "zip",
|
||||
"pattern": "{ArmedPolice.exe,config.yaml,keys/*,json/*,server.sh}",
|
||||
"pattern": "{*.exe,config.yaml,dist/*,keys/*,json/*,server.sh}",
|
||||
"options": {
|
||||
"dot": true,
|
||||
"ignore": [
|
||||
@ -47,7 +47,7 @@
|
||||
{
|
||||
"name": "ArmedPoliceServer-Linux",
|
||||
"format": "tar",
|
||||
"pattern": "{ArmedPolice,config.yaml,keys/*,json/*,server.sh}",
|
||||
"pattern": "{ArmedPolice,config.yaml,dist/*,keys/*,json/*,server.sh}",
|
||||
"options": {
|
||||
"dot": true,
|
||||
"ignore": [
|
||||
|
@ -163,6 +163,7 @@ func (this *Router) registerAPI() {
|
||||
_api := new(api.Manage)
|
||||
manageV1.POST("/equipment", _api.Equipment)
|
||||
manageV1.GET("/equipment/select", _api.EquipmentSelect)
|
||||
manageV1.GET("/equipment/tree", _api.EquipmentTree)
|
||||
manageV1.POST("/equipment/detail", _api.EquipmentDetail)
|
||||
manageV1.POST("/equipment/add", _api.EquipmentAdd)
|
||||
manageV1.POST("/equipment/edit", _api.EquipmentEdit)
|
||||
|
@ -4,6 +4,6 @@ import "testing"
|
||||
|
||||
func TestSha256String(t *testing.T) {
|
||||
//t.Log(Md5String("9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05"))
|
||||
t.Log(HASHIDEncode(1))
|
||||
t.Log(HASHIDEncode(12))
|
||||
t.Log(HASHIDDecode("d3rJnGwE9o"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user