Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
7333934e7a

+ 17 - 17
controllers/drug_stock_api_contorller.go View File

@@ -1179,19 +1179,25 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1179 1179
 				}
1180 1180
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1181 1181
 
1182
-				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
1183
-					utils.ErrorLog("last_price")
1184
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1185
-					return
1186
-				}
1187
-				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1188
-
1182
+				//if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
1183
+				//	utils.ErrorLog("last_price")
1184
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1185
+				//	return
1186
+				//}
1187
+				//last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1188
+				//fmt.Println(last_price)
1189 1189
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1190 1190
 
1191 1191
 				total := float64(count) * price
1192
-				retail_price_total := float64(count) * last_price
1192
+				retail_price_total := float64(count) * price
1193 1193
 				remark := items["remark"].(string)
1194 1194
 				max_unit := items["max_unit"].(string)
1195
+				dealer := int64(items["dealer"].(float64))
1196
+				fmt.Println("dealer2222222222222222222", dealer)
1197
+				manufacturer := int64(items["manufacturer"].(float64))
1198
+				fmt.Println("manufacturer22222222222222", manufacturer)
1199
+				number := items["number"].(string)
1200
+				batch_number := items["batch_number"].(string)
1195 1201
 				var productDates int64
1196 1202
 				var expiryDates int64
1197 1203
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
@@ -1222,13 +1228,6 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1222 1228
 
1223 1229
 				}
1224 1230
 
1225
-				dealer := int64(items["dealer"].(float64))
1226
-
1227
-				manufacturer := int64(items["manufacturer"].(float64))
1228
-
1229
-				number := items["number"].(string)
1230
-				batch_number := items["batch_number"].(string)
1231
-
1232 1231
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1233 1232
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1234 1233
 					WarehouseOutId:          warehouseOut.ID,
@@ -1243,13 +1242,14 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1243 1242
 					Type:                    types,
1244 1243
 					Manufacturer:            manufacturer,
1245 1244
 					Dealer:                  dealer,
1246
-					RetailPrice:             last_price,
1245
+					RetailPrice:             price,
1247 1246
 					RetailTotalPrice:        retail_price_total,
1248 1247
 					CountUnit:               max_unit,
1249 1248
 					ExpiryDate:              expiryDates,
1250 1249
 					ProductDate:             productDates,
1251 1250
 					Number:                  number,
1252 1251
 					BatchNumber:             batch_number,
1252
+					IsSys:                   0,
1253 1253
 				}
1254 1254
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1255 1255
 
@@ -1488,7 +1488,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1488 1488
 					return
1489 1489
 				}
1490 1490
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1491
-
1491
+				fmt.Println("price23223232323232323232323232322322", price)
1492 1492
 				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
1493 1493
 					utils.ErrorLog("retail_price")
1494 1494
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 55 - 22
controllers/stock_in_api_controller.go View File

@@ -92,6 +92,7 @@ func StockManagerApiRegistRouters() {
92 92
 	beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
93 93
 	beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
94 94
 	beego.Router("/api/stock/getsinglecancelorder", &StockManagerApiController{}, "Get:GetSingleCancelOrder")
95
+	beego.Router("/api/stock/getcancelstockorderprint", &StockManagerApiController{}, "Get:GetCancelStockOrderPrint")
95 96
 
96 97
 }
97 98
 
@@ -1141,7 +1142,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1141 1142
 					return
1142 1143
 				}
1143 1144
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1144
-
1145
+				fmt.Println("999999992932323232323223232322323", price)
1145 1146
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1146 1147
 
1147 1148
 				total := float64(count) * price
@@ -1232,6 +1233,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1232 1233
 			})
1233 1234
 			return
1234 1235
 		} else {
1236
+			fmt.Println("jiage223444444444444444444", item.Price)
1235 1237
 			_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1236 1238
 			if errcodes == gorm.ErrRecordNotFound {
1237 1239
 				service.AddSigleWarehouseOut(&warehouseOut)
@@ -1678,11 +1680,12 @@ func (c *StockManagerApiController) CreateCancelStock() {
1678 1680
 
1679 1681
 	// 改变入库单的值
1680 1682
 	for _, item := range cancelStockInfos {
1681
-
1683
+		fmt.Println("经理俄2433444 我认为侮辱侮辱侮辱侮辱侮辱侮辱我无污染武荣", item.GoodId, item.OrgId)
1682 1684
 		//查询该耗材的入库记录
1683 1685
 		list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
1684 1686
 		//调用退库的方法
1685
-		service.UpdateCancelOut(list, item.Count)
1687
+		parseDateErr := service.UpdateCancelOut(list, item.Count)
1688
+		fmt.Println("999999999999", parseDateErr)
1686 1689
 	}
1687 1690
 
1688 1691
 	if errs != nil {
@@ -1789,9 +1792,6 @@ func (this *StockManagerApiController) DeleteCancelStockInfo() {
1789 1792
 func (c *StockManagerApiController) EditCancelStock() {
1790 1793
 	cancel_time := c.GetString("cancel_time")
1791 1794
 	id, _ := c.GetInt64("id", 0)
1792
-	types, _ := c.GetInt64("type", 0)
1793
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1794
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1795 1795
 
1796 1796
 	if id == 0 {
1797 1797
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1812,11 +1812,9 @@ func (c *StockManagerApiController) EditCancelStock() {
1812 1812
 	cancelStock, _ := service.FindCancelStockById(id, c.GetAdminUserInfo().CurrentOrgId)
1813 1813
 
1814 1814
 	tempCancelStock := models.CancelStock{
1815
-		ID:           cancelStock.ID,
1816
-		Mtime:        mtime,
1817
-		ReturnTime:   cancelDate.Unix(),
1818
-		Manufacturer: manufacturer_id,
1819
-		Dealer:       dealer_id,
1815
+		ID:         cancelStock.ID,
1816
+		Mtime:      mtime,
1817
+		ReturnTime: cancelDate.Unix(),
1820 1818
 	}
1821 1819
 
1822 1820
 	service.EditCancelStock(tempCancelStock)
@@ -1878,9 +1876,6 @@ func (c *StockManagerApiController) EditCancelStock() {
1878 1876
 						OrderNumber:   cancelStock.OrderNumber,
1879 1877
 						CancelStockId: cancelStock.ID,
1880 1878
 						Mtime:         time.Now().Unix(),
1881
-						Type:          types,
1882
-						Manufacturer:  manufacturer_id,
1883
-						Dealer:        dealer_id,
1884 1879
 					}
1885 1880
 					cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
1886 1881
 
@@ -1896,9 +1891,6 @@ func (c *StockManagerApiController) EditCancelStock() {
1896 1891
 						OrderNumber:   cancelStock.OrderNumber,
1897 1892
 						CancelStockId: cancelStock.ID,
1898 1893
 						Mtime:         time.Now().Unix(),
1899
-						Type:          types,
1900
-						Manufacturer:  manufacturer_id,
1901
-						Dealer:        dealer_id,
1902 1894
 					}
1903 1895
 					upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
1904 1896
 				}
@@ -1908,11 +1900,42 @@ func (c *StockManagerApiController) EditCancelStock() {
1908 1900
 	var errs error
1909 1901
 	if len(cancelStockInfos) > 0 {
1910 1902
 		errs = service.CreateCancelStockInfo(cancelStockInfos)
1903
+		// 改变入库单的值
1904
+		for _, item := range cancelStockInfos {
1905
+			//查询该耗材的入库记录
1906
+			list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
1907
+			//调用退库的方法
1908
+			parseDateErr := service.UpdateCancelOut(list, item.Count)
1909
+			if parseDateErr != nil {
1910
+				utils.ErrorLog(errs.Error())
1911
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1912
+				return
1913
+			}
1914
+
1915
+			c.ServeSuccessJSON(map[string]interface{}{
1916
+				"msg": "编辑成功",
1917
+			})
1918
+		}
1911 1919
 	}
1912 1920
 
1913 1921
 	if len(upDateCancelStockInfos) > 0 {
1914 1922
 		for _, item := range upDateCancelStockInfos {
1923
+
1915 1924
 			errs = service.UpDateCancelStockInfo(item)
1925
+			list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
1926
+			//调用退库的方法
1927
+			parseDateErr := service.UpdateCancelOut(list, item.Count)
1928
+			fmt.Println("999999999999", parseDateErr)
1929
+
1930
+			if parseDateErr != nil {
1931
+				utils.ErrorLog(errs.Error())
1932
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1933
+				return
1934
+			}
1935
+
1936
+			c.ServeSuccessJSON(map[string]interface{}{
1937
+				"msg": "编辑成功",
1938
+			})
1916 1939
 		}
1917 1940
 	}
1918 1941
 
@@ -3910,11 +3933,12 @@ func (this *StockManagerApiController) GetStockDrugCount() {
3910 3933
 	count, _ := service.GetStockDrugCount(startTime, endTime, orgId)
3911 3934
 	outList, _ := service.GetAutoDiallysisBefor(startTime, endTime, orgId)
3912 3935
 	autoCount, _ := service.GetOutStockTotalCountFour(startTime, endTime, orgId)
3913
-
3936
+	totalCount, _ := service.GetCancelOutTotalCount(startTime, endTime, orgId)
3914 3937
 	this.ServeSuccessJSON(map[string]interface{}{
3915
-		"count":     count,
3916
-		"outList":   outList,
3917
-		"autoCount": autoCount,
3938
+		"count":      count,
3939
+		"outList":    outList,
3940
+		"autoCount":  autoCount,
3941
+		"totalCount": totalCount,
3918 3942
 	})
3919 3943
 }
3920 3944
 
@@ -3995,7 +4019,7 @@ func (this *StockManagerApiController) GetExprotStockList() {
3995 4019
 		}
3996 4020
 		endTime = theTime.Unix()
3997 4021
 	}
3998
-
4022
+	fmt.Println("ids2222222222222222", ids)
3999 4023
 	list, _ := service.GetExprotStockList(orgId, ids, startTime, endTime)
4000 4024
 	this.ServeSuccessJSON(map[string]interface{}{
4001 4025
 		"list": list,
@@ -4050,3 +4074,12 @@ func (this *StockManagerApiController) GetSingleCancelOrder() {
4050 4074
 		"list": order,
4051 4075
 	})
4052 4076
 }
4077
+
4078
+func (this *StockManagerApiController) GetCancelStockOrderPrint() {
4079
+	id := this.GetString("id")
4080
+	idStr := strings.Split(id, ",")
4081
+	list, _ := service.GetCancelStockOrderPrint(idStr)
4082
+	this.ServeSuccessJSON(map[string]interface{}{
4083
+		"list": list,
4084
+	})
4085
+}

+ 1 - 0
models/self_drug_models.go View File

@@ -596,6 +596,7 @@ type StDrugWarehouseInfo struct {
596 596
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
597 597
 	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
598 598
 	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number"`
599
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
599 600
 	DrugName         string  `json:"drug_name"`
600 601
 	DrugType         int64   `json:"drug_type"`
601 602
 	MaxUnit          string  `json:"max_unit"`

+ 7 - 0
models/stock_models.go View File

@@ -97,6 +97,7 @@ type StWarehousingInfo struct {
97 97
 	PackingUnit       string  `json:"packing_unit"`
98 98
 	TotalCount        int64   `json:"total_count"`
99 99
 	SpecificationName string  `json:"specification_name"`
100
+	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
100 101
 }
101 102
 
102 103
 func (StWarehousingInfo) TableName() string {
@@ -273,6 +274,12 @@ func (SalesReturnInfo) TableName() string {
273 274
 	return "xt_sales_return_info"
274 275
 }
275 276
 
277
+type VmCancelStockInfo struct {
278
+	GoodId int64 `gorm:"column:good_id" json:"good_id"`
279
+	Count  int64 `gorm:"column:count" json:"count"`
280
+	OrgId  int64 `gorm:"column:org_id" json:"org_id"`
281
+}
282
+
276 283
 type CancelStockInfo struct {
277 284
 	ID            int64       `gorm:"column:id" json:"id"`
278 285
 	GoodId        int64       `gorm:"column:good_id" json:"good_id"`

+ 1 - 0
models/stock_query_models.go View File

@@ -8,6 +8,7 @@ type StockInfo struct {
8 8
 	GoodTypeId            int64                   `gorm:"column:good_type_id" json:"good_type_id"`
9 9
 	GoodUnit              int64                   `gorm:"column:good_unit" json:"good_unit"`
10 10
 	MinUnit               string                  `gorm:"column:min_unit" json:"min_unit"`
11
+	PackingUnit           string                  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
11 12
 	QueryWarehousingInfo  []QueryWarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_warehousing_info"`
12 13
 	QuerySalesReturnInfo  []QuerySalesReturnInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_sales_return_info"`
13 14
 	QueryWarehouseOutInfo []QueryWarehouseOutInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_warehouseout_info"`

+ 2 - 2
service/gobal_config_service.go View File

@@ -256,7 +256,7 @@ func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType
256 256
 
257 257
 	if len(keyword) > 0 {
258 258
 
259
-		db = db.Where("x.warehousing_order like ? or t.drug_spec like ? or s.creater like ?", likeKey, likeKey, likeKey)
259
+		db = db.Where("x.warehousing_order like ? or t.drug_name like ? or s.creater like ?", likeKey, likeKey, likeKey)
260 260
 
261 261
 	}
262 262
 
@@ -327,7 +327,7 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
327 327
 	}
328 328
 
329 329
 	if len(keyword) > 0 {
330
-		db = db.Where("x.warehouse_out_order_number like ? or b.drug_spec like ? or t.creater like ?", likeKey, likeKey, likeKey)
330
+		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ? or t.creater like ?", likeKey, likeKey, likeKey)
331 331
 	}
332 332
 
333 333
 	if manufacturerId > 0 {

+ 55 - 14
service/stock_service.go View File

@@ -743,7 +743,7 @@ func FindDrugWarehousingInfoByIdOne(id []string, org_id int64) (list []*models.S
743 743
 	if org_id > 0 {
744 744
 		db = db.Where("x.org_id = ?", org_id)
745 745
 	}
746
-	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,t.manufacturer,t.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
746
+	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,x.batch_number,t.manufacturer,t.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
747 747
 	return list, err
748 748
 }
749 749
 
@@ -3146,7 +3146,7 @@ func GetExprotStockList(orgid int64, orderid []string, startime int64, endtime i
3146 3146
 	if endtime > 0 {
3147 3147
 		db = db.Where("x.ctime<=?", endtime)
3148 3148
 	}
3149
-	err = db.Select("x.id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,Sum(x.warehousing_count)as total_count,x.price,x.dealer,x.manufacturer,x.remark,t.good_name,t.packing_unit,t.specification_name,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&info).Error
3149
+	err = db.Select("x.id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.dealer,x.manufacturer,x.remark,x.license_number,t.good_name,t.packing_unit,t.specification_name,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&info).Error
3150 3150
 
3151 3151
 	return info, err
3152 3152
 }
@@ -3189,7 +3189,7 @@ func GetOutExprotList(orgid int64, ids []string, startime int64, endtime int64)
3189 3189
 		db = db.Where("x.ctime<=?", endtime)
3190 3190
 	}
3191 3191
 
3192
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,Sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
3192
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&out).Error
3193 3193
 	return out, err
3194 3194
 
3195 3195
 }
@@ -3316,13 +3316,13 @@ func GetWarehoureOrderInfoList(goodid int64, orgid int64) (info []*models.Wareho
3316 3316
 		db = db.Where("x.org_id = ?", orgid)
3317 3317
 	}
3318 3318
 
3319
-	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.manufacturer,x.remark,x.is_return,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number").Order("x.ctime desc").Find(&info).Error
3319
+	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.manufacturer,x.remark,x.is_return,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.org_id").Find(&info).Error
3320 3320
 	return info, err
3321 3321
 }
3322 3322
 
3323 3323
 func UpdateWarehousingCount(info *models.WarehousingInfo, goodid int64, orgid int64, warehousingId int64) error {
3324 3324
 
3325
-	err := XTWriteDB().Model(&info).Where("good_id = ? and org_id = ? and status =1 and warehousing_id = ?", goodid, orgid, warehousingId).Updates(map[string]interface{}{"stock_cout": info.StockCount}).Error
3325
+	err := XTWriteDB().Model(&info).Where("good_id = ? and org_id = ? and status =1 and warehousing_id = ?", goodid, orgid, warehousingId).Updates(map[string]interface{}{"stock_count": info.StockCount}).Error
3326 3326
 	return err
3327 3327
 }
3328 3328
 
@@ -3332,11 +3332,10 @@ func GetSingleCancelOrder(id int64, orgid int64) (info []*models.CancelStockInfo
3332 3332
 	return info, err
3333 3333
 }
3334 3334
 
3335
-func UpdateCancelOut(list []*models.WarehousingInfo, count int64) {
3335
+func UpdateCancelOut(list []*models.WarehousingInfo, count int64) error {
3336 3336
 
3337 3337
 	//遍历循环入库数据
3338
-	for _, item := range list {
3339
-
3338
+	for i, item := range list {
3340 3339
 		//计算每个批次剩余库存与入库数据的差 然后和退库数量比较
3341 3340
 		if (item.WarehousingCount - item.StockCount) >= count {
3342 3341
 			//如果差距大于退库数量,则直接把退库数量增加到该批次中
@@ -3344,7 +3343,7 @@ func UpdateCancelOut(list []*models.WarehousingInfo, count int64) {
3344 3343
 				GoodId:        item.GoodId,
3345 3344
 				OrgId:         item.OrgId,
3346 3345
 				WarehousingId: item.WarehousingId,
3347
-				StockCount:    count,
3346
+				StockCount:    item.StockCount + count,
3348 3347
 			}
3349 3348
 			UpdateWarehousingCount(&info, item.GoodId, item.OrgId, item.WarehousingId)
3350 3349
 			break
@@ -3354,19 +3353,61 @@ func UpdateCancelOut(list []*models.WarehousingInfo, count int64) {
3354 3353
 
3355 3354
 			//如果该批次小于退库数量,则先出库该相差数量
3356 3355
 			var countOne = item.WarehousingCount - item.StockCount
3356
+
3357 3357
 			infoOne := models.WarehousingInfo{
3358 3358
 				GoodId:        item.GoodId,
3359 3359
 				OrgId:         item.OrgId,
3360 3360
 				WarehousingId: item.WarehousingId,
3361
-				StockCount:    countOne,
3361
+				StockCount:    countOne + item.StockCount,
3362 3362
 			}
3363 3363
 
3364
-			UpdateWarehousingCount(&infoOne, item.GoodId, item.OrgId, item.WarehousingId)
3364
+			err := UpdateWarehousingCount(&infoOne, item.GoodId, item.OrgId, item.WarehousingId)
3365
+			if err == nil {
3366
+				//剩余的出库到第二个批次
3367
+				var countTwo = count - countOne
3368
+				infos := append(list, list[i+1])
3369
+				var idArray []*models.WarehousingInfo
3370
+				for _, it := range infos {
3371
+					if it.WarehousingId != item.WarehousingId {
3372
+						idArray = append(idArray, it)
3373
+					}
3374
+				}
3375
+				//查询更新后的库存
3376
+				UpdateCancelOut(idArray, countTwo)
3377
+				return err
3378
+			} else {
3379
+				return err
3380
+			}
3365 3381
 
3366
-			//剩余的出库到第二个批次
3367
-			var countTwo = count - countOne
3368
-			UpdateCancelOut(list, countTwo)
3369 3382
 		}
3370 3383
 	}
3371 3384
 
3385
+	return err
3386
+}
3387
+
3388
+func GetCancelStockOrderPrint(idstr []string) (info []*models.CancelStockInfo, err error) {
3389
+
3390
+	if len(idstr) > 0 {
3391
+		err = XTReadDB().Model(&info).Where("cancel_stock_id in(?)", idstr).Preload("GoodInfo", "status = 1").Find(&info).Error
3392
+	} else {
3393
+		err = XTReadDB().Model(&info).Preload("GoodInfo", "status = 1").Find(&info).Error
3394
+	}
3395
+	return info, err
3396
+}
3397
+
3398
+func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3399
+
3400
+	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3401
+
3402
+	if startime > 0 {
3403
+		db = db.Where("x.ctime >=?", startime)
3404
+	}
3405
+	if endtime > 0 {
3406
+		db = db.Where("x.ctime <= ?", endtime)
3407
+	}
3408
+	if orgid > 0 {
3409
+		db = db.Where("x.org_id = ?", orgid)
3410
+	}
3411
+	err = db.Select("x.good_id,sum(x.count) as count").Group("x.good_id").Scan(&info).Error
3412
+	return info, err
3372 3413
 }

+ 28 - 13
service/warhouse_service.go View File

@@ -522,23 +522,30 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
522 522
 	// 将该批次的剩余库存数量转换为拆零数量
523 523
 
524 524
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
525
-	fmt.Println("88i8uu7777777777777777777777777777", stock_number)
526
-	fmt.Println("77777544656666666666666666", deliver_number)
525
+
527 526
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
528 527
 	if stock_number >= deliver_number {
528
+		fmt.Println("价格表32322222222222222222232322332", advice.Price)
529 529
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
530 530
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
531 531
 			WarehouseOutId:          warehouseout.ID,
532 532
 			Status:                  1,
533 533
 			Ctime:                   time.Now().Unix(),
534
-			Remark:                  "",
534
+			Remark:                  advice.Remark,
535 535
 			OrgId:                   orgID,
536 536
 			Type:                    1,
537
-			Manufacturer:            0,
538
-			Dealer:                  0,
537
+			Manufacturer:            advice.Manufacturer,
538
+			Dealer:                  advice.Dealer,
539 539
 			IsSys:                   0,
540 540
 			SysRecordTime:           advice.Ctime,
541 541
 			DrugId:                  advice.DrugId,
542
+			ExpiryDate:              advice.ExpiryDate,
543
+			ProductDate:             advice.ProductDate,
544
+			Number:                  advice.Number,
545
+			BatchNumber:             advice.BatchNumber,
546
+			Count:                   advice.Count,
547
+			RetailPrice:             advice.RetailPrice,
548
+			Price:                   advice.Price,
542 549
 		}
543 550
 
544 551
 		warehouseOutInfo.Count = deliver_number
@@ -591,14 +598,21 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
591 598
 			WarehouseOutId:          warehouseout.ID,
592 599
 			Status:                  1,
593 600
 			Ctime:                   time.Now().Unix(),
594
-			Remark:                  "",
601
+			Remark:                  advice.Remark,
595 602
 			OrgId:                   orgID,
596 603
 			Type:                    1,
597
-			Manufacturer:            0,
598
-			Dealer:                  0,
604
+			Manufacturer:            advice.Manufacturer,
605
+			Dealer:                  advice.Dealer,
599 606
 			IsSys:                   0,
600 607
 			SysRecordTime:           advice.Ctime,
601 608
 			DrugId:                  advice.DrugId,
609
+			ExpiryDate:              advice.ExpiryDate,
610
+			ProductDate:             advice.ProductDate,
611
+			Number:                  advice.Number,
612
+			BatchNumber:             advice.BatchNumber,
613
+			Count:                   advice.Count,
614
+			RetailPrice:             advice.RetailPrice,
615
+			Price:                   advice.Price,
602 616
 		}
603 617
 
604 618
 		warehouseOutInfo.Count = stock_number
@@ -1130,6 +1144,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1130 1144
 	fmt.Println("8888888888888888888", deliver_number)
1131 1145
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1132 1146
 	if stock_number >= deliver_number {
1147
+		fmt.Println("g2332232332323232232323322332", goods.Price)
1133 1148
 		warehouseOutInfo := &models.WarehouseOutInfo{
1134 1149
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1135 1150
 			WarehouseOutId:          warehouseOut.ID,
@@ -1152,8 +1167,8 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1152 1167
 			LicenseNumber:           goods.LicenseNumber,
1153 1168
 		}
1154 1169
 		warehouseOutInfo.Count = goods.Count
1155
-		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1156
-		warehouseOutInfo.Price = stockInInfo.Price
1170
+		//stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1171
+		//warehouseOutInfo.Price = stockInInfo.Price
1157 1172
 
1158 1173
 		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1159 1174
 		if errOne != nil {
@@ -1202,9 +1217,9 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1202 1217
 			LicenseNumber:           goods.LicenseNumber,
1203 1218
 		}
1204 1219
 		warehouseOutInfo.Count = stock_number
1205
-		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1206
-		fmt.Println("stockINFO2232232323223322332323223323223", stockInInfo)
1207
-		warehouseOutInfo.Price = stockInInfo.Price
1220
+		//stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1221
+		//fmt.Println("stockINFO2232232323223322332323223323223", stockInInfo)
1222
+		//warehouseOutInfo.Price = stockInInfo.Price
1208 1223
 
1209 1224
 		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1210 1225
 		fmt.Println("errOne2232323232323232333232323", errOne)