Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
fe9109fc50

+ 4 - 4
controllers/dialysis_parameter_api_controller.go View File

@@ -263,8 +263,8 @@ func (this *DialysisPrameterApiController) GetCollectList() {
263 263
 
264 264
 		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
265 265
 		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
266
-			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
267
-			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
266
+			goodUser, _ := service.GetLastDialysisGoodsTwo(item.PatientId, orgId, startime.Unix())
267
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepareTwo(item.PatientId, orgId, startime.Unix())
268 268
 			item.LastAutomaticReduceDetail = goodUser
269 269
 			item.LastDialysisBeforePrepare = lastGoodUserDetial
270 270
 		}
@@ -283,8 +283,8 @@ func (this *DialysisPrameterApiController) GetCollectList() {
283 283
 		//获取当天排班的每个患者的库存使用情况
284 284
 		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
285 285
 		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
286
-			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
287
-			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
286
+			goodUser, _ := service.GetLastDialysisGoodsTwo(item.PatientId, orgId, startime.Unix())
287
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepareTwo(item.PatientId, orgId, startime.Unix())
288 288
 
289 289
 			fmt.Println(goodUser)
290 290
 			fmt.Println(lastGoodUserDetial)

+ 24 - 0
service/mobile_dialysis_service.go View File

@@ -1470,9 +1470,12 @@ func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64
1470 1470
 }
1471 1471
 
1472 1472
 func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1473
+
1473 1474
 	var Id []*DialysisGoodsDetailDate
1475
+
1474 1476
 	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1475 1477
 	if len(Id) > 0 {
1478
+
1476 1479
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
1477 1480
 	}
1478 1481
 	return
@@ -1543,3 +1546,24 @@ func PCGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, pa
1543 1546
 
1544 1547
 	return vms, err, total
1545 1548
 }
1549
+
1550
+func GetLastDialysisGoodsTwo(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1551
+
1552
+	var Id []*DialysisGoodsDetailDate
1553
+
1554
+	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1555
+	if len(Id) > 0 {
1556
+
1557
+		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
1558
+	}
1559
+	return
1560
+}
1561
+
1562
+func GetLastDialysisBeforePrepareTwo(patient_id int64, orgID int64, record_time int64) (goodUser []*DialysisBeforePrepare, err error) {
1563
+	var Id []*DialysisGoodsDate
1564
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1565
+	if len(Id) > 0 {
1566
+		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordDate).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Find(&goodUser).Error
1567
+	}
1568
+	return
1569
+}