正在显示
11 个修改的文件
包含
261 行增加
和
120 行删除
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type CreateProductRecordCommand struct { | 11 | type CreateProductRecordCommand struct { |
12 | + ProductRecordId int `json:"productRecordId"` | ||
12 | // 车间ID | 13 | // 车间ID |
13 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 14 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
14 | // 生产线ID | 15 | // 生产线ID |
@@ -9,7 +9,6 @@ import ( | @@ -9,7 +9,6 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
10 | 10 | ||
11 | "github.com/linmadan/egglib-go/core/application" | 11 | "github.com/linmadan/egglib-go/core/application" |
12 | - "github.com/linmadan/egglib-go/transaction/pg" | ||
13 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 12 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
14 | "github.com/linmadan/egglib-go/utils/tool_funs" | 13 | "github.com/linmadan/egglib-go/utils/tool_funs" |
15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" |
@@ -73,52 +72,83 @@ func (productRecordService *ProductRecordService) CreateProductRecord(operateInf | @@ -73,52 +72,83 @@ func (productRecordService *ProductRecordService) CreateProductRecord(operateInf | ||
73 | transactionContext.RollbackTransaction() | 72 | transactionContext.RollbackTransaction() |
74 | }() | 73 | }() |
75 | 74 | ||
75 | + //日期 | ||
76 | dataTime, err := time.ParseInLocation("2006-01-02", param.CreatedDate, time.Local) | 76 | dataTime, err := time.ParseInLocation("2006-01-02", param.CreatedDate, time.Local) |
77 | if err != nil { | 77 | if err != nil { |
78 | return nil, application.ThrowError(application.ARG_ERROR, "日期格式错误") | 78 | return nil, application.ThrowError(application.ARG_ERROR, "日期格式错误") |
79 | } | 79 | } |
80 | + //生产记录存储 | ||
81 | + productRecordRepo, _ := factory.CreateProductRecordRepository(map[string]interface{}{ | ||
82 | + "transactionContext": transactionContext, | ||
83 | + }) | ||
80 | 84 | ||
85 | + //生产计划 | ||
81 | productPlanRepo, _ := factory.CreateProductPlanRepository(map[string]interface{}{ | 86 | productPlanRepo, _ := factory.CreateProductPlanRepository(map[string]interface{}{ |
82 | "transactionContext": transactionContext, | 87 | "transactionContext": transactionContext, |
83 | }) | 88 | }) |
84 | - | ||
85 | - _, err = productPlanRepo.FindOne(map[string]interface{}{ | 89 | + //生产计划数据 |
90 | + productPlanData, err := productPlanRepo.FindOne(map[string]interface{}{ | ||
86 | "product_plan_id": param.ProductPlanId, | 91 | "product_plan_id": param.ProductPlanId, |
87 | "company_id": operateInfo.CompanyId, | 92 | "company_id": operateInfo.CompanyId, |
88 | }) | 93 | }) |
89 | if err != nil { | 94 | if err != nil { |
90 | return nil, application.ThrowError(application.ARG_ERROR, "生产计划id错误,"+err.Error()) | 95 | return nil, application.ThrowError(application.ARG_ERROR, "生产计划id错误,"+err.Error()) |
91 | } | 96 | } |
97 | + //用户数据 | ||
98 | + var user *domain.User | ||
99 | + userService := domainService.NewUserService() | ||
100 | + user, err = userService.User(operateInfo.UserId) | ||
101 | + if err != nil { | ||
102 | + return nil, application.ThrowError(application.ARG_ERROR, "获取用户错误,"+err.Error()) | ||
103 | + } | ||
104 | + var org *domain.Org | ||
105 | + org, err = userService.Organization(operateInfo.OrgId) | ||
106 | + if err != nil { | ||
107 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
108 | + } | ||
109 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
110 | + "transactionContext": transactionContext, | ||
111 | + }) | ||
112 | + workshop, err := workshopRepo.FindOne(map[string]interface{}{"workshopId": param.WorkshopId}) | ||
113 | + if err != nil { | ||
114 | + return nil, application.ThrowError(application.ARG_ERROR, "获取车间数据失败"+err.Error()) | ||
115 | + } | ||
116 | + workstation, err := workshop.FindWorkStation(param.WorkshopId, param.LineId, param.SectionId) | ||
117 | + if err != nil { | ||
118 | + return nil, application.ThrowError(application.ARG_ERROR, "获取车间工段数据失败"+err.Error()) | ||
119 | + } | ||
92 | 120 | ||
93 | - productRecordDomainService, _ := domainService.NewPGProductRecordService(transactionContext.(*pg.TransactionContext)) | ||
94 | - submitProductRecordCommand := domainService.SubmitOptions{ | 121 | + productRecordData := &domain.ProductRecord{ |
122 | + ProductRecordId: param.ProductRecordId, | ||
95 | CompanyId: operateInfo.CompanyId, | 123 | CompanyId: operateInfo.CompanyId, |
96 | OrgId: operateInfo.OrgId, | 124 | OrgId: operateInfo.OrgId, |
97 | - ProductPlanId: param.ProductPlanId, | ||
98 | - WorkshopId: param.WorkshopId, | ||
99 | - LineId: param.LineId, | ||
100 | - SectionId: param.SectionId, | ||
101 | - ProductGroupId: 0, | ||
102 | - EmployeeId: param.WorkerId, | ||
103 | - UnitConversionId: 0, | ||
104 | - Weigh: param.Weigh, | 125 | + ProductRecordType: domain.RecordTypeSecondLevelWeigh, |
126 | + ProductWorker: user, | ||
127 | + WorkStation: workstation, | ||
105 | CreatedAt: dataTime, | 128 | CreatedAt: dataTime, |
106 | - } | ||
107 | - productRecordData, err := productRecordDomainService.SubmitProductRecord(domain.RecordTypeSecondLevelWeigh, tool_funs.SimpleStructToMap(submitProductRecordCommand)) | ||
108 | - if err != nil { | ||
109 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 129 | + UpdatedAt: time.Now(), |
130 | + ProductRecordInfo: &domain.ProductRecordInfo{ | ||
131 | + ProductDate: productPlanData.ProductDate.Local().Format("2006-01-02"), | ||
132 | + Original: param.Weigh, | ||
133 | + Weigh: utils.Round(param.Weigh, 1), | ||
134 | + WeighBefore: utils.Round(param.Weigh, 1), | ||
135 | + UnitConversionId: 0, | ||
136 | + ApproveStatus: domain.ProductRecordNotApprove, | ||
137 | + ProductPlanId: productPlanData.ProductPlanId, | ||
138 | + BatchNumber: productPlanData.BatchNumber, | ||
139 | + PlanProductName: productPlanData.PlanProductName, | ||
140 | + ProductGroupId: 0, | ||
141 | + WorkOn: productPlanData.WorkOn, | ||
142 | + }, | ||
143 | + Ext: domain.NewExt(org.OrgName), | ||
110 | } | 144 | } |
111 | //保存并审核 | 145 | //保存并审核 |
112 | if param.SaveAndApprove { | 146 | if param.SaveAndApprove { |
113 | - svr, _ := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
114 | - _, err = svr.Approve( | ||
115 | - productRecordData.ProductRecordId, | ||
116 | - operateInfo.UserId, | ||
117 | - productRecordData.ProductRecordInfo.WeighBefore, | ||
118 | - time.Now()) | ||
119 | - if err != nil { | ||
120 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 147 | + productRecordData.Approve(user, param.Weigh, time.Now(), domain.ProductRecordApproved) |
121 | } | 148 | } |
149 | + _, err = productRecordRepo.Save(productRecordData) | ||
150 | + if err != nil { | ||
151 | + return nil, application.ThrowError(application.ARG_ERROR, "保存生产记录"+err.Error()) | ||
122 | } | 152 | } |
123 | if err := transactionContext.CommitTransaction(); err != nil { | 153 | if err := transactionContext.CommitTransaction(); err != nil { |
124 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 154 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "time" | 7 | "time" |
8 | 8 | ||
9 | "github.com/linmadan/egglib-go/core/application" | 9 | "github.com/linmadan/egglib-go/core/application" |
10 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/command" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/command" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/dto" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/dto" |
@@ -226,8 +227,10 @@ func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.Opera | @@ -226,8 +227,10 @@ func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.Opera | ||
226 | if err != nil { | 227 | if err != nil { |
227 | return application.ThrowError(application.ARG_ERROR, err.Error()) | 228 | return application.ThrowError(application.ARG_ERROR, err.Error()) |
228 | } | 229 | } |
230 | + | ||
229 | //汇总奖惩明细 | 231 | //汇总奖惩明细 |
230 | - err = srv.CreateRewardSummaryByProductTrouble(troubleData) | 232 | + summaryServe, _ := domainService.NewPGRewardSummaryStaticService(transactionContext.(*pgTransaction.TransactionContext)) |
233 | + err = summaryServe.CreateRewardSummaryByProductTrouble(troubleData) | ||
231 | if err != nil { | 234 | if err != nil { |
232 | return application.ThrowError(application.ARG_ERROR, "计算功过奖惩明细失败,"+err.Error()) | 235 | return application.ThrowError(application.ARG_ERROR, "计算功过奖惩明细失败,"+err.Error()) |
233 | } | 236 | } |
@@ -442,7 +445,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -442,7 +445,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
442 | productTroubleRepo, _ := factory.CreateProductTroubleRepository(map[string]interface{}{ | 445 | productTroubleRepo, _ := factory.CreateProductTroubleRepository(map[string]interface{}{ |
443 | "transactionContext": transactionContext, | 446 | "transactionContext": transactionContext, |
444 | }) | 447 | }) |
445 | - | 448 | + summaryServe, _ := domainService.NewPGRewardSummaryStaticService(transactionContext.(*pgTransaction.TransactionContext)) |
446 | for i := range troubleDataList { | 449 | for i := range troubleDataList { |
447 | //添加事故数据 | 450 | //添加事故数据 |
448 | _, err = productTroubleRepo.Save(troubleDataList[i]) | 451 | _, err = productTroubleRepo.Save(troubleDataList[i]) |
@@ -450,7 +453,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -450,7 +453,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
450 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 453 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
451 | } | 454 | } |
452 | //汇总奖惩明细 | 455 | //汇总奖惩明细 |
453 | - err = srv.CreateRewardSummaryByProductTrouble(troubleDataList[i]) | 456 | + err = summaryServe.CreateRewardSummaryByProductTrouble(troubleDataList[i]) |
454 | if err != nil { | 457 | if err != nil { |
455 | return nil, application.ThrowError(application.ARG_ERROR, "计算功过奖惩明细失败,"+err.Error()) | 458 | return nil, application.ThrowError(application.ARG_ERROR, "计算功过奖惩明细失败,"+err.Error()) |
456 | } | 459 | } |
@@ -463,7 +466,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -463,7 +466,7 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
463 | } | 466 | } |
464 | 467 | ||
465 | // 奖惩汇总数据列表 | 468 | // 奖惩汇总数据列表 |
466 | -func (srv ProductTroubleService) ListRewardSummary(param query.ListRewardSummaryQuery) (int64, []dto.RewardSummaryList, error) { | 469 | +func (srv ProductTroubleService) ListRewardSummary(param *query.ListRewardSummaryQuery) (int64, []dto.RewardSummaryList, error) { |
467 | 470 | ||
468 | transactionContext, err := factory.CreateTransactionContext(nil) | 471 | transactionContext, err := factory.CreateTransactionContext(nil) |
469 | if err != nil { | 472 | if err != nil { |
@@ -549,73 +552,73 @@ func (srv ProductTroubleService) ListRewardSummary(param query.ListRewardSummary | @@ -549,73 +552,73 @@ func (srv ProductTroubleService) ListRewardSummary(param query.ListRewardSummary | ||
549 | } | 552 | } |
550 | 553 | ||
551 | // 根据事故数据创建奖惩汇总数据 | 554 | // 根据事故数据创建奖惩汇总数据 |
552 | -func (srv ProductTroubleService) CreateRewardSummaryByProductTrouble(param *domain.ProductTrouble) error { | ||
553 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
554 | - if err != nil { | ||
555 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
556 | - } | ||
557 | - if err := transactionContext.StartTransaction(); err != nil { | ||
558 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
559 | - } | ||
560 | - defer func() { | ||
561 | - transactionContext.RollbackTransaction() | ||
562 | - }() | ||
563 | - | ||
564 | - rewardSummaryRepo, _ := factory.CreateRewardSummaryRepository(map[string]interface{}{ | ||
565 | - "transactionContext": transactionContext, | ||
566 | - }) | ||
567 | - | ||
568 | - //查询是否已经有汇总数据 | ||
569 | - condtion := map[string]interface{}{ | ||
570 | - "orgId": param.OrgId, | ||
571 | - "companyId": param.CompanyId, | ||
572 | - "lineId": param.WorkStation.LineId, | ||
573 | - "sectionId": param.WorkStation.SectionId, | ||
574 | - "workshopId": param.WorkStation.WorkshopId, | ||
575 | - "workerId": param.ProductWorker.UserId, | ||
576 | - "recordDateStr": param.RecordDate.Format("200-01-02"), | ||
577 | - } | ||
578 | - | ||
579 | - _, summaryList, err := rewardSummaryRepo.Find(condtion) | ||
580 | - if err != nil { | ||
581 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
582 | - } | ||
583 | - | ||
584 | - var summaryData *domain.RewardSummary | ||
585 | - nowTime := time.Now() | ||
586 | - if len(summaryList) > 0 { | ||
587 | - summaryData = summaryList[0] | ||
588 | - } else { | ||
589 | - summaryData = &domain.RewardSummary{ | ||
590 | - Id: 0, | ||
591 | - CompanyId: param.CompanyId, | ||
592 | - OrgId: param.OrgId, | ||
593 | - WorkStation: param.WorkStation, | ||
594 | - Worker: param.ProductWorker, | ||
595 | - RecordDate: param.RecordDate, | ||
596 | - RecordDateStr: param.RecordDate.Format("2006-01-02"), | ||
597 | - UpToStandard: 0.0, | ||
598 | - Yield: 0.0, | ||
599 | - AccidentNum1: 0, | ||
600 | - AccidentAmount1: 0.0, | ||
601 | - AccidentNum2: 0, | ||
602 | - AccidentAmount2: 0.0, | ||
603 | - AccidentNum3: 0, | ||
604 | - AccidentNum4: 0, | ||
605 | - SummaryResult: 0.0, | ||
606 | - CreatedAt: nowTime, | ||
607 | - UpdatedAt: nowTime, | ||
608 | - } | ||
609 | - } | ||
610 | - // 将审核过的事故放入汇总数据计算 | ||
611 | - summaryData.SummaryAccident(param) | ||
612 | - summaryData.UpdatedAt = nowTime | ||
613 | - _, err = rewardSummaryRepo.Save(summaryData) | ||
614 | - if err != nil { | ||
615 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
616 | - } | ||
617 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
618 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
619 | - } | ||
620 | - return nil | ||
621 | -} | 555 | +// func (srv ProductTroubleService) CreateRewardSummaryByProductTrouble(param *domain.ProductTrouble) error { |
556 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
557 | +// if err != nil { | ||
558 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
559 | +// } | ||
560 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
561 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
562 | +// } | ||
563 | +// defer func() { | ||
564 | +// transactionContext.RollbackTransaction() | ||
565 | +// }() | ||
566 | + | ||
567 | +// rewardSummaryRepo, _ := factory.CreateRewardSummaryRepository(map[string]interface{}{ | ||
568 | +// "transactionContext": transactionContext, | ||
569 | +// }) | ||
570 | + | ||
571 | +// //查询是否已经有汇总数据 | ||
572 | +// condtion := map[string]interface{}{ | ||
573 | +// "orgId": param.OrgId, | ||
574 | +// "companyId": param.CompanyId, | ||
575 | +// "lineId": param.WorkStation.LineId, | ||
576 | +// "sectionId": param.WorkStation.SectionId, | ||
577 | +// "workshopId": param.WorkStation.WorkshopId, | ||
578 | +// "workerId": param.ProductWorker.UserId, | ||
579 | +// "recordDateStr": param.RecordDate.Format("200-01-02"), | ||
580 | +// } | ||
581 | + | ||
582 | +// _, summaryList, err := rewardSummaryRepo.Find(condtion) | ||
583 | +// if err != nil { | ||
584 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
585 | +// } | ||
586 | + | ||
587 | +// var summaryData *domain.RewardSummary | ||
588 | +// nowTime := time.Now() | ||
589 | +// if len(summaryList) > 0 { | ||
590 | +// summaryData = summaryList[0] | ||
591 | +// } else { | ||
592 | +// summaryData = &domain.RewardSummary{ | ||
593 | +// Id: 0, | ||
594 | +// CompanyId: param.CompanyId, | ||
595 | +// OrgId: param.OrgId, | ||
596 | +// WorkStation: param.WorkStation, | ||
597 | +// Worker: param.ProductWorker, | ||
598 | +// RecordDate: param.RecordDate, | ||
599 | +// RecordDateStr: param.RecordDate.Format("2006-01-02"), | ||
600 | +// UpToStandard: 0.0, | ||
601 | +// Yield: 0.0, | ||
602 | +// AccidentNum1: 0, | ||
603 | +// AccidentAmount1: 0.0, | ||
604 | +// AccidentNum2: 0, | ||
605 | +// AccidentAmount2: 0.0, | ||
606 | +// AccidentNum3: 0, | ||
607 | +// AccidentNum4: 0, | ||
608 | +// SummaryResult: 0.0, | ||
609 | +// CreatedAt: nowTime, | ||
610 | +// UpdatedAt: nowTime, | ||
611 | +// } | ||
612 | +// } | ||
613 | +// // 将审核过的事故放入汇总数据计算 | ||
614 | +// summaryData.SummaryAccident(param) | ||
615 | +// summaryData.UpdatedAt = nowTime | ||
616 | +// _, err = rewardSummaryRepo.Save(summaryData) | ||
617 | +// if err != nil { | ||
618 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
619 | +// } | ||
620 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
621 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
622 | +// } | ||
623 | +// return nil | ||
624 | +// } |
@@ -2,10 +2,11 @@ package constant | @@ -2,10 +2,11 @@ package constant | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
6 | ) | 7 | ) |
7 | 8 | ||
8 | -//var Configurator utils.Configurator = utils.NewConfig("ini","config/app_test.conf") | 9 | +// var Configurator utils.Configurator = utils.NewConfig("ini","config/app_test.conf") |
9 | var Configurator utils.Configurator = utils.EnvConfigurator{} | 10 | var Configurator utils.Configurator = utils.EnvConfigurator{} |
10 | 11 | ||
11 | var SERVICE_NAME = "allied-creation-manufacture" | 12 | var SERVICE_NAME = "allied-creation-manufacture" |
@@ -16,13 +17,14 @@ var LOG_LEVEL = "debug" | @@ -16,13 +17,14 @@ var LOG_LEVEL = "debug" | ||
16 | var LOG_FILE = "app.log" | 17 | var LOG_FILE = "app.log" |
17 | var PPROF_ON = true | 18 | var PPROF_ON = true |
18 | 19 | ||
19 | -//天联共创基础模块 | 20 | +// 天联共创基础模块 |
20 | var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com" | 21 | var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com" |
21 | 22 | ||
22 | -//天联共创用户模块 | ||
23 | -var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com" | 23 | +// 天联共创用户模块 |
24 | +// svar ALLIED_CREATION_USER_HOST = "http://localhost:8081" | ||
25 | +var ALLIED_CREATION_USER_HOST = "http://allied-creation-user-test.fjmaimaimai.com" | ||
24 | 26 | ||
25 | -//天联共创业务模块 | 27 | +// 天联共创业务模块 |
26 | var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com" | 28 | var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com" |
27 | 29 | ||
28 | var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301" | 30 | var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301" |
@@ -3,11 +3,11 @@ | @@ -3,11 +3,11 @@ | ||
3 | 3 | ||
4 | package constant | 4 | package constant |
5 | 5 | ||
6 | -var POSTGRESQL_DB_NAME = "terms" | 6 | +var POSTGRESQL_DB_NAME = "allied_creation_test" |
7 | var POSTGRESQL_USER = "postgres" | 7 | var POSTGRESQL_USER = "postgres" |
8 | -var POSTGRESQL_PASSWORD = "123456" | ||
9 | -var POSTGRESQL_HOST = "127.0.0.1" | ||
10 | -var POSTGRESQL_PORT = "5432" | 8 | +var POSTGRESQL_PASSWORD = "eagle1010" |
9 | +var POSTGRESQL_HOST = "114.55.200.59" | ||
10 | +var POSTGRESQL_PORT = "31543" | ||
11 | var DISABLE_CREATE_TABLE = false | 11 | var DISABLE_CREATE_TABLE = false |
12 | var DISABLE_SQL_GENERATE_PRINT = false | 12 | var DISABLE_SQL_GENERATE_PRINT = false |
13 | var DISABLE_SQL_GENERATE_COMMENT = true | 13 | var DISABLE_SQL_GENERATE_COMMENT = true |
@@ -158,11 +158,6 @@ func (m *RewardStandard) ShowTargeFault() string { | @@ -158,11 +158,6 @@ func (m *RewardStandard) ShowTargeFault() string { | ||
158 | return show | 158 | return show |
159 | } | 159 | } |
160 | 160 | ||
161 | -// 编辑 奖惩标准时 ,是否需要将旧数据做备份处理 | ||
162 | -func (m *RewardStandard) NeedMakeBackup() bool { | ||
163 | - // 当前时间与 数据最后更新的时间 不是同一天时 | ||
164 | - // 备份数据 | ||
165 | - updateAt := m.UpdatedAt.Local().Format("2006-01-02") | ||
166 | - nowDate := time.Now().Format("2006-01-02") | ||
167 | - return !(updateAt == nowDate) | 161 | +func (m *RewardStandard) VerdictTarget(val1 int, val float64) int { |
162 | + return 0 | ||
168 | } | 163 | } |
@@ -14,14 +14,20 @@ type RewardSummary struct { | @@ -14,14 +14,20 @@ type RewardSummary struct { | ||
14 | WorkStation WorkStation `json:"workStation"` //工作位置 | 14 | WorkStation WorkStation `json:"workStation"` //工作位置 |
15 | Worker User `json:"user"` //员工 | 15 | Worker User `json:"user"` //员工 |
16 | UpToStandard float64 `json:"upToStandard"` //合格率 | 16 | UpToStandard float64 `json:"upToStandard"` //合格率 |
17 | + UpToStandardResult float64 `json:"upToStandardResult"` //合格率 功过评定结果 `功` `过` `不奖不惩` | ||
17 | Yield float64 `json:"yield"` //产能 | 18 | Yield float64 `json:"yield"` //产能 |
19 | + YieldResult float64 `json:"yieldResult"` //产能 功过评定结果 | ||
18 | AccidentNum1 int `json:"accidentNum1"` //质量事故 次数 | 20 | AccidentNum1 int `json:"accidentNum1"` //质量事故 次数 |
19 | AccidentAmount1 float64 `json:"accidentAmount1"` //质量事故 损失金额 | 21 | AccidentAmount1 float64 `json:"accidentAmount1"` //质量事故 损失金额 |
22 | + AccidentResult1 string `json:"accidentResult1"` //质量事故 功过评定结果 | ||
20 | AccidentNum2 int `json:"accidentNum2"` //安全事故 次数 | 23 | AccidentNum2 int `json:"accidentNum2"` //安全事故 次数 |
21 | AccidentAmount2 float64 `json:"accidentAmount2"` //安全事故 损失金额 | 24 | AccidentAmount2 float64 `json:"accidentAmount2"` //安全事故 损失金额 |
25 | + AccidentResult2 string `json:"accidentResult2"` //安全事故 功过评定结果 | ||
22 | AccidentNum3 int `json:"accidentNum3"` //异物金属事故 次数 | 26 | AccidentNum3 int `json:"accidentNum3"` //异物金属事故 次数 |
27 | + AccidentResult3 string `json:"accidentResult3"` //异物金属事故 功过评定结果 | ||
23 | AccidentNum4 int `json:"accidentNum4"` //异物非金属事故 次数 | 28 | AccidentNum4 int `json:"accidentNum4"` //异物非金属事故 次数 |
24 | - SummaryResult float64 `json:"summaryResult"` //奖惩计算结果 | 29 | + AccidentResult4 string `json:"accidentResult4"` //异物非金属事故 功过评定结果 |
30 | + SummaryResult float64 `json:"summaryResult"` //奖惩金额计算结果(元) | ||
25 | CreatedAt time.Time `json:"createdAt"` // | 31 | CreatedAt time.Time `json:"createdAt"` // |
26 | UpdatedAt time.Time `json:"UpdatedAt"` // | 32 | UpdatedAt time.Time `json:"UpdatedAt"` // |
27 | } | 33 | } |
@@ -2,12 +2,13 @@ package domainService | @@ -2,12 +2,13 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
6 | + | ||
5 | "github.com/mohae/deepcopy" | 7 | "github.com/mohae/deepcopy" |
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
10 | - "time" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | const ( | 14 | const ( |
@@ -21,7 +22,7 @@ const ( | @@ -21,7 +22,7 @@ const ( | ||
21 | DefaultCCJUnitQuantity = 0.2 //kg 穿串机默认的换算数量 1串/0.1千克 | 22 | DefaultCCJUnitQuantity = 0.2 //kg 穿串机默认的换算数量 1串/0.1千克 |
22 | ) | 23 | ) |
23 | 24 | ||
24 | -//EmployeeProductStatics 员工产能统计 | 25 | +// EmployeeProductStatics 员工产能统计 |
25 | func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain.ProductRecord) (interface{}, error) { | 26 | func (ptr *PGProductRecordService) EmployeeProductStatics(productRecord *domain.ProductRecord) (interface{}, error) { |
26 | 27 | ||
27 | var ( | 28 | var ( |
@@ -249,10 +250,11 @@ func (ptr *PGProductRecordService) personalProductStatics(productPlan *domain.Pr | @@ -249,10 +250,11 @@ func (ptr *PGProductRecordService) personalProductStatics(productPlan *domain.Pr | ||
249 | if employeeProductRecord, err = employeeProductRecordRepository.Save(employeeProductRecord); err != nil { | 250 | if employeeProductRecord, err = employeeProductRecordRepository.Save(employeeProductRecord); err != nil { |
250 | log.Logger.Error(fmt.Sprintf("生产记录:[%v] 员工:[%v] 处理异常:%v", productRecord.ProductRecordId, productRecord.ProductWorker.UserId, err.Error())) | 251 | log.Logger.Error(fmt.Sprintf("生产记录:[%v] 员工:[%v] 处理异常:%v", productRecord.ProductRecordId, productRecord.ProductWorker.UserId, err.Error())) |
251 | } | 252 | } |
253 | + //TODO 记录奖惩明细 | ||
252 | return nil, nil | 254 | return nil, nil |
253 | } | 255 | } |
254 | 256 | ||
255 | -//WorkshopProductStatics 车间产能统计 | 257 | +// WorkshopProductStatics 车间产能统计 |
256 | func (ptr *PGProductRecordService) WorkshopProductStatics(productRecord *domain.ProductRecord) (interface{}, error) { | 258 | func (ptr *PGProductRecordService) WorkshopProductStatics(productRecord *domain.ProductRecord) (interface{}, error) { |
257 | var ( | 259 | var ( |
258 | workshopRepository, _ = repository.NewWorkshopRepository(ptr.transactionContext) | 260 | workshopRepository, _ = repository.NewWorkshopRepository(ptr.transactionContext) |
1 | +package domainService | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/linmadan/egglib-go/core/application" | ||
8 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" | ||
11 | +) | ||
12 | + | ||
13 | +//功过奖惩明细汇总 | ||
14 | + | ||
15 | +type PGRewardSummaryStaticService struct { | ||
16 | + transactionContext *pgTransaction.TransactionContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewPGRewardSummaryStaticService(transactionContext *pgTransaction.TransactionContext) (*PGRewardSummaryStaticService, error) { | ||
20 | + if transactionContext == nil { | ||
21 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
22 | + } else { | ||
23 | + return &PGRewardSummaryStaticService{ | ||
24 | + transactionContext: transactionContext, | ||
25 | + }, nil | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +// 根据 | ||
30 | +func (c *PGRewardSummaryStaticService) CreateRewardSummaryByProductTrouble(param *domain.ProductTrouble) error { | ||
31 | + rewardSummaryRepo, _ := repository.NewRewardSummaryRepository(c.transactionContext) | ||
32 | + //查询是否已经有汇总数据 | ||
33 | + condtion := map[string]interface{}{ | ||
34 | + "orgId": param.OrgId, | ||
35 | + "companyId": param.CompanyId, | ||
36 | + "lineId": param.WorkStation.LineId, | ||
37 | + "sectionId": param.WorkStation.SectionId, | ||
38 | + "workshopId": param.WorkStation.WorkshopId, | ||
39 | + "workerId": param.ProductWorker.UserId, | ||
40 | + "recordDateStr": param.RecordDate.Format("200-01-02"), | ||
41 | + } | ||
42 | + | ||
43 | + _, summaryList, err := rewardSummaryRepo.Find(condtion) | ||
44 | + if err != nil { | ||
45 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
46 | + } | ||
47 | + | ||
48 | + var summaryData *domain.RewardSummary | ||
49 | + nowTime := time.Now() | ||
50 | + if len(summaryList) > 0 { | ||
51 | + summaryData = summaryList[0] | ||
52 | + } else { | ||
53 | + summaryData = &domain.RewardSummary{ | ||
54 | + Id: 0, | ||
55 | + CompanyId: param.CompanyId, | ||
56 | + OrgId: param.OrgId, | ||
57 | + WorkStation: param.WorkStation, | ||
58 | + Worker: param.ProductWorker, | ||
59 | + RecordDate: param.RecordDate, | ||
60 | + RecordDateStr: param.RecordDate.Format("2006-01-02"), | ||
61 | + UpToStandard: 0.0, | ||
62 | + Yield: 0.0, | ||
63 | + AccidentNum1: 0, | ||
64 | + AccidentAmount1: 0.0, | ||
65 | + AccidentNum2: 0, | ||
66 | + AccidentAmount2: 0.0, | ||
67 | + AccidentNum3: 0, | ||
68 | + AccidentNum4: 0, | ||
69 | + SummaryResult: 0.0, | ||
70 | + CreatedAt: nowTime, | ||
71 | + UpdatedAt: nowTime, | ||
72 | + } | ||
73 | + } | ||
74 | + // 将审核过的事故放入汇总数据计算 | ||
75 | + summaryData.SummaryAccident(param) | ||
76 | + | ||
77 | + //获取奖惩标准 按 | ||
78 | + rewardStandardRepo, _ := repository.NewRewardStandardRepository(c.transactionContext) | ||
79 | + | ||
80 | + rewardStandardRepo.Find(map[string]interface{}{ | ||
81 | + "companyId": param.CompanyId, | ||
82 | + "orgId": param.OrgId, | ||
83 | + }) | ||
84 | + | ||
85 | + summaryData.UpdatedAt = nowTime | ||
86 | + _, err = rewardSummaryRepo.Save(summaryData) | ||
87 | + if err != nil { | ||
88 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
89 | + } | ||
90 | + return nil | ||
91 | +} |
@@ -72,3 +72,14 @@ func (c *ProductTroubleController) ApproveProductTrouble() { | @@ -72,3 +72,14 @@ func (c *ProductTroubleController) ApproveProductTrouble() { | ||
72 | err := srv.ApproveProductTrouble(operater, int64(getQuery.Id)) | 72 | err := srv.ApproveProductTrouble(operater, int64(getQuery.Id)) |
73 | c.Response(nil, err) | 73 | c.Response(nil, err) |
74 | } | 74 | } |
75 | + | ||
76 | +func (c *ProductTroubleController) ListRewardSummary() { | ||
77 | + srv := service.NewProductTroubleService(nil) | ||
78 | + getQuery := query.ListRewardSummaryQuery{} | ||
79 | + Must(c.Unmarshal(&getQuery)) | ||
80 | + operater := ParseOperateInfo(c.BaseController) | ||
81 | + getQuery.CompanyId = operater.CompanyId | ||
82 | + getQuery.OrgId = operater.OrgId | ||
83 | + total, data, err := srv.ListRewardSummary(&getQuery) | ||
84 | + ResponseGrid(c.BaseController, total, data, err) | ||
85 | +} |
@@ -12,5 +12,5 @@ func init() { | @@ -12,5 +12,5 @@ func init() { | ||
12 | web.Router("/product_trouble/remove", &controllers.ProductTroubleController{}, "Post:DeleteProductTrouble") | 12 | web.Router("/product_trouble/remove", &controllers.ProductTroubleController{}, "Post:DeleteProductTrouble") |
13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") | 13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") |
14 | web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble") | 14 | web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble") |
15 | - | 15 | + web.Router("/product_trouble/reward_summary/seach", &controllers.ProductTroubleController{}, "Post:ListRewardSummary") |
16 | } | 16 | } |
-
请 注册 或 登录 后发表评论