Kaynağa Gözat

提交代码

陈少旭 10 ay önce
ebeveyn
işleme
f70607528b

+ 150 - 0
controllers/new_stock_api_controller.go Dosyayı Görüntüle

@@ -0,0 +1,150 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"XT_New/utils"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"time"
10
+)
11
+
12
+type NewStockApiController struct {
13
+	BaseAuthAPIController
14
+}
15
+
16
+func NewStockApiRegistRouters() {
17
+	beego.Router("/api/drug/stock", &NewStockApiController{}, "Get:GetDrugStock")
18
+	beego.Router("/api/drug/change", &NewStockApiController{}, "Get:GetDrugChange")
19
+	//beego.Router("/api/drug/query", &NewStockApiController{}, "Get:GetDrugQuery")
20
+
21
+}
22
+
23
+func (c *NewStockApiController) GetDrugStock() {
24
+	start_time := c.GetString("start_time")
25
+	end_time := c.GetString("end_time")
26
+
27
+	timeLayout := "2006-01-02"
28
+	loc, _ := time.LoadLocation("Local")
29
+	var startTime int64
30
+	if len(start_time) > 0 {
31
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
32
+		if err != nil {
33
+			fmt.Println(err)
34
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
35
+			return
36
+		}
37
+		startTime = theTime.Unix()
38
+	}
39
+	var endTime int64
40
+	if len(end_time) > 0 {
41
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
42
+		if err != nil {
43
+			utils.ErrorLog(err.Error())
44
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
45
+			return
46
+		}
47
+		endTime = theTime.Unix()
48
+	}
49
+
50
+	admin := c.GetAdminUserInfo()
51
+	is_pc, _ := c.GetInt64("is_pc", 0)
52
+	is_bg, _ := c.GetInt64("is_bg", 0)
53
+	//manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
54
+	//dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
55
+	fmt.Println(startTime)
56
+	fmt.Println(endTime)
57
+
58
+	warehousingInfo, err := service.FindAllDrugWarehousingInfo(admin.CurrentOrgId, is_pc, is_bg, startTime, endTime)
59
+	//list, _ := service.GetAll/**/StoreHouseListThree(admin.CurrentOrgId)
60
+	if err == nil {
61
+		c.ServeSuccessJSON(map[string]interface{}{
62
+			"info": warehousingInfo,
63
+			//"manufacturerList": manufacturerList,
64
+			//"dealerList":       dealerList,
65
+			//"list": list,
66
+		})
67
+	} else {
68
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
69
+	}
70
+}
71
+
72
+func (c *NewStockApiController) GetDrugChange() {
73
+	start_time := c.GetString("start_time")
74
+	end_time := c.GetString("end_time")
75
+
76
+	timeLayout := "2006-01-02"
77
+	loc, _ := time.LoadLocation("Local")
78
+	var startTime int64
79
+	if len(start_time) > 0 {
80
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
81
+		if err != nil {
82
+			fmt.Println(err)
83
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
84
+			return
85
+		}
86
+		startTime = theTime.Unix()
87
+	}
88
+	var endTime int64
89
+	if len(end_time) > 0 {
90
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
91
+		if err != nil {
92
+			utils.ErrorLog(err.Error())
93
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
94
+			return
95
+		}
96
+		endTime = theTime.Unix()
97
+	}
98
+	orgId := c.GetAdminUserInfo().CurrentOrgId
99
+	page, _ := c.GetInt64("page")
100
+	limit, _ := c.GetInt64("limit")
101
+	list, total, _ := service.GetNewDrugFlow(orgId, limit, page, startTime, endTime)
102
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
103
+	dealerList, _ := service.GetAllDealerList(orgId)
104
+	houseList, _ := service.GetAllStoreHouseList(orgId)
105
+	//patientList, _ := service.GetAllPatientListSix(orgId)
106
+	c.ServeSuccessJSON(map[string]interface{}{
107
+		"info":             list,
108
+		"total":            total,
109
+		"manufacturerList": manufacturerList,
110
+		"dealerList":       dealerList,
111
+		"houseList":        houseList,
112
+		//"patientList":      patientList,
113
+	})
114
+}
115
+func (c *NewStockApiController) GetDrugQuery() {
116
+	id, _ := c.GetInt64("id", 0)
117
+
118
+	if id <= 0 {
119
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
120
+		return
121
+	}
122
+	admin := c.GetAdminUserInfo()
123
+
124
+	warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
125
+
126
+	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
127
+	dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
128
+	if err != nil {
129
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
130
+		return
131
+	}
132
+
133
+	if warehousing.ID <= 0 {
134
+		return
135
+	}
136
+
137
+	warehousingInfo, err := service.FindDrugWarehousingInfoByIdThree(id, admin.CurrentOrgId)
138
+	list, _ := service.GetAllStoreHouseListThree(admin.CurrentOrgId)
139
+	if err == nil {
140
+		c.ServeSuccessJSON(map[string]interface{}{
141
+			"info":             warehousingInfo,
142
+			"warehousing":      warehousing,
143
+			"manufacturerList": manufacturerList,
144
+			"dealerList":       dealerList,
145
+			"list":             list,
146
+		})
147
+	} else {
148
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
149
+	}
150
+}

+ 4 - 0
models/drug_stock.go Dosyayı Görüntüle

@@ -461,6 +461,10 @@ type DrugFlow struct {
461 461
 	FlushOverCount            int64                  `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
462 462
 	Remark                    string                 `gorm:"column:remark" json:"remark" form:"remark"`
463 463
 	OperateTime               int64                  `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
464
+	SaleDate                  string                 `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
465
+	PCount                    float64
466
+	SDate                     string
467
+	PDate                     int64
464 468
 }
465 469
 
466 470
 func (DrugFlow) TableName() string {

+ 70 - 0
models/new_drug_stock.go Dosyayı Görüntüle

@@ -0,0 +1,70 @@
1
+package models
2
+
3
+type NewDrugFlow struct {
4
+	ID                        int64                  `gorm:"column:id" json:"id" form:"id"`
5
+	WarehousingId             int64                  `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
6
+	DrugId                    int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
7
+	Number                    string                 `gorm:"column:number" json:"number" form:"number"`
8
+	BatchNumber               string                 `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
9
+	Count                     int64                  `gorm:"column:count" json:"count" form:"count"`
10
+	UserOrgId                 int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
11
+	PatientId                 int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
12
+	SystemTime                int64                  `gorm:"column:system_time" json:"system_time" form:"system_time"`
13
+	ConsumableType            int64                  `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
14
+	IsSys                     int64                  `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
15
+	WarehousingOrder          string                 `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
16
+	WarehouseOutId            int64                  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
17
+	WarehouseOutOrderNumber   string                 `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
18
+	IsEdit                    int64                  `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
19
+	CancelStockId             int64                  `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
20
+	CancelOrderNumber         string                 `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
21
+	Manufacturer              int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
22
+	Dealer                    int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
23
+	Creator                   int64                  `gorm:"column:creator" json:"creator" form:"creator"`
24
+	UpdateCreator             int64                  `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
25
+	Status                    int64                  `gorm:"column:status" json:"status" form:"status"`
26
+	Ctime                     int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
27
+	Mtime                     int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
28
+	Price                     float64                `gorm:"column:price" json:"price" form:"price"`
29
+	WarehousingDetailId       int64                  `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
30
+	WarehouseOutDetailId      int64                  `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
31
+	CancelOutDetailId         int64                  `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
32
+	ExpireDate                int64                  `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
33
+	ProductDate               int64                  `gorm:"column:product_date" json:"product_date" form:"product_date"`
34
+	MaxUnit                   string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
35
+	MinUnit                   string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
36
+	StockMaxNumber            int64                  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
37
+	StockMinNumber            int64                  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
38
+	LastStockMaxNumber        int64                  `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
39
+	LastStockMinNumber        int64                  `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
40
+	DrugWarehouseInfo         []*DrugWarehouseInfo   `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
41
+	BaseDrugLib               BaseDrugLib            `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
42
+	AdviceId                  int64                  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
43
+	SupplyWarehouseId         int64                  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
44
+	SupplyCancelOutId         int64                  `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
45
+	SupplyWarehouseDetailInfo int64                  `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
46
+	StorehouseId              int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
47
+	SecondWarehouseInfoId     int64                  `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
48
+	AdminUserId               int64                  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
49
+	LastPrice                 float64                `gorm:"column:last_price" json:"last_price" form:"last_price"`
50
+	StockCount                string                 `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
51
+	PharmacyId                int64                  `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
52
+	DrugWarehouseInfoOne      DrugWarehouseInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
53
+	IsRead                    int64                  `gorm:"column:is_read" json:"is_read" form:"is_read"`
54
+	IsCheck                   int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
55
+	OverCount                 int64                  `gorm:"column:over_count" json:"over_count" form:"over_count"`
56
+	RetailPrice               float64                `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
57
+	XtDrugWarehouseOutInfo    XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
58
+	OrderId                   int64                  `gorm:"column:order_id" json:"order_id" form:"order_id"`
59
+	FlushOverCount            int64                  `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
60
+	Remark                    string                 `gorm:"column:remark" json:"remark" form:"remark"`
61
+	OperateTime               int64                  `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
62
+	SaleDate                  string                 `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
63
+	PCount                    float64
64
+	SDate                     string
65
+	PDate                     int64
66
+}
67
+
68
+func (NewDrugFlow) TableName() string {
69
+	return "xt_drug_flow"
70
+}

+ 38 - 0
models/new_stock.go Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+package models
2
+
3
+type DrugWarehouseInfoTenOne struct {
4
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
5
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
6
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
7
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
8
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
9
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
10
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
11
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
12
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
13
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
14
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
15
+	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
16
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
17
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
18
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
19
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
20
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
21
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
22
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
23
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
24
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
25
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
26
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
27
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
28
+	//Base                      Drug    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
29
+	BaseDrugLib               BaseDrugLib `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID"json:"drug" `
30
+	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
31
+	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
32
+	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
33
+	PcDate                    int64       `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
34
+}
35
+
36
+func (DrugWarehouseInfoTenOne) TableName() string {
37
+	return "xt_drug_warehouse_info"
38
+}

+ 1 - 0
routers/router.go Dosyayı Görüntüle

@@ -87,4 +87,5 @@ func init() {
87 87
 	controllers.SignApiRegistRouters()
88 88
 	controllers.ZuobiaoApiRegistRouters()
89 89
 	controllers.HisExportDataApiRegistRouters()
90
+	//controllers.NewStockApiRegistRouters()
90 91
 }

+ 50 - 0
service/new_stock_medical_insurance_service.go Dosyayı Görüntüle

@@ -0,0 +1,50 @@
1
+package service
2
+
3
+import "XT_New/models"
4
+
5
+func FindAllDrugWarehousingInfo(org_id int64, is_pc int64, is_bg int64, start_time int64, end_time int64) (list []*models.DrugWarehouseInfoTenOne, err error) {
6
+	db := readDb.Model(&models.DrugWarehouseInfoTenOne{}).Preload("BaseDrugLib", "org_id = ?", org_id)
7
+	if is_pc != 0 {
8
+		db = db.Where("is_pc = ?", is_pc)
9
+	}
10
+	if is_bg != 0 {
11
+		db = db.Where("is_bg = ?", is_bg)
12
+	}
13
+	if start_time != 0 {
14
+		db = db.Where("ctime >= ?", start_time)
15
+
16
+	}
17
+	if end_time != 0 {
18
+		db = db.Where("ctime <= ?", end_time)
19
+
20
+	}
21
+
22
+	err = db.Where("status = 1 and org_id = ?", org_id).Find(&list).Error
23
+	return list, err
24
+}
25
+
26
+func GetNewDrugFlow(orgid int64, limit int64, page int64, startTime int64, endTime int64) (drug_flow []*models.NewDrugFlow, total int64, err error) {
27
+
28
+	offset := (page - 1) * limit
29
+	db := XTReadDB().Model(drug_flow).Where("status = 1")
30
+	if orgid > 0 {
31
+		db = db.Where("user_org_id = ?", orgid)
32
+	}
33
+	if startTime > 0 {
34
+		db = db.Where("ctime >=? ", startTime)
35
+	}
36
+	if endTime > 0 {
37
+		db = db.Where("ctime<=?", endTime)
38
+	}
39
+	//if stock_type > 0 {
40
+
41
+	//手动入库
42
+	//if stock_type == 1 {
43
+	db = db.Where("consumable_type <> 1")
44
+	//}
45
+
46
+	//}
47
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Preload("XtDrugWarehouseOutInfo", "status = 1").Find(&drug_flow).Error
48
+
49
+	return drug_flow, total, err
50
+}