Browse Source

修改redis清除数据时间

csx 4 years ago
parent
commit
47847067c6

+ 29 - 0
controllers/dialysis_api_controller.go View File

@@ -56,6 +56,8 @@ func DialysisApiRegistRouters() {
56 56
 
57 57
 	beego.Router("/api/func_per/get", &DialysisApiController{}, "Get:GetFuncPurview")
58 58
 
59
+	beego.Router("/api/doctoradvice/get", &DialysisApiController{}, "Get:GetLastOrNextDoctorAdvice")
60
+
59 61
 }
60 62
 
61 63
 func (c *DialysisApiController) PostPrescription() {
@@ -5107,3 +5109,30 @@ func (this *DialysisApiController) GetFuncPurview() {
5107 5109
 		})
5108 5110
 	}
5109 5111
 }
5112
+
5113
+func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
5114
+	change_type, _ := this.GetInt64("type", 0)
5115
+	record_date := this.GetString("record_time")
5116
+	patient_id, _ := this.GetInt64("patient_id", 0)
5117
+
5118
+	timeLayout := "2006-01-02"
5119
+	loc, _ := time.LoadLocation("Local")
5120
+	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5121
+	record_time := theAdviceRecordTime.Unix()
5122
+	adminUserInfo := this.GetAdminUserInfo()
5123
+	advices, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
5124
+	if err == nil {
5125
+		if len(advices) == 0 {
5126
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
5127
+			return
5128
+		} else {
5129
+			this.ServeSuccessJSON(map[string]interface{}{
5130
+				"advices": advices,
5131
+			})
5132
+			return
5133
+		}
5134
+	} else {
5135
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
5136
+		return
5137
+	}
5138
+}

+ 0 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2856,7 +2856,6 @@ func (this *DialysisAPIController) StartDialysis() {
2856 2856
 				} else {
2857 2857
 
2858 2858
 					if prescription.Niprocart > 0 {
2859
-
2860 2859
 						warehouseOutInfo := &models.WarehouseOutInfo{
2861 2860
 							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
2862 2861
 							WarehouseOutId:          warehouseOut.ID,

+ 4 - 0
enums/error_code.go View File

@@ -200,6 +200,8 @@ const ( // ErrorCode
200 200
 	ErrorCodeExportError = 20050
201 201
 
202 202
 	ErrorCodeOrgNoPatient = 20051
203
+
204
+	ErrorCodeDoctorAdviceEmpty = 20052
203 205
 )
204 206
 
205 207
 var ErrCodeMsgs = map[int]string{
@@ -397,6 +399,8 @@ var ErrCodeMsgs = map[int]string{
397 399
 	ErrorCodeExportError: "导入出错,请下载并查看相关日志",
398 400
 
399 401
 	ErrorCodeOrgNoPatient: "暂无病人",
402
+
403
+	ErrorCodeDoctorAdviceEmpty: "没有更多了",
400 404
 }
401 405
 
402 406
 type SGJError struct {

+ 19 - 0
service/doctor_advice_service.go View File

@@ -270,3 +270,22 @@ func UpdateDataTwo(id int64, model models.ConfigViewModel) error {
270 270
 	err := writeDb.Model(&model).Where("id=?", id).Update(map[string]interface{}{"name": model.Name, "orders": model.Order, "remark": model.Remark, "update_time": time.Now().Unix()}).Error
271 271
 	return err
272 272
 }
273
+
274
+type AdviceDate struct {
275
+	RecordDate int64
276
+}
277
+
278
+func GetDoctorAdviceByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
279
+	if change_type == 1 { //根据日期取出上一方数据
280
+
281
+		var Id AdviceDate
282
+		err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
283
+		err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).Find(&advice).Error
284
+
285
+	} else if change_type == 2 {
286
+		var Id AdviceDate
287
+		err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
288
+		err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).Find(&advice).Error
289
+	}
290
+	return
291
+}