Bläddra i källkod

更新数据413

XMLWAN 4 år sedan
förälder
incheckning
1c282a8f2a

+ 19 - 6
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Visa fil

@@ -605,7 +605,7 @@ func (this *NewDialysisApiController) GetDoctorAdvices() {
605 605
 	fmt.Println("病人ID", newPatientInfo.BloodId)
606 606
 	advice, _, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
607 607
 	one, total, err := service.GetNewDoctorAdviceOne(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
608
-	fmt.Print(one, total, err)
608
+	fmt.Println("err------------------------", err)
609 609
 	if err != nil {
610 610
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
611 611
 		return
@@ -1948,7 +1948,7 @@ func (this *NewDialysisApiController) DeleteBed() {
1948 1948
 	adminInfo := this.GetMobileAdminUserInfo()
1949 1949
 	orgid := adminInfo.Org.Id
1950 1950
 	_, errcode := service.GetSchedu(id, theTime.Unix(), orgid)
1951
-	fmt.Println("errcode ----------------", errcode)
1951
+	fmt.Println("errcode", errcode)
1952 1952
 	if errcode == gorm.ErrRecordNotFound {
1953 1953
 		err := service.DeleteBed(id)
1954 1954
 		fmt.Println("删除失败", err)
@@ -1967,6 +1967,19 @@ func (this *NewDialysisApiController) LoginOut() {
1967 1967
 
1968 1968
 	this.DelSession("mobile_admin_user_info")
1969 1969
 	this.Ctx.SetCookie("token_cookie", "")
1970
+	id, _ := this.GetInt64("id")
1971
+	fmt.Println("id------------------------------------------", id)
1972
+	loginLog := models.SgjUserAdminLoginLog{
1973
+		AdminUserId: id,
1974
+		OrgId:       0,
1975
+		AppId:       0,
1976
+		Ip:          utils.GetIP(this.Ctx.Request),
1977
+		OperateType: 2,
1978
+		AppType:     0,
1979
+		Ctime:       time.Now().Unix(),
1980
+	}
1981
+	err := service.CreateLoginLod(&loginLog)
1982
+	fmt.Println("err--------", err)
1970 1983
 	returnData := make(map[string]interface{}, 0)
1971 1984
 	returnData["msg"] = "删除失败"
1972 1985
 	this.ServeSuccessJSON(returnData)
@@ -2062,10 +2075,10 @@ func (this *NewDialysisApiController) GetOrgInformation() {
2062 2075
 	cityes, err := service.GetOrgProvince(information.City)
2063 2076
 	district, err := service.GetOrgProvince(information.District)
2064 2077
 	fmt.Print("err", err)
2065
-	if err != nil {
2066
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2067
-		return
2068
-	}
2078
+	//if err != nil {
2079
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2080
+	//	return
2081
+	//}
2069 2082
 	this.ServeSuccessJSON(map[string]interface{}{
2070 2083
 		"information": information,
2071 2084
 		"name":        name,

+ 16 - 0
models/patient_models.go Visa fil

@@ -797,3 +797,19 @@ func (XtPatients) TableName() string {
797 797
 
798 798
 	return "xt_patients"
799 799
 }
800
+
801
+type SgjUserAdminLoginLog struct {
802
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
803
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
804
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
805
+	AppId       int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
806
+	Ip          string `gorm:"column:ip" json:"ip" form:"ip"`
807
+	OperateType int64  `gorm:"column:operate_type" json:"operate_type" form:"operate_type"`
808
+	AppType     int64  `gorm:"column:app_type" json:"app_type" form:"app_type"`
809
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
810
+}
811
+
812
+func (SgjUserAdminLoginLog) TableName() string {
813
+
814
+	return "sgj_user_admin_login_log"
815
+}

+ 12 - 5
service/patientmanage_service.go Visa fil

@@ -495,7 +495,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
495 495
 		db = db.Where("x.start_time>=?", start)
496 496
 	}
497 497
 	if end > 0 {
498
-		db = db.Where("start_time<=?", end)
498
+		db = db.Where("x.start_time<=?", end)
499 499
 	}
500 500
 	//offset := (page - 1) * limit
501 501
 	err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
@@ -505,6 +505,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
505 505
 }
506 506
 
507 507
 func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end int64, limit int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvice, total int64, err error) {
508
+	fmt.Println("advicetype------------------------------", advice_type)
508 509
 	db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
509 510
 	table := UserReadDB().Table("sgj_user_admin_role as r")
510 511
 	fmt.Println("table", table)
@@ -523,10 +524,10 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
523 524
 		db = db.Where("x.start_time>=?", start)
524 525
 	}
525 526
 	if end > 0 {
526
-		db = db.Where("start_time<=?", end)
527
+		db = db.Where("x.start_time<=?", end)
527 528
 	}
528 529
 	offset := (page - 1) * limit
529
-	err = db.Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("x.start_time desc").Scan(&doctoradvice).Error
530
+	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&doctoradvice).Error
530 531
 	fmt.Print("错误是什么", err)
531 532
 	return
532 533
 }
@@ -881,14 +882,14 @@ func GetAllDoctorTwo(orgid int64, appid int64) (appRole []*models.SgjUserAdminRo
881 882
 func GetDoctorAdviceDetail(id int64, orgid int64) (advices []*models.DoctorAdvices, err error) {
882 883
 
883 884
 	db := XTReadDB().Table("xt_doctor_advice as x")
884
-	err = db.Order("x.id desc").Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,x.single_dose,x.single_dose_unit,x.prescribing_number,x.prescribing_number_unit,x.delivery_way,x.execution_frequency,x.advice_doctor,x.status,x.created_time,x.updated_time,x.advice_affirm,x.remark,x.stop_time,x.stop_reason,x.stop_doctor,x.stop_state,x.parent_id,x.execution_time,x.execution_staff,x.execution_state,x.checker,x.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.groupno = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
885
+	err = db.Order("x.id desc").Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,x.single_dose,x.single_dose_unit,x.prescribing_number,x.prescribing_number_unit,x.delivery_way,x.execution_frequency,x.advice_doctor,x.status,x.created_time,x.updated_time,x.advice_affirm,x.remark,x.stop_time,x.stop_reason,x.stop_doctor,x.stop_state,x.parent_id,x.execution_time,x.execution_staff,x.execution_state,x.checker,x.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.start_time = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
885 886
 
886 887
 	return advices, err
887 888
 }
888 889
 
889 890
 func DeleteManagement(groupid int64, orgid int64) error {
890 891
 
891
-	err := XTWriteDB().Model(models.DoctorAdvice{}).Where("groupno=? and user_org_id = ?", groupid, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
892
+	err := XTWriteDB().Model(models.DoctorAdvice{}).Where("start_time =? and user_org_id = ?", groupid, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
892 893
 	return err
893 894
 }
894 895
 
@@ -1264,3 +1265,9 @@ func UpdatedBed(id int64, number *models.DeviceNumber) error {
1264 1265
 	err = XTWriteDB().Model(&number).Where("id=?", id).Update(map[string]interface{}{"number": number.Number, "zone_id": number.ZoneID, "group_id": number.GroupID, "mtime": time.Now().Unix()}).Error
1265 1266
 	return err
1266 1267
 }
1268
+
1269
+func CreateLoginLod(log *models.SgjUserAdminLoginLog) error {
1270
+
1271
+	err := UserWriteDB().Model(&log).Create(&log).Error
1272
+	return err
1273
+}