XMLWAN před 3 roky
rodič
revize
3b98879efd

+ 109 - 10
controllers/drug_stock_api_contorller.go Zobrazit soubor

@@ -87,9 +87,11 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
87 87
 	}
88 88
 	timeStr := time.Now().Format("2006-01-02")
89 89
 	timeArr := strings.Split(timeStr, "-")
90
-	total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
90
+	total, _ := service.FindAllWarehouseTotalOne(adminUserInfo.CurrentOrgId)
91 91
 	total = total + 1
92
+	fmt.Println("total2323232323232", total)
92 93
 	warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
94
+	fmt.Println("r入库单据好  2323232322223", warehousing_order)
93 95
 	operation_time := time.Now().Unix()
94 96
 	creater := adminUserInfo.AdminUser.Id
95 97
 	warehousing := models.DrugWarehouse{
@@ -1692,6 +1694,7 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
1692 1694
 	}
1693 1695
 
1694 1696
 	var cancelStockInfos []*models.DrugCancelStockInfo
1697
+	var drugFlow []*models.DrugFlow
1695 1698
 
1696 1699
 	if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
1697 1700
 		thisStockIn, _ := dataBody["cancelStock"].([]interface{})
@@ -1773,6 +1776,7 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
1773 1776
 
1774 1777
 				batch_number := items["batch_number"].(string)
1775 1778
 				max_unit := items["max_unit"].(string)
1779
+				batch_number_id := int64(items["batch_number_id"].(float64))
1776 1780
 				cancelStockInfo := &models.DrugCancelStockInfo{
1777 1781
 					OrderNumber:      cancelStock.OrderNumber,
1778 1782
 					CancelStockId:    cancelStock.ID,
@@ -1794,23 +1798,118 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
1794 1798
 					MaxUnit:          max_unit,
1795 1799
 					ProductDate:      productDates,
1796 1800
 					ExpiryDate:       expiryDates,
1801
+					BatchNumberId:    batch_number_id,
1797 1802
 				}
1798 1803
 				cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
1799 1804
 
1805
+				flow := &models.DrugFlow{
1806
+					WarehousingId:           0,
1807
+					DrugId:                  drug_id,
1808
+					Number:                  "",
1809
+					BatchNumber:             batch_number,
1810
+					Count:                   count,
1811
+					UserOrgId:               adminUserInfo.CurrentOrgId,
1812
+					PatientId:               0,
1813
+					SystemTime:              ctime,
1814
+					ConsumableType:          4,
1815
+					IsSys:                   0,
1816
+					WarehousingOrder:        "",
1817
+					WarehouseOutId:          0,
1818
+					WarehouseOutOrderNumber: "",
1819
+					IsEdit:                  0,
1820
+					CancelStockId:           cancelStock.ID,
1821
+					CancelOrderNumber:       cancelStock.OrderNumber,
1822
+					Manufacturer:            0,
1823
+					Dealer:                  0,
1824
+					Creator:                 adminUserInfo.AdminUser.Id,
1825
+					UpdateCreator:           0,
1826
+					Status:                  1,
1827
+					Ctime:                   time.Now().Unix(),
1828
+					Mtime:                   0,
1829
+					Price:                   price,
1830
+					WarehousingDetailId:     0,
1831
+					WarehouseOutDetailId:    0,
1832
+					CancelOutDetailId:       0,
1833
+					ExpireDate:              expiryDates,
1834
+					ProductDate:             productDates,
1835
+					MaxUnit:                 max_unit,
1836
+					MinUnit:                 "",
1837
+				}
1838
+				drugFlow = append(drugFlow, flow)
1800 1839
 			}
1801 1840
 		}
1802 1841
 	}
1803
-	errs := service.CreateDrugCancelStockInfo(cancelStockInfos)
1804
-	if errs != nil {
1805
-		utils.ErrorLog(errs.Error())
1806
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1807
-		return
1808
-	}
1842
+	//扣减库存逻辑
1843
+	for _, item := range cancelStockInfos {
1844
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1845
+		//查询当前药品退库的批次号的总入库数
1846
+		infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
1847
+		fmt.Println("hhh2h3h2hh3233", item.MaxUnit, medical.MaxUnit)
1848
+		var total_count int64
1849
+		if item.MaxUnit == medical.MaxUnit {
1850
+			total_count = infoWareInfo.WarehousingCount
1851
+			fmt.Println("进来了吗发大发阿道夫阿方阿道夫撒发大发阿方阿方阿方阿道夫阿方暗示法", total_count)
1852
+		}
1853
+		//转化为最小库存
1854
+		if item.MaxUnit == medical.MinUnit {
1855
+			total_count = infoWareInfo.WarehousingCount * medical.MinNumber
1856
+		}
1857
+		fmt.Println("itme.count2323232323232323232332", item.Count)
1858
+		fmt.Println("23232322322323232332", total_count)
1859
+		//判断退库数量是否大于总入库数量
1860
+		if item.Count > total_count {
1861
+			c.ServeSuccessJSON(map[string]interface{}{
1862
+				"msg": "2",
1863
+			})
1864
+			return
1865
+		}
1866
+		//正常退库
1867
+		if item.Count <= infoWareInfo.WarehousingCount {
1868
+			//创建退库详情
1869
+			errs := service.CreateDrugCancelStockInfo(cancelStockInfos)
1870
+			//创建库存明细
1871
+			service.CreateDrugFlow(drugFlow)
1809 1872
 
1810
-	c.ServeSuccessJSON(map[string]interface{}{
1811
-		"msg": "退库成功",
1812
-	})
1873
+			var total int64
1874
+			//退库到当前批次,获取当前退库批次的库存
1875
+			info, _ := service.GetDrugWarehouseInfoById(item.BatchNumberId)
1876
+
1877
+			if info.MaxUnit == item.MaxUnit {
1878
+				total = item.Count + info.StockMaxNumber
1879
+
1880
+				warehouseInfo := models.XtDrugWarehouseInfo{
1881
+					StockMaxNumber: total,
1882
+				}
1883
+				errs = service.UpdateDrugWarehouseInfo(&warehouseInfo, item.BatchNumberId)
1884
+				if errs != nil {
1885
+					utils.ErrorLog(errs.Error())
1886
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1887
+					return
1888
+				}
1889
+
1890
+				c.ServeSuccessJSON(map[string]interface{}{
1891
+					"msg": "1",
1892
+				})
1893
+			}
1894
+			if medical.MinUnit == item.MaxUnit {
1895
+				total = item.Count + info.StockMinNumber
1896
+				warehouseInfo := models.XtDrugWarehouseInfo{
1897
+					StockMinNumber: total,
1898
+				}
1899
+
1900
+				errs = service.UpdateDrugWarehouseInfoOne(&warehouseInfo, item.BatchNumberId)
1901
+				if errs != nil {
1902
+					utils.ErrorLog(errs.Error())
1903
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1904
+					return
1905
+				}
1813 1906
 
1907
+				c.ServeSuccessJSON(map[string]interface{}{
1908
+					"msg": "1",
1909
+				})
1910
+			}
1911
+		}
1912
+	}
1814 1913
 }
1815 1914
 func (c *StockDrugApiController) GetDrugCancelStockInfoList() {
1816 1915
 	id, _ := c.GetInt64("id", 0)

+ 7 - 5
controllers/gobal_config_api_controller.go Zobrazit soubor

@@ -2010,16 +2010,18 @@ func (c *GobalConfigApiController) GetDrugCountList() {
2010 2010
 	outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2011 2011
 	auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2012 2012
 	info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
2013
+	cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
2013 2014
 	if err != nil {
2014 2015
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2015 2016
 		return
2016 2017
 	}
2017 2018
 	c.ServeSuccessJSON(map[string]interface{}{
2018
-		"countList":    list,
2019
-		"outCountList": outCountList,
2020
-		"auCountList":  auCountList,
2021
-		"minCount":     countList,
2022
-		"info":         info,
2019
+		"countList":       list,
2020
+		"outCountList":    outCountList,
2021
+		"auCountList":     auCountList,
2022
+		"minCount":        countList,
2023
+		"info":            info,
2024
+		"cancelCountList": cancelCountList,
2023 2025
 	})
2024 2026
 }
2025 2027
 

+ 5 - 5
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -1812,11 +1812,6 @@ func (c *StockManagerApiController) CreateCancelStock() {
1812 1812
 
1813 1813
 				dealer, _ := items["dealer"].(string)
1814 1814
 
1815
-				//productDate, _ := items["product_date"].(string)
1816
-				//product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
1817
-				//
1818
-				//expiryDate, _ := items["expiry_date"].(string)
1819
-				//expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
1820 1815
 				var expiryDates int64
1821 1816
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
1822 1817
 					expiryDates = 0
@@ -1906,6 +1901,11 @@ func (c *StockManagerApiController) CreateCancelStock() {
1906 1901
 		//调用退库的方法
1907 1902
 		parseDateErr := service.UpdateCancelOut(list, item.Count)
1908 1903
 		fmt.Println("999999999999", parseDateErr)
1904
+		if parseDateErr != nil {
1905
+			utils.ErrorLog(parseDateErr.Error())
1906
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1907
+			return
1908
+		}
1909 1909
 	}
1910 1910
 
1911 1911
 	if errs != nil {

+ 2 - 1
models/drug_stock.go Zobrazit soubor

@@ -238,6 +238,7 @@ type DrugCancelStockInfo struct {
238 238
 	BatchNumber      string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
239 239
 	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
240 240
 	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
241
+	BatchNumberId    int64       `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
241 242
 }
242 243
 
243 244
 func (DrugCancelStockInfo) TableName() string {
@@ -336,7 +337,7 @@ type DrugFlow struct {
336 337
 	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
337 338
 	IsEdit                  int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
338 339
 	CancelStockId           int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
339
-	CancelOrderNumber       int64   `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
340
+	CancelOrderNumber       string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
340 341
 	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
341 342
 	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
342 343
 	Creator                 int64   `gorm:"column:creator" json:"creator" form:"creator"`

+ 21 - 18
models/good_models.go Zobrazit soubor

@@ -107,24 +107,27 @@ func (GoodsTypeOne) TableName() string {
107 107
 }
108 108
 
109 109
 type XtCancelStockInfo struct {
110
-	ID            int64       `gorm:"column:id" json:"id"`
111
-	GoodId        int64       `gorm:"column:good_id" json:"good_id"`
112
-	CancelStockId int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
113
-	GoodTypeId    int64       `gorm:"column:good_type_id" json:"good_type_id"`
114
-	Count         int64       `gorm:"column:count" json:"count"`
115
-	Price         float64     `gorm:"column:price" json:"price"`
116
-	Total         float64     `gorm:"column:total" json:"total"`
117
-	ProductDate   int64       `gorm:"column:product_date" json:"product_date"`
118
-	ExpiryDate    int64       `gorm:"column:expiry_date" json:"expiry_date"`
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
-	OrderNumber   string      `gorm:"column:order_number" json:"order_number"`
124
-	Type          int64       `gorm:"column:type" json:"type"`
125
-	CancelStock   CancelStock `ForeignKey:CancelStockId json:"CancelStock"`
126
-	Dealer        int64       `gorm:"column:dealer" json:"dealer"`
127
-	Manufacturer  int64       `gorm:"column:manufacturer" json:"manufacturer"`
110
+	ID              int64    `gorm:"column:id" json:"id"`
111
+	GoodId          int64    `gorm:"column:good_id" json:"good_id"`
112
+	CancelStockId   int64    `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
113
+	GoodTypeId      int64    `gorm:"column:good_type_id" json:"good_type_id"`
114
+	Count           int64    `gorm:"column:count" json:"count"`
115
+	Price           float64  `gorm:"column:price" json:"price"`
116
+	Total           float64  `gorm:"column:total" json:"total"`
117
+	ProductDate     int64    `gorm:"column:product_date" json:"product_date"`
118
+	ExpiryDate      int64    `gorm:"column:expiry_date" json:"expiry_date"`
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
+	OrderNumber     string   `gorm:"column:order_number" json:"order_number"`
124
+	Type            int64    `gorm:"column:type" json:"type"`
125
+	Dealer          string   `gorm:"column:dealer" json:"dealer"`
126
+	Manufacturer    string   `gorm:"column:manufacturer" json:"manufacturer"`
127
+	GoodInfo        GoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"GoodInfo"`
128
+	Number          string   `gorm:"column:number" json:"number" form:"number"`
129
+	RegisterAccount string   `gorm:"column:register_account" json:"register_account" form:"register_account"`
130
+	Remark          string   `gorm:"column:remark" json:"remark" form:"remark"`
128 131
 }
129 132
 
130 133
 func (XtCancelStockInfo) TableName() string {

+ 2 - 0
models/self_drug_models.go Zobrazit soubor

@@ -67,6 +67,7 @@ type XtBaseDrug struct {
67 67
 	LmtUsedFlag            int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
68 68
 	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
69 69
 	PrescribingNumberUnit  string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
70
+	MinNumber              int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
70 71
 }
71 72
 
72 73
 func (XtBaseDrug) TableName() string {
@@ -394,6 +395,7 @@ type XtDrugWarehouseInfo struct {
394 395
 	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
395 396
 	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number"`
396 397
 	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
398
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
397 399
 }
398 400
 
399 401
 func (XtDrugWarehouseInfo) TableName() string {

+ 14 - 14
models/stock_models.go Zobrazit soubor

@@ -282,20 +282,20 @@ type VmCancelStockInfo struct {
282 282
 }
283 283
 
284 284
 type CancelStock struct {
285
-	ID              int64  `gorm:"column:id" json:"id"`
286
-	OrderNumber     string `gorm:"column:order_number" json:"order_number"`
287
-	OperaTime       int64  `gorm:"column:opera_time" json:"opera_time"`
288
-	Total           int64  `gorm:"column:total" json:"total"`
289
-	Creater         int64  `gorm:"column:creater" json:"creater"`
290
-	Ctime           int64  `gorm:"column:ctime" json:"ctime"`
291
-	Mtime           int64  `gorm:"column:mtime" json:"mtime"`
292
-	Status          int64  `gorm:"column:status" json:"status"`
293
-	OrgId           int64  `gorm:"column:org_id" json:"org_id"`
294
-	ReturnTime      int64  `gorm:"column:return_time" json:"return_time"`
295
-	Dealer          int64  `gorm:"column:dealer" json:"dealer"`
296
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer"`
297
-	Type            int64  `gorm:"column:type" json:"type"`
298
-	CancelStockInfo []*XtCancelStockInfo
285
+	ID                int64                `gorm:"column:id" json:"id"`
286
+	OrderNumber       string               `gorm:"column:order_number" json:"order_number"`
287
+	OperaTime         int64                `gorm:"column:opera_time" json:"opera_time"`
288
+	Total             int64                `gorm:"column:total" json:"total"`
289
+	Creater           int64                `gorm:"column:creater" json:"creater"`
290
+	Ctime             int64                `gorm:"column:ctime" json:"ctime"`
291
+	Mtime             int64                `gorm:"column:mtime" json:"mtime"`
292
+	Status            int64                `gorm:"column:status" json:"status"`
293
+	OrgId             int64                `gorm:"column:org_id" json:"org_id"`
294
+	ReturnTime        int64                `gorm:"column:return_time" json:"return_time"`
295
+	Dealer            int64                `gorm:"column:dealer" json:"dealer"`
296
+	Manufacturer      int64                `gorm:"column:manufacturer" json:"manufacturer"`
297
+	Type              int64                `gorm:"column:type" json:"type"`
298
+	XtCancelStockInfo []*XtCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"XtCancelStockInfo"`
299 299
 }
300 300
 
301 301
 func (CancelStock) TableName() string {

+ 17 - 0
service/gobal_config_service.go Zobrazit soubor

@@ -664,6 +664,23 @@ func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*m
664 664
 
665 665
 }
666 666
 
667
+func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.XtCancelStockInfo, err error) {
668
+
669
+	db := XTReadDB().Table(" xt_drug_cancel_stock_info as x").Where("x.status = 1")
670
+
671
+	if startime > 0 {
672
+		db = db.Where("x.ctime >=?", startime)
673
+	}
674
+	if endtime > 0 {
675
+		db = db.Where("x.ctime<=?", endtime)
676
+	}
677
+	if orgid > 0 {
678
+		db = db.Where("x.org_id = ?", orgid)
679
+	}
680
+	err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
681
+	return info, err
682
+}
683
+
667 684
 func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
668 685
 
669 686
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")

+ 42 - 4
service/stock_service.go Zobrazit soubor

@@ -337,6 +337,11 @@ func FindAllWarehouseTotal(org_id int64) (total int64, err error) {
337 337
 	err = readDb.Model(&models.Warehousing{}).Where("org_id = ?", org_id).Count(&total).Error
338 338
 	return total, err
339 339
 }
340
+
341
+func FindAllWarehouseTotalOne(org_id int64) (total int64, err error) {
342
+	err = readDb.Model(&models.XtDrugWarehouse{}).Where("org_id = ?", org_id).Count(&total).Error
343
+	return total, err
344
+}
340 345
 func AddSigleWarehouse(warehouse *models.Warehousing) error {
341 346
 	err := writeDb.Create(&warehouse).Error
342 347
 	return err
@@ -505,7 +510,7 @@ func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
505 510
 	if len(drugflow) > 0 {
506 511
 		utx := writeDb.Begin()
507 512
 		if len(drugflow) > 0 {
508
-			thisSQL := "INSERT INTO xt_drug_flow (warehousing_id, drug_id, number,batch_number,count,user_org_id,patient_id,system_time,consumable_type,is_sys,warehousing_order,warehouse_out_id,warehouse_out_order_number,is_edit,cancel_stock_id,cancel_order_number,manufacturer,dealer,creator,update_creator,status,ctime,mtime,price,warehousing_detail_id,warehouse_out_detail_id,cancel_out_detail_id,expire_date,product_date,max_unit,min_unit ) VALUES "
513
+			thisSQL := "INSERT INTO xt_drug_flow (warehousing_id, drug_id, number,batch_number,count,user_org_id,patient_id,system_time,consumable_type,is_sys,warehousing_order,warehouse_out_id,warehouse_out_order_number,is_edit,cancel_stock_id,cancel_order_number,manufacturer,dealer,creator,update_creator,status,ctime,mtime,price,warehousing_detail_id,warehouse_out_detail_id,cancel_out_detail_id,expire_date,product_date,max_unit,min_unit) VALUES "
509 514
 			insertParams := make([]string, 0)
510 515
 			insertData := make([]interface{}, 0)
511 516
 			for _, info := range drugflow {
@@ -1506,11 +1511,11 @@ func CreateDrugCancelStockInfo(cancelStockInfo []*models.DrugCancelStockInfo) (e
1506 1511
 	if len(cancelStockInfo) > 0 {
1507 1512
 		utx := writeDb.Begin()
1508 1513
 		if len(cancelStockInfo) > 0 {
1509
-			thisSQL := "INSERT INTO xt_drug_cancel_stock_info (drug_id,cancel_stock_id, count, price,total,ctime,status,org_id,order_number,type,dealer,manufacturer,retail_price,retail_total_price,register_account,batch_number,remark,max_unit,product_date,expiry_date) VALUES "
1514
+			thisSQL := "INSERT INTO xt_drug_cancel_stock_info (drug_id,cancel_stock_id, count, price,total,ctime,status,org_id,order_number,type,dealer,manufacturer,retail_price,retail_total_price,register_account,batch_number,remark,max_unit,product_date,expiry_date,batch_number_id) VALUES "
1510 1515
 			insertParams := make([]string, 0)
1511 1516
 			insertData := make([]interface{}, 0)
1512 1517
 			for _, info := range cancelStockInfo {
1513
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1518
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1514 1519
 				insertData = append(insertData, info.DrugId)
1515 1520
 				insertData = append(insertData, info.CancelStockId)
1516 1521
 				insertData = append(insertData, info.Count)
@@ -1531,6 +1536,7 @@ func CreateDrugCancelStockInfo(cancelStockInfo []*models.DrugCancelStockInfo) (e
1531 1536
 				insertData = append(insertData, info.MaxUnit)
1532 1537
 				insertData = append(insertData, info.ProductDate)
1533 1538
 				insertData = append(insertData, info.ExpiryDate)
1539
+				insertData = append(insertData, info.BatchNumberId)
1534 1540
 			}
1535 1541
 			thisSQL += strings.Join(insertParams, ", ")
1536 1542
 			err = utx.Exec(thisSQL, insertData...).Error
@@ -3602,7 +3608,7 @@ func GetCancelStockOrderPrintOne(idstr []string, orgid int64) (info []*models.Ca
3602 3608
 
3603 3609
 	if len(idstr) > 0 {
3604 3610
 		err = XTReadDB().Model(&info).Where("id in(?)", idstr).
3605
-			Preload("CancelStockInfo", func(db *gorm.DB) *gorm.DB {
3611
+			Preload("XtCancelStockInfo", func(db *gorm.DB) *gorm.DB {
3606 3612
 				return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("GoodInfo", "status = 1 and org_id = ?", orgid)
3607 3613
 			}).Find(&info).Error
3608 3614
 	}
@@ -3991,3 +3997,35 @@ func GetCancelStockDetail(id int64) (info []*models.DrugCancelStockInfo, err err
3991 3997
 	err = db.Find(&info).Error
3992 3998
 	return info, err
3993 3999
 }
4000
+
4001
+func GetDrugWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
4002
+
4003
+	info := models.XtDrugWarehouseInfo{}
4004
+
4005
+	db := XTReadDB().Model(&info).Where("status = 1")
4006
+	if id > 0 {
4007
+		db = db.Where("id = ?", id)
4008
+	}
4009
+	err := db.Select("drug_id,warehousing_count").Find(&info).Error
4010
+
4011
+	return info, err
4012
+}
4013
+
4014
+func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
4015
+
4016
+	info := models.XtDrugWarehouseInfo{}
4017
+	err := XTReadDB().Model(&info).Where("id=? and status =1", id).Find(&info).Error
4018
+	return info, err
4019
+}
4020
+
4021
+func UpdateDrugWarehouseInfo(info *models.XtDrugWarehouseInfo, id int64) error {
4022
+
4023
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber}).Error
4024
+	return err
4025
+}
4026
+
4027
+func UpdateDrugWarehouseInfoOne(info *models.XtDrugWarehouseInfo, id int64) error {
4028
+
4029
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_min_number": info.StockMaxNumber}).Error
4030
+	return err
4031
+}

+ 3 - 3
service/warhouse_service.go Zobrazit soubor

@@ -1258,7 +1258,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1258 1258
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
1259 1259
 	fmt.Println("err222222222222222222222", warehouse.StockCount)
1260 1260
 	if err != nil {
1261
-		fmt.Println("232323232323进来")
1261
+
1262 1262
 		return err
1263 1263
 	}
1264 1264
 
@@ -1306,7 +1306,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1306 1306
 			UserOrgId:               goods.OrgId,
1307 1307
 			PatientId:               goods.PatientId,
1308 1308
 			SystemTime:              record_time,
1309
-			ConsumableType:          3,
1309
+			ConsumableType:          2,
1310 1310
 			IsSys:                   goods.IsSys,
1311 1311
 			WarehousingOrder:        "",
1312 1312
 			WarehouseOutId:          warehouseOut.ID,
@@ -1394,7 +1394,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1394 1394
 			UserOrgId:               goods.OrgId,
1395 1395
 			PatientId:               0,
1396 1396
 			SystemTime:              record_time,
1397
-			ConsumableType:          3,
1397
+			ConsumableType:          2,
1398 1398
 			IsSys:                   0,
1399 1399
 			WarehousingOrder:        "",
1400 1400
 			WarehouseOutId:          warehouseOut.ID,