package main /* 思路: 按照三个SQL进行查询,结果封装到指定结构体,并对比三个查询结果,按照姓名和身份证作为关联项,任意其他项值不等,则保留下来 */ import ( "database/sql" "errors" "fmt" excelize "github.com/xuri/excelize/v2" "strings" "time" _ "github.com/go-sql-driver/mysql" ) var SQL2Ku = ` select '公务员表统计多人' Type,'' AS A0195, m0207 Work,m0201 Name,m0203 IDNumber from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='1' and m1.rpt='@rpt' and m2.rpt='@rpt' and m0203 not in (select a0184 from a01 where a0163='1' and a0160='1') union all select '公务员表采集多人' Type,'' AS A0195,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='1' and a0184 not in(select m0203 from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='1' and m1.rpt='@rpt' and m2.rpt='@rpt') union all select '参公群团表统计多人' Type,'' AS A0195,m0207 Work,m0201 Name,m0203 IDNumber from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='2' and m1.rpt='@rpt' and m2.rpt='@rpt' and m0203 not in (select a0184 from a01 where a0163='1' and a0160='5') union all select '参公群团表采集多人' Type,'' AS A0195,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='5' and a0184 not in(select m0203 from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='2' and m1.rpt='@rpt' and m2.rpt='@rpt') union all select '参公事业表统计多人' Type,'' AS A0195,m0207 Work,m0201 Name,m0203 IDNumber from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='3' and m1.rpt='@rpt' and m2.rpt='@rpt' and m0203 not in (select a0184 from a01 where a0163='1' and a0160='6') union all select '参公事业表采集多人' Type,'' AS A0195,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='6' and a0184 not in(select m0203 from m_m02 m2 inner join m_m01 m1 on m2.ouuid=m1.ouuid where m0104='3' and m1.rpt='@rpt' and m2.rpt='@rpt') union all select '基础库比统计库多' Type,(select b0101 from b01 where b0111=a.a0195) AS A0195,a0192a Work,a.a0101 Name,a.A0184 IDNumber from a01 a where a0163='1' and a0184 not in(select m0203 from m_m02 inner join tb_set_unit s on m_m02.unid=s.TBUNITID and rpid='@rpt' and rpt='@rpt' and TBUNITID<>'0' and ouuid in (select ouuid from m_m01)) union all select '基础库比统计库少' Type,(select m0101 from m_m01 where unid=m.unid and rpt='@rpt') AS A0195,m0207 Work,m.m0201 Name,m.m0203 IDNumber from m_m02 m inner join tb_set_unit s on m.unid=s.TBUNITID and rpid='@rpt' and rpt='@rpt' and TBUNITID<>'0' where m0203 not in(select a0184 from a01 where a0163='1') and ouuid in (select ouuid from m_m01) ` var SQLJck = ` select ifnull(A0184,'')IDNumber, ifnull(A0101,'') Name, ifnull(A0192A,'') Work, ifnull(substr(a0107, 1, 6),'') BirthDate, IF(A0104 = 1, '男', '女') Gender, ifnull((select min(code_name) from code_value where A0117=code_value and code_type='GB3304'),'') Ethnicity, ifnull(substr(a0134, 1, 6),'') WorkStartDate, ifnull((select min(code_name) from code_value where A0141=code_value and code_type='GB4762'),'') PoliticalStatus, ifnull((select case when A0801B like '1%' then '研究生' when A0801B like '2%' then '大学本科' when A0801B like '3%' then '大学专科' else '中专及以下' end from A08 where A0831=1 and A01.A0000=A08.A0000 limit 1), '') FullTimeEducation, ifnull((select case when A0801B like '1%' then '研究生' when A0801B like '2%' then '大学本科' when A0801B like '3%' then '大学专科' else '中专及以下' end from A08 where A0834=1 and A01.A0000=A08.A0000 limit 1), '') HighestEducation, ifnull((select case when A0901B like '3%' then '硕士' when A0901B like '4%' then '学士' else '博士' end from A08 where A0835=1 and A01.A0000=A08.A0000 limit 1), '') HighestDegree, ifnull((select min(code_name) from code_value where A0123=code_value and code_type='XZ93'),'') JobCategory, ifnull((select min(code_name) from A05, code_value where A0501B=code_value and code_type='ZB09' and A0531=0 and A0524=1 and A01.A0000=A05.A0000), '') CurrentPositionLevel, ifnull((select substr(A0504, 1, 6) from A05 where A0531=0 and A0524=1 and A01.A0000=A05.A0000), '') CurrentPositionStartDate, ifnull((select min(code_name) from A05, code_value where A0501B=code_value and code_type='ZB148' and A0531=1 and A0524=1 and A01.A0000=A05.A0000), '') CurrentRankLevel, ifnull((select ifnull(DATE_FORMAT(DATE_ADD(concat(substr(A0530, 1, 4),'-',substr(A0530, 5, 2),'-01'), INTERVAL ifnull(A0532, 0) MONTH), '%Y%m'), ifnull(substr(A0504, 1, 6), '')) from A05 where A0531=1 and A0524=1 and A01.A0000=A05.A0000 limit 1), '') CurrentRankStartDate, IF(A0197 = 1, '是', '否') Has2YearsGrassrootsExp, ifnull((select min(code_name) from A15, code_value where A1517=code_value and code_type='ZB18' and A1521='2023' and A01.A0000=A15.A0000), '') AnnualAssessment2023, ifnull((select min(code_name) from code_value where A0160=code_value and code_type='ZB125'),'') PersonCategory, ifnull((select '是' from A99Z1 where A99Z101=1 and A99Z103=1 and A99Z102 like '@rpt%' and A01.A0000=A99Z1.A0000 limit 1), '否') SelectedFor2024 from A01 where A0163 = '1' ` var SQLZjk = ` select ifnull(M0203,'') IDNumber, ifnull(M0201,'') Name, ifnull(M0207,'') Work, ifnull(substr(M0204, 1, 6) ,'') BirthDate, IF(M0202 = 1, '男', '女') Gender, ifnull((select min(code_name) from code_value where M0205=code_value and code_type='GB3304'),'') Ethnicity, ifnull(substr(M0216, 1, 6),'') WorkStartDate, ifnull((select min(code_name) from code_value where M0206=code_value and code_type='GB4762'),'') PoliticalStatus, ifnull((select min(code_name) from code_value where M0242=code_value and code_type='M_D_C11'),'') FullTimeEducation, ifnull((select min(code_name) from code_value where M0212=code_value and code_type='M_D_C11'),'') HighestEducation, ifnull((select min(code_name) from code_value where M0213=code_value and code_type='M_D_C12'),'') HighestDegree, ifnull((select min(code_name) from code_value where M0246=code_value and code_type='XZ93'),'') JobCategory, ifnull((select min(code_name) from code_value where M0208=code_value and code_type='ZB09'),'') CurrentPositionLevel, ifnull(substr(M0233, 1, 6),'') CurrentPositionStartDate, ifnull((select min(code_name) from code_value where M0243=code_value and code_type='ZB148'),'') CurrentRankLevel, ifnull(substr(M0244, 1, 6),'') CurrentRankStartDate, IF(M0215 = 1, '是', '否') Has2YearsGrassrootsExp, ifnull((select min(code_name) from code_value where M0251=code_value and code_type='M_D_C32_2021'),'') AnnualAssessment2023, ifnull((select case M0104 when 2 then '参照管理机关工作人员' when 3 then '参照管理事业单位人员' else '公务员' end from M_M01 where M_M01.UNID=M_M02.UNID and rpt='@rpt' limit 1),'') PersonCategory, ifnull((select IF(M0525 = 1, '是', '否') from M_M05 where M0503=M0203 and rpt='@rpt' limit 1),'否') SelectedFor2024 from M_M02 where rpt = '@rpt' ` var SQLGzk = ` select ifnull(S0202,'') IDNumber, ifnull(S0201,'') Name, ifnull(S0203,'') Work, '-' BirthDate, '-' Gender, '-' Ethnicity, '-' WorkStartDate, '-' PoliticalStatus, '-' FullTimeEducation, ifnull((select min(code_name) from code_value where S0225=code_value and code_type='M_D_C11'),'') HighestEducation, '-' HighestDegree, '-' JobCategory, ifnull((select min(code_name) from code_value where S0204=code_value and code_type='ZB09'),'') CurrentPositionLevel, '-' CurrentPositionStartDate, ifnull((select min(code_name) from code_value where S0205=code_value and code_type='ZB148'),'') CurrentRankLevel, '-' CurrentRankStartDate, '-' Has2YearsGrassrootsExp, '-' AnnualAssessment2023, '-' PersonCategory, '-' SelectedFor2024 from m_s02 where rpt='@rpt' and S0208=1 union all select ifnull(S0402,'') IDNumber, ifnull(S0401,'') Name, ifnull(S0403,'') Work, '-' BirthDate, '-' Gender, '-' Ethnicity, '-' WorkStartDate, '-' PoliticalStatus, '-' FullTimeEducation, ifnull((select min(code_name) from code_value where S0425=code_value and code_type='M_D_C11'),'') HighestEducation, '-' HighestDegree, '-' JobCategory, ifnull((select min(code_name) from code_value where S0404=code_value and code_type='ZB09'),'') CurrentPositionLevel, '-' CurrentPositionStartDate, ifnull((select min(code_name) from code_value where S0405=code_value and code_type='ZB148'),'') CurrentRankLevel, '-' CurrentRankStartDate, '-' Has2YearsGrassrootsExp, '-' AnnualAssessment2023, '-' PersonCategory, '-' SelectedFor2024 from m_s04 where rpt='@rpt' and S0408=1 ` var SQLCzk = ` select A0101 Name, A0184 IDNumber, ifnull((select min(code_name) from code_value where A0221=code_value and code_type='ZB09'),'') CurrentPositionLevel, ifnull((select min(code_name) from code_value where A0192E=code_value and code_type='ZB148'),'') CurrentRankLevel, ifnull(A0195, '') OldWork from C01 where C0105 like '@rpt%' ` var SQLBhb = ` select M0501 Name, M0503 IDNumber, ifnull((select min(code_name) from code_value where M0515=code_value and code_type='ZB09'),'') CurrentPositionLevel, ifnull((select min(code_name) from code_value where M0515=code_value and code_type='ZB148'),'') CurrentRankLevel, M0510 OldWork from M_M05 a where M0511=2 and M0514=3 ` // 存在所有对象信息 - 集合 func main() { db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8") fmt.Println("操作数据库连接:", db) // 创建临时文件夹 dir := time.Now().Format("2006102150405") file := fmt.Sprintf("对比结果-%s.xlsx", dir) var rpt string // 获取全局报告期 query := "SELECT aaa005 FROM aa01 WHERE aaa001 = 'PERIOD'" err := db.QueryRow(query).Scan(&rpt) if err != nil { if errors.Is(err, sql.ErrNoRows) { fmt.Println("没有找到匹配的记录") } else { fmt.Println("查询失败:", err) } return } fmt.Println("当前报告期:", rpt) peoplesJck := queryBySQL(db, SQLJck, rpt) peoplesZjk := queryBySQL(db, SQLZjk, rpt) peoplesGzk := queryBySQL(db, SQLGzk, rpt) results1 := mergeResults(peoplesJck, peoplesZjk, peoplesGzk) peoplesCzk := queryByCzSQL(db, SQLCzk, rpt) peoplesBhb := queryByCzSQL(db, SQLBhb, rpt) results2 := mergeCzResults(peoplesCzk, peoplesBhb) results3 := queryByChaSQL(db, SQL2Ku, rpt) // 创建一个新的 Excel 文件 f := excelize.NewFile() _ = f.NewSheet("三库对比") _ = f.NewSheet("辞职人员对比") _ = f.NewSheet("两库人头差") saveSheet1(f, results1) saveSheet2(f, results2) saveSheet3(f, results3) f.DeleteSheet("Sheet1") f.SetActiveSheet(0) // 保存文件 if err := f.SaveAs(file); err != nil { fmt.Println("保存文件失败:", err) } else { fmt.Printf("文件已保存为 %s", file) } fmt.Println("执行结束!") } /* */ func saveSheet1(f *excelize.File, results []Diff) { sheetName := "三库对比" // 设置表头 headers := []string{"身份证号", "姓名", "职务", "项名称", "基础库", "中间库", "工资库"} for i, header := range headers { cell := fmt.Sprintf("%c1", 'A'+i) _ = f.SetCellValue(sheetName, cell, header) } // 写入数据 for i, diff := range results { row := i + 2 // 数据从第二行开始 _ = f.SetCellValue(sheetName, fmt.Sprintf("A%d", row), diff.IDNumber) _ = f.SetCellValue(sheetName, fmt.Sprintf("B%d", row), diff.Name) _ = f.SetCellValue(sheetName, fmt.Sprintf("C%d", row), diff.Work) _ = f.SetCellValue(sheetName, fmt.Sprintf("D%d", row), diff.ColName) _ = f.SetCellValue(sheetName, fmt.Sprintf("E%d", row), diff.Jck) _ = f.SetCellValue(sheetName, fmt.Sprintf("F%d", row), diff.Zjk) } } /* */ func saveSheet2(f *excelize.File, results []Diff) { sheetName := "辞职人员对比" // 设置表头 headers := []string{"身份证号", "姓名", "项名称", "辞职库", "中间库"} for i, header := range headers { cell := fmt.Sprintf("%c1", 'A'+i) _ = f.SetCellValue(sheetName, cell, header) } // 写入数据 for i, diff := range results { row := i + 2 // 数据从第二行开始 _ = f.SetCellValue(sheetName, fmt.Sprintf("A%d", row), diff.IDNumber) _ = f.SetCellValue(sheetName, fmt.Sprintf("B%d", row), diff.Name) _ = f.SetCellValue(sheetName, fmt.Sprintf("C%d", row), diff.ColName) _ = f.SetCellValue(sheetName, fmt.Sprintf("D%d", row), diff.Jck) _ = f.SetCellValue(sheetName, fmt.Sprintf("E%d", row), diff.Zjk) } } /* */ func saveSheet3(f *excelize.File, results []Cha) { sheetName := "两库人头差" // 设置表头 headers := []string{"类型", "统计单位", "职务", "姓名", "身份证号"} for i, header := range headers { cell := fmt.Sprintf("%c1", 'A'+i) _ = f.SetCellValue(sheetName, cell, header) } // 写入数据 for i, diff := range results { row := i + 2 // 数据从第二行开始 _ = f.SetCellValue(sheetName, fmt.Sprintf("A%d", row), diff.Type) _ = f.SetCellValue(sheetName, fmt.Sprintf("B%d", row), diff.A0195) _ = f.SetCellValue(sheetName, fmt.Sprintf("C%d", row), diff.Work) _ = f.SetCellValue(sheetName, fmt.Sprintf("D%d", row), diff.Name) _ = f.SetCellValue(sheetName, fmt.Sprintf("E%d", row), diff.IDNumber) } } /* queryBySQL 按照基础脚本查询 */ func queryBySQL(db *sql.DB, SQL, rpt string) []Person { rows, err := db.Query(strings.Replace(SQL, "@rpt", rpt, -1)) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } defer func(rows *sql.Rows) { err := rows.Close() if err != nil { fmt.Printf("错误") } }(rows) var people []Person for rows.Next() { var p Person err := rows.Scan( &p.IDNumber, &p.Name, &p.Work, &p.BirthDate, &p.Gender, &p.Ethnicity, &p.WorkStartDate, &p.PoliticalStatus, &p.FullTimeEducation, &p.HighestEducation, &p.HighestDegree, &p.JobCategory, &p.CurrentPositionLevel, &p.CurrentPositionStartDate, &p.CurrentRankLevel, &p.CurrentRankStartDate, &p.Has2YearsGrassrootsExp, &p.AnnualAssessment2023, &p.PersonCategory, &p.SelectedFor2024, ) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } people = append(people, p) } if err = rows.Err(); err != nil { _ = fmt.Errorf("发生报错:%s", err) } return people } /* queryByCzSQL 按照辞职脚本查询 */ func queryByCzSQL(db *sql.DB, SQL, rpt string) []CzPerson { rows, err := db.Query(strings.Replace(SQL, "@rpt", rpt, -1)) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } defer func(rows *sql.Rows) { err := rows.Close() if err != nil { fmt.Printf("错误") } }(rows) var people []CzPerson for rows.Next() { var p CzPerson err := rows.Scan( &p.Name, &p.IDNumber, &p.CurrentPositionLevel, &p.CurrentRankLevel, &p.OldWork, ) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } people = append(people, p) } if err = rows.Err(); err != nil { _ = fmt.Errorf("发生报错:%s", err) } return people } /* queryByCzSQL 按照辞职脚本查询 */ func queryByChaSQL(db *sql.DB, SQL, rpt string) []Cha { rows, err := db.Query(strings.Replace(SQL, "@rpt", rpt, -1)) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } defer func(rows *sql.Rows) { err := rows.Close() if err != nil { fmt.Printf("错误") } }(rows) var people []Cha for rows.Next() { var p Cha err := rows.Scan( &p.Type, &p.A0195, &p.Work, &p.Name, &p.IDNumber, ) if err != nil { _ = fmt.Errorf("发生报错:%s", err) } people = append(people, p) } if err = rows.Err(); err != nil { _ = fmt.Errorf("发生报错:%s", err) } return people } /* mergeResults 基础人员对比 */ func mergeResults(peoplesJck, peoplesZjk, peoplesGzk []Person) []Diff { jckMap := mapPersonToDiff(peoplesJck) zjkMap := mapPersonToDiff(peoplesZjk) gzkMap := mapPersonToDiff(peoplesGzk) var diffs []Diff // 遍历所有可能的键 allKeys, nl := make(map[string]int), make(map[string]map[string]string) for key := range jckMap { allKeys[key] += 4 } for key := range zjkMap { allKeys[key] += 2 } for key := range gzkMap { allKeys[key] += 1 } for key := range allKeys { idNumber := strings.Split(key, "_")[0] name := strings.Split(key, "_")[1] if allKeys[key] == 1 { // 全部存在 基础 diffs = setDiffs(gzkMap, key, nl, nl, gzkMap, idNumber, name, gzkMap[key]["职务"], diffs) } else if allKeys[key] == 2 { // 全部存在 中间 diffs = setDiffs(zjkMap, key, nl, zjkMap, nl, idNumber, name, zjkMap[key]["职务"], diffs) } else if allKeys[key] == 3 { // 全部存在 中间 + 工资 diffs = setDiffs(zjkMap, key, nl, zjkMap, gzkMap, idNumber, name, zjkMap[key]["职务"], diffs) } else if allKeys[key] == 4 { // 全部存在 基础 diffs = setDiffs(jckMap, key, jckMap, nl, nl, idNumber, name, jckMap[key]["职务"], diffs) } else if allKeys[key] == 5 { // 全部存在 基础 + 工资 diffs = setDiffs(jckMap, key, jckMap, nl, gzkMap, idNumber, name, jckMap[key]["职务"], diffs) } else if allKeys[key] == 6 { // 全部存在 基础 + 中间 diffs = setDiffs(zjkMap, key, jckMap, zjkMap, nl, idNumber, name, zjkMap[key]["职务"], diffs) } else { // 全部存在 基础 + 中间 + 工资 diffs = setDiffs(jckMap, key, jckMap, zjkMap, gzkMap, idNumber, name, jckMap[key]["职务"], diffs) } } return diffs } func setDiffs( oneMap map[string]map[string]string, key string, jckMap map[string]map[string]string, zjkMap map[string]map[string]string, gzkMap map[string]map[string]string, idNumber string, name string, work string, diffs []Diff) []Diff { for colName := range oneMap[key] { if colName == "身份证号" || colName == "姓名" { continue } var diff Diff if gzMap[colName] { // 指定需要注意工资部分 if jckMap[key][colName] != zjkMap[key][colName] || jckMap[key][colName] != gzkMap[key][colName] || zjkMap[key][colName] != gzkMap[key][colName] { diff = Diff{ IDNumber: idNumber, Name: name, Work: work, ColName: colName, Jck: jckMap[key][colName], Zjk: zjkMap[key][colName], Gzk: gzkMap[key][colName], } diffs = append(diffs, diff) } } else { // 需要公共比较 if jckMap[key][colName] != zjkMap[key][colName] { diff = Diff{ IDNumber: idNumber, Name: name, Work: work, ColName: colName, Jck: jckMap[key][colName], Zjk: zjkMap[key][colName], Gzk: gzkMap[key][colName], } diffs = append(diffs, diff) } } } return diffs } /* mergeCzResults 辞职人员对比 */ func mergeCzResults(peoplesCzk, peoplesBhb []CzPerson) []Diff { jckMap := mapCzPersonToDiff(peoplesCzk) zjkMap := mapCzPersonToDiff(peoplesBhb) var diffs []Diff // 遍历所有可能的键 allKeys := make(map[string]bool) for key := range jckMap { allKeys[key] = true } for key := range zjkMap { allKeys[key] = true } for key := range allKeys { idNumber := strings.Split(key, "_")[0] name := strings.Split(key, "_")[1] // 获取每个属性的值 for colName := range jckMap[key] { if colName == "身份证号" || colName == "姓名" { continue } var diff Diff // 需要公共比较 if colName == "职务层次" || colName == "职级" { if jckMap[key][colName] == zjkMap[key][colName] || jckMap[key]["职务层次"] == zjkMap[key]["职级"] || jckMap[key]["职级"] == zjkMap[key]["职务层次"] { continue } } if jckMap[key][colName] != zjkMap[key][colName] { diff = Diff{ IDNumber: idNumber, Name: name, ColName: colName, Jck: jckMap[key][colName], Zjk: zjkMap[key][colName], } diffs = append(diffs, diff) } } } return diffs } // 示例数组 var gzMap map[string]bool func init() { ArrGz := []string{"身份证号", "姓名", "最高学历", "现职务层次", "现职级层次"} // 将数组转换为 map gzMap = make(map[string]bool) for _, item := range ArrGz { gzMap[item] = true } } /* mapPersonToDiff 基础查询对比 */ func mapPersonToDiff(people []Person) map[string]map[string]string { result := make(map[string]map[string]string) for _, person := range people { key := person.IDNumber + "_" + person.Name if result[key] == nil { result[key] = make(map[string]string) } result[key]["身份证号"] = person.IDNumber result[key]["姓名"] = person.Name result[key]["职务"] = person.Work result[key]["出生时间"] = person.BirthDate result[key]["性别"] = person.Gender result[key]["民族"] = person.Ethnicity result[key]["参加工作时间"] = person.WorkStartDate result[key]["政治面貌"] = person.PoliticalStatus result[key]["全日制学历"] = person.FullTimeEducation result[key]["最高学历"] = person.HighestEducation result[key]["最高学位"] = person.HighestDegree result[key]["职位类别"] = person.JobCategory result[key]["现职务层次"] = person.CurrentPositionLevel result[key]["任现职务层次时间"] = person.CurrentPositionStartDate result[key]["现职级层次"] = person.CurrentRankLevel result[key]["任现职级层次时间"] = person.CurrentRankStartDate result[key]["是否具有2年以上基层经验"] = person.Has2YearsGrassrootsExp result[key]["上年年度考核结果"] = person.AnnualAssessment2023 result[key]["人员类别"] = person.PersonCategory result[key]["本年考录选调生"] = person.SelectedFor2024 } return result } /* mapCzPersonToDiff 辞职查询对比 */ func mapCzPersonToDiff(people []CzPerson) map[string]map[string]string { result := make(map[string]map[string]string) for _, person := range people { key := person.IDNumber + "_" + person.Name if result[key] == nil { result[key] = make(map[string]string) } result[key]["身份证号"] = person.IDNumber result[key]["姓名"] = person.Name result[key]["职务层次"] = person.CurrentPositionLevel result[key]["职级"] = person.CurrentRankLevel result[key]["原职务"] = person.OldWork } return result } func Eq(a, b *string) bool { if *a == "" { a = nil } if *b == "" { a = nil } return a == b } type Person struct { IDNumber string // 身份证号 Name string // 姓名 Work string // 职务 BirthDate string // 出生时间 Gender string // 性别 Ethnicity string // 民族 WorkStartDate string // 参加工作时间 PoliticalStatus string // 政治面貌 FullTimeEducation string // 全日制学历 HighestEducation string // 最高学历 HighestDegree string // 最高学位 JobCategory string // 职位类别 CurrentPositionLevel string // 现职务层次 CurrentPositionStartDate string // 任现职务层次时间 CurrentRankLevel string // 现职级层次 CurrentRankStartDate string // 任现职级层次时间 Has2YearsGrassrootsExp string // 是否具有2年以上基层经验 AnnualAssessment2023 string // 上年度考核结果 PersonCategory string // 人员类别 SelectedFor2024 string // 本年考录选调生 } type CzPerson struct { IDNumber string // 身份证号 Name string // 姓名 CurrentPositionLevel string // 职务层次 CurrentRankLevel string // 职级 OldWork string // 原职务 } type Diff struct { IDNumber string `json:"身份证号"` // 身份证号 Name string `json:"姓名"` // 姓名 Work string `json:"职务"` // 职务 ColName string `json:"项名称"` // 项名称 Jck string `json:"基础库"` // 基础库 Zjk string `json:"中间库"` // 中间库 Gzk string `json:"工资库"` // 工资库 } type Cha struct { Type string `json:"类型"` // 类型 A0195 string `json:"统计单位"` // 统计单位 Work string `json:"职务"` // 职务 Name string `json:"姓名"` // 姓名 IDNumber string `json:"身份证号"` // 身份证号 }