作者 Your Name

Merge branch 'dev' into test

... ... @@ -127,15 +127,23 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
//车间数据
workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取车间列表
_, workshopList, err := workshopRepo.Find(map[string]interface{}{
"companyId": operate.CompanyId,
"orgId": operate.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error())
}
//车间名称+/+工人名 作为键名
workerMap := map[string][]*domain.User{}
for _, v := range productGroupList {
workStationName := strings.Join([]string{
v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName,
}, "/")
workStationMap[workStationName] = v.WorkStation
for _, vv := range v.GroupMembers {
k := v.WorkStation.WorkshopName + "/" + vv.UserName
isIn := false
... ... @@ -150,6 +158,19 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param
}
}
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
for _, v := range workshopList {
for _, v2 := range v.ProductLines {
for _, v3 := range v2.ProductSections {
workStationName := strings.Join([]string{
v.WorkshopName, v2.LineName, v3.SectionName,
}, "/")
workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3)
}
}
}
var attendanceList []*domain.ProductAttendanceRecord
nowTime := time.Now()
//检查导入的数据
... ...
... ... @@ -384,18 +384,23 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
//车间数据
workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取车间列表
_, workshopList, err := workshopRepo.Find(map[string]interface{}{
"companyId": operate.CompanyId,
"orgId": operate.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error())
}
//车间名称+/+工人名 作为键名
workerMap := map[string][]*domain.User{}
//班组名称 作为键名
productGroupMap := map[string]*domain.ProductGroup{}
for _, v := range productGroupList {
workStationName := strings.Join([]string{
v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName,
}, "/")
workStationMap[workStationName] = v.WorkStation
productGroupMap[v.GroupName] = v
for _, vv := range v.GroupMembers {
k := v.WorkStation.WorkshopName + "/" + vv.UserName
isIn := false
... ... @@ -410,7 +415,18 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera
}
}
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
for _, v := range workshopList {
for _, v2 := range v.ProductLines {
for _, v3 := range v2.ProductSections {
workStationName := strings.Join([]string{
v.WorkshopName, v2.LineName, v3.SectionName,
}, "/")
workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3)
}
}
}
productRecordList := []*domain.ProductRecord{}
nowTime := time.Now()
... ...
... ... @@ -455,7 +455,7 @@ func (productRecordService *ProductRecordService) CancelProductRecord(cmd *comma
return struct{}{}, nil
}
// BatchAddProductRecord 从文件导入的数据,批量添加生产记录
// BatchAddProductRecord 从文件导入的数据,批量添加生产记录,二级品数据
func (productRecordService *ProductRecordService) BatchAddProductRecord(operate *domain.OperateInfo, param []command.BatchAddProductRecordCommand) (
failRows []interface{}, err error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -499,18 +499,22 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
//车间数据
workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取车间列表
_, workshopList, err := workshopRepo.Find(map[string]interface{}{
"companyId": operate.CompanyId,
"orgId": operate.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error())
}
//车间名称+/+工人名 作为键名
workerMap := map[string][]*domain.User{}
//班组名称 作为键名
productGroupMap := map[string]*domain.ProductGroup{}
for _, v := range productGroupList {
workStationName := strings.Join([]string{
v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName,
}, "/")
workStationMap[workStationName] = v.WorkStation
productGroupMap[v.GroupName] = v
for _, vv := range v.GroupMembers {
k := v.WorkStation.WorkshopName + "/" + vv.UserName
isIn := false
... ... @@ -526,6 +530,19 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
}
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
for _, v := range workshopList {
for _, v2 := range v.ProductLines {
for _, v3 := range v2.ProductSections {
workStationName := strings.Join([]string{
v.WorkshopName, v2.LineName, v3.SectionName,
}, "/")
workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3)
}
}
}
productRecordList := []*domain.ProductRecord{}
nowTime := time.Now()
for i := range param {
... ... @@ -545,7 +562,7 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
}
//检查工位
var workStation *domain.WorkStation
workStationName := param[i].WorkerName + "/" + param[i].LineName + "/" + param[i].SectionName
workStationName := param[i].WorkshopName + "/" + param[i].LineName + "/" + param[i].SectionName
if v, ok := workStationMap[workStationName]; ok {
workStation = v
} else {
... ...
... ... @@ -333,7 +333,19 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "查询操作人数据失败。"+err.Error())
}
//车间数据
workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取车间列表
_, workshopList, err := workshopRepo.Find(map[string]interface{}{
"companyId": operateInfo.CompanyId,
"orgId": operateInfo.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error())
}
//生产班组 数据
productGroupRepo, _ := factory.CreateProductGroupRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -345,18 +357,13 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
//车间名称+/+工人名 作为键名
workerMap := map[string][]*domain.User{}
//班组名称 作为键名
productGroupMap := map[string]*domain.ProductGroup{}
// productGroupMap := map[string]*domain.ProductGroup{}
for _, v := range productGroupList {
workStationName := strings.Join([]string{
v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName,
}, "/")
workStationMap[workStationName] = v.WorkStation
productGroupMap[v.GroupName] = v
// productGroupMap[v.GroupName] = v
for _, vv := range v.GroupMembers {
k := v.WorkStation.WorkshopName + "/" + vv.UserName
isIn := false
... ... @@ -371,6 +378,18 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper
}
}
}
//车间名称+/+线别名称+/+工段名称 作为键名
workStationMap := map[string]*domain.WorkStation{}
for _, v := range workshopList {
for _, v2 := range v.ProductLines {
for _, v3 := range v2.ProductSections {
workStationName := strings.Join([]string{
v.WorkshopName, v2.LineName, v3.SectionName,
}, "/")
workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3)
}
}
}
troubleDataList := make([]*domain.ProductTrouble, 0, len(param))
nowTime := time.Now()
... ...