正在显示
16 个修改的文件
包含
106 行增加
和
25 行删除
| @@ -113,4 +113,8 @@ spec: | @@ -113,4 +113,8 @@ spec: | ||
| 113 | - name: SMS_SERVE_HOST | 113 | - name: SMS_SERVE_HOST |
| 114 | value: "https://sms.fjmaimaimai.com:9897" | 114 | value: "https://sms.fjmaimaimai.com:9897" |
| 115 | - name: SUPLUS_SALE_APP | 115 | - name: SUPLUS_SALE_APP |
| 116 | - value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" | ||
| 116 | + value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" | ||
| 117 | + - name: MANUFACTURE_DEFAULT_COMPANYID | ||
| 118 | + value: "23" | ||
| 119 | + - name: MANUFACTURE_DEFAULT_ORGID | ||
| 120 | + value: "487" |
| @@ -30,7 +30,7 @@ func (attendanceService *AttendanceService) WorkerAttendanceReport(cmd *command. | @@ -30,7 +30,7 @@ func (attendanceService *AttendanceService) WorkerAttendanceReport(cmd *command. | ||
| 30 | // return nil, err | 30 | // return nil, err |
| 31 | //} | 31 | //} |
| 32 | attendanceReportService, _ := domainService.NewPGWorkerAttendanceReportService(transactionContext.(*pgTransaction.TransactionContext)) | 32 | attendanceReportService, _ := domainService.NewPGWorkerAttendanceReportService(transactionContext.(*pgTransaction.TransactionContext)) |
| 33 | - if _, err := attendanceReportService.Report(constant.MANUFACTURE_WEIGH_DEFAULT_COMPANYID, constant.MANUFACTURE_WEIGH_DEFAULT_COMPANYID, cmd.DeviceZkTeco); err != nil { | 33 | + if _, err := attendanceReportService.Report(constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_COMPANYID, cmd.DeviceZkTeco); err != nil { |
| 34 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 34 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 35 | } | 35 | } |
| 36 | if err := transactionContext.CommitTransaction(); err != nil { | 36 | if err := transactionContext.CommitTransaction(); err != nil { |
| @@ -37,7 +37,7 @@ func (crontabService *CrontabService) initTask() { | @@ -37,7 +37,7 @@ func (crontabService *CrontabService) initTask() { | ||
| 37 | }) | 37 | }) |
| 38 | task.AddTask("PullPrdMoK3cloud", PullPrdMoK3cloud) | 38 | task.AddTask("PullPrdMoK3cloud", PullPrdMoK3cloud) |
| 39 | 39 | ||
| 40 | - autoApproveAttendanceRecord := task.NewTask("autoApproveAttendanceRecord", "0 */1 * * * *", AutoApproveProductAttendanceRecord) | 40 | + autoApproveAttendanceRecord := task.NewTask("autoApproveAttendanceRecord", "0 */2 * * * *", AutoApproveProductAttendanceRecord) |
| 41 | task.AddTask("autoApproveAttendanceRecord", autoApproveAttendanceRecord) | 41 | task.AddTask("autoApproveAttendanceRecord", autoApproveAttendanceRecord) |
| 42 | 42 | ||
| 43 | autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) | 43 | autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) |
| @@ -335,9 +335,11 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | @@ -335,9 +335,11 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | ||
| 335 | var result = make([]*dto.ProductJobDto, 0) | 335 | var result = make([]*dto.ProductJobDto, 0) |
| 336 | for i := range productJobs { | 336 | for i := range productJobs { |
| 337 | item := productJobs[i] | 337 | item := productJobs[i] |
| 338 | - item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | 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 | result = append(result, newJobDto) | 343 | result = append(result, newJobDto) |
| 342 | } | 344 | } |
| 343 | return count, result, nil | 345 | return count, result, nil |
| @@ -17,7 +17,7 @@ type CreateProductPlanCommand struct { | @@ -17,7 +17,7 @@ type CreateProductPlanCommand struct { | ||
| 17 | // 车间ID | 17 | // 车间ID |
| 18 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 18 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
| 19 | // 批号 | 19 | // 批号 |
| 20 | - BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 20 | + BatchNumber string `cname:"批号" json:"batchNumber"` |
| 21 | // 生产日期 | 21 | // 生产日期 |
| 22 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` | 22 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
| 23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
| @@ -19,7 +19,7 @@ type UpdateProductPlanCommand struct { | @@ -19,7 +19,7 @@ type UpdateProductPlanCommand struct { | ||
| 19 | // 车间ID | 19 | // 车间ID |
| 20 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 20 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
| 21 | // 批号 | 21 | // 批号 |
| 22 | - BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 22 | + BatchNumber string `cname:"批号" json:"batchNumber"` |
| 23 | // 生产日期 | 23 | // 生产日期 |
| 24 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` | 24 | ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
| 25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
| @@ -30,6 +30,8 @@ type UpdateProductPlanCommand struct { | @@ -30,6 +30,8 @@ type UpdateProductPlanCommand struct { | ||
| 30 | PlanProductName string `cname:"计划的产品名称" json:"planProductName"` | 30 | PlanProductName string `cname:"计划的产品名称" json:"planProductName"` |
| 31 | // 产品ID | 31 | // 产品ID |
| 32 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` | 32 | ProductId int `cname:"产品ID" json:"productId" valid:"Required"` |
| 33 | + // 投入量规格 默认份 | ||
| 34 | + DevotedUnit string `cname:"投入量规格" json:"devotedUnit" ` | ||
| 33 | // 数量(保留两位小数) | 35 | // 数量(保留两位小数) |
| 34 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` | 36 | Quantity float64 `cname:"数量(保留两位小数)" json:"quantity" valid:"Required"` |
| 35 | // 单位 | 37 | // 单位 |
| @@ -39,7 +41,7 @@ type UpdateProductPlanCommand struct { | @@ -39,7 +41,7 @@ type UpdateProductPlanCommand struct { | ||
| 39 | // 重量 | 41 | // 重量 |
| 40 | Weight float64 `cname:"重量" json:"weight"` | 42 | Weight float64 `cname:"重量" json:"weight"` |
| 41 | // 备注 | 43 | // 备注 |
| 42 | - Remark string `cname:"备注" json:"remark" valid:"Required"` | 44 | + Remark string `cname:"备注" json:"remark"` |
| 43 | // 生产日期 | 45 | // 生产日期 |
| 44 | ProductDateTime time.Time `cname:"生产日期" json:"productDateTime" ` | 46 | ProductDateTime time.Time `cname:"生产日期" json:"productDateTime" ` |
| 45 | } | 47 | } |
| @@ -24,6 +24,8 @@ type ProductPlanDto struct { | @@ -24,6 +24,8 @@ type ProductPlanDto struct { | ||
| 24 | WorkOnDescription string `json:"workOnDescription"` | 24 | WorkOnDescription string `json:"workOnDescription"` |
| 25 | // 机台 (A、B、C、D 区分机器大小) | 25 | // 机台 (A、B、C、D 区分机器大小) |
| 26 | Machine string `json:"machine"` | 26 | Machine string `json:"machine"` |
| 27 | + // 产品ID | ||
| 28 | + ProductId int `json:"productId,omitempty"` | ||
| 27 | // 计划的产品名称 | 29 | // 计划的产品名称 |
| 28 | PlanProductName string `json:"planProductName,omitempty"` | 30 | PlanProductName string `json:"planProductName,omitempty"` |
| 29 | // 投入量规格 默认份 | 31 | // 投入量规格 默认份 |
| @@ -51,12 +53,14 @@ func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanD | @@ -51,12 +53,14 @@ func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanD | ||
| 51 | d.WorkshopId = m.Workshop.WorkshopId | 53 | d.WorkshopId = m.Workshop.WorkshopId |
| 52 | d.WorkshopName = m.Workshop.WorkshopName | 54 | d.WorkshopName = m.Workshop.WorkshopName |
| 53 | d.WorkOn = m.WorkOn | 55 | d.WorkOn = m.WorkOn |
| 56 | + | ||
| 54 | d.Machine = m.Machine | 57 | d.Machine = m.Machine |
| 55 | d.PlanProductName = m.PlanProductName | 58 | d.PlanProductName = m.PlanProductName |
| 56 | d.UnitQuantity = m.PlanDevoted | 59 | d.UnitQuantity = m.PlanDevoted |
| 57 | d.DevotedUnit = "份" | 60 | d.DevotedUnit = "份" |
| 58 | if m.Ext.ProductPlanExt != nil { | 61 | if m.Ext.ProductPlanExt != nil { |
| 59 | d.DevotedUnit = m.Ext.ProductPlanExt.DevotedUnit | 62 | d.DevotedUnit = m.Ext.ProductPlanExt.DevotedUnit |
| 63 | + d.ProductId = m.Ext.ProductPlanExt.ProductId | ||
| 60 | } | 64 | } |
| 61 | d.PlanStatus = m.PlanStatus | 65 | d.PlanStatus = m.PlanStatus |
| 62 | d.TotalProduct = 0 | 66 | d.TotalProduct = 0 |
| @@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" |
| 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
| 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" |
| 14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
| 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | 15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" |
| 15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 16 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
| 16 | "time" | 17 | "time" |
| @@ -61,6 +62,16 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | @@ -61,6 +62,16 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | ||
| 61 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 65 | + if len(cmd.BatchNumber) == 0 { | ||
| 66 | + generator := redis.NewPlanBatchCodeCache(cmd.CompanyId) | ||
| 67 | + code, err := redis.GenCode(generator) | ||
| 68 | + if err != nil { | ||
| 69 | + log.Logger.Error(err.Error()) | ||
| 70 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "服务器异常") | ||
| 71 | + } | ||
| 72 | + cmd.BatchNumber = code | ||
| 73 | + } | ||
| 74 | + | ||
| 64 | newProductPlan := &domain.ProductPlan{ | 75 | newProductPlan := &domain.ProductPlan{ |
| 65 | CompanyId: cmd.CompanyId, | 76 | CompanyId: cmd.CompanyId, |
| 66 | OrgId: cmd.OrgId, | 77 | OrgId: cmd.OrgId, |
| @@ -89,6 +100,7 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | @@ -89,6 +100,7 @@ func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.Cre | ||
| 89 | DevotedUnit: cmd.DevotedUnit, | 100 | DevotedUnit: cmd.DevotedUnit, |
| 90 | }), | 101 | }), |
| 91 | } | 102 | } |
| 103 | + | ||
| 92 | if cmd.Weight > 0 { | 104 | if cmd.Weight > 0 { |
| 93 | newProductPlan.PlanDevoted.Weight = cmd.Weight | 105 | newProductPlan.PlanDevoted.Weight = cmd.Weight |
| 94 | } | 106 | } |
| @@ -262,7 +274,7 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.Upd | @@ -262,7 +274,7 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(cmd *command.Upd | ||
| 262 | ProductId: product.ProductId, | 274 | ProductId: product.ProductId, |
| 263 | ProductCode: product.ProductCode, | 275 | ProductCode: product.ProductCode, |
| 264 | ProductName: product.ProductName, | 276 | ProductName: product.ProductName, |
| 265 | - //ProductSpec: product.ProductSpec, | 277 | + DevotedUnit: cmd.DevotedUnit, |
| 266 | }) | 278 | }) |
| 267 | productPlan.PlanDevoted.UnitWeight = product.ProductSpec.UnitWeight | 279 | productPlan.PlanDevoted.UnitWeight = product.ProductSpec.UnitWeight |
| 268 | cmd.PlanProductName = product.ProductName | 280 | cmd.PlanProductName = product.ProductName |
| 1 | package syncdata | 1 | package syncdata |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
| 4 | "strconv" | 6 | "strconv" |
| 5 | "strings" | 7 | "strings" |
| 6 | "time" | 8 | "time" |
| @@ -181,8 +183,15 @@ func (srv *PullDataK3CloudService) PullMaterial(timeFilter time.Time) error { | @@ -181,8 +183,15 @@ func (srv *PullDataK3CloudService) PullMaterial(timeFilter time.Time) error { | ||
| 181 | if err != nil { | 183 | if err != nil { |
| 182 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 184 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 183 | } | 185 | } |
| 186 | + | ||
| 187 | + var userService = domainService.NewUserService() | ||
| 188 | + org, err := userService.Organization(constant.MANUFACTURE_DEFAULT_ORGID) | ||
| 189 | + if err != nil { | ||
| 190 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 191 | + } | ||
| 192 | + | ||
| 184 | //MaterialK3cloud表数据到Proudct表 | 193 | //MaterialK3cloud表数据到Proudct表 |
| 185 | - err = materialDao.SyncDataProudct(nowTime.Unix()) | 194 | + err = materialDao.SyncDataProudct(nowTime.Unix(), org.OrgName) |
| 186 | if err != nil { | 195 | if err != nil { |
| 187 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 196 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 188 | } | 197 | } |
| @@ -175,7 +175,7 @@ func (workshopService *WorkshopService) RemoveWorkshop(removeWorkshopCommand *co | @@ -175,7 +175,7 @@ func (workshopService *WorkshopService) RemoveWorkshop(removeWorkshopCommand *co | ||
| 175 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeWorkshopCommand.WorkshopId))) | 175 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeWorkshopCommand.WorkshopId))) |
| 176 | } | 176 | } |
| 177 | if !workshop.CanRemove() { | 177 | if !workshop.CanRemove() { |
| 178 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当车间下存在线别") | 178 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前车间下存在线别,不可删除") |
| 179 | } | 179 | } |
| 180 | if workshop, err := workshopRepository.Remove(workshop); err != nil { | 180 | if workshop, err := workshopRepository.Remove(workshop); err != nil { |
| 181 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 181 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -7,16 +7,16 @@ import ( | @@ -7,16 +7,16 @@ import ( | ||
| 7 | 7 | ||
| 8 | var ( | 8 | var ( |
| 9 | // 生产制造 - 称重系统 - 默认公司 | 9 | // 生产制造 - 称重系统 - 默认公司 |
| 10 | - MANUFACTURE_WEIGH_DEFAULT_COMPANYID = 1 | 10 | + MANUFACTURE_DEFAULT_COMPANYID = 1 |
| 11 | // 生产制造 - 称重系统 - 默认组织 | 11 | // 生产制造 - 称重系统 - 默认组织 |
| 12 | - MANUFACTURE_WEIGH_DEFAULT_ORGID = 1 | 12 | + MANUFACTURE_DEFAULT_ORGID = 1 |
| 13 | ) | 13 | ) |
| 14 | 14 | ||
| 15 | func init() { | 15 | func init() { |
| 16 | - if os.Getenv("MANUFACTURE_WEIGH_DEFAULT_COMPANY_ID") != "" { | ||
| 17 | - MANUFACTURE_WEIGH_DEFAULT_COMPANYID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_WEIGH_DEFAULT_COMPANYID")) | 16 | + if os.Getenv("MANUFACTURE_DEFAULT_COMPANYID") != "" { |
| 17 | + MANUFACTURE_DEFAULT_COMPANYID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_DEFAULT_COMPANYID")) | ||
| 18 | } | 18 | } |
| 19 | - if os.Getenv("MANUFACTURE_WEIGH_DEFAULT_ORGID") != "" { | ||
| 20 | - MANUFACTURE_WEIGH_DEFAULT_ORGID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_WEIGH_DEFAULT_ORGID")) | 19 | + if os.Getenv("MANUFACTURE_DEFAULT_ORGID") != "" { |
| 20 | + MANUFACTURE_DEFAULT_ORGID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_DEFAULT_ORGID")) | ||
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| @@ -104,6 +104,14 @@ func (workshop *Workshop) UpdateLine(lineId int, lineName string) error { | @@ -104,6 +104,14 @@ func (workshop *Workshop) UpdateLine(lineId int, lineName string) error { | ||
| 104 | if line.Removed == Deleted { | 104 | if line.Removed == Deleted { |
| 105 | return fmt.Errorf("生产线:%v已删除", line.LineName) | 105 | return fmt.Errorf("生产线:%v已删除", line.LineName) |
| 106 | } | 106 | } |
| 107 | + for _, v := range workshop.ProductLines { | ||
| 108 | + if v.Removed == Deleted { | ||
| 109 | + continue | ||
| 110 | + } | ||
| 111 | + if v.LineName == lineName && v.LineId != lineId { | ||
| 112 | + return fmt.Errorf("生产线:%v已存在", lineName) | ||
| 113 | + } | ||
| 114 | + } | ||
| 107 | line.LineName = lineName | 115 | line.LineName = lineName |
| 108 | return nil | 116 | return nil |
| 109 | } | 117 | } |
| @@ -174,6 +182,21 @@ func (workshop *Workshop) UpdateSection(lineId, sectionId int, sectionName strin | @@ -174,6 +182,21 @@ func (workshop *Workshop) UpdateSection(lineId, sectionId int, sectionName strin | ||
| 174 | if section.Removed == Deleted { | 182 | if section.Removed == Deleted { |
| 175 | return fmt.Errorf("工段:%v已删除", section.SectionName) | 183 | return fmt.Errorf("工段:%v已删除", section.SectionName) |
| 176 | } | 184 | } |
| 185 | + | ||
| 186 | + // 当前线下面工段不能重复 | ||
| 187 | + line, err := workshop.FindLine(lineId) | ||
| 188 | + if err != nil { | ||
| 189 | + return err | ||
| 190 | + } | ||
| 191 | + for _, v := range line.ProductSections { | ||
| 192 | + if v.Removed == Deleted { | ||
| 193 | + continue | ||
| 194 | + } | ||
| 195 | + if v.SectionName == sectionName && v.SectionId != sectionId { | ||
| 196 | + return fmt.Errorf("工段:%v已存在", sectionName) | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + | ||
| 177 | section.SectionName = sectionName | 200 | section.SectionName = sectionName |
| 178 | return nil | 201 | return nil |
| 179 | } | 202 | } |
| @@ -2,6 +2,7 @@ package dao | @@ -2,6 +2,7 @@ package dao | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
| 5 | "strconv" | 6 | "strconv" |
| 6 | "strings" | 7 | "strings" |
| 7 | 8 | ||
| @@ -106,15 +107,15 @@ func (d *MaterialK3cloudDao) SyncDataMaterialK3cloud(data []models.MaterialK3clo | @@ -106,15 +107,15 @@ func (d *MaterialK3cloudDao) SyncDataMaterialK3cloud(data []models.MaterialK3clo | ||
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | //SyncDataProudct 同步MaterialK3cloud表数据到Proudct表 | 109 | //SyncDataProudct 同步MaterialK3cloud表数据到Proudct表 |
| 109 | -func (d *MaterialK3cloudDao) SyncDataProudct(version int64) error { | 110 | +func (d *MaterialK3cloudDao) SyncDataProudct(version int64, orgName string) error { |
| 110 | // -- 插入或者更新 | 111 | // -- 插入或者更新 |
| 111 | - sql := `INSERT INTO "manufacture"."product"( | 112 | + sql := fmt.Sprintf(`INSERT INTO "manufacture"."product"( |
| 112 | "company_id", "org_id", "product_id", "product_code", "product_name", | 113 | "company_id", "org_id", "product_id", "product_code", "product_name", |
| 113 | - "product_category", "product_spec", "created_at", "updated_at" | 114 | + "product_category", "product_spec", "created_at", "updated_at","ext" |
| 114 | ) | 115 | ) |
| 115 | - SELECT 0,use_org_id,"join_product_id","number","name","material_group_name", | ||
| 116 | - json_build_object('unit',specification),now(),now() | ||
| 117 | - FROM "manufacture"."material_k3cloud" WHERE "data_version"=? AND "material_group_number" LIKE '05%' | 116 | + SELECT %v,%v,"join_product_id","number","name","material_group_name", |
| 117 | + json_build_object('unit',specification),now(),now(),json_build_object('orgName','%v') | ||
| 118 | + FROM "manufacture"."material_k3cloud" WHERE "data_version"=? AND "material_group_number" LIKE '05%%' | ||
| 118 | ON conflict ( product_id ) DO | 119 | ON conflict ( product_id ) DO |
| 119 | UPDATE | 120 | UPDATE |
| 120 | SET ( | 121 | SET ( |
| @@ -122,7 +123,7 @@ func (d *MaterialK3cloudDao) SyncDataProudct(version int64) error { | @@ -122,7 +123,7 @@ func (d *MaterialK3cloudDao) SyncDataProudct(version int64) error { | ||
| 122 | "product_category", "product_spec", "updated_at")=( | 123 | "product_category", "product_spec", "updated_at")=( |
| 123 | EXCLUDED."company_id", EXCLUDED."org_id",EXCLUDED."product_id", | 124 | EXCLUDED."company_id", EXCLUDED."org_id",EXCLUDED."product_id", |
| 124 | EXCLUDED."product_code",EXCLUDED."product_name",EXCLUDED."product_category", | 125 | EXCLUDED."product_code",EXCLUDED."product_name",EXCLUDED."product_category", |
| 125 | - EXCLUDED."product_spec", EXCLUDED."updated_at") ` | 126 | + EXCLUDED."product_spec", EXCLUDED."updated_at") `, constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_ORGID, orgName) |
| 126 | _, err := d.transactionContext.PgTx.Exec(sql, version) | 127 | _, err := d.transactionContext.PgTx.Exec(sql, version) |
| 127 | return err | 128 | return err |
| 128 | } | 129 | } |
| @@ -61,3 +61,28 @@ func NewProductCodeCache(id int) ProductCodeCache { | @@ -61,3 +61,28 @@ func NewProductCodeCache(id int) ProductCodeCache { | ||
| 61 | Time: time.Now(), | 61 | Time: time.Now(), |
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| 64 | + | ||
| 65 | +type PlanBatchCodeCache struct { | ||
| 66 | + CompanyId int | ||
| 67 | + Time time.Time | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +func (ca PlanBatchCodeCache) CacheKey() string { | ||
| 71 | + str := fmt.Sprintf("%v:plan-batch-code:%v:%v", constant.CACHE_PREFIX, ca.CompanyId, ca.Time.Format("20060102")) | ||
| 72 | + return str | ||
| 73 | +} | ||
| 74 | +func (ca PlanBatchCodeCache) Format(index int) string { | ||
| 75 | + if index <= 999 { | ||
| 76 | + return fmt.Sprintf("%v%03d", ca.Time.Format("20060102"), index) | ||
| 77 | + } | ||
| 78 | + return fmt.Sprintf("%v%d", ca.Time.Format("20060102"), index) | ||
| 79 | +} | ||
| 80 | +func (ca PlanBatchCodeCache) Expire() time.Duration { | ||
| 81 | + return time.Hour * 24 | ||
| 82 | +} | ||
| 83 | +func NewPlanBatchCodeCache(id int) PlanBatchCodeCache { | ||
| 84 | + return PlanBatchCodeCache{ | ||
| 85 | + CompanyId: id, | ||
| 86 | + Time: time.Now(), | ||
| 87 | + } | ||
| 88 | +} |
| @@ -174,7 +174,6 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | @@ -174,7 +174,6 @@ func (repository *ProductPlanRepository) Find(queryOptions map[string]interface{ | ||
| 174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) | 174 | query := sqlbuilder.BuildQuery(tx.Model(&productPlanModels), queryOptions) |
| 175 | query.SetWhereByQueryOption("company_id = ?", "companyId") | 175 | query.SetWhereByQueryOption("company_id = ?", "companyId") |
| 176 | query.SetWhereByQueryOption("org_id = ?", "orgId") | 176 | query.SetWhereByQueryOption("org_id = ?", "orgId") |
| 177 | - query.SetWhereByQueryOption("batch_number=?", "batchNumber") | ||
| 178 | 177 | ||
| 179 | if v, ok := queryOptions["batchNumber"]; ok && len(v.(string)) > 0 { | 178 | if v, ok := queryOptions["batchNumber"]; ok && len(v.(string)) > 0 { |
| 180 | query.Where(fmt.Sprintf(`batch_number like '%%%v%%'`, v)) | 179 | query.Where(fmt.Sprintf(`batch_number like '%%%v%%'`, v)) |
| @@ -14,7 +14,7 @@ import ( | @@ -14,7 +14,7 @@ import ( | ||
| 14 | func WorkshopWorkTimeRecordStatics(c context.Context, t *asynq.Task) error { | 14 | func WorkshopWorkTimeRecordStatics(c context.Context, t *asynq.Task) error { |
| 15 | svr := service.NewAttendanceService(nil) | 15 | svr := service.NewAttendanceService(nil) |
| 16 | cmd := &command.WorkshopWorkTimeRecordStaticsCommand{} | 16 | cmd := &command.WorkshopWorkTimeRecordStaticsCommand{} |
| 17 | - if err := json.Unmarshal(t.Payload(), cmd); err != nil { | 17 | + if err := json.Unmarshal(t.Payload(), cmd); err != nil || cmd == nil { |
| 18 | return err | 18 | return err |
| 19 | } | 19 | } |
| 20 | log.Logger.Debug(fmt.Sprintf("【考勤记录统计】 消费 记录ID:%v 时间:%v", cmd.ProductAttendanceId, cmd.WorkTimeBefore)) | 20 | log.Logger.Debug(fmt.Sprintf("【考勤记录统计】 消费 记录ID:%v 时间:%v", cmd.ProductAttendanceId, cmd.WorkTimeBefore)) |
-
请 注册 或 登录 后发表评论