XMLWAN před 4 roky
rodič
revize
fe9109fc50

+ 4 - 4
controllers/dialysis_parameter_api_controller.go Zobrazit soubor

263
 
263
 
264
 		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
264
 		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
265
 		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
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
 			item.LastAutomaticReduceDetail = goodUser
268
 			item.LastAutomaticReduceDetail = goodUser
269
 			item.LastDialysisBeforePrepare = lastGoodUserDetial
269
 			item.LastDialysisBeforePrepare = lastGoodUserDetial
270
 		}
270
 		}
283
 		//获取当天排班的每个患者的库存使用情况
283
 		//获取当天排班的每个患者的库存使用情况
284
 		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
284
 		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
285
 		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
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
 			fmt.Println(goodUser)
289
 			fmt.Println(goodUser)
290
 			fmt.Println(lastGoodUserDetial)
290
 			fmt.Println(lastGoodUserDetial)

+ 24 - 0
service/mobile_dialysis_service.go Zobrazit soubor

1470
 }
1470
 }
1471
 
1471
 
1472
 func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1472
 func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1473
+
1473
 	var Id []*DialysisGoodsDetailDate
1474
 	var Id []*DialysisGoodsDetailDate
1475
+
1474
 	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
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
 	if len(Id) > 0 {
1477
 	if len(Id) > 0 {
1478
+
1476
 		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
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
 	return
1481
 	return
1543
 
1546
 
1544
 	return vms, err, total
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
+}