XMLWAN 3 年 前
コミット
e879d84598

+ 4 - 2
controllers/drug_stock_api_contorller.go ファイルの表示

@@ -1365,9 +1365,11 @@ func (c *StockDrugApiController) GetDrugWarehouseOutInfoList() {
1365 1365
 	adminInfo := c.GetAdminUserInfo()
1366 1366
 	warehouseOutInfo, _ := service.FindDrugWarehouseOutInfoById(id, adminInfo.CurrentOrgId)
1367 1367
 	warehouseOut, _ := service.FindDrugWareHouseOutById(id, adminInfo.CurrentOrgId)
1368
+	manulist, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
1368 1369
 	c.ServeSuccessJSON(map[string]interface{}{
1369
-		"list": warehouseOutInfo,
1370
-		"info": warehouseOut,
1370
+		"list":     warehouseOutInfo,
1371
+		"info":     warehouseOut,
1372
+		"manulist": manulist,
1371 1373
 	})
1372 1374
 
1373 1375
 }

+ 54 - 0
controllers/gobal_config_api_controller.go ファイルの表示

@@ -92,6 +92,9 @@ func GobalConfigRegistRouters() {
92 92
 	//新接口
93 93
 	beego.Router("/api/drugstock/drugstocklist", &GobalConfigApiController{}, "Get:GetDrugStockList")
94 94
 	beego.Router("/api/drugstock/getdrugstockflow", &GobalConfigApiController{}, "Get:GetDrugStockFllow")
95
+
96
+	beego.Router("/api/drugoutstock/getoutdrugstockflow", &GobalConfigApiController{}, "Get:GetDrugOutStockFlow")
97
+	beego.Router("/api/drug/getbatchorderdetail", &GobalConfigApiController{}, "Get:GetBatchOrderDetail")
95 98
 }
96 99
 
97 100
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1881,6 +1884,7 @@ func (c *GobalConfigApiController) GetDrugStockFllow() {
1881 1884
 	}
1882 1885
 	orgId := c.GetAdminUserInfo().CurrentOrgId
1883 1886
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1887
+
1884 1888
 	//查询入库数据
1885 1889
 	if stock_type == 3 || stock_type == 0 {
1886 1890
 		list, total, err := service.GetDrugStockFlow(drug_id, startTime, endTime, page, limit, orgId)
@@ -1895,8 +1899,42 @@ func (c *GobalConfigApiController) GetDrugStockFllow() {
1895 1899
 		})
1896 1900
 	}
1897 1901
 
1902
+}
1903
+
1904
+func (c *GobalConfigApiController) GetDrugOutStockFlow() {
1905
+	drug_id, _ := c.GetInt64("drug_id")
1906
+	start_time := c.GetString("start_time")
1907
+	end_time := c.GetString("end_time")
1908
+	stock_type, _ := c.GetInt64("stock_type")
1909
+	page, _ := c.GetInt64("page")
1910
+	limit, _ := c.GetInt64("limit")
1911
+
1912
+	timeLayout := "2006-01-02"
1913
+	loc, _ := time.LoadLocation("Local")
1914
+	var startTime int64
1915
+	if len(start_time) > 0 {
1916
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1917
+		if err != nil {
1918
+			fmt.Println(err)
1919
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1920
+			return
1921
+		}
1922
+		startTime = theTime.Unix()
1923
+	}
1924
+	var endTime int64
1925
+	if len(end_time) > 0 {
1926
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1927
+		if err != nil {
1928
+			utils.ErrorLog(err.Error())
1929
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1930
+			return
1931
+		}
1932
+		endTime = theTime.Unix()
1933
+	}
1934
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1898 1935
 	if stock_type >= 0 && stock_type != 3 {
1899 1936
 		outList, total, err := service.GetDrugStockOutFlow(drug_id, startTime, endTime, page, limit, orgId, stock_type)
1937
+
1900 1938
 		if err != nil {
1901 1939
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1902 1940
 			return
@@ -1906,5 +1944,21 @@ func (c *GobalConfigApiController) GetDrugStockFllow() {
1906 1944
 			"total":   total,
1907 1945
 		})
1908 1946
 	}
1947
+}
1948
+
1949
+func (c *GobalConfigApiController) GetBatchOrderDetail() {
1909 1950
 
1951
+	drug_id, _ := c.GetInt64("drug_id")
1952
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1953
+	limit, _ := c.GetInt64("limit")
1954
+	page, _ := c.GetInt64("page")
1955
+	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, limit, page)
1956
+	if err != nil {
1957
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1958
+		return
1959
+	}
1960
+	c.ServeSuccessJSON(map[string]interface{}{
1961
+		"detail": detail,
1962
+		"total":  total,
1963
+	})
1910 1964
 }

+ 44 - 0
controllers/stock_in_api_controller.go ファイルの表示

@@ -78,6 +78,8 @@ func StockManagerApiRegistRouters() {
78 78
 	beego.Router("/api/good/getwarehouseorderinfolist", &StockManagerApiController{}, "Get:GetWarehouseOrderInfolist")
79 79
 
80 80
 	beego.Router("/api/good/postsearchgoodlist", &StockManagerApiController{}, "Get:PostSearchGoodList")
81
+
82
+	beego.Router("/api/good/getallstocklist", &StockManagerApiController{}, "Get:GetAllStockList")
81 83
 }
82 84
 
83 85
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -3608,3 +3610,45 @@ func (this *StockManagerApiController) PostSearchGoodList() {
3608 3610
 		"manufacturerList": manufacturerList,
3609 3611
 	})
3610 3612
 }
3613
+
3614
+func (this *StockManagerApiController) GetAllStockList() {
3615
+
3616
+	page, _ := this.GetInt64("page", -1)
3617
+	limit, _ := this.GetInt64("limit", -1)
3618
+	start_time := this.GetString("start_time")
3619
+	end_time := this.GetString("end_time")
3620
+	types, _ := this.GetInt64("type", 0)
3621
+	keywords := this.GetString("keywords")
3622
+
3623
+	timeLayout := "2006-01-02"
3624
+	loc, _ := time.LoadLocation("Local")
3625
+	var startTime int64
3626
+	if len(start_time) > 0 {
3627
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3628
+		if err != nil {
3629
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3630
+			return
3631
+		}
3632
+		startTime = theTime.Unix()
3633
+	}
3634
+	var endTime int64
3635
+	if len(end_time) > 0 {
3636
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3637
+		if err != nil {
3638
+			utils.ErrorLog(err.Error())
3639
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3640
+			return
3641
+		}
3642
+		endTime = theTime.Unix()
3643
+	}
3644
+	adminUserInfo := this.GetAdminUserInfo()
3645
+	orgId := adminUserInfo.CurrentOrgId
3646
+
3647
+	list, total, _ := service.GetAllStockList(page, limit, startTime, endTime, types, keywords, orgId)
3648
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3649
+	this.ServeSuccessJSON(map[string]interface{}{
3650
+		"list":             list,
3651
+		"total":            total,
3652
+		"manufacturerList": manufacturerList,
3653
+	})
3654
+}

+ 31 - 0
models/stock_models.go ファイルの表示

@@ -101,6 +101,37 @@ func (WarehousingInfo) TableName() string {
101 101
 	return "xt_warehouse_info"
102 102
 }
103 103
 
104
+type VmWarehousingInfo struct {
105
+	ID                int64       `gorm:"column:id" json:"id"`
106
+	WarehousingId     int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
107
+	GoodId            int64       `gorm:"column:good_id" json:"good_id"`
108
+	GoodTypeId        int64       `gorm:"column:good_type_id" json:"good_type_id"`
109
+	Number            string      `gorm:"column:number" json:"number"`
110
+	ProductDate       int64       `gorm:"column:product_date" json:"product_date"`
111
+	ExpiryDate        int64       `gorm:"column:expiry_date" json:"expiry_date"`
112
+	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
113
+	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
114
+	Price             float64     `gorm:"column:price" json:"price"`
115
+	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
116
+	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
117
+	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
118
+	Remark            string      `gorm:"column:remark" json:"remark"`
119
+	Ctime             int64       `gorm:"column:ctime" json:"ctime"`
120
+	Mtime             int64       `gorm:"column:mtime" json:"mtime"`
121
+	Status            int64       `gorm:"column:status" json:"status"`
122
+	OrgId             int64       `gorm:"column:org_id" json:"org_id"`
123
+	IsReturn          int64       `gorm:"column:is_return" json:"is_return"`
124
+	StockCount        int64       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
125
+	Warehousing       Warehousing `ForeignKey:WarehousingId json:"warehouse"`
126
+	WarehousingOrder  string      `gorm:"column:warehousing_order" json:"warehousing_order"`
127
+	GoodInfo          GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
128
+	Type              int64       `gorm:"column:type" json:"type"`
129
+	GoodName          string      `gorm:"column:good_name" json:"good_name"`
130
+	SpecificationName string      `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
131
+	MinNumber         int64       `gorm:"column:min_number" json:"min_number" form:"min_number"`
132
+	MinUnit           string      `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
133
+}
134
+
104 135
 type WarehouseOut struct {
105 136
 	ID                      int64        `gorm:"column:id" json:"id"`
106 137
 	WarehouseOutOrderNumber string       `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`

+ 8 - 2
service/gobal_config_service.go ファイルの表示

@@ -524,7 +524,7 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
524 524
 		db = db.Where("x.org_id = ?", orgid)
525 525
 	}
526 526
 
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.packing_unit,t.dosage,t.manufacturer").Offset(offset).Count(&total).Group("x.drug_id").Order("x.ctime desc").Scan(&list).Error
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 528
 	return list, total, err
529 529
 }
530 530
 
@@ -547,7 +547,7 @@ func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, l
547 547
 		db = db.Where("x.drug_id = ?", drugid)
548 548
 	}
549 549
 
550
-	err = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status = 1 and t.org_id = ?", orgid).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.packing_unit,t.dosage,t.manufacturer").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
550
+	err = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status = 1 and t.org_id = ?", orgid).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).Order("x.ctime desc").Scan(&list).Error
551 551
 	return list, total, err
552 552
 }
553 553
 
@@ -578,3 +578,9 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
578 578
 	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.warehouse_info_id").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
579 579
 	return list, total, err
580 580
 }
581
+
582
+func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
583
+	offset := (page - 1) * limit
584
+	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ?", drugid, orgid).Offset(offset).Count(&total).Find(&drug).Error
585
+	return drug, total, err
586
+}

+ 27 - 0
service/stock_service.go ファイルの表示

@@ -2734,3 +2734,30 @@ func FindGoodInfoByIdTwo(id int64) (goodInfo models.GoodInfo, err error) {
2734 2734
 	err = readDb.Model(&models.GoodInfo{}).Where("id = ? AND status = 1", id).First(&goodInfo).Error
2735 2735
 	return
2736 2736
 }
2737
+
2738
+func GetAllStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.VmWarehousingInfo, total int64, err error) {
2739
+
2740
+	offset := (page - 1) * limit
2741
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1")
2742
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
2743
+	fmt.Println(table)
2744
+	if startime > 0 {
2745
+		db = db.Where("x.ctime>=?", startime)
2746
+	}
2747
+	if endtime > 0 {
2748
+		db = db.Where("x.ctime<=?", endtime)
2749
+	}
2750
+
2751
+	likeKey := "%" + keyword + "%"
2752
+	if len(likeKey) > 0 {
2753
+		db = db.Where("t.good_name like ?", likeKey)
2754
+	}
2755
+	if orgid > 0 {
2756
+		db = db.Where("x.org_id = ?", orgid)
2757
+	}
2758
+	if good_type > 0 {
2759
+		db = db.Where("t.good_type_id = ?", good_type)
2760
+	}
2761
+	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.manufacturer,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").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
+	return info, total, err
2763
+}