123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/service"
- "XT_New/utils"
- "fmt"
- "github.com/astaxie/beego"
- "time"
- )
-
- type NewStockApiController struct {
- BaseAuthAPIController
- }
-
- func NewStockApiRegistRouters() {
- beego.Router("/api/drug/stock", &NewStockApiController{}, "Get:GetDrugStock")
- beego.Router("/api/drug/change", &NewStockApiController{}, "Get:GetDrugChange")
- //beego.Router("/api/drug/query", &NewStockApiController{}, "Get:GetDrugQuery")
-
- }
-
- func (c *NewStockApiController) GetDrugStock() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- admin := c.GetAdminUserInfo()
- is_pc, _ := c.GetInt64("is_pc", 0)
- is_bg, _ := c.GetInt64("is_bg", 0)
- //manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
- //dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
- fmt.Println(startTime)
- fmt.Println(endTime)
-
- warehousingInfo, err := service.FindAllDrugWarehousingInfo(admin.CurrentOrgId, is_pc, is_bg, startTime, endTime)
- //list, _ := service.GetAll/**/StoreHouseListThree(admin.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "info": warehousingInfo,
- //"manufacturerList": manufacturerList,
- //"dealerList": dealerList,
- //"list": list,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *NewStockApiController) GetDrugChange() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- is_sale, _ := c.GetInt64("is_sale")
- is_bg, _ := c.GetInt64("is_bg")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- list, total, _ := service.GetNewDrugFlow(orgId, limit, page, startTime, endTime, is_sale, is_bg)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- //patientList, _ := service.GetAllPatientListSix(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "info": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "houseList": houseList,
- //"patientList": patientList,
- })
- }
- func (c *NewStockApiController) GetDrugQuery() {
- id, _ := c.GetInt64("id", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- admin := c.GetAdminUserInfo()
-
- warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- if warehousing.ID <= 0 {
- return
- }
-
- warehousingInfo, err := service.FindDrugWarehousingInfoByIdThree(id, admin.CurrentOrgId)
- list, _ := service.GetAllStoreHouseListThree(admin.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "info": warehousingInfo,
- "warehousing": warehousing,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "list": list,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
|