浏览代码

历史排班

28169 1年前
父节点
当前提交
92b1c03410
共有 2 个文件被更改,包括 50 次插入45 次删除
  1. 41 45
      controllers/schedule_api_controller.go
  2. 9 0
      service/dialysis_service.go

+ 41 - 45
controllers/schedule_api_controller.go 查看文件

@@ -103,7 +103,7 @@ func (c *ScheduleApiController) CoverSch() {
103 103
 	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
104 104
 	//	return
105 105
 	//}
106
-	order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
106
+	order, _ := service.GetOneDialysisOrderOne(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
107 107
 	if order.ID > 0 {
108 108
 
109 109
 		service.UpdateDialysiOrderByPatientId(id_two, sch_two.ScheduleType, sch_two.PartitionId, sch_two.BedId)
@@ -188,7 +188,7 @@ func (c *ScheduleApiController) ExchangeSch() {
188 188
 
189 189
 	err := service.UpdateScheduleThree(sch, sch_two)
190 190
 
191
-	order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
191
+	order, _ := service.GetOneDialysisOrderOne(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
192 192
 	if order.ID > 0 {
193 193
 		//查询该患者的排班机位
194 194
 		pSchedule, _ := service.GetPscheduleDate(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
@@ -1679,15 +1679,16 @@ func (c *ScheduleApiController) CreateScheduleTwo() {
1679 1679
 	tm := time.Unix(int64(schedule_two.ScheduleDate), 0)
1680 1680
 	timeStr := tm.Format(timeTemplate)
1681 1681
 	if timeNow > timeStr {
1682
+		fmt.Println("寄哪里地方")
1682 1683
 		utils.ErrorLog(timeNow)
1683 1684
 		utils.ErrorLog(timeStr)
1684 1685
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
1685 1686
 		return
1686 1687
 	}
1687
-	if schedule_two == nil {
1688
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
1689
-		return
1690
-	}
1688
+	//if schedule_two == nil {
1689
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
1690
+	//	return
1691
+	//}
1691 1692
 
1692 1693
 	//order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule_two.ScheduleDate, schedule_two.PatientId)
1693 1694
 	//if err != nil {
@@ -1896,57 +1897,52 @@ func (c *ScheduleApiController) CreateScheduleTwo() {
1896 1897
 	lastSchedule, _ := service.GetLastSchedule(patientID, adminUserInfo.CurrentOrgId)
1897 1898
 
1898 1899
 	//查询上机床位号 更改床位号
1899
-	order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule_two.ScheduleDate, schedule_two.PatientId)
1900
-
1900
+	order, err := service.GetOneDialysisOrderOne(adminINfo.CurrentOrgId, schedule_two.ScheduleDate, schedule_two.PatientId)
1901
+	fmt.Println("errw222222222222222222", order.ID)
1901 1902
 	if order.ID > 0 {
1902 1903
 		service.UpdateDialysiOrderByPatientId(order.ID, schedule.ScheduleType, schedule.PartitionId, order.BedID)
1903 1904
 		redis := service.RedisClient()
1904
-		key := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_order"
1905
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_order"
1905 1906
 		redis.Set(key, "", time.Second)
1906
-		keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
1907
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
1907 1908
 
1908 1909
 		//清空key 值
1909 1910
 		redis.Set(keyOne, "", time.Second)
1910 1911
 
1911 1912
 	}
1912 1913
 
1913
-	if err == nil {
1914
-		redis := service.RedisClient()
1915
-		key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1916
-		redis.Set(key, "", time.Second)
1917
-		//处方
1918
-		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
1919
-		redis.Set(keyOne, "", time.Second)
1920
-		//医嘱
1921
-		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
1922
-		redis.Set(keyTwo, "", time.Second)
1923
-		keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
1924
-		redis.Set(keySix, "", time.Second)
1925
-		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
1926
-		redis.Set(keyThree, "", time.Second)
1927
-		keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
1928
-		redis.Set(keyFour, "", time.Second)
1929
-		keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
1930
-		redis.Set(keyFive, "", time.Second)
1931
-		keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
1932
-		redis.Set(keySeven, "", time.Second)
1933
-		defer redis.Close()
1934
-		schedule.Patient = patientInfo.Name
1914
+	redis := service.RedisClient()
1915
+	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1916
+	redis.Set(key, "", time.Second)
1917
+	//处方
1918
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
1919
+	redis.Set(keyOne, "", time.Second)
1920
+	//医嘱
1921
+	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
1922
+	redis.Set(keyTwo, "", time.Second)
1923
+	keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
1924
+	redis.Set(keySix, "", time.Second)
1925
+	keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
1926
+	redis.Set(keyThree, "", time.Second)
1927
+	keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
1928
+	redis.Set(keyFour, "", time.Second)
1929
+	keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
1930
+	redis.Set(keyFive, "", time.Second)
1931
+	keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
1932
+	redis.Set(keySeven, "", time.Second)
1933
+	defer redis.Close()
1934
+	schedule.Patient = patientInfo.Name
1935 1935
 
1936
-		//去除当天患者排班中重复数据,保留最后一条数据
1937
-		service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
1936
+	//去除当天患者排班中重复数据,保留最后一条数据
1937
+	service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
1938 1938
 
1939
-		c.ServeSuccessJSON(map[string]interface{}{
1940
-			"msg":          "ok",
1941
-			"schedule":     schedule,
1942
-			"schedule_two": schedule_two,
1943
-			"lastSchedule": lastSchedule,
1944
-		})
1945
-		return
1946
-	} else {
1947
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
1948
-		return
1949
-	}
1939
+	c.ServeSuccessJSON(map[string]interface{}{
1940
+		"msg":          "ok",
1941
+		"schedule":     schedule,
1942
+		"schedule_two": schedule_two,
1943
+		"lastSchedule": lastSchedule,
1944
+	})
1945
+	return
1950 1946
 
1951 1947
 }
1952 1948
 

+ 9 - 0
service/dialysis_service.go 查看文件

@@ -1066,6 +1066,15 @@ func GetOneDialysisOrder(orgID, orderData int64, patient_id int64) (*models.Dial
1066 1066
 	return &order, nil
1067 1067
 }
1068 1068
 
1069
+func GetOneDialysisOrderOne(orgID, orderData int64, patient_id int64) (models.DialysisOrder, error) {
1070
+
1071
+	order := models.DialysisOrder{}
1072
+
1073
+	err := readDb.Where("user_org_id=? and dialysis_date=? and status=1 and patient_id = ?", orgID, orderData, patient_id).Find(&order).Error
1074
+
1075
+	return order, err
1076
+}
1077
+
1069 1078
 func GetPscheduleDate(schedule_date int64, patient_id int64, user_org_id int64) (models.XtSchedule, error) {
1070 1079
 
1071 1080
 	schedule := models.XtSchedule{}