|
@ -16,8 +16,6 @@ import ( |
|
|
_ "github.com/go-sql-driver/mysql" |
|
|
_ "github.com/go-sql-driver/mysql" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var demo = "select a0101 name from a01" |
|
|
|
|
|
|
|
|
|
|
|
var hzbSQL = "select concat('copy D:\\\\insigma\\\\old\\\\', PHOTONAME, ' D:\\\\insigma\\\\new\\\\', a0184, substr(PHOTONAME, instr(PHOTONAME,'.'))) name " + |
|
|
var hzbSQL = "select concat('copy D:\\\\insigma\\\\old\\\\', PHOTONAME, ' D:\\\\insigma\\\\new\\\\', a0184, substr(PHOTONAME, instr(PHOTONAME,'.'))) name " + |
|
|
"from a57 join a01 on a57.a0000=a01.a0000 where PHOTONAME not REGEXP '^[0-9A-Za-z]' or " + |
|
|
"from a57 join a01 on a57.a0000=a01.a0000 where PHOTONAME not REGEXP '^[0-9A-Za-z]' or " + |
|
|
"lower(substr(PHOTONAME, instr(PHOTONAME,'.')+1)) not in ('jpg', 'jpeg')" |
|
|
"lower(substr(PHOTONAME, instr(PHOTONAME,'.')+1)) not in ('jpg', 'jpeg')" |
|
@ -38,8 +36,8 @@ func main() { |
|
|
} else { |
|
|
} else { |
|
|
fmt.Println("您操作可能存在问题!\n" + |
|
|
fmt.Println("您操作可能存在问题!\n" + |
|
|
"请联系张献维...\n" + |
|
|
"请联系张献维...\n" + |
|
|
"hzb : Hzb数据库照片问题处理,生产脚本!\n" + |
|
|
"hzb : Hzb数据库照片问题处理,生产脚本用于[img]操作,生成身份证/首信格式!\n" + |
|
|
"mysql : MySQL数据库照片问题处理,生产脚本!\n" + |
|
|
"mysql : MySQL数据库照片问题处理,生产脚本用于[img]操作,生成身份证/首信格式!\n" + |
|
|
"img : 照片格式处理,新照片存储同目录下!") |
|
|
"img : 照片格式处理,新照片存储同目录下!") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -80,7 +78,11 @@ func getDirList(dirpath string) ([]string, error) { |
|
|
if f == nil { |
|
|
if f == nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
if !f.IsDir() && !strings.HasSuffix(f.Name(), ".jpeg") && !strings.HasSuffix(f.Name(), ".jpg") && !strings.HasSuffix(f.Name(), ".JPEG") && !strings.HasSuffix(f.Name(), ".JPG") { |
|
|
if !f.IsDir() && |
|
|
|
|
|
!strings.HasSuffix(f.Name(), ".jpeg") && |
|
|
|
|
|
!strings.HasSuffix(f.Name(), ".jpg") && |
|
|
|
|
|
!strings.HasSuffix(f.Name(), ".JPEG") && |
|
|
|
|
|
!strings.HasSuffix(f.Name(), ".JPG") { |
|
|
dirList = append(dirList, path) |
|
|
dirList = append(dirList, path) |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
@ -92,14 +94,19 @@ func getDirList(dirpath string) ([]string, error) { |
|
|
|
|
|
|
|
|
func writeFile(allStr string) { |
|
|
func writeFile(allStr string) { |
|
|
file3, _ := os.Create(time.Now().Format("20060102150405") + ".txt") |
|
|
file3, _ := os.Create(time.Now().Format("20060102150405") + ".txt") |
|
|
file3.WriteString(allStr) |
|
|
_, err := file3.WriteString(allStr) |
|
|
file3.Close() |
|
|
if err != nil { |
|
|
|
|
|
_ = fmt.Errorf("[writeFile::1]发生异常:%s", err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
_ = file3.Close() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// queryHzb Hzb数据库照片问题处理,用于生成身份证/首信格式
|
|
|
func queryHzb() { |
|
|
func queryHzb() { |
|
|
db, err := sql.Open("mysql", "root:admin@tcp(localhost:35017)/hy_qggwy?charset=utf8") |
|
|
db, err := sql.Open("mysql", "root:admin@tcp(localhost:35017)/hy_qggwy?charset=utf8") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[queryHzb::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
rows, _ := db.Query(hzbSQL) |
|
|
rows, _ := db.Query(hzbSQL) |
|
@ -107,23 +114,32 @@ func queryHzb() { |
|
|
name, _ := rows.Columns() |
|
|
name, _ := rows.Columns() |
|
|
endStr := "" |
|
|
endStr := "" |
|
|
for rows.Next() { |
|
|
for rows.Next() { |
|
|
rows.Scan(&name[0]) |
|
|
err := rows.Scan(&name[0]) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = fmt.Errorf("[queryHzb::2]发生异常:%s", err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
endStr = endStr + "\r\n" + name[0] |
|
|
endStr = endStr + "\r\n" + name[0] |
|
|
} |
|
|
} |
|
|
writeFile(endStr) |
|
|
writeFile(endStr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// queryMySQL Hzb数据库照片问题处理,用于生成身份证/首信格式
|
|
|
func queryMySQL() { |
|
|
func queryMySQL() { |
|
|
db, err := sql.Open("mysql", "gwydb:gwydbpwd@tcp(localhost:7953)/gwybase?charset=utf8") |
|
|
db, err := sql.Open("mysql", "gwydb:gwydbpwd@tcp(localhost:7953)/gwybase?charset=utf8") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[queryMySQL::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
rows, _ := db.Query(mysqlSQL) |
|
|
rows, _ := db.Query(mysqlSQL) |
|
|
fmt.Println(mysqlSQL) |
|
|
fmt.Println(mysqlSQL) |
|
|
name, endStr := "", "" |
|
|
name, endStr := "", "" |
|
|
for rows.Next() { |
|
|
for rows.Next() { |
|
|
rows.Scan(&name) |
|
|
err := rows.Scan(&name) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = fmt.Errorf("[queryMySQL::2]发生异常:%s", err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
endStr = endStr + "\r\n" + name |
|
|
endStr = endStr + "\r\n" + name |
|
|
} |
|
|
} |
|
|
writeFile(endStr) |
|
|
writeFile(endStr) |
|
@ -133,21 +149,21 @@ func runTiff(fPath, tPath string) { |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runTiff::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runTiff::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := tiff.Decode(file) //解码
|
|
|
img, err := tiff.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runTiff::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -155,21 +171,21 @@ func runPic(fPath, tPath string) { |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPic::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPic::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := jpeg.Decode(file) //解码
|
|
|
img, err := jpeg.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPic::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -177,21 +193,21 @@ func runBmp(fPath, tPath string) { |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runBmp::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runBmp::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := bmp.Decode(file) //解码
|
|
|
img, err := bmp.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runBmp::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -199,21 +215,21 @@ func runGif(fPath, tPath string) { |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runGif::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runGif::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := gif.Decode(file) //解码
|
|
|
img, err := gif.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runGif::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -221,41 +237,41 @@ func runPng(fPath, tPath string) { |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
fmt.Println(fPath, " ", tPath) |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPng::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPng::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := png.Decode(file) //解码
|
|
|
img, err := png.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runPng::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func runJpg(fPath, tPath string) { |
|
|
func runJpg(fPath, tPath string) { |
|
|
file, err := os.Open(fPath) |
|
|
file, err := os.Open(fPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runJpg::1]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file.Close() |
|
|
defer file.Close() |
|
|
|
|
|
|
|
|
file1, err := os.Create(tPath) |
|
|
file1, err := os.Create(tPath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runJpg::2]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
defer file1.Close() |
|
|
defer file1.Close() |
|
|
|
|
|
|
|
|
img, err := jpeg.Decode(file) //解码
|
|
|
img, err := jpeg.Decode(file) //解码
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
_ = fmt.Errorf("[runJpg::3]发生异常:%s", err) |
|
|
} |
|
|
} |
|
|
jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
_ = jpeg.Encode(file1, img, nil) //编码,但是将图像质量从100改成5
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|