正在显示
21 个修改的文件
包含
180 行增加
和
40 行删除
| 1 | +package query | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "github.com/beego/beego/v2/core/validation" | ||
| 6 | + "reflect" | ||
| 7 | + "strings" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type GetSignInEmployeeQuery struct { | ||
| 11 | + // 查询偏离量 | ||
| 12 | + //Offset int `cname:"查询偏离量" json:"offset"` | ||
| 13 | + // 查询限制 | ||
| 14 | + //Limit int `cname:"查询限制" json:"limit"` | ||
| 15 | + // 页码 | ||
| 16 | + //PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
| 17 | + // 页数 | ||
| 18 | + //PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
| 19 | + // 当前公司 | ||
| 20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
| 21 | + // 当前登录的组织 | ||
| 22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
| 23 | + // IC卡号 | ||
| 24 | + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"` | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (listProductGroupQuery *GetSignInEmployeeQuery) Valid(validation *validation.Validation) { | ||
| 28 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (listProductGroupQuery *GetSignInEmployeeQuery) ValidateQuery() error { | ||
| 32 | + valid := validation.Validation{} | ||
| 33 | + b, err := valid.Valid(listProductGroupQuery) | ||
| 34 | + if err != nil { | ||
| 35 | + return err | ||
| 36 | + } | ||
| 37 | + if !b { | ||
| 38 | + elem := reflect.TypeOf(listProductGroupQuery).Elem() | ||
| 39 | + for _, validErr := range valid.Errors { | ||
| 40 | + field, isExist := elem.FieldByName(validErr.Field) | ||
| 41 | + if isExist { | ||
| 42 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
| 43 | + } else { | ||
| 44 | + return fmt.Errorf(validErr.Message) | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + return nil | ||
| 49 | +} |
| @@ -422,6 +422,37 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | @@ -422,6 +422,37 @@ func (productGroupService *ProductGroupService) SearchProductGroupEmployees(oper | ||
| 422 | }, nil | 422 | }, nil |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | +// 返回生产班组服务列表 | ||
| 426 | +func (productGroupService *ProductGroupService) GetSignEmployee(cmd *query.GetSignInEmployeeQuery) (interface{}, error) { | ||
| 427 | + if err := cmd.ValidateQuery(); err != nil { | ||
| 428 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
| 429 | + } | ||
| 430 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 431 | + if err != nil { | ||
| 432 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 433 | + } | ||
| 434 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 435 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 436 | + } | ||
| 437 | + defer func() { | ||
| 438 | + transactionContext.RollbackTransaction() | ||
| 439 | + }() | ||
| 440 | + | ||
| 441 | + var userService = domainService.NewUserService() | ||
| 442 | + | ||
| 443 | + worker, err := userService.UserByICCode(cmd.CompanyId, cmd.OrgId, cmd.IcCardNumber) | ||
| 444 | + if err != nil || worker == nil || worker.UserId == 0 { | ||
| 445 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户不存在") | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 449 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 450 | + } | ||
| 451 | + return map[string]interface{}{ | ||
| 452 | + "employee": worker, | ||
| 453 | + }, nil | ||
| 454 | +} | ||
| 455 | + | ||
| 425 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { | 456 | func NewProductGroupService(options map[string]interface{}) *ProductGroupService { |
| 426 | newProductGroupService := &ProductGroupService{} | 457 | newProductGroupService := &ProductGroupService{} |
| 427 | return newProductGroupService | 458 | return newProductGroupService |
| @@ -338,8 +338,8 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | @@ -338,8 +338,8 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | ||
| 338 | 338 | ||
| 339 | newJobDto := &dto.ProductJobDto{} | 339 | newJobDto := &dto.ProductJobDto{} |
| 340 | newJobDto.LoadDto(item, operateInfo.OrgId) | 340 | newJobDto.LoadDto(item, operateInfo.OrgId) |
| 341 | - newJobDto.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
| 342 | - newJobDto.WorkStation.Principal = item.WorkStation.Principal | 341 | + newJobDto.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId, 1) |
| 342 | + //newJobDto.WorkStation.Principal = item.WorkStation.Principal | ||
| 343 | result = append(result, newJobDto) | 343 | result = append(result, newJobDto) |
| 344 | } | 344 | } |
| 345 | return count, result, nil | 345 | return count, result, nil |
| @@ -22,7 +22,7 @@ type ReceiveMaterialCommand struct { | @@ -22,7 +22,7 @@ type ReceiveMaterialCommand struct { | ||
| 22 | // 工段ID | 22 | // 工段ID |
| 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` |
| 24 | // 生产小组ID | 24 | // 生产小组ID |
| 25 | - ProductGroupId int `cname:"生产小组" json:"productGroupId" valid:"Required"` | 25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` |
| 26 | // 员工Id 用户唯一标识 | 26 | // 员工Id 用户唯一标识 |
| 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` |
| 28 | // 物料ID | 28 | // 物料ID |
| @@ -22,7 +22,7 @@ type ReturnMaterialCommand struct { | @@ -22,7 +22,7 @@ type ReturnMaterialCommand struct { | ||
| 22 | // 工段ID | 22 | // 工段ID |
| 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` |
| 24 | // 生产小组ID | 24 | // 生产小组ID |
| 25 | - ProductGroupId int `cname:"生产小组" json:"productGroupId" valid:"Required"` | 25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` |
| 26 | // 员工Id 用户唯一标识 | 26 | // 员工Id 用户唯一标识 |
| 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` |
| 28 | // 物料ID | 28 | // 物料ID |
| @@ -22,7 +22,7 @@ type SubmitProductRecordCommand struct { | @@ -22,7 +22,7 @@ type SubmitProductRecordCommand struct { | ||
| 22 | // 工段ID | 22 | // 工段ID |
| 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | 23 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` |
| 24 | // 生产小组ID | 24 | // 生产小组ID |
| 25 | - ProductGroupId int `cname:"生产小组" json:"productGroupId" valid:"Required"` | 25 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` |
| 26 | // 员工Id 用户唯一标识 | 26 | // 员工Id 用户唯一标识 |
| 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | 27 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` |
| 28 | // 物料ID | 28 | // 物料ID |
| @@ -577,7 +577,7 @@ func (productPlanService *ProductPlanService) SearchProductPlanOnlineDispatchRec | @@ -577,7 +577,7 @@ func (productPlanService *ProductPlanService) SearchProductPlanOnlineDispatchRec | ||
| 577 | productPlanRepository = value | 577 | productPlanRepository = value |
| 578 | } | 578 | } |
| 579 | queryOptions := utils.ObjectToMap(cmd) | 579 | queryOptions := utils.ObjectToMap(cmd) |
| 580 | - //queryOptions["planDispatchStatus"] = 1 | 580 | + queryOptions["planDispatchStatus"] = 1 |
| 581 | count, productPlans, err := productPlanRepository.Find(queryOptions) | 581 | count, productPlans, err := productPlanRepository.Find(queryOptions) |
| 582 | if err != nil { | 582 | if err != nil { |
| 583 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 583 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -16,7 +16,7 @@ type ApproveProductRecordCommand struct { | @@ -16,7 +16,7 @@ type ApproveProductRecordCommand struct { | ||
| 16 | // 审核后重量 | 16 | // 审核后重量 |
| 17 | WeighAfter float64 `cname:"审核后重量" json:"weighAfter" valid:"Required"` | 17 | WeighAfter float64 `cname:"审核后重量" json:"weighAfter" valid:"Required"` |
| 18 | // 审核时间 | 18 | // 审核时间 |
| 19 | - ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"` | 19 | + //ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"` |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | func (approveProductRecordCommand *ApproveProductRecordCommand) Valid(validation *validation.Validation) { | 22 | func (approveProductRecordCommand *ApproveProductRecordCommand) Valid(validation *validation.Validation) { |
| @@ -98,6 +98,13 @@ func (workshopService *WorkshopService) GetWorkshop(getWorkshopQuery *query.GetW | @@ -98,6 +98,13 @@ func (workshopService *WorkshopService) GetWorkshop(getWorkshopQuery *query.GetW | ||
| 98 | if err != nil { | 98 | if err != nil { |
| 99 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 99 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 100 | } | 100 | } |
| 101 | + userService := domainService.NewUserService() | ||
| 102 | + if workshop.Principal.UserId > 0 { | ||
| 103 | + u, _ := userService.User(workshop.Principal.UserId) | ||
| 104 | + if u != nil { | ||
| 105 | + workshop.Principal = u | ||
| 106 | + } | ||
| 107 | + } | ||
| 101 | if workshop == nil { | 108 | if workshop == nil { |
| 102 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getWorkshopQuery.WorkshopId))) | 109 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getWorkshopQuery.WorkshopId))) |
| 103 | } else { | 110 | } else { |
| @@ -5,15 +5,16 @@ import "os" | @@ -5,15 +5,16 @@ import "os" | ||
| 5 | var MQTT_TOPIC = "/MQTT" | 5 | var MQTT_TOPIC = "/MQTT" |
| 6 | 6 | ||
| 7 | //设备商提供的测试地址 | 7 | //设备商提供的测试地址 |
| 8 | -//var MQTT_HOST = "175.24.122.87" | ||
| 9 | -//var MQTT_PORT = "1883" | ||
| 10 | -//var MQTT_USER = "user111" | ||
| 11 | -//var MQTT_PASSWORD = "user111" | ||
| 12 | -//内网测试地址 | ||
| 13 | -var MQTT_HOST = "192.168.100.222" | 8 | +var MQTT_HOST = "175.24.122.87" |
| 14 | var MQTT_PORT = "1883" | 9 | var MQTT_PORT = "1883" |
| 15 | -var MQTT_USER = "admin" | ||
| 16 | -var MQTT_PASSWORD = "123456" | 10 | +var MQTT_USER = "user111" |
| 11 | +var MQTT_PASSWORD = "user111" | ||
| 12 | + | ||
| 13 | +//内网测试地址 | ||
| 14 | +//var MQTT_HOST = "192.168.100.222" | ||
| 15 | +//var MQTT_PORT = "1883" | ||
| 16 | +//var MQTT_USER = "admin" | ||
| 17 | +//var MQTT_PASSWORD = "123456" | ||
| 17 | 18 | ||
| 18 | func init() { | 19 | func init() { |
| 19 | if os.Getenv("MQTT_HOST") != "" { | 20 | if os.Getenv("MQTT_HOST") != "" { |
| @@ -88,6 +88,10 @@ func (workshop *Workshop) RemoveLine(lineId int) (*ProductLine, error) { | @@ -88,6 +88,10 @@ func (workshop *Workshop) RemoveLine(lineId int) (*ProductLine, error) { | ||
| 88 | if err != nil { | 88 | if err != nil { |
| 89 | return nil, err | 89 | return nil, err |
| 90 | } | 90 | } |
| 91 | + sections := line.GetProductSections(NotDeleted) | ||
| 92 | + if len(sections) > 0 { | ||
| 93 | + return nil, fmt.Errorf("生产线:%v下存在工段,不可删除", line.LineName) | ||
| 94 | + } | ||
| 91 | if line.Removed == Deleted { | 95 | if line.Removed == Deleted { |
| 92 | return nil, fmt.Errorf("生产线:%v已删除", line.LineName) | 96 | return nil, fmt.Errorf("生产线:%v已删除", line.LineName) |
| 93 | } | 97 | } |
| @@ -5,10 +5,13 @@ import "strings" | @@ -5,10 +5,13 @@ import "strings" | ||
| 5 | /*车间列表*/ | 5 | /*车间列表*/ |
| 6 | type Workshops []*Workshop | 6 | type Workshops []*Workshop |
| 7 | 7 | ||
| 8 | -func (m Workshops) FindWorkStation(workshopId, lineId, sectionId int) *WorkStation { | 8 | +func (m Workshops) FindWorkStation(workshopId, lineId, sectionId int, flag ...int) *WorkStation { |
| 9 | for i := range m { | 9 | for i := range m { |
| 10 | item := m[i] | 10 | item := m[i] |
| 11 | workstation, err := item.FindWorkStation(workshopId, lineId, sectionId) | 11 | workstation, err := item.FindWorkStation(workshopId, lineId, sectionId) |
| 12 | + if len(flag) > 0 && flag[0] == 1 && workstation != nil { | ||
| 13 | + workstation.Principal = item.Principal | ||
| 14 | + } | ||
| 12 | if err == nil && workstation != nil { | 15 | if err == nil && workstation != nil { |
| 13 | return workstation | 16 | return workstation |
| 14 | } | 17 | } |
| @@ -39,6 +39,16 @@ func (gateway HttpLibAlliedCreationUser) UserByCode(companyId, orgId int, userCo | @@ -39,6 +39,16 @@ func (gateway HttpLibAlliedCreationUser) UserByCode(companyId, orgId int, userCo | ||
| 39 | } | 39 | } |
| 40 | return users[0], nil | 40 | return users[0], nil |
| 41 | } | 41 | } |
| 42 | +func (gateway HttpLibAlliedCreationUser) UserByICCode(companyId, orgId int, icCode string) (*models.User, error) { | ||
| 43 | + _, users, err := gateway.UserSearch(ReqUserSearch{CompanyId: int64(companyId), OrganizationId: int64(orgId), IcCardNumber: icCode, Limit: 1, PullRealTime: true}) | ||
| 44 | + if err != nil { | ||
| 45 | + return nil, err | ||
| 46 | + } | ||
| 47 | + if len(users) == 0 { | ||
| 48 | + return nil, fmt.Errorf("用户不存在") | ||
| 49 | + } | ||
| 50 | + return users[0], nil | ||
| 51 | +} | ||
| 42 | func (gateway HttpLibAlliedCreationUser) Users(userIds []int) ([]*models.User, error) { | 52 | func (gateway HttpLibAlliedCreationUser) Users(userIds []int) ([]*models.User, error) { |
| 43 | var list = make([]*models.User, 0) | 53 | var list = make([]*models.User, 0) |
| 44 | for i := range userIds { | 54 | for i := range userIds { |
| @@ -42,6 +42,8 @@ type ( | @@ -42,6 +42,8 @@ type ( | ||
| 42 | InCompanyIds []interface{} `json:"inCompanyIds,omitempty"` | 42 | InCompanyIds []interface{} `json:"inCompanyIds,omitempty"` |
| 43 | // 用户编号 企业内标识 | 43 | // 用户编号 企业内标识 |
| 44 | UserCode string `cname:"用户编号" json:"userCode,omitempty"` | 44 | UserCode string `cname:"用户编号" json:"userCode,omitempty"` |
| 45 | + // IC卡号 | ||
| 46 | + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"` | ||
| 45 | 47 | ||
| 46 | // 自定义高级查询 | 48 | // 自定义高级查询 |
| 47 | AdvancedQuery string `json:"advancedQuery"` | 49 | AdvancedQuery string `json:"advancedQuery"` |
| @@ -30,7 +30,7 @@ WITH ts_product as( | @@ -30,7 +30,7 @@ WITH ts_product as( | ||
| 30 | select sum(a.weight) total,a.ts from ( | 30 | select sum(a.weight) total,a.ts from ( |
| 31 | select | 31 | select |
| 32 | cast(device_running_record_info->>'count' as DECIMAL) weight, | 32 | cast(device_running_record_info->>'count' as DECIMAL) weight, |
| 33 | - to_char(product_date at time ZONE 'Asia/shanghai', 'mm:dd') ts | 33 | + to_char(product_date at time ZONE 'Asia/shanghai', 'mm-dd') ts |
| 34 | from manufacture.device_daily_running_record | 34 | from manufacture.device_daily_running_record |
| 35 | where | 35 | where |
| 36 | company_id = ? | 36 | company_id = ? |
| @@ -46,7 +46,7 @@ WITH ts_product as( | @@ -46,7 +46,7 @@ WITH ts_product as( | ||
| 46 | -- select * from ts_product | 46 | -- select * from ts_product |
| 47 | , ts_product_list as ( | 47 | , ts_product_list as ( |
| 48 | select d.ts,ts_product.total from ( | 48 | select d.ts,ts_product.total from ( |
| 49 | - select to_char(c.ts::timestamp,'mm:dd') ts from ( | 49 | + select to_char(c.ts::timestamp,'mm-dd') ts from ( |
| 50 | select generate_series(now() - interval '6 day',now(),'1 day') ts | 50 | select generate_series(now() - interval '6 day',now(),'1 day') ts |
| 51 | ) c ) d left join ts_product on d.ts = ts_product.ts | 51 | ) c ) d left join ts_product on d.ts = ts_product.ts |
| 52 | ) | 52 | ) |
| @@ -27,6 +27,14 @@ func (svr *UserService) UserByCode(companyId, orgId int, userCode string) (*doma | @@ -27,6 +27,14 @@ func (svr *UserService) UserByCode(companyId, orgId int, userCode string) (*doma | ||
| 27 | return svr.ToUser(rsp), nil | 27 | return svr.ToUser(rsp), nil |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | +func (svr *UserService) UserByICCode(companyId, orgId int, userCode string) (*domain.User, error) { | ||
| 31 | + rsp, err := svr.internalUserService.UserByICCode(companyId, orgId, userCode) | ||
| 32 | + if err != nil { | ||
| 33 | + return nil, err | ||
| 34 | + } | ||
| 35 | + return svr.ToUser(rsp), nil | ||
| 36 | +} | ||
| 37 | + | ||
| 30 | func (svr *UserService) Users(id []int) ([]*domain.User, error) { | 38 | func (svr *UserService) Users(id []int) ([]*domain.User, error) { |
| 31 | rsp, err := svr.internalUserService.Users(id) | 39 | rsp, err := svr.internalUserService.Users(id) |
| 32 | if err != nil { | 40 | if err != nil { |
| @@ -11,6 +11,14 @@ func SendWorkshopWorkTimeStaticJob(productRecord *domain.ProductAttendanceRecord | @@ -11,6 +11,14 @@ func SendWorkshopWorkTimeStaticJob(productRecord *domain.ProductAttendanceRecord | ||
| 11 | return SendAsyncJob(domain.TaskKeyWorkshopWorkTimeRecordStatics(), productRecord) | 11 | return SendAsyncJob(domain.TaskKeyWorkshopWorkTimeRecordStatics(), productRecord) |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | +func SendProductRecordStaticsJob(productRecord *domain.ProductRecord) error { | ||
| 15 | + task := asynq.NewTask(domain.TaskKeyPatternProductRecordStatics(), []byte(json.MarshalToString(productRecord))) | ||
| 16 | + | ||
| 17 | + client := asynq.NewClient(asynq.RedisClientOpt{Addr: constant.REDIS_ADDRESS}) | ||
| 18 | + _, err := client.Enqueue(task) | ||
| 19 | + return err | ||
| 20 | +} | ||
| 21 | + | ||
| 14 | func SendDeviceZkTecoReportJob(productRecord *domain.DeviceZkTeco) error { | 22 | func SendDeviceZkTecoReportJob(productRecord *domain.DeviceZkTeco) error { |
| 15 | return SendAsyncJob(domain.TaskDeviceZkTecoReport(), productRecord) | 23 | return SendAsyncJob(domain.TaskDeviceZkTecoReport(), productRecord) |
| 16 | } | 24 | } |
| @@ -75,6 +75,7 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[ | @@ -75,6 +75,7 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[ | ||
| 75 | productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext) | 75 | productRecordDao, _ := dao.NewProductRecordDao(ptr.transactionContext) |
| 76 | 76 | ||
| 77 | var response = make([]interface{}, 0) | 77 | var response = make([]interface{}, 0) |
| 78 | + var tmpXData = make([]string, 0) | ||
| 78 | for _, v := range workshop.GetProductLines(domain.NotDeleted) { | 79 | for _, v := range workshop.GetProductLines(domain.NotDeleted) { |
| 79 | var result = make([]*record, 0) | 80 | var result = make([]*record, 0) |
| 80 | if err := productRecordDao.TimeSectionProductRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*5), &result); err != nil { | 81 | if err := productRecordDao.TimeSectionProductRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*5), &result); err != nil { |
| @@ -87,12 +88,18 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[ | @@ -87,12 +88,18 @@ func (ptr *PGCommonStatisticsService) HourProductiveStatistics(queryOptions map[ | ||
| 87 | xData = append(xData, r.Ts) | 88 | xData = append(xData, r.Ts) |
| 88 | values = append(values, r.Total) | 89 | values = append(values, r.Total) |
| 89 | } | 90 | } |
| 91 | + if len(tmpXData) == 0 { | ||
| 92 | + tmpXData = xData | ||
| 93 | + } | ||
| 90 | response = append(response, map[string]interface{}{ | 94 | response = append(response, map[string]interface{}{ |
| 91 | "lineName": v.LineName, | 95 | "lineName": v.LineName, |
| 92 | "data": NewXYData(xData, values), | 96 | "data": NewXYData(xData, values), |
| 93 | }) | 97 | }) |
| 94 | } | 98 | } |
| 95 | - return response, nil | 99 | + return map[string]interface{}{ |
| 100 | + "xAxis": tmpXData, | ||
| 101 | + "list": response, | ||
| 102 | + }, nil | ||
| 96 | } | 103 | } |
| 97 | 104 | ||
| 98 | type HourProductiveStatisticsRequest struct { | 105 | type HourProductiveStatisticsRequest struct { |
| @@ -102,14 +109,15 @@ type HourProductiveStatisticsRequest struct { | @@ -102,14 +109,15 @@ type HourProductiveStatisticsRequest struct { | ||
| 102 | } | 109 | } |
| 103 | 110 | ||
| 104 | func NewXYData(xData []string, values interface{}) interface{} { | 111 | func NewXYData(xData []string, values interface{}) interface{} { |
| 105 | - return map[string]interface{}{ | ||
| 106 | - "xAxis": map[string]interface{}{ | ||
| 107 | - "data": xData, | ||
| 108 | - }, | ||
| 109 | - "source": map[string]interface{}{ | ||
| 110 | - "value": values, | ||
| 111 | - }, | ||
| 112 | - } | 112 | + //return map[string]interface{}{ |
| 113 | + //"xAxis": map[string]interface{}{ | ||
| 114 | + // "data": xData, | ||
| 115 | + //}, | ||
| 116 | + //"source": map[string]interface{}{ | ||
| 117 | + // "value": values, | ||
| 118 | + //}, | ||
| 119 | + //} | ||
| 120 | + return values | ||
| 113 | } | 121 | } |
| 114 | 122 | ||
| 115 | // 时段产能-统计 (传串设备) | 123 | // 时段产能-统计 (传串设备) |
| @@ -132,6 +140,8 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | @@ -132,6 +140,8 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | ||
| 132 | productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext) | 140 | productRecordDao, _ := dao.NewDeviceDailyRunningRecordDao(ptr.transactionContext) |
| 133 | 141 | ||
| 134 | var response = make([]interface{}, 0) | 142 | var response = make([]interface{}, 0) |
| 143 | + var tmpXData = make([]string, 0) | ||
| 144 | + | ||
| 135 | for _, v := range workshop.GetProductLines(domain.NotDeleted) { | 145 | for _, v := range workshop.GetProductLines(domain.NotDeleted) { |
| 136 | var result = make([]*record, 0) | 146 | var result = make([]*record, 0) |
| 137 | if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*24*7), &result); err != nil { | 147 | if err := productRecordDao.TimeSectionRunningRecord(request.CompanyId, request.OrgId, request.WorkshopId, v.LineId, SectionNameCCJ, time.Now().Add(-time.Hour*24*7), &result); err != nil { |
| @@ -144,13 +154,19 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | @@ -144,13 +154,19 @@ func (ptr *PGCommonStatisticsService) DailyProductiveStatistics(queryOptions map | ||
| 144 | xData = append(xData, r.Ts) | 154 | xData = append(xData, r.Ts) |
| 145 | values = append(values, r.Total) | 155 | values = append(values, r.Total) |
| 146 | } | 156 | } |
| 157 | + if len(tmpXData) == 0 { | ||
| 158 | + tmpXData = xData | ||
| 159 | + } | ||
| 147 | response = append(response, map[string]interface{}{ | 160 | response = append(response, map[string]interface{}{ |
| 148 | "lineName": v.LineName, | 161 | "lineName": v.LineName, |
| 149 | "data": NewXYData(xData, values), | 162 | "data": NewXYData(xData, values), |
| 150 | }) | 163 | }) |
| 151 | } | 164 | } |
| 152 | return map[string]interface{}{ | 165 | return map[string]interface{}{ |
| 153 | - "recent_7_day": response, | 166 | + "recent_7_day": map[string]interface{}{ |
| 167 | + "xAxis": tmpXData, | ||
| 168 | + "list": response, | ||
| 169 | + }, | ||
| 154 | }, nil | 170 | }, nil |
| 155 | } | 171 | } |
| 156 | 172 |
| @@ -2,11 +2,8 @@ package domainService | @@ -2,11 +2,8 @@ package domainService | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | - "github.com/hibiken/asynq" | ||
| 6 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
| 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
| 8 | - "github.com/linmadan/egglib-go/utils/json" | ||
| 9 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" |
| 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
| @@ -32,7 +29,7 @@ type SubmitOptions struct { | @@ -32,7 +29,7 @@ type SubmitOptions struct { | ||
| 32 | // 工段ID | 29 | // 工段ID |
| 33 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` | 30 | SectionId int `cname:"工段" json:"sectionId" valid:"Required"` |
| 34 | // 生产小组ID | 31 | // 生产小组ID |
| 35 | - ProductGroupId int `cname:"生产小组" json:"productGroupId" valid:"Required"` | 32 | + ProductGroupId int `cname:"生产小组" json:"productGroupId"` |
| 36 | // 员工Id 用户唯一标识 | 33 | // 员工Id 用户唯一标识 |
| 37 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` | 34 | EmployeeId int `cname:"员工" json:"employeeId" valid:"Required"` |
| 38 | // 物料ID | 35 | // 物料ID |
| @@ -209,14 +206,6 @@ func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, ap | @@ -209,14 +206,6 @@ func (ptr *PGProductRecordService) BatchApprove(list []*domain.ProductRecord, ap | ||
| 209 | return struct{}{}, nil | 206 | return struct{}{}, nil |
| 210 | } | 207 | } |
| 211 | 208 | ||
| 212 | -func SendProductRecordStaticsJob(productRecord *domain.ProductRecord) error { | ||
| 213 | - task := asynq.NewTask(domain.TaskKeyPatternProductRecordStatics(), []byte(json.MarshalToString(productRecord))) | ||
| 214 | - | ||
| 215 | - client := asynq.NewClient(asynq.RedisClientOpt{Addr: constant.REDIS_ADDRESS}) | ||
| 216 | - _, err := client.Enqueue(task) | ||
| 217 | - return err | ||
| 218 | -} | ||
| 219 | - | ||
| 220 | func NewPGProductRecordService(transactionContext *pgTransaction.TransactionContext) (*PGProductRecordService, error) { | 209 | func NewPGProductRecordService(transactionContext *pgTransaction.TransactionContext) (*PGProductRecordService, error) { |
| 221 | if transactionContext == nil { | 210 | if transactionContext == nil { |
| 222 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 211 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
| @@ -89,3 +89,14 @@ func (controller *ProductGroupController) SearchProductGroupEmployees() { | @@ -89,3 +89,14 @@ func (controller *ProductGroupController) SearchProductGroupEmployees() { | ||
| 89 | _, data, err := productGroupService.SearchProductGroupEmployees(operateInfo, cmd) | 89 | _, data, err := productGroupService.SearchProductGroupEmployees(operateInfo, cmd) |
| 90 | controller.Response(data, err) | 90 | controller.Response(data, err) |
| 91 | } | 91 | } |
| 92 | + | ||
| 93 | +func (controller *ProductGroupController) GetSignInEmployeeQuery() { | ||
| 94 | + productGroupService := service.NewProductGroupService(nil) | ||
| 95 | + cmd := &query.GetSignInEmployeeQuery{} | ||
| 96 | + Must(controller.Unmarshal(cmd)) | ||
| 97 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
| 98 | + cmd.OrgId = operateInfo.OrgId | ||
| 99 | + cmd.CompanyId = operateInfo.CompanyId | ||
| 100 | + data, err := productGroupService.GetSignEmployee(cmd) | ||
| 101 | + controller.Response(data, err) | ||
| 102 | +} |
| @@ -14,4 +14,5 @@ func init() { | @@ -14,4 +14,5 @@ func init() { | ||
| 14 | web.Router("/product-groups/", &controllers.ProductGroupController{}, "Get:ListProductGroup") | 14 | web.Router("/product-groups/", &controllers.ProductGroupController{}, "Get:ListProductGroup") |
| 15 | web.Router("/product-groups/search", &controllers.ProductGroupController{}, "Post:SearchProductGroup") | 15 | web.Router("/product-groups/search", &controllers.ProductGroupController{}, "Post:SearchProductGroup") |
| 16 | web.Router("/product-groups/employees", &controllers.ProductGroupController{}, "Post:SearchProductGroupEmployees") | 16 | web.Router("/product-groups/employees", &controllers.ProductGroupController{}, "Post:SearchProductGroupEmployees") |
| 17 | + web.Router("/product-groups/employee-signing", &controllers.ProductGroupController{}, "Post:GetSignInEmployeeQuery") | ||
| 17 | } | 18 | } |
-
请 注册 或 登录 后发表评论