Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
0048eb2baa

+ 2 - 2
conf/app.conf View File

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2
-httpport = 9529
3
-runmode =dev
2
+httpport = 9531
3
+runmode =prod
4 4
 #dev/prod
5 5
 
6 6
 #

+ 29 - 15
controllers/dialysis_api_controller.go View File

@@ -4271,24 +4271,38 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4271 4271
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4272 4272
 
4273 4273
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4274
-
4275
-	list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4276
-
4277 4274
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4278
-	goodType, err := service.GetAllGoodType(orgId)
4279
-	if err == nil {
4280
-		this.ServeSuccessJSON(map[string]interface{}{
4281
-			"list":     list,
4282
-			"total":    total,
4283
-			"config":   config,
4284
-			"goodType": goodType,
4285
-		})
4286
-		return
4275
+	goodType, _ := service.GetAllGoodType(orgId)
4276
+	if config.IsOpen == 0 {
4277
+		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4278
+		if err == nil {
4279
+			this.ServeSuccessJSON(map[string]interface{}{
4280
+				"list":     list,
4281
+				"total":    total,
4282
+				"config":   config,
4283
+				"goodType": goodType,
4284
+			})
4285
+			return
4287 4286
 
4288
-	} else {
4289
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4290
-		return
4287
+		} else {
4288
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4289
+			return
4290
+		}
4291 4291
 	}
4292
+	if config.IsOpen == 1 {
4293
+		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4294
+		if err == nil {
4295
+			this.ServeSuccessJSON(map[string]interface{}{
4296
+				"list":     list,
4297
+				"total":    total,
4298
+				"config":   config,
4299
+				"goodType": goodType,
4300
+			})
4301
+			return
4302
+		}
4303
+
4304
+	}
4305
+
4292 4306
 }
4293 4307
 
4294 4308
 func (this *DialysisApiController) GetDialysisAdviceTemplateList() {

+ 16 - 16
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1228,22 +1228,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1228 1228
 						}
1229 1229
 					}
1230 1230
 
1231
-					//if config.IsOpen == 1 && item.UserOrgId == 10318 {
1232
-					//
1233
-					//  service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1234
-					//  //更新字典里面的库存
1235
-					//  stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1236
-					//  var sum_count int64
1237
-					//  for _, its := range stockInfo {
1238
-					//    if its.MaxUnit == medical.MaxUnit {
1239
-					//      its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1240
-					//    }
1241
-					//    sum_count += its.StockMaxNumber + its.StockMinNumber
1242
-					//  }
1243
-					//  service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1244
-					//  //剩余库存
1245
-					//  service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1246
-					//}
1231
+					if config.IsOpen == 1 && item.UserOrgId == 10318 {
1232
+
1233
+						service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1234
+						//更新字典里面的库存
1235
+						stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1236
+						var sum_count int64
1237
+						for _, its := range stockInfo {
1238
+							if its.MaxUnit == medical.MaxUnit {
1239
+								its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1240
+							}
1241
+							sum_count += its.StockMaxNumber + its.StockMinNumber
1242
+						}
1243
+						service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1244
+						//剩余库存
1245
+						service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1246
+					}
1247 1247
 
1248 1248
 				}
1249 1249
 			}

+ 1 - 0
models/good_models.go View File

@@ -15,6 +15,7 @@ type GoodsType struct {
15 15
 	Number         int64  `gorm:"column:number" json:"number"`
16 16
 	OutStock       int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
17 17
 	StockAttribute int64  `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
18
+	IsOpen         int64  `gorm:"column:is_open" json:"is_open" form:"is_open"`
18 19
 }
19 20
 
20 21
 func (GoodsType) TableName() string {

+ 23 - 0
models/schedule_models.go View File

@@ -349,3 +349,26 @@ type NewMSchedualPatientVMList struct {
349 349
 func (NewMSchedualPatientVMList) TableName() string {
350 350
 	return "xt_patients"
351 351
 }
352
+
353
+type VmBloodScheduleTwo struct {
354
+	ID                          int64                       `gorm:"column:id" json:"id" form:"id"`
355
+	UserOrgId                   int64                       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
356
+	PartitionId                 int64                       `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
357
+	BedId                       int64                       `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
358
+	PatientId                   int64                       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
359
+	ScheduleDate                int64                       `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
360
+	ScheduleType                int64                       `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
361
+	ScheduleWeek                int64                       `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
362
+	ModeId                      int64                       `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
363
+	Status                      int64                       `gorm:"column:status" json:"status" form:"status"`
364
+	CreatedTime                 int64                       `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
+	UpdatedTime                 int64                       `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
+	IsExport                    int64                       `gorm:"column:is_export" json:"is_export" form:"is_export"`
367
+	DeviceNumber                *NewMDeviceNumberVM         `gorm:"ForeignKey:BedId" json:"device_number"`
368
+	SchedualPatient             *NewMSchedualPatientVMList  `gorm:"ForeignKey:PatientId" json:"patient"`
369
+	HisPrescriptionInfoTemplate HisPrescriptionInfoTemplate `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
370
+}
371
+
372
+func (VmBloodScheduleTwo) TableName() string {
373
+	return "xt_schedule"
374
+}

+ 47 - 1
service/dialysis_solution_service.go View File

@@ -266,6 +266,52 @@ func GetDialysisParameterGoodList(orgID int64, schedule_type int64, partition_id
266 266
 func SaveHisDialysis(orgid int64, ids []string) error {
267 267
 
268 268
 	goodsType := models.BloodGoodsType{}
269
-	err := XTWriteDB().Where("org_id = ? and status = 1 and id in(?)", orgid, ids).Update(map[string]interface{}{"is_open": goodsType.IsOpen}).Error
269
+	err := XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 1}).Error
270
+
271
+	err = XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id not in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 0}).Error
270 272
 	return err
271 273
 }
274
+
275
+func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
276
+
277
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
278
+	offset := (page - 1) * limit
279
+	if scheduleDate > 0 {
280
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
281
+	}
282
+	if schedule_type > 0 {
283
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
284
+	}
285
+	if partition_id > 0 {
286
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
287
+	}
288
+	if orgID > 0 {
289
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
290
+	}
291
+
292
+	if len(keywords) > 0 {
293
+		keywords = "%" + keywords + "%"
294
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
295
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
296
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
297
+			Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
298
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
299
+					return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
300
+				})
301
+			})
302
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
303
+		err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
304
+	} else {
305
+		err = db.Count(&total).Offset(offset).Limit(limit).
306
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
307
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
308
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
309
+			Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
310
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
311
+					return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
312
+				})
313
+			}).Find(&schedule).Error
314
+	}
315
+
316
+	return schedule, total, err
317
+}

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -295,10 +295,10 @@ func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (o
295 295
 		db = db.Where("x.org_id = ?", orgid)
296 296
 	}
297 297
 	if startime > 0 {
298
-		db = db.Where("x.ctime >= ?", startime)
298
+		db = db.Where("x.sys_record_time >= ?", startime)
299 299
 	}
300 300
 	if endtime > 0 {
301
-		db = db.Where("x.ctime<=?", endtime)
301
+		db = db.Where("x.sys_record_time<=?", endtime)
302 302
 	}
303 303
 	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,x.ctime,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
304 304
 	return out, err