Преглед изворни кода

Merge branch 'xt_statistics_branch'

csx пре 4 година
родитељ
комит
ed8da505c0

+ 1 - 0
controllers/gobal_config_api_controller.go Прегледај датотеку

1174
 }
1174
 }
1175
 
1175
 
1176
 func (this *GobalConfigApiController) GenerateLog() {
1176
 func (this *GobalConfigApiController) GenerateLog() {
1177
+
1177
 	log_type, _ := this.GetInt64("log_type", 0)
1178
 	log_type, _ := this.GetInt64("log_type", 0)
1178
 	logs, err := service.GetExportLogByType(this.GetAdminUserInfo().CurrentOrgId, log_type)
1179
 	logs, err := service.GetExportLogByType(this.GetAdminUserInfo().CurrentOrgId, log_type)
1179
 	if err != nil {
1180
 	if err != nil {

+ 0 - 4
controllers/mobile_api_controllers/mobile_api_base_controller.go Прегледај датотеку

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

+ 19 - 19
controllers/mobile_api_controllers/patient_api_controller.go Прегледај датотеку

715
 	var ids []string
715
 	var ids []string
716
 	if groupno == 0 {
716
 	if groupno == 0 {
717
 		advice_ids := c.GetString("advice_id")
717
 		advice_ids := c.GetString("advice_id")
718
-		ids = strings.Split(advice_ids, ",")
719
-		if len(ids) <= 0 {
718
+		if advice_ids == "" {
720
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
719
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
721
 			return
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
 	if groupno < 0 {
729
 	if groupno < 0 {
726
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
730
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
727
 		return
731
 		return
728
 	}
732
 	}
729
 
733
 
730
 	adminUserInfo := c.GetMobileAdminUserInfo()
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
 	var advice models.DoctorAdvice
736
 	var advice models.DoctorAdvice
745
 
737
 
775
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
767
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
776
 			return
768
 			return
777
 		}
769
 		}
778
-
779
 	}
770
 	}
780
 
771
 
781
 	checker := adminUserInfo.AdminUser.Id
772
 	checker := adminUserInfo.AdminUser.Id
786
 		Checker:     checker,
777
 		Checker:     checker,
787
 		UpdatedTime: time.Now().Unix(),
778
 		UpdatedTime: time.Now().Unix(),
788
 	}
779
 	}
789
-	fmt.Println()
790
-
791
 	var err error
780
 	var err error
792
 	if groupno > 0 {
781
 	if groupno > 0 {
793
 		err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
782
 		err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
794
 	} else {
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
 	if err != nil {
798
 	if err != nil {

+ 222 - 5
controllers/new_mobile_api_controllers/common_api_controller.go Прегледај датотеку

7
 	"XT_New/service"
7
 	"XT_New/service"
8
 	"encoding/json"
8
 	"encoding/json"
9
 	"fmt"
9
 	"fmt"
10
+	"github.com/jinzhu/gorm"
11
+	"strconv"
10
 	"time"
12
 	"time"
11
 )
13
 )
12
 
14
 
28
 
30
 
29
 func (this *CommonApiController) GetInspectionMinor() {
31
 func (this *CommonApiController) GetInspectionMinor() {
30
 	id, _ := this.GetInt64("id")
32
 	id, _ := this.GetInt64("id")
31
-	fmt.Println("id----------------------------------------", id)
32
 	minor, err := service.GetInspectionMinor(id)
33
 	minor, err := service.GetInspectionMinor(id)
33
 	if err != nil {
34
 	if err != nil {
34
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
35
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
55
 func (this *CommonApiController) SaveConfiguration() {
56
 func (this *CommonApiController) SaveConfiguration() {
56
 	adminInfo := this.GetAdminUserInfo()
57
 	adminInfo := this.GetAdminUserInfo()
57
 	orgid := adminInfo.CurrentOrgId
58
 	orgid := adminInfo.CurrentOrgId
58
-	fmt.Println(orgid)
59
-	fmt.Println("触发-------------------0")
60
 	dataBody := make(map[string]interface{}, 0)
59
 	dataBody := make(map[string]interface{}, 0)
61
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
60
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
62
 	fmt.Println("err", err)
61
 	fmt.Println("err", err)
69
 	largerange := dataBody["large_range"].(string)
68
 	largerange := dataBody["large_range"].(string)
70
 	fmt.Println("largerange", largerange)
69
 	fmt.Println("largerange", largerange)
71
 	sort := dataBody["sort"].(string)
70
 	sort := dataBody["sort"].(string)
71
+	sorts, err := strconv.ParseInt(sort, 10, 64)
72
 	fmt.Println("sort", sort)
72
 	fmt.Println("sort", sort)
73
 	standard := models.XtQualityControlStandard{
73
 	standard := models.XtQualityControlStandard{
74
 		InspectionMajor: inspectionmajor,
74
 		InspectionMajor: inspectionmajor,
75
 		InspectionMinor: inspectionMinor,
75
 		InspectionMinor: inspectionMinor,
76
 		MinRange:        minrange,
76
 		MinRange:        minrange,
77
 		LargeRange:      largerange,
77
 		LargeRange:      largerange,
78
-		Sort:            sort,
78
+		Sort:            sorts,
79
 		UserOrgId:       orgid,
79
 		UserOrgId:       orgid,
80
 		Status:          1,
80
 		Status:          1,
81
 		CreatedTime:     time.Now().Unix(),
81
 		CreatedTime:     time.Now().Unix(),
92
 }
92
 }
93
 
93
 
94
 func (this *CommonApiController) GetConfigurationlist() {
94
 func (this *CommonApiController) GetConfigurationlist() {
95
+	limit, _ := this.GetInt64("limit")
96
+	page, _ := this.GetInt64("page")
95
 	adminUser := this.GetAdminUserInfo()
97
 	adminUser := this.GetAdminUserInfo()
96
 	orgid := adminUser.CurrentOrgId
98
 	orgid := adminUser.CurrentOrgId
97
-	configurationlist, err := service.GetConfigurationlist(orgid)
99
+	configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
98
 	if err != nil {
100
 	if err != nil {
99
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
101
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
100
 		return
102
 		return
101
 	}
103
 	}
102
 	this.ServeSuccessJSON(map[string]interface{}{
104
 	this.ServeSuccessJSON(map[string]interface{}{
103
 		"configurationlist": configurationlist,
105
 		"configurationlist": configurationlist,
106
+		"total":             total,
107
+	})
108
+}
109
+
110
+func (this *CommonApiController) GetConfigurationDetail() {
111
+	id, _ := this.GetInt64("id")
112
+	fmt.Println("id是", id)
113
+	detail, err := service.GetConfigurationDetail(id)
114
+	if err != nil {
115
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
116
+		return
117
+	}
118
+	this.ServeSuccessJSON(map[string]interface{}{
119
+		"configurationdetail": detail,
120
+	})
121
+}
122
+
123
+func (this *CommonApiController) GetAllInspectionminor() {
124
+
125
+	minor, err := service.GetAllInspectionMinor(0)
126
+	if err != nil {
127
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
128
+		return
129
+	}
130
+	this.ServeSuccessJSON(map[string]interface{}{
131
+		"minor": minor,
132
+	})
133
+}
134
+
135
+func (this *CommonApiController) UpdateConfiguration() {
136
+	id, _ := this.GetInt64("id")
137
+	fmt.Println("id", id)
138
+	dataBody := make(map[string]interface{}, 0)
139
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
140
+	fmt.Println("err", err)
141
+	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
142
+	fmt.Println("大项", inspectionmajor)
143
+	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
144
+	fmt.Println("小项", inspectionMinor)
145
+	minrange := dataBody["min_range"].(string)
146
+	fmt.Println("minragne", minrange)
147
+	largerange := dataBody["large_range"].(string)
148
+	fmt.Println("largerange", largerange)
149
+	sort := int64(dataBody["sort"].(float64))
150
+
151
+	standard := models.XtQualityControlStandard{
152
+		InspectionMajor: inspectionmajor,
153
+		InspectionMinor: inspectionMinor,
154
+		MinRange:        minrange,
155
+		LargeRange:      largerange,
156
+		Sort:            sort,
157
+	}
158
+	err = service.UpdarteConfiguration(&standard, id)
159
+	if err != nil {
160
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
161
+		return
162
+	}
163
+	this.ServeSuccessJSON(map[string]interface{}{
164
+		"standard": standard,
165
+	})
166
+}
167
+
168
+func (this *CommonApiController) DeleteConfiguration() {
169
+	id, _ := this.GetInt64("id")
170
+	err := service.DeleteConfiguration(id)
171
+	if err != nil {
172
+		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
173
+		return
174
+	}
175
+	returnData := make(map[string]interface{}, 0)
176
+	returnData["msg"] = "ok"
177
+	this.ServeSuccessJSON(returnData)
178
+	return
179
+}
180
+
181
+func (this *CommonApiController) GetAllInspectiondata() {
182
+	adminUser := this.GetAdminUserInfo()
183
+	orgid := adminUser.CurrentOrgId
184
+
185
+	//查询该机构是否有数据
186
+	_, errcode := service.GetAllInspectionData(orgid)
187
+	if errcode == gorm.ErrRecordNotFound {
188
+		inspection, err := service.GetAllInspectiondatatwo(0)
189
+		if err != nil {
190
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
191
+			return
192
+		}
193
+		this.ServeSuccessJSON(map[string]interface{}{
194
+			"inspection": inspection,
195
+		})
196
+	} else if errcode == nil {
197
+		inspection, err := service.GetAllInspectiondatatwo(orgid)
198
+		if err != nil {
199
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
200
+			return
201
+		}
202
+		this.ServeSuccessJSON(map[string]interface{}{
203
+			"inspection": inspection,
204
+		})
205
+	}
206
+
207
+}
208
+
209
+func (this *CommonApiController) SaveCheckConfiguration() {
210
+	dataBody := make(map[string]interface{}, 0)
211
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
212
+	fmt.Println("err", err)
213
+	adminUser := this.GetAdminUserInfo()
214
+	orgid := adminUser.CurrentOrgId
215
+	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
216
+	fmt.Println("大项", inspectionmajor)
217
+	frequency := dataBody["frequency"].(string)
218
+	fmt.Println("凭次", frequency)
219
+	sort := dataBody["sort"].(string)
220
+	sorts, err := strconv.ParseInt(sort, 10, 64)
221
+	fmt.Println("sort", sort)
222
+	_, errcode := service.GetInspectionMajorById(inspectionmajor)
223
+	if errcode == gorm.ErrRecordNotFound {
224
+		configuration := models.XtCheckConfiguration{
225
+			InspectionMajor:     inspectionmajor,
226
+			InspectionFrequency: frequency,
227
+			Sort:                sorts,
228
+			UserOrgId:           orgid,
229
+			Status:              1,
230
+			CreatedTime:         time.Now().Unix(),
231
+		}
232
+		err := service.CreateCheckConfiguration(&configuration)
233
+		if err != nil {
234
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
235
+			return
236
+		}
237
+		this.ServeSuccessJSON(map[string]interface{}{
238
+			"configuration": configuration,
239
+		})
240
+	} else if errcode == nil {
241
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
242
+		return
243
+	}
244
+}
245
+
246
+func (this *CommonApiController) GetAllCheckList() {
247
+	adminUser := this.GetAdminUserInfo()
248
+	orgid := adminUser.CurrentOrgId
249
+	fmt.Println("org", orgid)
250
+	page, _ := this.GetInt64("page")
251
+	limit, _ := this.GetInt64("limit")
252
+	checkList, total, err := service.GetAllCheckList(orgid, page, limit)
253
+	if err != nil {
254
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
255
+		return
256
+	}
257
+	this.ServeSuccessJSON(map[string]interface{}{
258
+		"checklist": checkList,
259
+		"total":     total,
104
 	})
260
 	})
105
 }
261
 }
262
+
263
+func (this *CommonApiController) GetCheckdetail() {
264
+
265
+	id, _ := this.GetInt64("id")
266
+	detail, err := service.GetCheckDetail(id)
267
+	if err != nil {
268
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
269
+		return
270
+	}
271
+	this.ServeSuccessJSON(map[string]interface{}{
272
+		"checkdetail": detail,
273
+	})
274
+}
275
+
276
+func (this *CommonApiController) UpdateCheck() {
277
+	id, _ := this.GetInt64("id")
278
+	fmt.Println(id)
279
+	dataBody := make(map[string]interface{}, 0)
280
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
281
+	fmt.Println(err)
282
+	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
283
+	fmt.Println("大项", inspectionmajor)
284
+	frequency := dataBody["frequency"].(string)
285
+	fmt.Println("凭次", frequency)
286
+	sort := int64(dataBody["sort"].(float64))
287
+	fmt.Println("sort", sort)
288
+
289
+	Inspection, err := service.GetInspectionMajorById(inspectionmajor)
290
+	if Inspection.ID > 0 && Inspection.ID != id {
291
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
292
+		return
293
+	}
294
+
295
+	configuration := models.XtCheckConfiguration{
296
+		InspectionMajor:     inspectionmajor,
297
+		InspectionFrequency: frequency,
298
+		Sort:                sort,
299
+	}
300
+
301
+	err = service.UpdateCheck(&configuration, id)
302
+	if err != nil {
303
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
304
+		return
305
+	}
306
+	this.ServeSuccessJSON(map[string]interface{}{
307
+		"configuration": configuration,
308
+	})
309
+}
310
+
311
+func (this *CommonApiController) DeleteCheck() {
312
+	id, _ := this.GetInt64("id")
313
+	err := service.DeleteCheck(id)
314
+	if err != nil {
315
+		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
316
+		return
317
+	}
318
+	returnData := make(map[string]interface{}, 0)
319
+	returnData["msg"] = "ok"
320
+	this.ServeSuccessJSON(returnData)
321
+	return
322
+}

+ 10 - 0
controllers/new_mobile_api_controllers/common_api_router.go Прегледај датотеку

11
 	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
11
 	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
12
 	beego.Router("/com/api/saveconfiguration", &CommonApiController{}, "Post:SaveConfiguration")
12
 	beego.Router("/com/api/saveconfiguration", &CommonApiController{}, "Post:SaveConfiguration")
13
 	beego.Router("com/api/getconfigurationlist", &CommonApiController{}, "Get:GetConfigurationlist")
13
 	beego.Router("com/api/getconfigurationlist", &CommonApiController{}, "Get:GetConfigurationlist")
14
+	beego.Router("com/api/getconfigurationdetail", &CommonApiController{}, "Get:GetConfigurationDetail")
15
+	beego.Router("com/api/getallinspectionminor", &CommonApiController{}, "Get:GetAllInspectionminor")
16
+	beego.Router("com/api/updateconfiguration", &CommonApiController{}, "Post:UpdateConfiguration")
17
+	beego.Router("com/api/deleteconfiguration", &CommonApiController{}, "Delete:DeleteConfiguration")
18
+	beego.Router("com/api/getallinspectiondata", &CommonApiController{}, "Get:GetAllInspectiondata")
19
+	beego.Router("/com/api/savecheckconfiguration", &CommonApiController{}, "Post:SaveCheckConfiguration")
20
+	beego.Router("/com/api/getallchecklist", &CommonApiController{}, "Get:GetAllCheckList")
21
+	beego.Router("/com/api/getcheckdetail", &CommonApiController{}, "Get:GetCheckdetail")
22
+	beego.Router("/com/api/updatecheck", &CommonApiController{}, "Post:UpdateCheck")
23
+	beego.Router("/com/api/deletecheck", &CommonApiController{}, "Delete:DeleteCheck")
14
 }
24
 }

+ 7 - 1
controllers/patient_api_controller.go Прегледај датотеку

3560
 						service.CreateExportErrLog(&err_log)
3560
 						service.CreateExportErrLog(&err_log)
3561
 						continue
3561
 						continue
3562
 					}
3562
 					}
3563
+					//}
3563
 					patient.IdCardNo = id_card_no
3564
 					patient.IdCardNo = id_card_no
3564
 					//patient.Birthday = GetBirthDay(id_card_no).Unix()
3565
 					//patient.Birthday = GetBirthDay(id_card_no).Unix()
3565
 					if GetBirthDay(id_card_no) == nil {
3566
 					if GetBirthDay(id_card_no) == nil {
3873
 func IsIdCard(id string) (res bool) {
3874
 func IsIdCard(id string) (res bool) {
3874
 	id = strings.ToUpper(id)
3875
 	id = strings.ToUpper(id)
3875
 	if len(id) != 15 && len(id) != 18 {
3876
 	if len(id) != 15 && len(id) != 18 {
3877
+		fmt.Println("1111111")
3876
 		return false
3878
 		return false
3877
 	}
3879
 	}
3878
 	r := regexp.MustCompile("(\\d{15})|(\\d{17}([0-9]|X))")
3880
 	r := regexp.MustCompile("(\\d{15})|(\\d{17}([0-9]|X))")
3879
 	if !r.MatchString(id) {
3881
 	if !r.MatchString(id) {
3882
+		fmt.Println("222222")
3883
+
3880
 		return false
3884
 		return false
3881
 	}
3885
 	}
3882
 	if len(id) == 15 {
3886
 	if len(id) == 15 {
3883
 		tm2, _ := time.Parse("01/02/2006", string([]byte(id)[8:10])+"/"+string([]byte(id)[10:12])+"/"+"19"+string([]byte(id)[6:8]))
3887
 		tm2, _ := time.Parse("01/02/2006", string([]byte(id)[8:10])+"/"+string([]byte(id)[10:12])+"/"+"19"+string([]byte(id)[6:8]))
3884
-		if tm2.Unix() <= 0 {
3888
+		if tm2.Unix() == 0 {
3889
+			fmt.Println("44444443333")
3890
+
3885
 			return false
3891
 			return false
3886
 		}
3892
 		}
3887
 		return true
3893
 		return true

+ 112 - 30
controllers/schedule_api_controller.go Прегледај датотеку

715
 	utils.ErrorLog("%v", dataBody)
715
 	utils.ErrorLog("%v", dataBody)
716
 	export_time := time.Now().Unix()
716
 	export_time := time.Now().Unix()
717
 	var schedules []*models.Schedule
717
 	var schedules []*models.Schedule
718
+	var failed_total int
718
 	var total_schedule []interface{}
719
 	var total_schedule []interface{}
719
-
720
 	var patients []*models.Patients
720
 	var patients []*models.Patients
721
 
721
 
722
 	patients, _, _ = service.GetAllPatientList(this.GetAdminUserInfo().CurrentOrgId)
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
 	if dataBody["schedule"] != nil || reflect.TypeOf(dataBody["schedule"]).String() == "[]interface {}" {
730
 	if dataBody["schedule"] != nil || reflect.TypeOf(dataBody["schedule"]).String() == "[]interface {}" {
725
 		tempSchedule := dataBody["schedule"].([]interface{})
731
 		tempSchedule := dataBody["schedule"].([]interface{})
726
 		total_schedule = tempSchedule
732
 		total_schedule = tempSchedule
771
 				} else if len(patient) == 1 { //
777
 				} else if len(patient) == 1 { //
772
 					sch.PatientId = patient[0].ID
778
 					sch.PatientId = patient[0].ID
773
 
779
 
774
-				} else if len(patient) > 2 { //出现同名的情况
780
+				} else if len(patient) > 1 { //出现同名的情况
775
 
781
 
776
 					err_log := models.ExportErrLog{
782
 					err_log := models.ExportErrLog{
777
 						LogType:    2,
783
 						LogType:    2,
798
 				log := models.ExportLog{
804
 				log := models.ExportLog{
799
 					LogType:    2,
805
 					LogType:    2,
800
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
809
 					SuccessNum: int64(len(schedules)),
804
 					CreateTime: time.Now().Unix(),
810
 					CreateTime: time.Now().Unix(),
805
 					UpdateTime: time.Now().Unix(),
811
 					UpdateTime: time.Now().Unix(),
835
 				log := models.ExportLog{
841
 				log := models.ExportLog{
836
 					LogType:    2,
842
 					LogType:    2,
837
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
846
 					SuccessNum: int64(len(schedules)),
841
 					CreateTime: time.Now().Unix(),
847
 					CreateTime: time.Now().Unix(),
842
 					UpdateTime: time.Now().Unix(),
848
 					UpdateTime: time.Now().Unix(),
868
 					log := models.ExportLog{
874
 					log := models.ExportLog{
869
 						LogType:    2,
875
 						LogType:    2,
870
 						UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 						SuccessNum: int64(len(schedules)),
879
 						SuccessNum: int64(len(schedules)),
874
 						CreateTime: time.Now().Unix(),
880
 						CreateTime: time.Now().Unix(),
875
 						UpdateTime: time.Now().Unix(),
881
 						UpdateTime: time.Now().Unix(),
907
 				log := models.ExportLog{
913
 				log := models.ExportLog{
908
 					LogType:    2,
914
 					LogType:    2,
909
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
918
 					SuccessNum: int64(len(schedules)),
913
 					CreateTime: time.Now().Unix(),
919
 					CreateTime: time.Now().Unix(),
914
 					UpdateTime: time.Now().Unix(),
920
 					UpdateTime: time.Now().Unix(),
940
 						log := models.ExportLog{
946
 						log := models.ExportLog{
941
 							LogType:    2,
947
 							LogType:    2,
942
 							UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 							SuccessNum: int64(len(schedules)),
951
 							SuccessNum: int64(len(schedules)),
946
 							CreateTime: time.Now().Unix(),
952
 							CreateTime: time.Now().Unix(),
947
 							UpdateTime: time.Now().Unix(),
953
 							UpdateTime: time.Now().Unix(),
971
 						log := models.ExportLog{
977
 						log := models.ExportLog{
972
 							LogType:    2,
978
 							LogType:    2,
973
 							UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 							SuccessNum: int64(len(schedules)),
982
 							SuccessNum: int64(len(schedules)),
977
 							CreateTime: time.Now().Unix(),
983
 							CreateTime: time.Now().Unix(),
978
 							UpdateTime: time.Now().Unix(),
984
 							UpdateTime: time.Now().Unix(),
1008
 				log := models.ExportLog{
1014
 				log := models.ExportLog{
1009
 					LogType:    2,
1015
 					LogType:    2,
1010
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1019
 					SuccessNum: int64(len(schedules)),
1014
 					CreateTime: time.Now().Unix(),
1020
 					CreateTime: time.Now().Unix(),
1015
 					UpdateTime: time.Now().Unix(),
1021
 					UpdateTime: time.Now().Unix(),
1038
 				log := models.ExportLog{
1044
 				log := models.ExportLog{
1039
 					LogType:    2,
1045
 					LogType:    2,
1040
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1049
 					SuccessNum: int64(len(schedules)),
1044
 					CreateTime: time.Now().Unix(),
1050
 					CreateTime: time.Now().Unix(),
1045
 					UpdateTime: time.Now().Unix(),
1051
 					UpdateTime: time.Now().Unix(),
1078
 				log := models.ExportLog{
1084
 				log := models.ExportLog{
1079
 					LogType:    2,
1085
 					LogType:    2,
1080
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1089
 					SuccessNum: int64(len(schedules)),
1084
 					CreateTime: time.Now().Unix(),
1090
 					CreateTime: time.Now().Unix(),
1085
 					UpdateTime: time.Now().Unix(),
1091
 					UpdateTime: time.Now().Unix(),
1106
 				log := models.ExportLog{
1112
 				log := models.ExportLog{
1107
 					LogType:    2,
1113
 					LogType:    2,
1108
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1117
 					SuccessNum: int64(len(schedules)),
1112
 					CreateTime: time.Now().Unix(),
1118
 					CreateTime: time.Now().Unix(),
1113
 					UpdateTime: time.Now().Unix(),
1119
 					UpdateTime: time.Now().Unix(),
1157
 				log := models.ExportLog{
1163
 				log := models.ExportLog{
1158
 					LogType:    2,
1164
 					LogType:    2,
1159
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1168
 					SuccessNum: int64(len(schedules)),
1163
 					CreateTime: time.Now().Unix(),
1169
 					CreateTime: time.Now().Unix(),
1164
 					UpdateTime: time.Now().Unix(),
1170
 					UpdateTime: time.Now().Unix(),
1167
 				}
1173
 				}
1168
 				service.CreateExportLog(&log)
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
 				this.ServeSuccessJSON(map[string]interface{}{
1190
 				this.ServeSuccessJSON(map[string]interface{}{
1171
 					"msg":         "导入成功",
1191
 					"msg":         "导入成功",
1172
-					"total_num":   len(total_schedule),
1192
+					"total_num":   len(total_schedule) + failed_total,
1173
 					"success_num": len(schedules),
1193
 					"success_num": len(schedules),
1174
 					"fail_num":    int64(len(errLogs)),
1194
 					"fail_num":    int64(len(errLogs)),
1175
 				})
1195
 				})
1177
 				log := models.ExportLog{
1197
 				log := models.ExportLog{
1178
 					LogType:    2,
1198
 					LogType:    2,
1179
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 					SuccessNum: int64(len(schedules)),
1202
 					SuccessNum: int64(len(schedules)),
1183
 					CreateTime: time.Now().Unix(),
1203
 					CreateTime: time.Now().Unix(),
1184
 					UpdateTime: time.Now().Unix(),
1204
 					UpdateTime: time.Now().Unix(),
1187
 				}
1207
 				}
1188
 				service.CreateExportLog(&log)
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
 				this.ServeSuccessJSON(map[string]interface{}{
1224
 				this.ServeSuccessJSON(map[string]interface{}{
1191
 					"msg":         "导入成功",
1225
 					"msg":         "导入成功",
1192
 					"total_num":   len(total_schedule),
1226
 					"total_num":   len(total_schedule),
1198
 			log := models.ExportLog{
1232
 			log := models.ExportLog{
1199
 				LogType:    2,
1233
 				LogType:    2,
1200
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
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
 				SuccessNum: int64(len(schedules)),
1237
 				SuccessNum: int64(len(schedules)),
1204
 				CreateTime: time.Now().Unix(),
1238
 				CreateTime: time.Now().Unix(),
1205
 				UpdateTime: time.Now().Unix(),
1239
 				UpdateTime: time.Now().Unix(),
1208
 			}
1242
 			}
1209
 			service.CreateExportLog(&log)
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
 			this.ServeSuccessJSON(map[string]interface{}{
1259
 			this.ServeSuccessJSON(map[string]interface{}{
1212
 				"msg":         "导入成功",
1260
 				"msg":         "导入成功",
1213
 				"total_num":   len(total_schedule),
1261
 				"total_num":   len(total_schedule),
1283
 				} else if len(patient) == 1 { //
1331
 				} else if len(patient) == 1 { //
1284
 					sch.PatientID = patient[0].ID
1332
 					sch.PatientID = patient[0].ID
1285
 
1333
 
1286
-				} else if len(patient) > 2 { //出现同名的情况
1334
+				} else if len(patient) > 1 { //出现同名的情况
1287
 
1335
 
1288
 					err_log := models.ExportErrLog{
1336
 					err_log := models.ExportErrLog{
1289
 						LogType:    3,
1337
 						LogType:    3,
1645
 	})
1693
 	})
1646
 	return
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
+}

+ 29 - 2
models/common_models.go Прегледај датотеку

5
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
5
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
6
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
6
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
7
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
7
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
8
-	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
8
+	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
9
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
9
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
10
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
10
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
11
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
11
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
21
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
21
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
22
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
22
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
23
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
23
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
24
-	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
24
+	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
25
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
25
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
26
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
26
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
27
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
27
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
32
 func (XtQualityControlStandard) TableName() string {
32
 func (XtQualityControlStandard) TableName() string {
33
 	return "xt_quality_control_standard"
33
 	return "xt_quality_control_standard"
34
 }
34
 }
35
+
36
+type CheckConfiguration struct {
37
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
38
+	InspectionMajor     int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
39
+	InspectionFrequency string `gorm:"column:inspection_frequency" json:"inspection_frequency" form:"inspection_frequency"`
40
+	Sort                int64  `gorm:"column:sort" json:"sort" form:"sort"`
41
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
42
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
43
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
44
+	UpdatedTime         int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
45
+	ProjectName         string `gorm:"column:project_name" json:"project_name" form:"project_name"`
46
+}
47
+
48
+type XtCheckConfiguration struct {
49
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
50
+	InspectionMajor     int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
51
+	InspectionFrequency string `gorm:"column:inspection_frequency" json:"inspection_frequency" form:"inspection_frequency"`
52
+	Sort                int64  `gorm:"column:sort" json:"sort" form:"sort"`
53
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
54
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
55
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
56
+	UpdatedTime         int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
57
+}
58
+
59
+func (XtCheckConfiguration) TableName() string {
60
+	return "xt_check_configuration"
61
+}

+ 98 - 6
service/common_service.go Прегледај датотеку

3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
 	"fmt"
5
 	"fmt"
6
+	"github.com/jinzhu/gorm"
7
+	"time"
6
 )
8
 )
7
 
9
 
8
 func GetInspectionMajor(orgid int64) (inspection []*models.XtInspectionReference, err error) {
10
 func GetInspectionMajor(orgid int64) (inspection []*models.XtInspectionReference, err error) {
29
 	return err
31
 	return err
30
 }
32
 }
31
 
33
 
32
-func GetConfigurationlist(orgid int64) (standard []*models.QualityControlStandard, err error) {
33
-
34
-	//err = XTReadDB().Model(&standard).Where("user_org_id = ? and status =1", orgid).Order("sort asc,created_time desc").Find(&standard).Error
35
-	//return standard,err
34
+func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*models.QualityControlStandard, total int64, err error) {
36
 
35
 
37
 	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
36
 	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
38
 	if orgid > 0 {
37
 	if orgid > 0 {
40
 	}
39
 	}
41
 	table := XTReadDB().Table("xt_inspection_reference as s")
40
 	table := XTReadDB().Table("xt_inspection_reference as s")
42
 	fmt.Println(table)
41
 	fmt.Println(table)
43
-	err = db.Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").
44
-		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Order("x.sort asc,x.created_time desc").Scan(&standard).Error
42
+	offset := (page - 1) * limit
43
+	err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").Count(&total).
44
+		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
45
+	return standard, total, err
46
+}
47
+
48
+func GetConfigurationDetail(id int64) (models.XtQualityControlStandard, error) {
49
+	standard := models.XtQualityControlStandard{}
50
+	err := XTReadDB().Model(&standard).Where("id=? and status = 1", id).Find(&standard).Error
51
+	return standard, err
52
+}
53
+
54
+func GetAllInspectionMinor(orgid int64) (standard []*models.XtInspectionReference, err error) {
55
+
56
+	err = XTReadDB().Model(&standard).Where("org_id = ? and status = 1", orgid).Find(&standard).Error
45
 	return standard, err
57
 	return standard, err
46
 }
58
 }
59
+
60
+func UpdarteConfiguration(st *models.XtQualityControlStandard, id int64) error {
61
+
62
+	err := XTWriteDB().Model(&st).Where("id = ?", id).Updates(map[string]interface{}{"inspection_major": st.InspectionMajor, "inspection_minor": st.InspectionMinor, "min_range": st.MinRange, "large_range": st.LargeRange, "sort": st.Sort, "updated_time": time.Now().Unix()}).Error
63
+	return err
64
+}
65
+
66
+func DeleteConfiguration(id int64) (err error) {
67
+
68
+	err = XTWriteDB().Model(models.XtQualityControlStandard{}).Where("id=?", id).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
69
+	return err
70
+}
71
+
72
+func GetAllInspectionData(orgid int64) (*models.XtInspectionReference, error) {
73
+	diseases := models.XtInspectionReference{}
74
+	err := XTReadDB().Model(&diseases).Where("org_id = ? and status = 1", orgid).Find(&diseases).Error
75
+	if err == gorm.ErrRecordNotFound {
76
+		return nil, err
77
+	}
78
+	if err != nil {
79
+		return nil, err
80
+	}
81
+	return &diseases, nil
82
+}
83
+
84
+func GetAllInspectiondatatwo(orgid int64) (reference []*models.XtInspectionReference, err error) {
85
+
86
+	err = XTReadDB().Model(&reference).Where("org_id = ? and status = 1", orgid).Group("project_name").Find(&reference).Error
87
+	return reference, err
88
+}
89
+
90
+func GetInspectionMajorById(marjor int64) (*models.XtCheckConfiguration, error) {
91
+	configuration := models.XtCheckConfiguration{}
92
+	err := XTReadDB().Model(&configuration).Where("inspection_major = ? and status =1", marjor).Find(&configuration).Error
93
+	if err == gorm.ErrRecordNotFound {
94
+		return nil, err
95
+	}
96
+	if err != nil {
97
+		return nil, err
98
+	}
99
+	return &configuration, nil
100
+}
101
+
102
+func CreateCheckConfiguration(configuration *models.XtCheckConfiguration) error {
103
+	err := XTWriteDB().Create(&configuration).Error
104
+	return err
105
+}
106
+
107
+func GetAllCheckList(orgid int64, page int64, limit int64) (check []*models.CheckConfiguration, total int64, err error) {
108
+
109
+	db := XTReadDB().Table("xt_check_configuration as x").Where("x.status =1")
110
+	table := XTReadDB().Table("xt_inspection_reference as r")
111
+	fmt.Println(table)
112
+	if orgid > 0 {
113
+		db = db.Where("x.user_org_id = ?", orgid)
114
+	}
115
+	offset := (page - 1) * limit
116
+	err = db.Group("x.id").Order("x.sort asc,x.created_time desc").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,r.project_name").Count(&total).
117
+		Joins("left join xt_inspection_reference as r on r.project_id = x.inspection_major").Offset(offset).Limit(limit).Scan(&check).Error
118
+	return check, total, err
119
+}
120
+
121
+func GetCheckDetail(id int64) (models.XtCheckConfiguration, error) {
122
+
123
+	configuration := models.XtCheckConfiguration{}
124
+	err := XTReadDB().Model(&configuration).Where("id=? and status =1", id).Find(&configuration).Error
125
+	return configuration, err
126
+}
127
+
128
+func UpdateCheck(con *models.XtCheckConfiguration, id int64) error {
129
+
130
+	err := XTWriteDB().Model(&con).Where("id=?", id).Updates(map[string]interface{}{"inspection_major": con.InspectionMajor, "inspection_frequency": con.InspectionFrequency, "sort": con.Sort, "updated_time": time.Now().Unix()}).Error
131
+	return err
132
+}
133
+
134
+func DeleteCheck(id int64) error {
135
+
136
+	err := XTWriteDB().Model(models.XtCheckConfiguration{}).Where("id=?", id).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
137
+	return err
138
+}

+ 4 - 3
service/dialysis_service.go Прегледај датотеку

884
 	return err
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
 	ut := writeDb.Begin()
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
 	if err != nil {
891
 	if err != nil {
892
 		ut.Rollback()
892
 		ut.Rollback()
893
 		return
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
 	if err != nil {
897
 	if err != nil {
897
 		ut.Rollback()
898
 		ut.Rollback()
898
 		return
899
 		return

+ 1 - 1
service/gobal_config_service.go Прегледај датотеку

160
 
160
 
161
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
161
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
162
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
162
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
163
-		Preload("ExportErrLog", "status = 1").Find(&log).Error
163
+		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error
164
 	return
164
 	return
165
 }
165
 }

+ 26 - 0
service/patient_service.go Прегледај датотеку

1267
 			return
1267
 			return
1268
 		}
1268
 		}
1269
 	}
1269
 	}
1270
+	patientsNew := models.XtPatientsNew{
1271
+		Name:              patient.Name,
1272
+		Gender:            patient.Gender,
1273
+		Phone:             patient.Phone,
1274
+		IdCardNo:          patient.IdCardNo,
1275
+		FirstDialysisDate: patient.FirstDialysisDate,
1276
+		Source:            patient.Source,
1277
+		Lapseto:           patient.Lapseto,
1278
+		IsInfectious:      patient.IsInfectious,
1279
+		DialysisNo:        patient.DialysisNo,
1280
+		Height:            patient.Height,
1281
+		HomeAddress:       patient.HomeAddress,
1282
+		IsExcelExport:     1,
1283
+		BloodPatients:     1,
1284
+		Status:            1,
1285
+		CreatedTime:       time.Now().Unix(),
1286
+		UserOrgId:         patient.UserOrgId,
1287
+		BloodId:           patient.ID,
1288
+		Avatar:            "https://images.shengws.com/201809182128111.png",
1289
+	}
1290
+	err = utx.Create(&patientsNew).Error
1291
+	if err != nil {
1292
+		utx.Rollback()
1293
+		btx.Rollback()
1294
+		return
1295
+	}
1270
 	utx.Commit()
1296
 	utx.Commit()
1271
 	btx.Commit()
1297
 	btx.Commit()
1272
 
1298
 

+ 1 - 1
service/schedule_service.go Прегледај датотеку

356
 }
356
 }
357
 
357
 
358
 func UpdateScheduleStatus(date int64, org_id int64) (err error) {
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
 	return
360
 	return
361
 }
361
 }
362
 
362