feat:完善项目

This commit is contained in:
henry
2021-11-19 15:34:22 +08:00
parent 7efe403bf0
commit c5f4a5d281
10 changed files with 168 additions and 21 deletions

View File

@ -1,3 +1,58 @@
# ArmedPolice
## ArmedPolice 武警工单系统管理
ArmedPolice 武警ERP
武警工单系统是一个基于Golang开发的后台管理系统
#### 注意事项
* ***config.yaml*** 包含了项目的运行配置
* 执行 ***build_linux.sh***、***build_window.sh*** 即可编译对应的运行程序
* 数据存储,仅支持***mysql***、***sqlite***
* 在使用***mysql***作为存储引擎时,需要提前先创建好数据表,并在配置中填写相应的连接信息
* 在使用***sqlite***,需要设置文件存储地址
``` type
# 数据引擎
engine:
# 开启会输出sql日志
debug: true
# db_mode - mysql | sqlite
db_mode: mysql
```
* 缓存存储,仅支持***mysql***、***sqlite***
* 在使用***redis***时,在配置中填写相应的连接信息
``` type
# 数据引擎
cache:
# memory | redis
type: redis
```
### 项目目录
* ***json*** 配置管理,存放配置并项目运行加载
* ***log*** 日志管理
* ***doc*** api文档管理
### 项目启动
- Windows
- 在根目录执行双击ArmedPolice.exe
- 在控制台中执行./ArmedPolice.exe可携带参数启动参数-key=value(建议第二种)
- Linux
- 在根目录执行ArmedPolice可携带参数启动参数 -key=value
- 执行server.sh ***start***|***restart***|***stop***
``` type
servier.sh
# 替换为你自己的执行程序
APP_NAME=main
# 项目的路径(替换成项目的路径)
PROJECT_LOCATION=/home/www/SciencesServer
```
- 参数信息
- init=truefalse 项目第一次运行设置true会自动迁移数据表默认false
- config="" 配置文件存放地址,默认./config.yaml
- mode=debugrelease 版本信息默认release

View File

@ -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

View File

@ -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()},
)
}

View File

@ -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

View File

@ -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 {

View File

@ -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())).

View File

@ -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 {

View File

@ -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())).

View File

@ -36,7 +36,7 @@
{
"name": "ArmedPoliceServer-Window",
"format": "zip",
"pattern": "{*.exe,config.yaml,dist/*,keys/*,json/*,server.sh}",
"pattern": "{*.exe,config.yaml,dist/*,keys/*,json/*,README.md}",
"options": {
"dot": true,
"ignore": [

View File

@ -197,6 +197,7 @@ func (this *Router) registerAPI() {
workV1.POST("/examine", _api.Examine)
workV1.POST("/delete", _api.Delete)
workV1.GET("/schedule", _api.Schedule)
workV1.POST("/schedule/basic", _api.ScheduleBasic)
workV1.POST("/schedule/edit", _api.ScheduleEdit)
workV1.POST("/schedule/delete", _api.ScheduleDelete)
workV1.POST("/repair", _api.Repair)
@ -236,7 +237,7 @@ func (this *Router) Init() *gin.Engine {
app.MaxMultipartMemory = 4 << 20
this.handler = app
// 注册路由
this.registerWeb()
//this.registerWeb()
this.registerAPI()
return app