XMLWAN vor 3 Jahren
Ursprung
Commit
719f502eba

+ 160 - 1
controllers/stock_in_api_controller.go Datei anzeigen

@@ -101,7 +101,7 @@ func StockManagerApiRegistRouters() {
101 101
 
102 102
 	//耗材调价
103 103
 	beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
104
-
104
+	beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
105 105
 }
106 106
 
107 107
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -4713,3 +4713,162 @@ func (this *StockManagerApiController) GetSearchGoodWarehouseList() {
4713 4713
 		"dealerList":       dealerList,
4714 4714
 	})
4715 4715
 }
4716
+
4717
+func (this *StockManagerApiController) SaveAdjuestPrice() {
4718
+	timeLayout := "2006-01-02"
4719
+	loc, _ := time.LoadLocation("Local")
4720
+	dataBody := make(map[string]interface{}, 0)
4721
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
4722
+	if err != nil {
4723
+		utils.ErrorLog(err.Error())
4724
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4725
+		return
4726
+	}
4727
+	tableData, _ := dataBody["tableData"].([]interface{})
4728
+	if len(tableData) > 0 {
4729
+		for _, item := range tableData {
4730
+			items := item.(map[string]interface{})
4731
+
4732
+			if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
4733
+				utils.ErrorLog("good_name")
4734
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4735
+				return
4736
+			}
4737
+			good_name := items["good_name"].(string)
4738
+
4739
+			if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
4740
+				utils.ErrorLog("good_name")
4741
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4742
+				return
4743
+			}
4744
+
4745
+			if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
4746
+				utils.ErrorLog("packing_price")
4747
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4748
+				return
4749
+			}
4750
+			packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
4751
+
4752
+			if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
4753
+				utils.ErrorLog("warehousing_order")
4754
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4755
+				return
4756
+			}
4757
+			warehousing_order := items["warehousing_order"].(string)
4758
+
4759
+			if items["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
4760
+				utils.ErrorLog("license_number")
4761
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4762
+				return
4763
+			}
4764
+			license_number := items["license_number"].(string)
4765
+
4766
+			if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
4767
+				utils.ErrorLog("dealer")
4768
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4769
+				return
4770
+			}
4771
+			dealer := items["dealer"].(string)
4772
+
4773
+			if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
4774
+				utils.ErrorLog("manufacturer")
4775
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4776
+				return
4777
+			}
4778
+			manufacturer := items["manufacturer"].(string)
4779
+
4780
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
4781
+				utils.ErrorLog("specification_name")
4782
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4783
+				return
4784
+			}
4785
+			specification_name := items["specification_name"].(string)
4786
+
4787
+			if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
4788
+				utils.ErrorLog("remark")
4789
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4790
+				return
4791
+			}
4792
+			remark := items["remark"].(string)
4793
+
4794
+			if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
4795
+				utils.ErrorLog("warehousing_unit")
4796
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4797
+				return
4798
+			}
4799
+			warehousing_unit := items["warehousing_unit"].(string)
4800
+
4801
+			if items["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
4802
+				utils.ErrorLog("buy_price")
4803
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4804
+				return
4805
+			}
4806
+			buy_price, _ := strconv.ParseFloat(items["buy_price"].(string), 64)
4807
+
4808
+			if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
4809
+				utils.ErrorLog("count")
4810
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4811
+				return
4812
+			}
4813
+			count := int64(items["count"].(float64))
4814
+
4815
+			if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
4816
+				utils.ErrorLog("new_price")
4817
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4818
+				return
4819
+			}
4820
+			new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
4821
+
4822
+			if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
4823
+				utils.ErrorLog("good_id")
4824
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4825
+				return
4826
+			}
4827
+			good_id := int64(items["good_id"].(float64))
4828
+
4829
+			if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
4830
+				utils.ErrorLog("start_time")
4831
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4832
+				return
4833
+			}
4834
+			var startTime int64
4835
+			start_time := items["start_time"].(string)
4836
+			if len(start_time) > 0 {
4837
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4838
+				if err != nil {
4839
+					fmt.Println(err)
4840
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4841
+					return
4842
+				}
4843
+				startTime = theTime.Unix()
4844
+			}
4845
+			orgId := this.GetAdminUserInfo().CurrentOrgId
4846
+			adjustprice := models.XtStockAdjustPrice{
4847
+				GoodName:          good_name,
4848
+				SpecificationName: specification_name,
4849
+				WarehousingUnit:   warehousing_unit,
4850
+				Count:             count,
4851
+				BuyPrice:          buy_price,
4852
+				PackingPrice:      packing_price,
4853
+				NewPrice:          new_price,
4854
+				Manufacturer:      manufacturer,
4855
+				Dealer:            dealer,
4856
+				Remark:            remark,
4857
+				GoodId:            good_id,
4858
+				UserOrgId:         orgId,
4859
+				Ctime:             time.Now().Unix(),
4860
+				Mtime:             0,
4861
+				Status:            1,
4862
+				WarehousingOrder:  warehousing_order,
4863
+				LicenseNumber:     license_number,
4864
+				StartTime:         startTime,
4865
+			}
4866
+
4867
+			service.CreateAdjustPrice(&adjustprice)
4868
+		}
4869
+	}
4870
+
4871
+	this.ServeSuccessJSON(map[string]interface{}{
4872
+		"msg": "保存成功!",
4873
+	})
4874
+}

+ 20 - 0
models/patient_models.go Datei anzeigen

@@ -779,6 +779,26 @@ func (XtInspectionReference) TableName() string {
779 779
 	return "xt_inspection_reference"
780 780
 }
781 781
 
782
+type VmXtInspection struct {
783
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
784
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
785
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
786
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
787
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
788
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
789
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
790
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
791
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
792
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
793
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
794
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
795
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
796
+	RangeType    int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
797
+	RangeMin     string `gorm:"column:range_min" json:"range_min" form:"range_min"`
798
+	RangeMax     string `gorm:"column:range_max" json:"range_max" form:"range_max"`
799
+	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
800
+}
801
+
782 802
 type XtInspection struct {
783 803
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
784 804
 	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`

+ 28 - 0
models/stock_models.go Datei anzeigen

@@ -797,4 +797,32 @@ type BloodWarehouseInfo struct {
797 797
 	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
798 798
 	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
799 799
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
800
+	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
801
+	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
802
+}
803
+
804
+type XtStockAdjustPrice struct {
805
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
806
+	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
807
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
808
+	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
809
+	Count             int64   `gorm:"column:count" json:"count" form:"count"`
810
+	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
811
+	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
812
+	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
813
+	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
814
+	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
815
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
816
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
817
+	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
818
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
819
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
820
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
821
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
822
+	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
823
+	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
824
+}
825
+
826
+func (XtStockAdjustPrice) TableName() string {
827
+	return "xt_stock_adjust_price"
800 828
 }

+ 8 - 6
service/patientmanage_service.go Datei anzeigen

@@ -1659,21 +1659,23 @@ func GetInspectionDetailByProject(project_id int64, patientid int64, inspect_dat
1659 1659
 	return inspection, err
1660 1660
 }
1661 1661
 
1662
-func GetInspectionItemlist(patientid int64, inspect_date []string, projectid []string) (inspection []*models.XtInspection, err error) {
1662
+func GetInspectionItemlist(patientid int64, inspect_date []string, projectid []string) (inspection []*models.VmInspection, err error) {
1663 1663
 
1664
-	db := XTReadDB().Model(&inspection).Where("status = 1")
1664
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1665
+	table := XTReadDB().Table("xt_inspection_reference as s").Where("s.status = 1")
1666
+	fmt.Println(table)
1665 1667
 	if patientid > 0 {
1666
-		db = db.Where("patient_id = ?", patientid)
1668
+		db = db.Where("x.patient_id = ?", patientid)
1667 1669
 	}
1668 1670
 	if len(inspect_date) > 0 {
1669
-		db = db.Where("inspect_date in(?)", inspect_date)
1671
+		db = db.Where("x.inspect_date in(?)", inspect_date)
1670 1672
 	}
1671 1673
 
1672 1674
 	if len(projectid) > 0 {
1673
-		db = db.Where("project_id in(?)", projectid)
1675
+		db = db.Where("x.project_id in(?)", projectid)
1674 1676
 	}
1675 1677
 
1676
-	err = db.Find(&inspection).Error
1678
+	err = db.Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,t.range_max,t.range_min,t.range_value,t.unit").Joins("left join xt_inspection_reference as t on t.id = x.item_id").Scan(&inspection).Error
1677 1679
 	return inspection, err
1678 1680
 }
1679 1681
 

+ 7 - 1
service/stock_service.go Datei anzeigen

@@ -4294,6 +4294,12 @@ func GetSearchGoodWarehouseList(keyword string, orgid int64) (info []*models.Blo
4294 4294
 	if orgid > 0 {
4295 4295
 		db = db.Where("x.org_id = ?", orgid)
4296 4296
 	}
4297
-	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.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.warehousing_unit,t.good_name,t.specification_name,x.manufacturer,t.packing_price,t.id").Joins("left join xt_good_information as t on t.id = x.good_id").Where("t.good_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
4297
+	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.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.warehousing_unit,t.good_name,t.specification_name,x.manufacturer,t.packing_price,t.id as good_id,t.packing_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Where("t.good_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
4298 4298
 	return info, err
4299 4299
 }
4300
+
4301
+func CreateAdjustPrice(adjustPrice *models.XtStockAdjustPrice) error {
4302
+
4303
+	err := XTWriteDB().Create(&adjustPrice).Error
4304
+	return err
4305
+}