Browse Source

消毒计划

XMLWAN 4 years ago
parent
commit
d94f62feb0

+ 3 - 3
controllers/new_mobile_api_controllers/new_manage_api_controller.go View File

@@ -42,7 +42,7 @@ func (this *NewManageApiController) GetDisInfectionTime() {
42 42
 	//根据床位号获取设备型号
43 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 46
 	fmt.Println("infomation========", infomation)
47 47
 	fmt.Println("err-------", err)
48 48
 	if err == gorm.ErrRecordNotFound {
@@ -50,7 +50,7 @@ func (this *NewManageApiController) GetDisInfectionTime() {
50 50
 		plan, errcode := service.GetDisInfectionTime(orgid, unitType.UnitType, scheduletype, scheduleweek)
51 51
 		//如果没有消毒计划,去查询该设备的上次消毒时间
52 52
 		if errcode == gorm.ErrRecordNotFound {
53
-			infor, errco := service.GetLaseDeviceInfomationTwo(orgid, bedid)
53
+			infor, errco := service.GetLaseDeviceInfomationTwo(orgid, bedid, scheduletype)
54 54
 			if errco != nil {
55 55
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
56 56
 				return
@@ -202,7 +202,7 @@ func (this *NewManageApiController) SaveDisInfectionInfo() {
202 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 206
 			if errcode != nil {
207 207
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
208 208
 				return

+ 6 - 6
service/manage_service.go View File

@@ -1157,10 +1157,10 @@ func GetUnitType(bedid int64, orgid int64) (models.DeviceAddmacher, error) {
1157 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 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 1164
 	if err == gorm.ErrRecordNotFound {
1165 1165
 		return nil, err
1166 1166
 	}
@@ -1170,9 +1170,9 @@ func GetLaseDeviceInfomation(orgid int64, bedid int64, date int64) (*models.Devi
1170 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 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 1176
 	return information, err
1177 1177
 }
1178 1178
 
@@ -1225,8 +1225,8 @@ func CreateInformationTwo(information *models.DeviceInformation) error {
1225 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 1231
 	return err
1232 1232
 }