浏览代码

修改bug

csx 4 年前
父节点
当前提交
07717a03a0

+ 1 - 0
controllers/gobal_config_api_controller.go 查看文件

@@ -1174,6 +1174,7 @@ func RemoveRepeatedOrgElement(orgs []*models.Org) (newOrgs []*models.Org) {
1174 1174
 }
1175 1175
 
1176 1176
 func (this *GobalConfigApiController) GenerateLog() {
1177
+
1177 1178
 	log_type, _ := this.GetInt64("log_type", 0)
1178 1179
 	logs, err := service.GetExportLogByType(this.GetAdminUserInfo().CurrentOrgId, log_type)
1179 1180
 	if err != nil {

+ 0 - 4
controllers/mobile_api_controllers/mobile_api_base_controller.go 查看文件

@@ -116,7 +116,6 @@ func (this *MobileBaseAPIAuthController) Prepare() {
116 116
 			} else {
117 117
 				roles = strings.Split(role.RoleIds, ",")
118 118
 			}
119
-			fmt.Println(roles)
120 119
 
121 120
 			//获取该用户下所有角色的权限总集
122 121
 			var userRolePurviews string
@@ -132,7 +131,6 @@ func (this *MobileBaseAPIAuthController) Prepare() {
132 131
 			}
133 132
 			//该用户所拥有角色的权限的总集
134 133
 			userRolePurviewsArr = RemoveRepeatedPurviewElement(strings.Split(userRolePurviews, ","))
135
-			fmt.Println(userRolePurviewsArr)
136 134
 			//系统所记录的权限列表
137 135
 			allPermission, _ := service.GetAllFunctionPurview()
138 136
 
@@ -146,8 +144,6 @@ func (this *MobileBaseAPIAuthController) Prepare() {
146 144
 					//获取该角色的所有权限
147 145
 					for _, items := range userRolePurviewsArr {
148 146
 						id, _ := strconv.ParseInt(items, 10, 64)
149
-						fmt.Println(id)
150
-						fmt.Println(item.ID)
151 147
 
152 148
 						if id == item.ID {
153 149
 							isPermission = true

+ 19 - 19
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

@@ -715,31 +715,23 @@ func (c *PatientApiController) CheckDoctorAdvice() {
715 715
 	var ids []string
716 716
 	if groupno == 0 {
717 717
 		advice_ids := c.GetString("advice_id")
718
-		ids = strings.Split(advice_ids, ",")
719
-		if len(ids) <= 0 {
718
+		if advice_ids == "" {
720 719
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
721 720
 			return
721
+		} else {
722
+			ids = strings.Split(advice_ids, ",")
723
+			if len(ids) <= 0 {
724
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
725
+				return
726
+			}
722 727
 		}
723 728
 	}
724
-
725 729
 	if groupno < 0 {
726 730
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
727 731
 		return
728 732
 	}
729 733
 
730 734
 	adminUserInfo := c.GetMobileAdminUserInfo()
731
-	//
732
-	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
733
-	//if appRole.UserType != 3 {
734
-	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
735
-	//	if getPermissionErr != nil {
736
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
737
-	//		return
738
-	//	} else if headNursePermission == nil {
739
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
740
-	//		return
741
-	//	}
742
-	//}
743 735
 
744 736
 	var advice models.DoctorAdvice
745 737
 
@@ -775,7 +767,6 @@ func (c *PatientApiController) CheckDoctorAdvice() {
775 767
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
776 768
 			return
777 769
 		}
778
-
779 770
 	}
780 771
 
781 772
 	checker := adminUserInfo.AdminUser.Id
@@ -786,13 +777,22 @@ func (c *PatientApiController) CheckDoctorAdvice() {
786 777
 		Checker:     checker,
787 778
 		UpdatedTime: time.Now().Unix(),
788 779
 	}
789
-	fmt.Println()
790
-
791 780
 	var err error
792 781
 	if groupno > 0 {
793 782
 		err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
794 783
 	} else {
795
-		err = service.BatchCheckOldDoctorAdvice(&advices, ids)
784
+
785
+		if len(ids[0]) <= 0 {
786
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
787
+			return
788
+		} else {
789
+			t := time.Now().Format("2006-01-02")
790
+			timeLayout2 := "2006-01-02"
791
+			loc, _ := time.LoadLocation("Local")
792
+			theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
793
+			err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, theTime.Unix())
794
+
795
+		}
796 796
 	}
797 797
 
798 798
 	if err != nil {

+ 110 - 28
controllers/schedule_api_controller.go 查看文件

@@ -715,12 +715,18 @@ func (this *ScheduleApiController) ExportSchedule() {
715 715
 	utils.ErrorLog("%v", dataBody)
716 716
 	export_time := time.Now().Unix()
717 717
 	var schedules []*models.Schedule
718
+	var failed_total int
718 719
 	var total_schedule []interface{}
719
-
720 720
 	var patients []*models.Patients
721 721
 
722 722
 	patients, _, _ = service.GetAllPatientList(this.GetAdminUserInfo().CurrentOrgId)
723 723
 
724
+	if dataBody["failed_schedule"] != nil || reflect.TypeOf(dataBody["failed_schedule"]).String() == "[]interface {}" {
725
+		tempSchedule := dataBody["failed_schedule"].([]interface{})
726
+		failed_total = len(tempSchedule)
727
+
728
+	}
729
+
724 730
 	if dataBody["schedule"] != nil || reflect.TypeOf(dataBody["schedule"]).String() == "[]interface {}" {
725 731
 		tempSchedule := dataBody["schedule"].([]interface{})
726 732
 		total_schedule = tempSchedule
@@ -798,8 +804,8 @@ func (this *ScheduleApiController) ExportSchedule() {
798 804
 				log := models.ExportLog{
799 805
 					LogType:    2,
800 806
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
801
-					TotalNum:   int64(len(total_schedule)),
802
-					FailNum:    1,
807
+					TotalNum:   int64(len(total_schedule) + failed_total),
808
+					FailNum:    1 + int64(failed_total),
803 809
 					SuccessNum: int64(len(schedules)),
804 810
 					CreateTime: time.Now().Unix(),
805 811
 					UpdateTime: time.Now().Unix(),
@@ -835,8 +841,8 @@ func (this *ScheduleApiController) ExportSchedule() {
835 841
 				log := models.ExportLog{
836 842
 					LogType:    2,
837 843
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
838
-					TotalNum:   int64(len(total_schedule)),
839
-					FailNum:    1,
844
+					TotalNum:   int64(len(total_schedule) + failed_total),
845
+					FailNum:    1 + int64(failed_total),
840 846
 					SuccessNum: int64(len(schedules)),
841 847
 					CreateTime: time.Now().Unix(),
842 848
 					UpdateTime: time.Now().Unix(),
@@ -868,8 +874,8 @@ func (this *ScheduleApiController) ExportSchedule() {
868 874
 					log := models.ExportLog{
869 875
 						LogType:    2,
870 876
 						UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
871
-						TotalNum:   int64(len(total_schedule)),
872
-						FailNum:    1,
877
+						TotalNum:   int64(len(total_schedule) + failed_total),
878
+						FailNum:    1 + int64(failed_total),
873 879
 						SuccessNum: int64(len(schedules)),
874 880
 						CreateTime: time.Now().Unix(),
875 881
 						UpdateTime: time.Now().Unix(),
@@ -907,8 +913,8 @@ func (this *ScheduleApiController) ExportSchedule() {
907 913
 				log := models.ExportLog{
908 914
 					LogType:    2,
909 915
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
910
-					TotalNum:   int64(len(total_schedule)),
911
-					FailNum:    1,
916
+					TotalNum:   int64(len(total_schedule) + failed_total),
917
+					FailNum:    1 + int64(failed_total),
912 918
 					SuccessNum: int64(len(schedules)),
913 919
 					CreateTime: time.Now().Unix(),
914 920
 					UpdateTime: time.Now().Unix(),
@@ -940,8 +946,8 @@ func (this *ScheduleApiController) ExportSchedule() {
940 946
 						log := models.ExportLog{
941 947
 							LogType:    2,
942 948
 							UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
943
-							TotalNum:   int64(len(total_schedule)),
944
-							FailNum:    1,
949
+							TotalNum:   int64(len(total_schedule) + failed_total),
950
+							FailNum:    1 + int64(failed_total),
945 951
 							SuccessNum: int64(len(schedules)),
946 952
 							CreateTime: time.Now().Unix(),
947 953
 							UpdateTime: time.Now().Unix(),
@@ -971,8 +977,8 @@ func (this *ScheduleApiController) ExportSchedule() {
971 977
 						log := models.ExportLog{
972 978
 							LogType:    2,
973 979
 							UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
974
-							TotalNum:   int64(len(total_schedule)),
975
-							FailNum:    1,
980
+							TotalNum:   int64(len(total_schedule) + failed_total),
981
+							FailNum:    1 + int64(failed_total),
976 982
 							SuccessNum: int64(len(schedules)),
977 983
 							CreateTime: time.Now().Unix(),
978 984
 							UpdateTime: time.Now().Unix(),
@@ -1008,8 +1014,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1008 1014
 				log := models.ExportLog{
1009 1015
 					LogType:    2,
1010 1016
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1011
-					TotalNum:   int64(len(total_schedule)),
1012
-					FailNum:    1,
1017
+					TotalNum:   int64(len(total_schedule) + failed_total),
1018
+					FailNum:    1 + int64(failed_total),
1013 1019
 					SuccessNum: int64(len(schedules)),
1014 1020
 					CreateTime: time.Now().Unix(),
1015 1021
 					UpdateTime: time.Now().Unix(),
@@ -1038,8 +1044,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1038 1044
 				log := models.ExportLog{
1039 1045
 					LogType:    2,
1040 1046
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1041
-					TotalNum:   int64(len(total_schedule)),
1042
-					FailNum:    1,
1047
+					TotalNum:   int64(len(total_schedule) + failed_total),
1048
+					FailNum:    1 + int64(failed_total),
1043 1049
 					SuccessNum: int64(len(schedules)),
1044 1050
 					CreateTime: time.Now().Unix(),
1045 1051
 					UpdateTime: time.Now().Unix(),
@@ -1078,8 +1084,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1078 1084
 				log := models.ExportLog{
1079 1085
 					LogType:    2,
1080 1086
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1081
-					TotalNum:   int64(len(total_schedule)),
1082
-					FailNum:    1,
1087
+					TotalNum:   int64(len(total_schedule) + failed_total),
1088
+					FailNum:    1 + int64(failed_total),
1083 1089
 					SuccessNum: int64(len(schedules)),
1084 1090
 					CreateTime: time.Now().Unix(),
1085 1091
 					UpdateTime: time.Now().Unix(),
@@ -1106,8 +1112,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1106 1112
 				log := models.ExportLog{
1107 1113
 					LogType:    2,
1108 1114
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1109
-					TotalNum:   int64(len(total_schedule)),
1110
-					FailNum:    1,
1115
+					TotalNum:   int64(len(total_schedule) + failed_total),
1116
+					FailNum:    1 + int64(failed_total),
1111 1117
 					SuccessNum: int64(len(schedules)),
1112 1118
 					CreateTime: time.Now().Unix(),
1113 1119
 					UpdateTime: time.Now().Unix(),
@@ -1157,8 +1163,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1157 1163
 				log := models.ExportLog{
1158 1164
 					LogType:    2,
1159 1165
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1160
-					TotalNum:   int64(len(total_schedule)),
1161
-					FailNum:    int64(len(errLogs)),
1166
+					TotalNum:   int64(len(total_schedule) + failed_total),
1167
+					FailNum:    int64(len(errLogs) + failed_total),
1162 1168
 					SuccessNum: int64(len(schedules)),
1163 1169
 					CreateTime: time.Now().Unix(),
1164 1170
 					UpdateTime: time.Now().Unix(),
@@ -1167,9 +1173,23 @@ func (this *ScheduleApiController) ExportSchedule() {
1167 1173
 				}
1168 1174
 				service.CreateExportLog(&log)
1169 1175
 
1176
+				if failed_total > 0 {
1177
+					err_log := models.ExportErrLog{
1178
+						LogType:   2,
1179
+						UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
1180
+						ErrMsg: "当前日期(" + this.GetString("date") + " " + GetWeekString(time.Now().Weekday().String()) +
1181
+							")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
1182
+						Status:     1,
1183
+						CreateTime: time.Now().Unix(),
1184
+						UpdateTime: time.Now().Unix(),
1185
+						ExportTime: export_time,
1186
+					}
1187
+					service.CreateExportErrLog(&err_log)
1188
+				}
1189
+
1170 1190
 				this.ServeSuccessJSON(map[string]interface{}{
1171 1191
 					"msg":         "导入成功",
1172
-					"total_num":   len(total_schedule),
1192
+					"total_num":   len(total_schedule) + failed_total,
1173 1193
 					"success_num": len(schedules),
1174 1194
 					"fail_num":    int64(len(errLogs)),
1175 1195
 				})
@@ -1177,8 +1197,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1177 1197
 				log := models.ExportLog{
1178 1198
 					LogType:    2,
1179 1199
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1180
-					TotalNum:   int64(len(total_schedule)),
1181
-					FailNum:    int64(len(errLogs)),
1200
+					TotalNum:   int64(len(total_schedule) + failed_total),
1201
+					FailNum:    int64(len(errLogs) + failed_total),
1182 1202
 					SuccessNum: int64(len(schedules)),
1183 1203
 					CreateTime: time.Now().Unix(),
1184 1204
 					UpdateTime: time.Now().Unix(),
@@ -1187,6 +1207,20 @@ func (this *ScheduleApiController) ExportSchedule() {
1187 1207
 				}
1188 1208
 				service.CreateExportLog(&log)
1189 1209
 
1210
+				if failed_total > 0 {
1211
+					err_log := models.ExportErrLog{
1212
+						LogType:   2,
1213
+						UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
1214
+						ErrMsg: "当前日期(" + this.GetString("date") + " " + GetWeekString(time.Now().Weekday().String()) +
1215
+							")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
1216
+						Status:     1,
1217
+						CreateTime: time.Now().Unix(),
1218
+						UpdateTime: time.Now().Unix(),
1219
+						ExportTime: export_time,
1220
+					}
1221
+					service.CreateExportErrLog(&err_log)
1222
+				}
1223
+
1190 1224
 				this.ServeSuccessJSON(map[string]interface{}{
1191 1225
 					"msg":         "导入成功",
1192 1226
 					"total_num":   len(total_schedule),
@@ -1198,8 +1232,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1198 1232
 			log := models.ExportLog{
1199 1233
 				LogType:    2,
1200 1234
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
1201
-				TotalNum:   int64(len(total_schedule)),
1202
-				FailNum:    int64(len(errLogs)),
1235
+				TotalNum:   int64(len(total_schedule) + failed_total),
1236
+				FailNum:    int64(len(errLogs) + failed_total),
1203 1237
 				SuccessNum: int64(len(schedules)),
1204 1238
 				CreateTime: time.Now().Unix(),
1205 1239
 				UpdateTime: time.Now().Unix(),
@@ -1208,6 +1242,20 @@ func (this *ScheduleApiController) ExportSchedule() {
1208 1242
 			}
1209 1243
 			service.CreateExportLog(&log)
1210 1244
 
1245
+			if failed_total > 0 {
1246
+				err_log := models.ExportErrLog{
1247
+					LogType:   2,
1248
+					UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
1249
+					ErrMsg: "当前日期(" + this.GetString("date") + " " + GetWeekString(time.Now().Weekday().String()) +
1250
+						")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
1251
+					Status:     1,
1252
+					CreateTime: time.Now().Unix(),
1253
+					UpdateTime: time.Now().Unix(),
1254
+					ExportTime: export_time,
1255
+				}
1256
+				service.CreateExportErrLog(&err_log)
1257
+			}
1258
+
1211 1259
 			this.ServeSuccessJSON(map[string]interface{}{
1212 1260
 				"msg":         "导入成功",
1213 1261
 				"total_num":   len(total_schedule),
@@ -1645,3 +1693,37 @@ func (c *ScheduleApiController) GetInitExcelInitDate() {
1645 1693
 	})
1646 1694
 	return
1647 1695
 }
1696
+
1697
+func GetWeekString(week string) string {
1698
+	var weekStr string
1699
+	switch week {
1700
+	case "Sunday":
1701
+		weekStr = "周日"
1702
+		break
1703
+	case "Monday":
1704
+		weekStr = "周一"
1705
+		break
1706
+	case "Tuesday":
1707
+		weekStr = "周二"
1708
+		break
1709
+	case "Wednesday":
1710
+		weekStr = "周三"
1711
+		break
1712
+	case "Thursday":
1713
+		weekStr = "周四"
1714
+
1715
+		break
1716
+	case "Friday":
1717
+		weekStr = "周五"
1718
+
1719
+		break
1720
+	case "Saturday":
1721
+		weekStr = "周六"
1722
+		break
1723
+	default:
1724
+		weekStr = ""
1725
+		break
1726
+
1727
+	}
1728
+	return weekStr
1729
+}

+ 4 - 3
service/dialysis_service.go 查看文件

@@ -884,15 +884,16 @@ func BatchExceOldDoctorAdvice(m *models.DoctorAdvice, ids []string) (err error)
884 884
 	return err
885 885
 }
886 886
 
887
-func BatchCheckOldDoctorAdvice(m *models.DoctorAdvice, ids []string) (err error) {
887
+func BatchCheckOldDoctorAdvice(m *models.DoctorAdvice, ids []string, org_id int64, date int64) (err error) {
888 888
 
889 889
 	ut := writeDb.Begin()
890
-	err = writeDb.Model(&models.DoctorAdvice{}).Where("status = 1   AND id IN (?)", ids).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
890
+	err = writeDb.Model(&models.DoctorAdvice{}).Where("status = 1   AND id IN (?) AND user_org_id = ? AND advice_date = ?", ids, org_id, date).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
891 891
 	if err != nil {
892 892
 		ut.Rollback()
893 893
 		return
894 894
 	}
895
-	err = writeDb.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?)", ids).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
895
+
896
+	err = writeDb.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?) AND user_org_id = ? AND advice_date = ?", ids, org_id, date).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
896 897
 	if err != nil {
897 898
 		ut.Rollback()
898 899
 		return

+ 1 - 1
service/schedule_service.go 查看文件

@@ -356,7 +356,7 @@ func FindSchPatientNameByName(name string, user_org_id int64) (patient []*models
356 356
 }
357 357
 
358 358
 func UpdateScheduleStatus(date int64, org_id int64) (err error) {
359
-	err = readDb.Model(&models.Schedule{}).Where("user_org_id = ? AND schedule_date >= ? AND status = 1", org_id, date).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
359
+	err = readDb.Model(&models.Schedule{}).Where("user_org_id = ? AND schedule_date > ? AND status = 1", org_id, date).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
360 360
 	return
361 361
 }
362 362