Bladeren bron

耗材参数

XMLWAN 3 jaren geleden
bovenliggende
commit
d1ffdc33a5

+ 20 - 19
controllers/drug_stock_api_contorller.go Bestand weergeven

@@ -1254,29 +1254,30 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1254 1254
 	}
1255 1255
 
1256 1256
 	//调用出库逻辑
1257
-	for _, item := range warehousingOutInfo {
1258
-
1259
-		// 出库流程
1260
-		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1261
-		drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
1262
-		if drup.ID > 0 {
1263
-			prescribingNumber := item.Count
1264
-
1265
-			service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
1266
-
1267
-		}
1257
+	//for _, item := range warehousingOutInfo {
1258
+	//
1259
+	//	// 出库流程
1260
+	//	// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1261
+	//	drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
1262
+	//	if drup.ID > 0 {
1263
+	//		prescribingNumber := item.Count
1264
+	//
1265
+	//		service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
1266
+	//
1267
+	//	}
1268
+	//
1269
+	//}
1268 1270
 
1271
+	errs := service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
1272
+	info, _ := service.FindLastDrugWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
1273
+	if errs != nil {
1274
+		utils.ErrorLog(errs.Error())
1275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
1276
+		return
1269 1277
 	}
1270 1278
 
1271
-	//errs := service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
1272
-	//info, _ := service.FindLastDrugWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
1273
-	//if errs != nil {
1274
-	//	utils.ErrorLog(errs.Error())
1275
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
1276
-	//	return
1277
-	//}
1278
-
1279 1279
 	c.ServeSuccessJSON(map[string]interface{}{
1280
+		"info":                  info,
1280 1281
 		"msg":                   "出库成功",
1281 1282
 		"warehousing_out_order": warehousing_out_order,
1282 1283
 	})

+ 41 - 0
controllers/stock_in_api_controller.go Bestand weergeven

@@ -83,6 +83,8 @@ func StockManagerApiRegistRouters() {
83 83
 
84 84
 	beego.Router("/api/stock/getstocklistbyid", &StockManagerApiController{}, "Get:GetStockListById")
85 85
 	beego.Router("/api/stock/getstockoutlist", &StockManagerApiController{}, "Get:GetStockOutList")
86
+
87
+	beego.Router("/api/good/getstockdrugcount", &StockManagerApiController{}, "Get:GetStockDrugCount")
86 88
 }
87 89
 
88 90
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -3733,3 +3735,42 @@ func (this *StockManagerApiController) GetStockOutList() {
3733 3735
 		"total":   total,
3734 3736
 	})
3735 3737
 }
3738
+
3739
+func (this *StockManagerApiController) GetStockDrugCount() {
3740
+
3741
+	adminUserInfo := this.GetAdminUserInfo()
3742
+	orgId := adminUserInfo.CurrentOrgId
3743
+	fmt.Println(orgId)
3744
+	timeLayout := "2006-01-02"
3745
+	loc, _ := time.LoadLocation("Local")
3746
+	start_time := this.GetString("start_time")
3747
+	end_time := this.GetString("end_time")
3748
+	var startTime int64
3749
+	if len(start_time) > 0 {
3750
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3751
+		if err != nil {
3752
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3753
+			return
3754
+		}
3755
+		startTime = theTime.Unix()
3756
+	}
3757
+	var endTime int64
3758
+	if len(end_time) > 0 {
3759
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3760
+		if err != nil {
3761
+			utils.ErrorLog(err.Error())
3762
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3763
+			return
3764
+		}
3765
+		endTime = theTime.Unix()
3766
+	}
3767
+
3768
+	count, _ := service.GetStockDrugCount(startTime, endTime, orgId)
3769
+	outList, _ := service.GetAutoDiallysisBefor(startTime, endTime, orgId)
3770
+	autoCount, _ := service.GetOutStockTotalCountFour(startTime, endTime, orgId)
3771
+	this.ServeSuccessJSON(map[string]interface{}{
3772
+		"count":     count,
3773
+		"outList":   outList,
3774
+		"autoCount": autoCount,
3775
+	})
3776
+}

+ 5 - 0
models/stock_models.go Bestand weergeven

@@ -353,3 +353,8 @@ type VmWarehouseOutInfo struct {
353 353
 	Price  float64 `gorm:"column:price" json:"price"`
354 354
 	OrgId  int64   `gorm:"column:org_id" json:"org_id"`
355 355
 }
356
+
357
+type VmWarehouseInfo struct {
358
+	GoodId int64 `gorm:"column:good_id" json:"good_id"`
359
+	Count  int64 `gorm:"column:count" json:"count"`
360
+}

+ 6 - 5
service/gobal_config_service.go Bestand weergeven

@@ -497,11 +497,11 @@ func GetDrugWarehuseOrderInfo(orgid int64) (drug []*models.DrugWarehouseInfo, er
497 497
 }
498 498
 
499 499
 func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
500
-
500
+	offset := (page - 1) * limit
501 501
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
502 502
 
503 503
 	likeKey := "%" + keyword + "%"
504
-	offset := (page - 1) * limit
504
+
505 505
 	if len(keyword) > 0 {
506 506
 		db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ? and  t.drug_name like ?", orgid, likeKey)
507 507
 	} else {
@@ -509,9 +509,10 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
509 509
 	}
510 510
 	if drugcategory > 0 {
511 511
 		db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ? and  t.drug_category = ?", orgid, drugcategory)
512
-	} else {
513
-		db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ? and  t.drug_category = ?", orgid, drugcategory)
514 512
 	}
513
+	//} else {
514
+	//	db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id")
515
+	//}
515 516
 
516 517
 	if startime > 0 {
517 518
 		db = db.Where("x.ctime >=?", startime)
@@ -524,7 +525,7 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
524 525
 		db = db.Where("x.org_id = ?", orgid)
525 526
 	}
526 527
 
527
-	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Offset(offset).Count(&total).Group("x.drug_id").Order("x.ctime desc").Scan(&list).Error
528
+	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ?", orgid).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
528 529
 	return list, total, err
529 530
 }
530 531
 

+ 42 - 1
service/stock_service.go Bestand weergeven

@@ -2759,7 +2759,7 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
2759 2759
 	if good_type > 0 {
2760 2760
 		db = db.Where("t.good_type_id = ?", good_type)
2761 2761
 	}
2762
-	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.manufacturer").Joins("left join xt_good_information as t on t.id = x.good_id").Offset(offset).Count(&total).Group("x.good_id").Scan(&info).Error
2762
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.manufacturer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&info).Error
2763 2763
 	return info, total, err
2764 2764
 }
2765 2765
 
@@ -2807,3 +2807,44 @@ func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, starti
2807 2807
 	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id").Offset(offset).Count(&total).Scan(&info).Error
2808 2808
 	return info, total, err
2809 2809
 }
2810
+
2811
+func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
2812
+
2813
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
2814
+	if startime > 0 {
2815
+		db = db.Where("x.ctime >=?", startime)
2816
+	}
2817
+	if endtime > 0 {
2818
+		db = db.Where("x.ctime<=?", endtime)
2819
+	}
2820
+	if orgid > 0 {
2821
+		db = db.Where("x.org_id = ?", orgid)
2822
+	}
2823
+
2824
+	err = db.Select("sum(x.warehousing_count) as count,x.good_id").Group("x.good_id").Scan(&info).Error
2825
+	return info, err
2826
+}
2827
+
2828
+func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
2829
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
2830
+	if startime > 0 {
2831
+		db = db.Where("x.ctime >=?", startime)
2832
+	}
2833
+	if endtime > 0 {
2834
+		db = db.Where("x.ctime<=?", endtime)
2835
+	}
2836
+	if orgid > 0 {
2837
+		db = db.Where("x.org_id = ?", orgid)
2838
+	}
2839
+
2840
+	err = db.Select("sum(x.count) as count,x.good_id").Where("is_sys = 0").Group("x.good_id").Scan(&info).Error
2841
+	return info, err
2842
+}
2843
+
2844
+func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
2845
+
2846
+	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
2847
+
2848
+	return autoMatic, err
2849
+
2850
+}