正在显示
8 个修改的文件
包含
53 行增加
和
13 行删除
@@ -20,9 +20,6 @@ import ( | @@ -20,9 +20,6 @@ import ( | ||
20 | ) | 20 | ) |
21 | 21 | ||
22 | func main() { | 22 | func main() { |
23 | - log.Logger.Info("server start ....") | ||
24 | - log.Logger.Info(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
25 | - | ||
26 | if constant.ENABLE_KAFKA_LOG { | 23 | if constant.ENABLE_KAFKA_LOG { |
27 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) | 24 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) |
28 | log.Logger.AddHook(w) | 25 | log.Logger.AddHook(w) |
@@ -34,6 +31,9 @@ func main() { | @@ -34,6 +31,9 @@ func main() { | ||
34 | }) | 31 | }) |
35 | log.Logger.AddHook(bw) | 32 | log.Logger.AddHook(bw) |
36 | redis.InitRedis() | 33 | redis.InitRedis() |
34 | + log.Logger.Debug("server start ....") | ||
35 | + log.Logger.Debug(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
36 | + | ||
37 | go mqtt.Start() | 37 | go mqtt.Start() |
38 | go task.Run() | 38 | go task.Run() |
39 | cron := crontab.NewCrontabService(nil) | 39 | cron := crontab.NewCrontabService(nil) |
@@ -2,6 +2,7 @@ package dto | @@ -2,6 +2,7 @@ package dto | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" | ||
5 | "strings" | 6 | "strings" |
6 | ) | 7 | ) |
7 | 8 | ||
@@ -19,6 +20,7 @@ type ProductGroupEmployeesDto struct { | @@ -19,6 +20,7 @@ type ProductGroupEmployeesDto struct { | ||
19 | WorkOnDescription string `json:"workOn,omitempty"` | 20 | WorkOnDescription string `json:"workOn,omitempty"` |
20 | // 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID) | 21 | // 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID) |
21 | //WorkStationId string `json:"workStationId,omitempty"` | 22 | //WorkStationId string `json:"workStationId,omitempty"` |
23 | + UserNamePinyin string `json:"pinyin"` | ||
22 | } | 24 | } |
23 | 25 | ||
24 | func NewProductGroupEmployeesDto(group *domain.ProductGroup) []*ProductGroupEmployeesDto { | 26 | func NewProductGroupEmployeesDto(group *domain.ProductGroup) []*ProductGroupEmployeesDto { |
@@ -41,6 +43,9 @@ func NewGroupEmployee(group *domain.ProductGroup, u *domain.User) *ProductGroupE | @@ -41,6 +43,9 @@ func NewGroupEmployee(group *domain.ProductGroup, u *domain.User) *ProductGroupE | ||
41 | workOns := domain.WorkOnDescription(group.WorkOn) | 43 | workOns := domain.WorkOnDescription(group.WorkOn) |
42 | item.WorkOnDescription = strings.Join(workOns, ",") | 44 | item.WorkOnDescription = strings.Join(workOns, ",") |
43 | //item.WorkStationId = group.WorkStation.WorkStationId | 45 | //item.WorkStationId = group.WorkStation.WorkStationId |
46 | + if len(item.UserName) > 0 { | ||
47 | + item.UserNamePinyin = converter.ToPinYin(item.UserName, "") | ||
48 | + } | ||
44 | return item | 49 | return item |
45 | } | 50 | } |
46 | 51 | ||
@@ -72,3 +77,11 @@ func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { | @@ -72,3 +77,11 @@ func NewProductGroupEmployeesDtos() *ProductGroupEmployeesDtos { | ||
72 | MapResult: make(map[int]*ProductGroupEmployeesDto), | 77 | MapResult: make(map[int]*ProductGroupEmployeesDto), |
73 | } | 78 | } |
74 | } | 79 | } |
80 | + | ||
81 | +func (ms *ProductGroupEmployeesDtos) Len() int { return len(ms.Result) } | ||
82 | +func (ms *ProductGroupEmployeesDtos) Less(i, j int) bool { | ||
83 | + return ms.Result[i].UserNamePinyin < ms.Result[j].UserNamePinyin | ||
84 | +} | ||
85 | +func (ms *ProductGroupEmployeesDtos) Swap(i, j int) { | ||
86 | + ms.Result[i], ms.Result[j] = ms.Result[j], ms.Result[i] | ||
87 | +} |
@@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" |
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
14 | + "sort" | ||
14 | "time" | 15 | "time" |
15 | ) | 16 | ) |
16 | 17 | ||
@@ -401,6 +402,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -401,6 +402,7 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
401 | items := dto.NewProductGroupEmployeesDto(item) | 402 | items := dto.NewProductGroupEmployeesDto(item) |
402 | results.Append(items...) | 403 | results.Append(items...) |
403 | } | 404 | } |
405 | + sort.Stable(results) | ||
404 | if err := transactionContext.CommitTransaction(); err != nil { | 406 | if err := transactionContext.CommitTransaction(); err != nil { |
405 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 407 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
406 | } | 408 | } |
@@ -3,8 +3,8 @@ package domain | @@ -3,8 +3,8 @@ package domain | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | const ( | 5 | const ( |
6 | - ParticipateNormal = 1 | ||
7 | - ParticipateSupport = 2 | 6 | + ParticipateNormal = 1 // 正常 |
7 | + ParticipateSupport = 2 // 支援 | ||
8 | ) | 8 | ) |
9 | 9 | ||
10 | const ( | 10 | const ( |
@@ -28,7 +28,7 @@ type EmployeeProductRecord struct { | @@ -28,7 +28,7 @@ type EmployeeProductRecord struct { | ||
28 | WorkOn int `json:"workOn"` | 28 | WorkOn int `json:"workOn"` |
29 | // 参与类型 1:正常 2:支援 | 29 | // 参与类型 1:正常 2:支援 |
30 | ParticipateType int `json:"participateType"` | 30 | ParticipateType int `json:"participateType"` |
31 | - // 产能 | 31 | + // 初始产能 |
32 | ProductWeigh float64 `json:"productWeigh"` | 32 | ProductWeigh float64 `json:"productWeigh"` |
33 | // 二级品产能 | 33 | // 二级品产能 |
34 | SecondLevelWeigh float64 `json:"secondLevelWeigh"` | 34 | SecondLevelWeigh float64 `json:"secondLevelWeigh"` |
@@ -72,9 +72,11 @@ func (employeeProductRecord *EmployeeProductRecord) UpdateProductWeigh(weigh flo | @@ -72,9 +72,11 @@ func (employeeProductRecord *EmployeeProductRecord) UpdateProductWeigh(weigh flo | ||
72 | employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh = make(map[string]float64) | 72 | employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh = make(map[string]float64) |
73 | } | 73 | } |
74 | if productRecordType == RecordTypeSecondLevelWeigh { | 74 | if productRecordType == RecordTypeSecondLevelWeigh { |
75 | + // 当前工段 | ||
75 | if employeeProductRecord.WorkStation.SectionName == sectionName { | 76 | if employeeProductRecord.WorkStation.SectionName == sectionName { |
76 | employeeProductRecord.SecondLevelWeigh += weigh | 77 | employeeProductRecord.SecondLevelWeigh += weigh |
77 | } else { | 78 | } else { |
79 | + // 其他工段的二级品 | ||
78 | if _, ok := employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh[sectionName]; ok { | 80 | if _, ok := employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh[sectionName]; ok { |
79 | employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh[sectionName] += weigh //存关联级的二级品 | 81 | employeeProductRecord.ProductRecordInfo.OtherSectionSecondLevelWeigh[sectionName] += weigh //存关联级的二级品 |
80 | } else { | 82 | } else { |
@@ -12,10 +12,10 @@ type ProductRecordStaticInfo struct { | @@ -12,10 +12,10 @@ type ProductRecordStaticInfo struct { | ||
12 | 12 | ||
13 | // 生产小组ID | 13 | // 生产小组ID |
14 | ProductGroupId int `json:"productGroupId,omitempty"` | 14 | ProductGroupId int `json:"productGroupId,omitempty"` |
15 | - | ||
16 | - TotalOtherSecondLevelWeigh float64 `json:"otherSecondLevelWeigh"` | 15 | + // 其他工段二级品的重量合计 |
16 | + TotalOtherSecondLevelWeigh float64 `json:"totalOtherSecondLevelWeigh"` | ||
17 | // 保存其他工段二级品的重量 | 17 | // 保存其他工段二级品的重量 |
18 | - OtherSectionSecondLevelWeigh map[string]float64 `json:"sectionSecondLevelWeigh"` | 18 | + OtherSectionSecondLevelWeigh map[string]float64 `json:"otherSectionSecondLevelWeigh"` |
19 | } | 19 | } |
20 | 20 | ||
21 | func (info *ProductRecordStaticInfo) OtherSecondLevelWeigh() float64 { | 21 | func (info *ProductRecordStaticInfo) OtherSecondLevelWeigh() float64 { |
@@ -12,6 +12,7 @@ type PGApproveAttendanceRecordsService struct { | @@ -12,6 +12,7 @@ type PGApproveAttendanceRecordsService struct { | ||
12 | transactionContext *pgTransaction.TransactionContext | 12 | transactionContext *pgTransaction.TransactionContext |
13 | } | 13 | } |
14 | 14 | ||
15 | +// 批量审核考勤记录 | ||
15 | func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt *domain.OperateInfo, list []*domain.ProductAttendanceRecord, approveUserId int, workTime float64, status int) (interface{}, error) { | 16 | func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt *domain.OperateInfo, list []*domain.ProductAttendanceRecord, approveUserId int, workTime float64, status int) (interface{}, error) { |
16 | var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext) | 17 | var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext) |
17 | var attendance *domain.ProductAttendanceRecord | 18 | var attendance *domain.ProductAttendanceRecord |
1 | package pg | 1 | package pg |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "context" | ||
4 | "fmt" | 5 | "fmt" |
6 | + "github.com/beego/beego/v2/core/logs" | ||
7 | + "log" | ||
5 | "reflect" | 8 | "reflect" |
6 | 9 | ||
7 | "github.com/go-pg/pg/v10" | 10 | "github.com/go-pg/pg/v10" |
8 | "github.com/go-pg/pg/v10/orm" | 11 | "github.com/go-pg/pg/v10/orm" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models" |
11 | - | ||
12 | - "github.com/linmadan/egglib-go/persistent/pg/hooks" | ||
13 | ) | 14 | ) |
14 | 15 | ||
15 | var DB *pg.DB | 16 | var DB *pg.DB |
@@ -22,7 +23,7 @@ func init() { | @@ -22,7 +23,7 @@ func init() { | ||
22 | Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT), | 23 | Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT), |
23 | }) | 24 | }) |
24 | if !constant.DISABLE_SQL_GENERATE_PRINT { | 25 | if !constant.DISABLE_SQL_GENERATE_PRINT { |
25 | - DB.AddQueryHook(hooks.SqlGeneratePrintHook{}) | 26 | + DB.AddQueryHook(SqlGeneratePrintHook{}) |
26 | } | 27 | } |
27 | if !constant.DISABLE_CREATE_TABLE { | 28 | if !constant.DISABLE_CREATE_TABLE { |
28 | for _, model := range []interface{}{ | 29 | for _, model := range []interface{}{ |
@@ -59,6 +60,23 @@ func init() { | @@ -59,6 +60,23 @@ func init() { | ||
59 | } | 60 | } |
60 | } | 61 | } |
61 | 62 | ||
63 | +type SqlGeneratePrintHook struct{} | ||
64 | + | ||
65 | +func (hook SqlGeneratePrintHook) BeforeQuery(c context.Context, q *pg.QueryEvent) (context.Context, error) { | ||
66 | + return c, nil | ||
67 | +} | ||
68 | + | ||
69 | +func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) error { | ||
70 | + sqlStr, err := q.FormattedQuery() | ||
71 | + if err != nil { | ||
72 | + return err | ||
73 | + } | ||
74 | + //log.Logger.Debug(string(sqlStr)) | ||
75 | + log.Println(string(sqlStr)) | ||
76 | + logs.Debug(string(sqlStr)) | ||
77 | + return nil | ||
78 | +} | ||
79 | + | ||
62 | func AddComments(db *pg.DB, model interface{}) { | 80 | func AddComments(db *pg.DB, model interface{}) { |
63 | tableName := db.Model(model).TableModel().Table().SQLName | 81 | tableName := db.Model(model).TableModel().Table().SQLName |
64 | columnsMap := make(map[string]*orm.Field) | 82 | columnsMap := make(map[string]*orm.Field) |
@@ -12,5 +12,9 @@ func ToPinYin(hans string, sep string) string { | @@ -12,5 +12,9 @@ func ToPinYin(hans string, sep string) string { | ||
12 | for i := range tmp { | 12 | for i := range tmp { |
13 | result = append(result, tmp[i]...) | 13 | result = append(result, tmp[i]...) |
14 | } | 14 | } |
15 | - return strings.Join(result, sep) | 15 | + py := strings.Join(result, sep) |
16 | + if len(py) == 0 { | ||
17 | + return strings.ToLower(hans) | ||
18 | + } | ||
19 | + return py | ||
16 | } | 20 | } |
-
请 注册 或 登录 后发表评论