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