作者 tangxvhui

更新

@@ -30,3 +30,4 @@ swagger.yaml @@ -30,3 +30,4 @@ swagger.yaml
30 *.log 30 *.log
31 lastupdate.tmp 31 lastupdate.tmp
32 allied-creation-manufacture 32 allied-creation-manufacture
  33 +main_local.go
  1 +{
  2 + // 使用 IntelliSense 了解相关属性。
  3 + // 悬停以查看现有属性的描述。
  4 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  5 + "version": "0.2.0",
  6 + "configurations": [
  7 + {
  8 + "name": "Launch file",
  9 + "type": "go",
  10 + "request": "launch",
  11 + "mode": "debug",
  12 + "program": "./main.go",
  13 + "buildFlags": "--tags=local"
  14 + }
  15 +
  16 + ]
  17 +}
  1 +//go:build !local
  2 +// +build !local
  3 +
1 package main 4 package main
2 5
3 import ( 6 import (
4 "fmt" 7 "fmt"
  8 + "time"
  9 +
5 "github.com/beego/beego/v2/server/web" 10 "github.com/beego/beego/v2/server/web"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
@@ -9,7 +14,6 @@ import ( @@ -9,7 +14,6 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" 14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt" 15 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/task" 16 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/task"
12 - "time"  
13 17
14 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" 18 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
15 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg" 19 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg"
@@ -2,8 +2,6 @@ package dto @@ -2,8 +2,6 @@ package dto
2 2
3 type RewardStandardInfo struct { 3 type RewardStandardInfo struct {
4 Id int `json:"id"` //奖惩标准id 4 Id int `json:"id"` //奖惩标准id
5 - CompanyId int `json:"companyId"` //企业id  
6 - OrgId int `json:"orgId"` //组织ID  
7 WorkshopId int `json:"workshopId"` //车间id 5 WorkshopId int `json:"workshopId"` //车间id
8 WorkshopName string `json:"workshopName"` // 6 WorkshopName string `json:"workshopName"` //
9 LineId int `json:"lineId"` //生产线ID 7 LineId int `json:"lineId"` //生产线ID
@@ -12,6 +12,6 @@ type RewardStandardList struct { @@ -12,6 +12,6 @@ type RewardStandardList struct {
12 TargetType int `json:"targetType"` //指标类别 1:产效 2:合格率 3:安全事故 4:质量事故 5:异物次数 12 TargetType int `json:"targetType"` //指标类别 1:产效 2:合格率 3:安全事故 4:质量事故 5:异物次数
13 TargetTypeName string `json:"targetTypeName"` //指标类别 13 TargetTypeName string `json:"targetTypeName"` //指标类别
14 TargeReward string `json:"targeReward"` //描述功劳指标 14 TargeReward string `json:"targeReward"` //描述功劳指标
15 - TargeFault string `json:"targeVal2"` //描述过失指标 15 + TargeFault string `json:"targeFault"` //描述过失指标
16 16
17 } 17 }
@@ -98,6 +98,8 @@ func (srv RewardStandardService) SaveRewardStandard(operateInfo *domain.OperateI @@ -98,6 +98,8 @@ func (srv RewardStandardService) SaveRewardStandard(operateInfo *domain.OperateI
98 rewardStandardData.ProductLine = productLineData.SimpleProductLine() 98 rewardStandardData.ProductLine = productLineData.SimpleProductLine()
99 rewardStandardData.Workshop = workShopData.SimpleWorkshop() 99 rewardStandardData.Workshop = workShopData.SimpleWorkshop()
100 rewardStandardData.Remark = param.Remark 100 rewardStandardData.Remark = param.Remark
  101 + rewardStandardData.CompanyId = operateInfo.CompanyId
  102 + rewardStandardData.OrgId = operateInfo.OrgId
101 err = rewardStandardData.UpdateTarge( 103 err = rewardStandardData.UpdateTarge(
102 param.TargetType, 104 param.TargetType,
103 param.TargeVal1, 105 param.TargeVal1,
@@ -114,7 +116,8 @@ func (srv RewardStandardService) SaveRewardStandard(operateInfo *domain.OperateI @@ -114,7 +116,8 @@ func (srv RewardStandardService) SaveRewardStandard(operateInfo *domain.OperateI
114 if err := transactionContext.CommitTransaction(); err != nil { 116 if err := transactionContext.CommitTransaction(); err != nil {
115 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 117 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
116 } 118 }
117 - return nil, nil 119 + param.Id = rewardStandardData.Id
  120 + return param, nil
118 } 121 }
119 122
120 //GetRewardStandard 根据id获取奖惩标准数据 123 //GetRewardStandard 根据id获取奖惩标准数据
@@ -224,7 +227,7 @@ func (srv RewardStandardService) ListRewardStandard(param *query.ListRewardStand @@ -224,7 +227,7 @@ func (srv RewardStandardService) ListRewardStandard(param *query.ListRewardStand
224 if param.PageSize > 0 { 227 if param.PageSize > 0 {
225 condition["limit"] = param.PageSize 228 condition["limit"] = param.PageSize
226 } 229 }
227 - offset := param.PageSize * (param.PageSize - 1) 230 + offset := param.PageSize * (param.PageNumber - 1)
228 if offset > 0 { 231 if offset > 0 {
229 condition["offset"] = offset 232 condition["offset"] = offset
230 } 233 }
@@ -3,10 +3,11 @@ package pg @@ -3,10 +3,11 @@ package pg
3 import ( 3 import (
4 "context" 4 "context"
5 "fmt" 5 "fmt"
6 - "github.com/beego/beego/v2/core/logs"  
7 "log" 6 "log"
8 "reflect" 7 "reflect"
9 8
  9 + "github.com/beego/beego/v2/core/logs"
  10 +
10 "github.com/go-pg/pg/v10" 11 "github.com/go-pg/pg/v10"
11 "github.com/go-pg/pg/v10/orm" 12 "github.com/go-pg/pg/v10/orm"
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" 13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
@@ -50,6 +51,7 @@ func init() { @@ -50,6 +51,7 @@ func init() {
50 (*models.WorkshopPlanCompletionRecord)(nil), 51 (*models.WorkshopPlanCompletionRecord)(nil),
51 (*models.ProductMaterialGroup)(nil), 52 (*models.ProductMaterialGroup)(nil),
52 (*models.ProductMaterial)(nil), 53 (*models.ProductMaterial)(nil),
  54 + (*models.RewardStandard)(nil),
53 } { 55 } {
54 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 56 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
55 Temp: false, 57 Temp: false,
@@ -9,8 +9,10 @@ import ( @@ -9,8 +9,10 @@ import (
9 //RewardStandard 奖惩标准 9 //RewardStandard 奖惩标准
10 type RewardStandard struct { 10 type RewardStandard struct {
11 tableName string `pg:"manufacture.reward_standard,alias:reward_standard"` 11 tableName string `pg:"manufacture.reward_standard,alias:reward_standard"`
12 - Id int `pg:"pk:id"` //奖惩标准 id  
13 - Workshop domain.SimpleWorkshop //车间id 12 + Id int `pg:"pk:id"` //奖惩标准 id
  13 + CompanyId int `comment:"企业id"` // 企业id
  14 + OrgId int `comment:"组织ID"` // 组织ID
  15 + Workshop domain.SimpleWorkshop //车间
14 ProductLine domain.SimpleProductLine //生产线 16 ProductLine domain.SimpleProductLine //生产线
15 ProductSection domain.ProductSection //工段 17 ProductSection domain.ProductSection //工段
16 Remark string //备注 18 Remark string //备注
@@ -50,6 +50,8 @@ func (repo *RewardStandardRepository) Save(param *domain.RewardStandard) (*domai @@ -50,6 +50,8 @@ func (repo *RewardStandardRepository) Save(param *domain.RewardStandard) (*domai
50 CreatedAt: param.CreatedAt, 50 CreatedAt: param.CreatedAt,
51 UpdatedAt: param.UpdatedAt, 51 UpdatedAt: param.UpdatedAt,
52 DeletedAt: param.DeletedAt, 52 DeletedAt: param.DeletedAt,
  53 + CompanyId: param.CompanyId,
  54 + OrgId: param.OrgId,
53 } 55 }
54 tx := repo.transactionContext.PgTx 56 tx := repo.transactionContext.PgTx
55 if param.Id == 0 { 57 if param.Id == 0 {
@@ -117,13 +119,13 @@ func (repo *RewardStandardRepository) Find(queryOptions map[string]interface{}) @@ -117,13 +119,13 @@ func (repo *RewardStandardRepository) Find(queryOptions map[string]interface{})
117 query.Offset(v) 119 query.Offset(v)
118 } 120 }
119 if v, ok := queryOptions["workshopId"]; ok { 121 if v, ok := queryOptions["workshopId"]; ok {
120 - query.Where("work_shop->>'workshopId'='?'", v) 122 + query.Where("workshop->>'workshopId'='?'", v)
121 } 123 }
122 if v, ok := queryOptions["lineId"]; ok { 124 if v, ok := queryOptions["lineId"]; ok {
123 - query.Where("product_line->>lineId='?'", v) 125 + query.Where("product_line->>'lineId'='?'", v)
124 } 126 }
125 if v, ok := queryOptions["sectionId"]; ok { 127 if v, ok := queryOptions["sectionId"]; ok {
126 - query.Where("product_section->>sectionId='?'", v) 128 + query.Where("product_section->>'sectionId'='?'", v)
127 } 129 }
128 130
129 if v, ok := queryOptions["targetType"]; ok { 131 if v, ok := queryOptions["targetType"]; ok {
@@ -168,5 +170,7 @@ func (repo *RewardStandardRepository) TransformToDomain(param *models.RewardStan @@ -168,5 +170,7 @@ func (repo *RewardStandardRepository) TransformToDomain(param *models.RewardStan
168 CreatedAt: param.CreatedAt, 170 CreatedAt: param.CreatedAt,
169 UpdatedAt: param.UpdatedAt, 171 UpdatedAt: param.UpdatedAt,
170 DeletedAt: param.DeletedAt, 172 DeletedAt: param.DeletedAt,
  173 + CompanyId: param.CompanyId,
  174 + OrgId: param.OrgId,
171 } 175 }
172 } 176 }
1 package beego 1 package beego
2 2
3 import ( 3 import (
4 - "github.com/beego/beego/v2/server/web"  
5 - "github.com/linmadan/egglib-go/web/beego/filters"  
6 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"  
7 "net/http" 4 "net/http"
8 "net/http/pprof" 5 "net/http/pprof"
9 "os" 6 "os"
10 "strconv" 7 "strconv"
11 8
  9 + "github.com/beego/beego/v2/server/web"
  10 + "github.com/linmadan/egglib-go/web/beego/filters"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
  12 +
12 . "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" 13 . "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
13 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/beego/routers" 14 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/beego/routers"
14 ) 15 )
@@ -30,7 +31,7 @@ func init() { @@ -30,7 +31,7 @@ func init() {
30 } 31 }
31 } 32 }
32 //https支持 33 //https支持
33 - web.BConfig.Listen.EnableHTTPS = true 34 + web.BConfig.Listen.EnableHTTPS = false
34 web.BConfig.Listen.HTTPSPort = 443 35 web.BConfig.Listen.HTTPSPort = 443
35 36
36 //进程内监控 37 //进程内监控
@@ -26,6 +26,8 @@ func (c RewardStandardController) UpdateRewardStandard() { @@ -26,6 +26,8 @@ func (c RewardStandardController) UpdateRewardStandard() {
26 srv := service.NewRewardStandardService(nil) 26 srv := service.NewRewardStandardService(nil)
27 createCommand := &command.SaveRewardStandardCommand{} 27 createCommand := &command.SaveRewardStandardCommand{}
28 Must(c.Unmarshal(createCommand)) 28 Must(c.Unmarshal(createCommand))
  29 + id, _ := c.GetInt(":id")
  30 + createCommand.Id = id
29 operater := ParseOperateInfo(c.BaseController) 31 operater := ParseOperateInfo(c.BaseController)
30 data, err := srv.SaveRewardStandard(operater, createCommand) 32 data, err := srv.SaveRewardStandard(operater, createCommand)
31 c.Response(data, err) 33 c.Response(data, err)