diff --git a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go index 2fff1c94..9c10c03e 100644 --- a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go +++ b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go @@ -586,3 +586,14 @@ func GetFsb(bureauId string) ([]map[string]interface{}, error) { list, err := db.SQL(sql, bureauId).Query().List() return list, err } + +/** +功能:根据单位代码,获取单位信息 +作者:黄海 +时间:2020-08-21 +*/ +func GetBureauInfoByCode(bureauCode string) ([]map[string]interface{}, error) { + sql := `select * from t_base_organization where b_use=1 and org_code=?` + list, err := db.SQL(sql, bureauCode).Query().List() + return list, err +} diff --git a/dsBaseRpc/Tools/InitOrg/Build/go_build_InitOrg_go.exe b/dsBaseRpc/Tools/InitOrg/Build/go_build_InitOrg_go.exe new file mode 100644 index 00000000..e52e635c Binary files /dev/null and b/dsBaseRpc/Tools/InitOrg/Build/go_build_InitOrg_go.exe differ diff --git a/dsBaseRpc/Tools/InitOrg/Data/22.23.24.25.通告稿_主体校、附设班信息.xlsx b/dsBaseRpc/Tools/InitOrg/Data/22.23.24.25.通告稿_主体校、附设班信息.xlsx new file mode 100644 index 00000000..59800fc7 Binary files /dev/null and b/dsBaseRpc/Tools/InitOrg/Data/22.23.24.25.通告稿_主体校、附设班信息.xlsx differ diff --git a/dsBaseRpc/Tools/InitOrg/InitFsb.go b/dsBaseRpc/Tools/InitOrg/InitFsb.go new file mode 100644 index 00000000..fdfe6e50 --- /dev/null +++ b/dsBaseRpc/Tools/InitOrg/InitFsb.go @@ -0,0 +1,50 @@ +package main + +import ( + "dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao" + "dsBaseRpc/Utils/CommonUtil" + "fmt" + "github.com/360EntSecGroup-Skylar/excelize/v2" +) + +func main() { + fileName := `./Tools/InitOrg/Data/22.23.24.25.通告稿_主体校、附设班信息.xlsx` + f, err := excelize.OpenFile(fileName) + if err != nil { + fmt.Println(err) + return + } + sheetName := `通告稿_附设班信息` + rows, err := f.GetRows(sheetName) + if err != nil { + fmt.Println(err.Error()) + } + for i, row := range rows { + //放过第一行 + if i == 0 { + continue + } + //单位名称 + orgName := row[1] + //机构编码 + orgCode := row[2] + //附设教学班类型 + fsbCode := row[10] + //插入附设班数据 + list, err := BaseOrganizationDao.GetBureauInfoByCode(orgCode) + if err != nil { + fmt.Println(orgCode) + //panic("查询机构代码出错!") + continue + } + if list == nil || len(list) == 0 { + fmt.Println(orgCode) + //panic("查询机构代码出错!") + continue + } + bureauId := list[0]["org_id"].(string) + BaseOrganizationDao.UpdateFsb(bureauId, []string{fsbCode}) + fmt.Println(CommonUtil.ConvertIntToString(i) + ":完成" + orgName) + } + fmt.Println("恭喜,所有数据初始化完成!") +} diff --git a/dsBaseRpc/Tools/InitOrg/InitOrg.go b/dsBaseRpc/Tools/InitOrg/InitOrg.go new file mode 100644 index 00000000..979e0eed --- /dev/null +++ b/dsBaseRpc/Tools/InitOrg/InitOrg.go @@ -0,0 +1,74 @@ +package main + +import ( + "dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao" + "dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationService" + "dsBaseRpc/Utils/CommonUtil" + "dsBaseRpc/models" + "fmt" + "github.com/360EntSecGroup-Skylar/excelize/v2" +) + +func main() { + fileName := `./Tools/InitOrg/Data/22.23.24.25.通告稿_主体校、附设班信息.xlsx` + f, err := excelize.OpenFile(fileName) + if err != nil { + fmt.Println(err) + return + } + sheetName := `通告稿_主体校信息` + rows, err := f.GetRows(sheetName) + if err != nil { + fmt.Println(err.Error()) + } + for i, row := range rows { + //放过第一行 + if i == 0 { + continue + } + //学校名 + orgName := row[1] + //机构编码 + orgCode := row[2] + //机构所在地 + areaCode := row[4][0:6] + //上级管理单位 + managerAreaCode := row[6][0:6] + //举办者类型码 + xxjbzm := row[8] + //办学类型 + xxbxlxm := row[10] + //城乡级别 + szdcxlxm := row[14] + + //已有的数据不再处理 + if orgCode == "3422000032" || orgCode == "3122001304" { + continue + } + //增加学校 + model := new(models.TBaseOrganization) + model.OrgId = CommonUtil.GetUUID() + model.BureauId = model.OrgId + model.OrgName = orgName + model.BUse = 1 + model.ManagerAreaCode = managerAreaCode + model.ProvinceCode = "220000" + model.CityCode = "220100" + model.DistrictCode = areaCode + model.SortId = 1 + model.Xxbxlxm = xxbxlxm + model.MainSchoolId = model.BureauId + model.OrgType = 2 + model.ParentId = "0" + model.AreaCode = areaCode + model.OrgCode = orgCode + model.MainSchoolType = 1 + model.Szdcxlxm = szdcxlxm + model.Xxjbzm = xxjbzm + BaseOrganizationDao.AddBaseOrganization(*model) + //通过管理员帐号 + BaseOrganizationService.UpdateManager(model.OrgId, 1) + fmt.Println(CommonUtil.ConvertIntToString(i) + ":成功完成" + orgName + "。") + } + fmt.Println("恭喜,所有学校初始化完成!") +}