|
|
@ -385,10 +385,13 @@ func (impl *ToyotaCalloffServiceImplement) ParseToyotaCallOffFile() { |
|
|
|
return |
|
|
|
} |
|
|
|
for _, project := range projectLi { |
|
|
|
if project.CalloffFolder == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
inboxPath := path.Join(conf.DbConfig.CallOffFolder, project.CalloffFolder) |
|
|
|
outBoxPath := path.Join(conf.DbConfig.OutCallOffFolder, project.CalloffFolder) |
|
|
|
errorBoxPath := path.Join(conf.DbConfig.ErrorCallOffFolder, project.CalloffFolder) |
|
|
|
go impl.LoadFile(user, project.ProjectId, inboxPath, outBoxPath, errorBoxPath) |
|
|
|
go impl.LoadFile(user, inboxPath, outBoxPath, errorBoxPath) |
|
|
|
} |
|
|
|
}(plant) |
|
|
|
} |
|
|
@ -396,7 +399,7 @@ func (impl *ToyotaCalloffServiceImplement) ParseToyotaCallOffFile() { |
|
|
|
} |
|
|
|
|
|
|
|
// LoadFile 读取目录下的文件
|
|
|
|
func (impl *ToyotaCalloffServiceImplement) LoadFile(user *global.User, projectId string, inBoxPath string, outBoxPath string, errBoxPath string) { |
|
|
|
func (impl *ToyotaCalloffServiceImplement) LoadFile(user *global.User, inBoxPath string, outBoxPath string, errBoxPath string) { |
|
|
|
log, _ := logger.NewLogger("CallOff", "PLN") |
|
|
|
fileInfoList, err := ioutil.ReadDir(inBoxPath) |
|
|
|
if err != nil { |
|
|
@ -412,7 +415,7 @@ func (impl *ToyotaCalloffServiceImplement) LoadFile(user *global.User, projectId |
|
|
|
continue |
|
|
|
} |
|
|
|
filepath := path.Join(inBoxPath, file.Name()) |
|
|
|
repeat, err := impl.ParseCsvFile(user, filepath, file.Name(), projectId) |
|
|
|
repeat, err := impl.ParseCsvFile(user, filepath, file.Name()) |
|
|
|
if err != nil { |
|
|
|
log.Error("解析广丰CallOff, 解析失败, 文件:" + file.Name() + ", 错误:" + err.Error()) |
|
|
|
if !repeat { |
|
|
@ -444,7 +447,7 @@ func (impl *ToyotaCalloffServiceImplement) LoadFile(user *global.User, projectId |
|
|
|
} |
|
|
|
|
|
|
|
// ParseCsvFile 解析csv文件
|
|
|
|
func (impl *ToyotaCalloffServiceImplement) ParseCsvFile(user *global.User, filepath string, filename string, projectId string) (bool, error) { |
|
|
|
func (impl *ToyotaCalloffServiceImplement) ParseCsvFile(user *global.User, filepath string, filename string) (bool, error) { |
|
|
|
// 第一个返回值表示是否可以重试
|
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
@ -512,7 +515,7 @@ func (impl *ToyotaCalloffServiceImplement) ParseCsvFile(user *global.User, filep |
|
|
|
callOff := model.ToyotaCalloff{ |
|
|
|
DemandId: demandId, |
|
|
|
SupplierCode: supplyCode, |
|
|
|
ProjectId: projectId, |
|
|
|
ProjectId: productFamily.ProjectId, |
|
|
|
ProductFamilyId: productFamilyId, |
|
|
|
TotalQty: 1, |
|
|
|
CheckSequence: seq, |
|
|
|