优化错误提示
This commit is contained in:
parent
7c83e5c87d
commit
457bf15a0f
BIN
iniDataForLinux
BIN
iniDataForLinux
Binary file not shown.
BIN
iniDataForMacOs
BIN
iniDataForMacOs
Binary file not shown.
22
main.go
22
main.go
@ -53,7 +53,6 @@ func init() {
|
||||
applogger.Info(fmt.Sprintf("程序启动,加载%s环境,尝试执行...", env))
|
||||
go downloadDecompression() // 启动立即执行一次数据下载、处理
|
||||
go queryBatchState()
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -436,12 +435,13 @@ func downloadDecompression() {
|
||||
|
||||
func batchInsert(fileName string, isLastCall bool, excludedFilename string) int {
|
||||
start := time.Now()
|
||||
db, _ := connectToDB()
|
||||
db, err := connectToDB()
|
||||
handleError(err, "连接数据库失败")
|
||||
|
||||
file, err := os.Open(path.Join(executableDir, txtPath, fileName))
|
||||
if err != nil {
|
||||
return -1
|
||||
} else {
|
||||
handleError(err, fmt.Sprintf("打开文件失败: %s", fileName))
|
||||
defer file.Close()
|
||||
|
||||
reader := csv.NewReader(bufio.NewReader(file))
|
||||
reader.Read()
|
||||
batchRows := 0
|
||||
@ -455,8 +455,7 @@ func batchInsert(fileName string, isLastCall bool, excludedFilename string) int
|
||||
templateID, _ := strconv.ParseUint(strings.TrimSpace(record[3]), 10, 32)
|
||||
status := 1
|
||||
|
||||
t := time.Now()
|
||||
s := t.Format("2006-01-02 15:04:05")
|
||||
s := time.Now().Format("2006-01-02 15:04:05")
|
||||
var batchName, dataFileName string
|
||||
|
||||
if isLastCall {
|
||||
@ -473,16 +472,13 @@ func batchInsert(fileName string, isLastCall bool, excludedFilename string) int
|
||||
IsPersonal: 0,
|
||||
Message: record[4],
|
||||
IsInternational: 0,
|
||||
IsSchedule: 0, //点发
|
||||
IsSchedule: 0,
|
||||
ScheduleTime: s,
|
||||
Token: token,
|
||||
}
|
||||
|
||||
sid, err := CreateBatch(batchParams)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return -1
|
||||
}
|
||||
handleError(err, "创建批次失败")
|
||||
|
||||
batch := Batch{
|
||||
CommunicationChannelID: record[0],
|
||||
@ -507,7 +503,7 @@ func batchInsert(fileName string, isLastCall bool, excludedFilename string) int
|
||||
applogger.Info(fmt.Sprintf("%s(批次文件)入库完成", fileName))
|
||||
applogger.Info(fmt.Sprintf("%s(批次文件)执行时间%s 插入批次次数:%d", fileName, elapsed, batchRows))
|
||||
return 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func CreateBatch(batchParams BatchParams) (int, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user