Kaynağa Gözat

消毒计划

XMLWAN 4 yıl önce
ebeveyn
işleme
d94f62feb0

+ 3 - 3
controllers/new_mobile_api_controllers/new_manage_api_controller.go Dosyayı Görüntüle

42
 	//根据床位号获取设备型号
42
 	//根据床位号获取设备型号
43
 	unitType, _ := service.GetUnitType(bedid, orgid)
43
 	unitType, _ := service.GetUnitType(bedid, orgid)
44
 	//查询使用登记最后一条消毒记录
44
 	//查询使用登记最后一条消毒记录
45
-	infomation, err := service.GetLaseDeviceInfomation(orgid, bedid, scheduledate)
45
+	infomation, err := service.GetLaseDeviceInfomation(orgid, bedid, scheduledate, scheduletype)
46
 	fmt.Println("infomation========", infomation)
46
 	fmt.Println("infomation========", infomation)
47
 	fmt.Println("err-------", err)
47
 	fmt.Println("err-------", err)
48
 	if err == gorm.ErrRecordNotFound {
48
 	if err == gorm.ErrRecordNotFound {
50
 		plan, errcode := service.GetDisInfectionTime(orgid, unitType.UnitType, scheduletype, scheduleweek)
50
 		plan, errcode := service.GetDisInfectionTime(orgid, unitType.UnitType, scheduletype, scheduleweek)
51
 		//如果没有消毒计划,去查询该设备的上次消毒时间
51
 		//如果没有消毒计划,去查询该设备的上次消毒时间
52
 		if errcode == gorm.ErrRecordNotFound {
52
 		if errcode == gorm.ErrRecordNotFound {
53
-			infor, errco := service.GetLaseDeviceInfomationTwo(orgid, bedid)
53
+			infor, errco := service.GetLaseDeviceInfomationTwo(orgid, bedid, scheduletype)
54
 			if errco != nil {
54
 			if errco != nil {
55
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
55
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
56
 				return
56
 				return
202
 				LongTime:         strconv.FormatInt(disinfectime, 10),
202
 				LongTime:         strconv.FormatInt(disinfectime, 10),
203
 			}
203
 			}
204
 
204
 
205
-			errcode := service.UpdateInformation(&information, scheduledate, bedid)
205
+			errcode := service.UpdateInformation(&information, scheduledate, bedid, scheduletype)
206
 			if errcode != nil {
206
 			if errcode != nil {
207
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
207
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
208
 				return
208
 				return

+ 6 - 6
service/manage_service.go Dosyayı Görüntüle

1157
 	return addmacher, err
1157
 	return addmacher, err
1158
 }
1158
 }
1159
 
1159
 
1160
-func GetLaseDeviceInfomation(orgid int64, bedid int64, date int64) (*models.DeviceInformation, error) {
1160
+func GetLaseDeviceInfomation(orgid int64, bedid int64, date int64, scheduletype int64) (*models.DeviceInformation, error) {
1161
 
1161
 
1162
 	information := models.DeviceInformation{}
1162
 	information := models.DeviceInformation{}
1163
-	err := UserReadDB().Model(&information).Where("bed_number = ? and user_org_id =? and status = 1 and date = ?", bedid, orgid, date).Find(&information).Error
1163
+	err := UserReadDB().Model(&information).Where("bed_number = ? and user_org_id =? and status = 1 and date = ? and class = ? ", bedid, orgid, date, scheduletype).Find(&information).Error
1164
 	if err == gorm.ErrRecordNotFound {
1164
 	if err == gorm.ErrRecordNotFound {
1165
 		return nil, err
1165
 		return nil, err
1166
 	}
1166
 	}
1170
 	return &information, nil
1170
 	return &information, nil
1171
 }
1171
 }
1172
 
1172
 
1173
-func GetLaseDeviceInfomationTwo(orgid int64, bedid int64) (models.DeviceInformation, error) {
1173
+func GetLaseDeviceInfomationTwo(orgid int64, bedid int64, scheduletype int64) (models.DeviceInformation, error) {
1174
 	information := models.DeviceInformation{}
1174
 	information := models.DeviceInformation{}
1175
-	err = UserReadDB().Model(&information).Where("bed_number= ? and user_org_id = ? and status = 1", bedid, orgid).Last(&information).Error
1175
+	err = UserReadDB().Model(&information).Where("bed_number= ? and user_org_id = ? and status = 1 and class = ?", bedid, orgid, scheduletype).Last(&information).Error
1176
 	return information, err
1176
 	return information, err
1177
 }
1177
 }
1178
 
1178
 
1225
 	return err
1225
 	return err
1226
 }
1226
 }
1227
 
1227
 
1228
-func UpdateInformation(information *models.DeviceInformation, scheduledate int64, bedid int64) error {
1228
+func UpdateInformation(information *models.DeviceInformation, scheduledate int64, bedid int64, scheduletype int64) error {
1229
 
1229
 
1230
-	err := UserWriteDB().Model(&information).Where("date = ? and bed_number = ?", scheduledate, bedid).Updates(map[string]interface{}{"long_time": information.LongTime, "disinfec_startime": information.DisinfecStartime, "disinfec_endtime": information.DisinfecEndtime}).Error
1230
+	err := UserWriteDB().Model(&information).Where("date = ? and bed_number = ? and class = ?", scheduledate, bedid, scheduletype).Updates(map[string]interface{}{"long_time": information.LongTime, "disinfec_startime": information.DisinfecStartime, "disinfec_endtime": information.DisinfecEndtime}).Error
1231
 	return err
1231
 	return err
1232
 }
1232
 }