forked from go/golangs_learn
				
			
				 6 changed files with 114 additions and 3 deletions
			
			
		@ -0,0 +1,21 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | 
				
			|||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | 
				
			|||
<assemblyIdentity | 
				
			|||
    version="1.0.0.0" | 
				
			|||
    processorArchitecture="x86" | 
				
			|||
    name="controls" | 
				
			|||
    type="win32" | 
				
			|||
></assemblyIdentity> | 
				
			|||
<dependency> | 
				
			|||
    <dependentAssembly> | 
				
			|||
        <assemblyIdentity | 
				
			|||
            type="win32" | 
				
			|||
            name="Microsoft.Windows.Common-Controls" | 
				
			|||
            version="6.0.0.0" | 
				
			|||
            processorArchitecture="*" | 
				
			|||
            publicKeyToken="6595b64144ccf1df" | 
				
			|||
            language="*" | 
				
			|||
        ></assemblyIdentity> | 
				
			|||
    </dependentAssembly> | 
				
			|||
</dependency> | 
				
			|||
</assembly> | 
				
			|||
@ -0,0 +1,83 @@ | 
				
			|||
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) | 
				
			|||
 | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
								
									Binary file not shown.
								
							
						
					| 
		 After Width: | Height: | Size: 264 KiB  | 
					Loading…
					
					
				
		Reference in new issue