forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.5 KiB
83 lines
2.5 KiB
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
"log"
|
|
)
|
|
|
|
type B01 struct {
|
|
b0111 string
|
|
b0111n string
|
|
}
|
|
|
|
func main() {
|
|
db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8")
|
|
|
|
log.Println("开始执行人员信息清洗")
|
|
makeA0000(db)
|
|
log.Println("执行完成人员信息清洗,准备机构信息清洗")
|
|
b01 := B01{
|
|
b0111: "001.001",
|
|
b0111n: "001.001",
|
|
}
|
|
makeB0111(db, &b01)
|
|
log.Println("执行完成机构信息清洗")
|
|
}
|
|
|
|
func makeB0111(db *sql.DB, b01 *B01) {
|
|
|
|
}
|
|
|
|
func makeA0000(db *sql.DB) {
|
|
// 创建临时表
|
|
db.Exec("drop table if exists a01_a01;")
|
|
db.Exec("create table a01_a01 (a0000o varchar(200),a0000n varchar(200),a5714n varchar(200),names varchar(200),paths varchar(200));")
|
|
|
|
// 迁移数据
|
|
db.Exec("delete from a01 where STATUS = 4;")
|
|
db.Exec("insert into a01_a01 select a0000,uuid(),'','','' from a01;")
|
|
|
|
// 更新数据
|
|
db.Exec("update a01_a01 set a0000n=upper(replace(a0000n, '-', '')) where 1=1;")
|
|
db.Exec("update a01,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a02,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a05,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a06,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a08,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a11,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a14,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a15,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a36,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a57,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a30,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a33,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a65,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
db.Exec("update a99z1,a01_a01 a1 set a0000=a0000n where a0000o=a0000;")
|
|
}
|
|
|
|
func UpdateB01B01(db *sql.DB, b0111n int, b0111o string) {
|
|
if b0111o == "" {
|
|
return
|
|
}
|
|
stmt, err := db.Prepare("update b01_b01 set b0111n=? where b0111o=?;")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
_, err = stmt.Exec(b0111n, b0111o)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
var b0111 string
|
|
var rowNum int
|
|
|
|
func QueryB01(db *sql.DB, b01 *B01) {
|
|
c, _ := db.Query("select b0111,@i:=@i+1 rownum from b01,(select @i:=0) rows where b0121='" + b01.b0111 + "' order by SORTID")
|
|
for c.Next() {
|
|
c.Scan(&b0111, &rowNum)
|
|
UpdateB01B01(db, rowNum, b01.b0111)
|
|
|
|
}
|
|
}
|
|
|