Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
66e9bea24a
3 changed files with 146 additions and 11 deletions
  1. 35 4
      controllers/stock_in_api_controller.go
  2. 92 4
      models/stock_models.go
  3. 19 3
      service/stock_service.go

+ 35 - 4
controllers/stock_in_api_controller.go View File

@@ -4877,11 +4877,42 @@ func (this *StockManagerApiController) SaveAdjuestPrice() {
4877 4877
 }
4878 4878
 
4879 4879
 func (this *StockManagerApiController) GetAllStockPrice() {
4880
-
4880
+	fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhh")
4881
+	timeLayout := "2006-01-02"
4882
+	loc, _ := time.LoadLocation("Local")
4883
+	dataBody := make(map[string]interface{}, 0)
4884
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
4885
+	fmt.Println(err)
4881 4886
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4882
-
4883
-	list, _ := service.GetAllStockPrice(orgId)
4887
+	keyword := this.GetString("keyword")
4888
+	fmt.Println("keywoer2r2r32rwrwr", keyword)
4889
+	start_time := this.GetString("start_time")
4890
+	end_time := this.GetString("end_time")
4891
+	var startTime int64
4892
+	if len(start_time) > 0 {
4893
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4894
+		if err != nil {
4895
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4896
+			return
4897
+		}
4898
+		startTime = theTime.Unix()
4899
+	}
4900
+	var endTime int64
4901
+	if len(end_time) > 0 {
4902
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
4903
+		if err != nil {
4904
+			utils.ErrorLog(err.Error())
4905
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4906
+			return
4907
+		}
4908
+		endTime = theTime.Unix()
4909
+	}
4910
+	fmt.Println("startTime23232233223232323232323", startTime)
4911
+	fmt.Println("endtime 23232232332232323232323232323", endTime)
4912
+	list, _ := service.GetAllStockPrice(orgId, startTime, endTime, keyword)
4913
+	doctor, _ := service.GetAllDoctorThree(orgId)
4884 4914
 	this.ServeSuccessJSON(map[string]interface{}{
4885
-		"list": list,
4915
+		"list":   list,
4916
+		"doctor": doctor,
4886 4917
 	})
4887 4918
 }

+ 92 - 4
models/stock_models.go View File

@@ -1,5 +1,7 @@
1 1
 package models
2 2
 
3
+import "XT/models"
4
+
3 5
 type Manufacturer struct {
4 6
 	ID               int64  `gorm:"column:id" json:"id"`
5 7
 	ManufacturerName string `gorm:"column:manufacturer_name" json:"manufacturer_name"`
@@ -802,6 +804,94 @@ type BloodWarehouseInfo struct {
802 804
 }
803 805
 
804 806
 type XtStockAdjustPrice struct {
807
+	ID                int64                  `gorm:"column:id" json:"id" form:"id"`
808
+	GoodName          string                 `gorm:"column:good_name" json:"good_name" form:"good_name"`
809
+	SpecificationName string                 `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
810
+	WarehousingUnit   string                 `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
811
+	Count             int64                  `gorm:"column:count" json:"count" form:"count"`
812
+	BuyPrice          float64                `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
813
+	PackingPrice      float64                `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
814
+	NewPrice          float64                `gorm:"column:new_price" json:"new_price" form:"new_price"`
815
+	Manufacturer      string                 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
816
+	Dealer            string                 `gorm:"column:dealer" json:"dealer" form:"dealer"`
817
+	Remark            string                 `gorm:"column:remark" json:"remark" form:"remark"`
818
+	GoodId            int64                  `gorm:"column:good_id" json:"good_id" form:"good_id"`
819
+	UserOrgId         int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
820
+	Ctime             int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
821
+	Mtime             int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
822
+	Status            int64                  `gorm:"column:status" json:"status" form:"status"`
823
+	WarehousingOrder  string                 `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
824
+	LicenseNumber     string                 `gorm:"column:license_number" json:"license_number" form:"license_number"`
825
+	StartTime         int64                  `gorm:"column:start_time" json:"start_time" form:"start_time"`
826
+	Creater           int64                  `gorm:"column:creater" json:"creater" form:"creater"`
827
+	Checker           int64                  `gorm:"column:checker" json:"checker" form:"checker"`
828
+	CheckerStatus     int64                  `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
829
+	CheckerTime       int64                  `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
830
+	GoodInfo          models.GoodInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
831
+	AdminRole         models.VMUserAdminRole `gorm:"ForeignKey:ID;AssociationForeignKey:Creater" `
832
+}
833
+
834
+func (XtStockAdjustPrice) TableName() string {
835
+	return "xt_stock_adjust_price"
836
+}
837
+
838
+type VmUserAdminRole struct {
839
+	ID                                      int64  `gorm:"column:id" json:"id" form:"id"`
840
+	AdminUserId                             int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
841
+	OrgId                                   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
842
+	AppId                                   int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
843
+	RoleId                                  int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
844
+	UserName                                string `gorm:"column:user_name" json:"user_name" form:"user_name"`
845
+	Avatar                                  string `gorm:"column:avatar" json:"avatar" form:"avatar"`
846
+	UserType                                int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
847
+	UserTitle                               int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
848
+	Intro                                   string `gorm:"column:intro" json:"intro" form:"intro"`
849
+	Status                                  int64  `gorm:"column:status" json:"status" form:"status"`
850
+	Ctime                                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
851
+	Mtime                                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
852
+	UserTitleName                           string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
853
+	RoleIds                                 string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
854
+	Message                                 string `gorm:"column:message" json:"message" form:"message"`
855
+	Sex                                     int64  `gorm:"column:sex" json:"sex" form:"sex"`
856
+	Birthday                                int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
857
+	Sort                                    int64  `gorm:"column:sort" json:"sort" form:"sort"`
858
+	IsSort                                  int64  `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
859
+	Department                              string `gorm:"column:department" json:"department" form:"department"`
860
+	DepartmentId                            int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
861
+	Age                                     int64  `gorm:"column:age" json:"age" form:"age"`
862
+	Nation                                  string `gorm:"column:nation" json:"nation" form:"nation"`
863
+	CardType                                int64  `gorm:"column:card_type" json:"card_type" form:"card_type"`
864
+	IdCard                                  string `gorm:"column:id_card" json:"id_card" form:"id_card"`
865
+	Education                               int64  `gorm:"column:education" json:"education" form:"education"`
866
+	StudyMajorName                          string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
867
+	WorkMajorName                           string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
868
+	RoleType                                int64  `gorm:"column:role_type" json:"role_type" form:"role_type"`
869
+	MedicalCode                             string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
870
+	DoctorCode                              string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
871
+	Licensing                               int64  `gorm:"column:licensing" json:"licensing" form:"licensing"`
872
+	JobNumber                               string `gorm:"column:job_number" json:"job_number" form:"job_number"`
873
+	PrescriptionQualificationIdentification int64  `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
874
+	IdentificationOutpatients               int64  `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
875
+	StartTime                               int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
876
+	MedicalRangeCode                        int64  `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
877
+	MedicalLevel                            int64  `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
878
+	MedicalTypeJob                          int64  `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
879
+	PharmacistRegistrationNumber            string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
880
+	DoctorRangeCode                         int64  `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
881
+	DoctorLevel                             int64  `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
882
+	DoctorTypeJob                           int64  `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
883
+	DoctorNumber                            string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
884
+	OutpatientIllnessCategory               string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
885
+	IsActive                                int64  `gorm:"column:is_active" json:"is_active" form:"is_active"`
886
+	ActiveStatus                            int64  `gorm:"column:active_status" json:"active_status" form:"active_status"`
887
+	IsMark                                  int64  `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
888
+}
889
+
890
+func (VmUserAdminRole) TableName() string {
891
+	return "sgj_user_admin_role"
892
+}
893
+
894
+type VmStockAdjustPrice struct {
805 895
 	ID                int64   `gorm:"column:id" json:"id" form:"id"`
806 896
 	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
807 897
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
@@ -825,8 +915,6 @@ type XtStockAdjustPrice struct {
825 915
 	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
826 916
 	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
827 917
 	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
828
-}
829
-
830
-func (XtStockAdjustPrice) TableName() string {
831
-	return "xt_stock_adjust_price"
918
+	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
919
+	UserName          string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
832 920
 }

+ 19 - 3
service/stock_service.go View File

@@ -4304,8 +4304,24 @@ func CreateAdjustPrice(adjustPrice *models.XtStockAdjustPrice) error {
4304 4304
 	return err
4305 4305
 }
4306 4306
 
4307
-func GetAllStockPrice(orgid int64) (list []*models.XtStockAdjustPrice, err error) {
4308
-
4309
-	err = XTReadDB().Model(&list).Where("user_org_id = ? and status = 1", orgid).Find(&list).Error
4307
+func GetAllStockPrice(orgid int64, startime int64, endtime int64, keyword string) (list []*models.VmStockAdjustPrice, err error) {
4308
+	likeKey := "%" + keyword + "%"
4309
+	db := XTReadDB().Table("xt_stock_adjust_price as x").Where("x.status = 1")
4310
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4311
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4312
+	fmt.Println(table, tab)
4313
+	if startime > 0 {
4314
+		db = db.Where("x.start_time>=?", startime)
4315
+	}
4316
+	if endtime > 0 {
4317
+		db = db.Where("x.end_time<=?", endtime)
4318
+	}
4319
+	if len(keyword) > 0 {
4320
+		db = db.Where("x.warehousing_order like ?", likeKey)
4321
+	}
4322
+	if orgid > 0 {
4323
+		db = db.Where("x.user_org_id = ?", orgid)
4324
+	}
4325
+	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,t.packing_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Scan(&list).Error
4310 4326
 	return list, err
4311 4327
 }