diff --git a/golang_learn/data_office/get_hy_jctj/main.go b/golang_learn/data_office/get_hy_jctj/main.go index e033a3d..ff5e5d5 100644 --- a/golang_learn/data_office/get_hy_jctj/main.go +++ b/golang_learn/data_office/get_hy_jctj/main.go @@ -16,21 +16,21 @@ import ( _ "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') +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' and STATUS=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,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='1' and STATUS=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,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' and STATUS=1) -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,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='5' and STATUS=1 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,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' and STATUS=1) -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,'' AS A0195,a0192a Work,a0101 Name,a0184 IDNumber from a01 where a0163='1' and a0160='6' and STATUS=1 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 b0101 from b01 where b0111=a.a0195) AS A0195,a0192a Work,a.a0101 Name,a.A0184 IDNumber from a01 a where a0163='1' and STATUS=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) +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 STATUS=1) and ouuid in (select ouuid from m_m01) ` @@ -59,7 +59,7 @@ select ifnull(A0184,'')IDNumber, 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' +where A0163 = '1' and STATUS=1 ` var SQLZjk = ` select ifnull(M0203,'') IDNumber, @@ -90,45 +90,45 @@ select ifnull(S0202,'') IDNumber, ifnull(S0201,'') Name, ifnull(S0203,'') Work, - '-' BirthDate, - '-' Gender, - '-' Ethnicity, - '-' WorkStartDate, - '-' PoliticalStatus, - '-' FullTimeEducation, + '' 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, + '' HighestDegree, + '' JobCategory, ifnull((select min(code_name) from code_value where S0204=code_value and code_type='ZB09'),'') CurrentPositionLevel, - '-' CurrentPositionStartDate, + '' CurrentPositionStartDate, ifnull((select min(code_name) from code_value where S0205=code_value and code_type='ZB148'),'') CurrentRankLevel, - '-' CurrentRankStartDate, - '-' Has2YearsGrassrootsExp, - '-' AnnualAssessment2023, - '-' PersonCategory, - '-' SelectedFor2024 + '' 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, + '' 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, + '' HighestDegree, + '' JobCategory, ifnull((select min(code_name) from code_value where S0404=code_value and code_type='ZB09'),'') CurrentPositionLevel, - '-' CurrentPositionStartDate, + '' CurrentPositionStartDate, ifnull((select min(code_name) from code_value where S0405=code_value and code_type='ZB148'),'') CurrentRankLevel, - '-' CurrentRankStartDate, - '-' Has2YearsGrassrootsExp, - '-' AnnualAssessment2023, - '-' PersonCategory, - '-' SelectedFor2024 + '' CurrentRankStartDate, + '' Has2YearsGrassrootsExp, + '' AnnualAssessment2023, + '' PersonCategory, + '' SelectedFor2024 from m_s04 where rpt='@rpt' and S0408=1 ` @@ -231,6 +231,7 @@ func saveSheet1(f *excelize.File, results []Diff) { _ = 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) + _ = f.SetCellValue(sheetName, fmt.Sprintf("G%d", row), diff.Gzk) } } @@ -428,30 +429,30 @@ func mergeResults(peoplesJck, peoplesZjk, peoplesGzk []Person) []Diff { allKeys[key] += 1 } + /** + 1 工资库 + 2 中间库 + 4 基础库 + */ + for key := range allKeys { idNumber := strings.Split(key, "_")[0] name := strings.Split(key, "_")[1] - if allKeys[key] == 1 { - // 全部存在 基础 + switch allKeys[key] { + case 1: // 存在 工资 diffs = setDiffs(gzkMap, key, nl, nl, gzkMap, idNumber, name, gzkMap[key]["职务"], diffs) - } else if allKeys[key] == 2 { - // 全部存在 中间 + case 2: // 存在 中间 diffs = setDiffs(zjkMap, key, nl, zjkMap, nl, idNumber, name, zjkMap[key]["职务"], diffs) - } else if allKeys[key] == 3 { - // 全部存在 中间 + 工资 + case 3: // 存在 中间 + 工资 diffs = setDiffs(zjkMap, key, nl, zjkMap, gzkMap, idNumber, name, zjkMap[key]["职务"], diffs) - } else if allKeys[key] == 4 { - // 全部存在 基础 + case 4: // 存在 基础 diffs = setDiffs(jckMap, key, jckMap, nl, nl, idNumber, name, jckMap[key]["职务"], diffs) - } else if allKeys[key] == 5 { - // 全部存在 基础 + 工资 + case 5: // 存在 基础 + 工资 diffs = setDiffs(jckMap, key, jckMap, nl, gzkMap, idNumber, name, jckMap[key]["职务"], diffs) - } else if allKeys[key] == 6 { - // 全部存在 基础 + 中间 + case 6: // 存在 基础 + 中间 diffs = setDiffs(zjkMap, key, jckMap, zjkMap, nl, idNumber, name, zjkMap[key]["职务"], diffs) - } else { - // 全部存在 基础 + 中间 + 工资 + default: // 全部存在 基础 + 中间 + 工资 diffs = setDiffs(jckMap, key, jckMap, zjkMap, gzkMap, idNumber, name, jckMap[key]["职务"], diffs) } }