123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- package controllers
-
- import (
- "Data_Upload_Api/enums"
- "Data_Upload_Api/models/sz"
- "Data_Upload_Api/service"
- "Data_Upload_Api/service/city"
- "Data_Upload_Api/utils"
- "fmt"
- _ "fmt"
- "github.com/astaxie/beego"
- _ "github.com/jinzhu/gorm"
- _ "math"
- _ "strconv"
- _ "strings"
- _ "time"
- )
-
- type SyncController struct {
- BaseAPIController
- }
-
- func SyncAPIRegisterRouters() {
- beego.Router("/sync/upload/hqyy", &SyncController{}, "get:SyncToHqyy")
- beego.Router("/sync/upload/lg2h", &SyncController{}, "get:SyncToLg2h")
- beego.Router("/sync/upload/smzy", &SyncController{}, "get:SyncToSmzy")
- }
-
- func (c *SyncController) SyncToLg2h() {
- // 第一步:到上报配置表中找到深圳需要上报的机构
- // sz_province, _ := beego.AppConfig.Int64("sz_province")
- // sz_city, _ := beego.AppConfig.Int64("sz_city")
- // configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
-
- org := &sz.DataUploadConfig{
- OrgId: 9598,
- ProvinceId: 19,
- CityId: 291,
- DepartmentName: "深圳市龙岗区第二人民医院",
- HospitalId: "455835506",
- InstType: 1,
- DbHost: "183.62.158.36",
- DbPort: "61433",
- DbPass: "LG2H+9897",
- DbUser: "sa",
- DbName: "xtzk",
- }
-
- // for _, org := range configs {
- // 第二步:跟进配置,创建数据库连接
- if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
- orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
- if err != nil {
- utils.ErrorLog("创建数据库连接失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- fmt.Println("触发了没有22222222")
- // 第三步:开始同步数据
- // 同步医院信息 t_hd_hospital
- // city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
- // // 同步水处理器 t_hd_wm
- // city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
- // // // 同步员工 t_hd_staff
- // city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
- // // // 同步病人 t_hd_patient
- // city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
- // // // 同步排班 t_hd_shift
- // city.SyncShift(orgDb, org.OrgId, org.HospitalId)
- // // 同步处方 t_hd_ps
- // city.SyncPs(orgDb, org.OrgId, org.HospitalId)
- // // 同步处方药品 t_hd_ps
- // city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
- // // // 同步转院信息 t_hd_patient_out
- // city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
- // // 同步处方信息 t_hd_doctors_advice
- // city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
- // // 同步透中信息 t_hd_middle
- // city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
- // // // 同步设备 t_hd_other_machine
- // city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
- // // // 同步维修 t_hd_maintain
- // city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
- // // // 同步设备 t_hd_dm
- // city.SyncDM(orgDb, org.OrgId, org.HospitalId)
- // // // 同步患者透析记录 t_hd_dialysis
- // city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
- // // 同步透析床位分区 t_hd_division
- // city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
- // // 患者通路信息表(T_HD_ACCESS)
- // city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
- // // 透析床位表(T_HD_SICKBED)
- // city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
- // // 患者诊断信息表(T_HD_DIAGNOSIS)
- // city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
- // 患者传染病检查记录表(T_HD_INFECTION
- //city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
- // // 透析并发症记录表(T_HD_COMPLICATION)
- // city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
- // // 血透患者检测结果表(T_HD_LIS_REPORT)
- // city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
- // // 血透患者检验结果指标表(T_HD_LIS_INDICATORS)
- // city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
-
- // 透析机透析液细菌培养检测记录表(t_hd_dm_dialysate_bc)
- // city.SyncLisCulture(orgDb,org.OrgId,org.HospitalId)
- //透析机透析液内毒素检测记录表(T_HD_DM_DIALYSATE_BC)
- // city.SyncDialysate(orgDb,org.OrgId,org.HospitalId)
-
- //物表消毒记录表(T_HD_SURFACE_DISINFECT)
- // city.SyncLisBodyDetection(orgDb,org.OrgId,org.HospitalId)
- // 第四步:关闭数据库连接
-
- //透析用水游离氯检测表(T_HD_WATER_FC)
- // city.SyncLisWaterFc(orgDb,org.OrgId,org.HospitalId)
-
- //透析用水有毒化学物检测表(T_HD_WATER_NC)
- // city.SynLisWaterNc(orgDb,org.OrgId,org.HospitalId)
-
- //透析用水PH值检测表(T_HD_WATER_PH)
- // city.SynLisWaterPh(orgDb,org.OrgId,org.HospitalId)
-
- //透析用水水硬度检测表(T_HD_WATER_WH)
- // city.SynListHadWater(orgDb,org.OrgId,org.HospitalId)
-
- //导管感染记录表(T_HD_CI)
- // city.SynListHdCi(orgDb,org.OrgId,org.HospitalId)
-
- //导管感染转归记录表(T_HD_CI_OUTCOME)
- // city.SynLisHdCiOutCome(orgDb,org.OrgId,org.HospitalId)
-
- //透析室空气消毒记录表(T_HD_AIR_DISINFECT)
- // city.SyncLisAirDetection(orgDb,org.OrgId,org.HospitalId)
-
- //透析用水细菌培养检测表(T_HD_WATER_BC)
- // city.SyncLisWaterBc(orgDb,org.OrgId,org.HospitalId)
-
- //透析用水内毒素检测表(T_HD_WATER_EN)
- // city.SyncLisWaterEn(orgDb,org.OrgId,org.HospitalId)
- // 第四步:关闭数据库连接
- service.CloseDB(orgDb)
- }
- // }
- c.ServeSuccessJSON(map[string]interface{}{
- "resultList": "12345",
- })
- return
- }
-
- func (c *SyncController) SyncToHqyy() {
- // 第一步:到上报配置表中找到深圳需要上报的机构
- // sz_province, _ := beego.AppConfig.Int64("sz_province")
- // sz_city, _ := beego.AppConfig.Int64("sz_city")
- // configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
-
- org := &sz.DataUploadConfig{
- OrgId: 9442,
- ProvinceId: 19,
- CityId: 291,
- DepartmentName: "暨南大学附属深圳华侨医院",
- HospitalId: "73307826X",
- InstType: 1,
- DbHost: "183.11.232.26",
- DbPort: "3306",
- DbPass: "1Q2W3e4r!@#$",
- DbUser: "sa",
- DbName: "xtzk",
- }
-
- // for _, org := range configs {
- // 第二步:跟进配置,创建数据库连接
- if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
- orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
- if err != nil {
- utils.ErrorLog("创建数据库连接失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- // 第三步:开始同步数据
- // 同步医院信息 t_hd_hospital
- city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
- // 同步水处理器 t_hd_wm
- city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
- // // 同步员工 t_hd_staff
- city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
- // // 同步病人 t_hd_patient
- city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
- // // 同步排班 t_hd_shift
- city.SyncShift(orgDb, org.OrgId, org.HospitalId)
- // 同步处方 t_hd_ps
- city.SyncPs(orgDb, org.OrgId, org.HospitalId)
- // 同步处方药品 t_hd_ps
- city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
- // // 同步转院信息 t_hd_patient_out
- city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
- // 同步处方信息 t_hd_doctors_advice
- city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
- // 同步透中信息 t_hd_middle
- city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
- // // 同步设备 t_hd_other_machine
- city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
- // // 同步维修 t_hd_maintain
- city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
- // // 同步设备 t_hd_dm
- city.SyncDM(orgDb, org.OrgId, org.HospitalId)
- // // 同步患者透析记录 t_hd_dialysis
- city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
- // 同步透析床位分区 t_hd_division
- city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
- // 患者通路信息表(T_HD_ACCESS)
- city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
- // 透析床位表(T_HD_SICKBED)
- city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
- // 患者诊断信息表(T_HD_DIAGNOSIS)
- city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
- // 患者传染病检查记录表(T_HD_INFECTION
- city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
- // 透析并发症记录表(T_HD_COMPLICATION)
- city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
- // 血透患者检测结果表(T_HD_LIS_REPORT)
- city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
- // 血透患者检验结果指标表(T_HD_LIS_INDICATORS)
- city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
-
- // 第四步:关闭数据库连接
- service.CloseDB(orgDb)
- }
- // }
- c.ServeSuccessJSON(map[string]interface{}{
- "resultList": "12345",
- })
- return
- }
-
- func (c *SyncController) SyncToSmzy() {
- // 第一步:到上报配置表中找到深圳需要上报的机构
- // sz_province, _ := beego.AppConfig.Int64("sz_province")
- // sz_city, _ := beego.AppConfig.Int64("sz_city")
- // configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
-
- org := &sz.DataUploadConfig{
- OrgId: 9504,
- ProvinceId: 19,
- CityId: 291,
- DepartmentName: "深圳生命之源血液透析中心",
- HospitalId: "MA5EU4PC0",
- InstType: 1,
- DbHost: "localhost",
- DbPort: "1433",
- DbPass: "1Q2W3e4r!@#$",
- DbUser: "sa",
- DbName: "xtzk",
- }
-
- // for _, org := range configs {
- // 第二步:跟进配置,创建数据库连接
- if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
- orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
- if err != nil {
- utils.ErrorLog("创建数据库连接失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- // 第三步:开始同步数据
- // 同步医院信息 t_hd_hospital
- city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
- // 同步水处理器 t_hd_wm
- city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
- // // 同步员工 t_hd_staff
- city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
- // // 同步病人 t_hd_patient
- city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
- // // 同步排班 t_hd_shift
- city.SyncShift(orgDb, org.OrgId, org.HospitalId)
- // 同步处方 t_hd_ps
- city.SyncPs(orgDb, org.OrgId, org.HospitalId)
- // 同步处方药品 t_hd_ps
- city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
- // // 同步转院信息 t_hd_patient_out
- city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
- // 同步处方信息 t_hd_doctors_advice
- city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
- // 同步透中信息 t_hd_middle
- city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
- // // 同步设备 t_hd_other_machine
- city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
- // // 同步维修 t_hd_maintain
- city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
- // // 同步设备 t_hd_dm
- city.SyncDM(orgDb, org.OrgId, org.HospitalId)
- // // 同步患者透析记录 t_hd_dialysis
- city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
- // 同步透析床位分区 t_hd_division
- city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
- // 患者通路信息表(T_HD_ACCESS)
- city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
- // 透析床位表(T_HD_SICKBED)
- city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
- // 患者诊断信息表(T_HD_DIAGNOSIS)
- city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
- // 患者传染病检查记录表(T_HD_INFECTION
- city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
- // 透析并发症记录表(T_HD_COMPLICATION)
- city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
- // 血透患者检测结果表(T_HD_LIS_REPORT)
- city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
- // 血透患者检验结果指标表(T_HD_LIS_INDICATORS)
- city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
-
- // 第四步:关闭数据库连接
- service.CloseDB(orgDb)
- }
- // }
- c.ServeSuccessJSON(map[string]interface{}{
- "resultList": "12345",
- })
- return
- }
|