Quellcode durchsuchen

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx vor 3 Jahren
Ursprung
Commit
5c912280ab

+ 1 - 1
conf/app.conf Datei anzeigen

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3
 runmode = dev
3
 runmode = dev
4
 
4
 
5
 #
5
 #

+ 204 - 104
controllers/drug_stock_api_contorller.go Datei anzeigen

71
 func (c *StockDrugApiController) CreateDrugWarehouse() {
71
 func (c *StockDrugApiController) CreateDrugWarehouse() {
72
 
72
 
73
 	warehousing_time := c.GetString("warehousing_time")
73
 	warehousing_time := c.GetString("warehousing_time")
74
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
75
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
76
 
74
 
77
 	types, _ := c.GetInt64("type", 0)
75
 	types, _ := c.GetInt64("type", 0)
78
 
76
 
100
 		Ctime:            ctime,
98
 		Ctime:            ctime,
101
 		Status:           1,
99
 		Status:           1,
102
 		WarehousingTime:  warehousingDate.Unix(),
100
 		WarehousingTime:  warehousingDate.Unix(),
103
-		Dealer:           dealer_id,
104
-		Manufacturer:     manufacturer_id,
105
 		Type:             types,
101
 		Type:             types,
106
 	}
102
 	}
107
 	service.AddSigleDrugWarehouse(&warehousing)
103
 	service.AddSigleDrugWarehouse(&warehousing)
144
 				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
140
 				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
145
 				total := float64(warehousing_count) * last_price
141
 				total := float64(warehousing_count) * last_price
146
 
142
 
147
-				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
-				//	utils.ErrorLog("retail_price")
149
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
-				//	return
151
-				//}
152
-				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
 				retail_price_total := float64(warehousing_count) * last_price
143
 				retail_price_total := float64(warehousing_count) * last_price
154
 
144
 
155
 				var productDates int64
145
 				var productDates int64
183
 
173
 
184
 				}
174
 				}
185
 
175
 
186
-				lot_number, _ := items["lot_number"].(string)
176
+				number, _ := items["number"].(string)
187
 
177
 
188
 				batch_number, _ := items["batch_number"].(string)
178
 				batch_number, _ := items["batch_number"].(string)
189
 
179
 
193
 					return
183
 					return
194
 				}
184
 				}
195
 				max_unit, _ := items["max_unit"].(string)
185
 				max_unit, _ := items["max_unit"].(string)
196
-				fmt.Println("最大单位00000000000000000000000000000000", max_unit)
186
+
197
 				if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
187
 				if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
198
 					utils.ErrorLog("min_unit")
188
 					utils.ErrorLog("min_unit")
199
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
189
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
200
 					return
190
 					return
201
 				}
191
 				}
202
 				min_unit, _ := items["min_unit"].(string)
192
 				min_unit, _ := items["min_unit"].(string)
203
-				fmt.Println("最下单位0090000000000000000000", min_unit)
193
+
204
 				var remark string
194
 				var remark string
205
 				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
195
 				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
206
 					remark = ""
196
 					remark = ""
208
 					remark = items["remark"].(string)
198
 					remark = items["remark"].(string)
209
 				}
199
 				}
210
 
200
 
201
+				manufacturer := int64(items["manufacturer"].(float64))
202
+
203
+				dealer := int64(items["dealer"].(float64))
204
+
211
 				warehouseInfo := &models.DrugWarehouseInfo{
205
 				warehouseInfo := &models.DrugWarehouseInfo{
212
 					WarehousingOrder: warehousing.WarehousingOrder,
206
 					WarehousingOrder: warehousing.WarehousingOrder,
213
 					WarehousingId:    warehousing.ID,
207
 					WarehousingId:    warehousing.ID,
214
 					DrugId:           drug_id,
208
 					DrugId:           drug_id,
215
-					Number:           lot_number,
209
+					Number:           number,
216
 					ProductDate:      productDates,
210
 					ProductDate:      productDates,
217
 					ExpiryDate:       expiryDates,
211
 					ExpiryDate:       expiryDates,
218
 					WarehousingCount: warehousing_count,
212
 					WarehousingCount: warehousing_count,
223
 					Remark:           remark,
217
 					Remark:           remark,
224
 					OrgId:            adminUserInfo.CurrentOrgId,
218
 					OrgId:            adminUserInfo.CurrentOrgId,
225
 					Type:             types,
219
 					Type:             types,
226
-					Manufacturer:     manufacturer_id,
227
-					Dealer:           dealer_id,
228
-					//RetailPrice:      retail_price,
220
+					Manufacturer:     manufacturer,
221
+					Dealer:           dealer,
229
 					StockMaxNumber:   warehousing_count,
222
 					StockMaxNumber:   warehousing_count,
230
 					RetailTotalPrice: retail_price_total,
223
 					RetailTotalPrice: retail_price_total,
231
 					BatchNumber:      batch_number,
224
 					BatchNumber:      batch_number,
396
 	types, _ := c.GetInt64("type", 0)
389
 	types, _ := c.GetInt64("type", 0)
397
 	keywords := c.GetString("keywords")
390
 	keywords := c.GetString("keywords")
398
 
391
 
399
-	fmt.Println(start_time)
400
-	fmt.Println(end_time)
401
-
402
 	timeLayout := "2006-01-02"
392
 	timeLayout := "2006-01-02"
403
 	loc, _ := time.LoadLocation("Local")
393
 	loc, _ := time.LoadLocation("Local")
404
 	var startTime int64
394
 	var startTime int64
423
 	}
413
 	}
424
 
414
 
425
 	adminUserInfo := c.GetAdminUserInfo()
415
 	adminUserInfo := c.GetAdminUserInfo()
426
-	warehouseList, total, err := service.FindAllDrugWarehousingList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
416
+	fmt.Println("hhh2h3h23h2h32h3h2h32h32h3h2h3", keywords)
417
+	//按药品名称搜索
418
+	var ids []int64
419
+	var idArray []int64
420
+	list, _ := service.GetDrugNameByKeyword(keywords, adminUserInfo.CurrentOrgId)
421
+	for _, item := range list {
422
+		ids = append(ids, item.ID)
423
+	}
424
+
425
+	//查找入库单详情
426
+	if len(ids) > 0 {
427
+		info, _ := service.GetDrugWarehouseOrderDetailTwo(ids, adminUserInfo.CurrentOrgId, startTime, endTime)
428
+		for _, it := range info {
429
+			idArray = append(idArray, it.WarehousingId)
430
+		}
431
+	}
432
+
433
+	warehouseList, total, err := service.FindAllDrugWarehousingListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, idArray)
427
 	if err == nil {
434
 	if err == nil {
428
 		c.ServeSuccessJSON(map[string]interface{}{
435
 		c.ServeSuccessJSON(map[string]interface{}{
429
 			"list":  warehouseList,
436
 			"list":  warehouseList,
445
 	warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
452
 	warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
446
 
453
 
447
 	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
454
 	manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
455
+	dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
448
 	if err != nil {
456
 	if err != nil {
449
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
457
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
450
 		return
458
 		return
461
 			"info":             warehousingInfo,
469
 			"info":             warehousingInfo,
462
 			"warehousing":      warehousing,
470
 			"warehousing":      warehousing,
463
 			"manufacturerList": manufacturerList,
471
 			"manufacturerList": manufacturerList,
472
+			"dealerList":       dealerList,
464
 		})
473
 		})
465
 	} else {
474
 	} else {
466
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
475
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
472
 	warehousing_time := c.GetString("warehousing_time")
481
 	warehousing_time := c.GetString("warehousing_time")
473
 	id, _ := c.GetInt64("id", 0)
482
 	id, _ := c.GetInt64("id", 0)
474
 	types, _ := c.GetInt64("type", 0)
483
 	types, _ := c.GetInt64("type", 0)
475
-	//manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
476
-	//dealer_id, _ := c.GetInt64("dealer_id", 0)
477
 
484
 
478
 	if id == 0 {
485
 	if id == 0 {
479
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
486
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
501
 		Status:           1,
508
 		Status:           1,
502
 		WarehousingTime:  warehousingDate.Unix(),
509
 		WarehousingTime:  warehousingDate.Unix(),
503
 		Type:             warehouse.Type,
510
 		Type:             warehouse.Type,
504
-		//Dealer:           dealer_id,
505
-		//Manufacturer:     manufacturer_id,
506
 	}
511
 	}
507
 
512
 
508
 	service.EditDrugWarehousingOne(warehousing, id)
513
 	service.EditDrugWarehousingOne(warehousing, id)
548
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
553
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
549
 				total := float64(warehousing_count) * price
554
 				total := float64(warehousing_count) * price
550
 
555
 
551
-				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
552
-				//	utils.ErrorLog("retail_price")
553
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
554
-				//	return
555
-				//}
556
-				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
557
-				//retail_price_total := float64(warehousing_count) * last_price
558
-
559
 				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
556
 				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
560
 					utils.ErrorLog("last_price")
557
 					utils.ErrorLog("last_price")
561
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
558
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
596
 
593
 
597
 				}
594
 				}
598
 
595
 
599
-				if items["lot_number"] == nil || reflect.TypeOf(items["lot_number"]).String() != "string" {
600
-					utils.ErrorLog("lot_number")
601
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
602
-					return
603
-				}
604
-				number, _ := items["lot_number"].(string)
596
+				number, _ := items["number"].(string)
605
 
597
 
606
 				batch_number, _ := items["batch_number"].(string)
598
 				batch_number, _ := items["batch_number"].(string)
607
 
599
 
623
 				}
615
 				}
624
 				id := int64(items["id"].(float64))
616
 				id := int64(items["id"].(float64))
625
 
617
 
626
-				//if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "float64" {
627
-				//	utils.ErrorLog("dealer")
628
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
629
-				//	return
630
-				//}
631
-				//dealer := int64(items["dealer"].(float64))
632
-				//
633
-				if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "float64" {
634
-					utils.ErrorLog("manufacturer")
635
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
636
-					return
637
-				}
638
 				manufacturer := int64(items["manufacturer"].(float64))
618
 				manufacturer := int64(items["manufacturer"].(float64))
619
+
620
+				dealer := int64(items["dealer"].(float64))
639
 				if id == 0 {
621
 				if id == 0 {
640
 					warehouseInfo := &models.DrugWarehouseInfo{
622
 					warehouseInfo := &models.DrugWarehouseInfo{
641
 						WarehousingOrder: warehouse.WarehousingOrder,
623
 						WarehousingOrder: warehouse.WarehousingOrder,
653
 						OrgId:            adminUserInfo.CurrentOrgId,
635
 						OrgId:            adminUserInfo.CurrentOrgId,
654
 						Type:             types,
636
 						Type:             types,
655
 						Manufacturer:     manufacturer,
637
 						Manufacturer:     manufacturer,
656
-						//Dealer:           dealer,
638
+						Dealer:           dealer,
657
 						RetailPrice:      last_price,
639
 						RetailPrice:      last_price,
658
 						RetailTotalPrice: retail_price_total,
640
 						RetailTotalPrice: retail_price_total,
659
 						BatchNumber:      batch_number,
641
 						BatchNumber:      batch_number,
680
 						OrgId:            adminUserInfo.CurrentOrgId,
662
 						OrgId:            adminUserInfo.CurrentOrgId,
681
 						Type:             types,
663
 						Type:             types,
682
 						Manufacturer:     manufacturer,
664
 						Manufacturer:     manufacturer,
683
-						//Dealer:           dealer,
665
+						Dealer:           dealer,
684
 						RetailPrice:      last_price,
666
 						RetailPrice:      last_price,
685
 						RetailTotalPrice: retail_price_total,
667
 						RetailTotalPrice: retail_price_total,
686
 						StockMaxNumber:   warehousing_count,
668
 						StockMaxNumber:   warehousing_count,
687
 						MaxUnit:          max_unit,
669
 						MaxUnit:          max_unit,
688
 						MinUnit:          min_unit,
670
 						MinUnit:          min_unit,
671
+						BatchNumber:      batch_number,
689
 					}
672
 					}
690
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
673
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
691
 				}
674
 				}
1122
 }
1105
 }
1123
 
1106
 
1124
 func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1107
 func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1125
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1126
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1108
+
1127
 	types, _ := c.GetInt64("type", 0)
1109
 	types, _ := c.GetInt64("type", 0)
1128
 
1110
 
1129
 	ctime := time.Now().Unix()
1111
 	ctime := time.Now().Unix()
1156
 		Ctime:                   ctime,
1138
 		Ctime:                   ctime,
1157
 		Status:                  1,
1139
 		Status:                  1,
1158
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1140
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1159
-		Dealer:                  dealer_id,
1160
-		Manufacturer:            manufacturer_id,
1161
 		Type:                    types,
1141
 		Type:                    types,
1162
 	}
1142
 	}
1163
-	service.AddSigleDrugWarehouseOut(&warehouseOut)
1143
+
1164
 	dataBody := make(map[string]interface{}, 0)
1144
 	dataBody := make(map[string]interface{}, 0)
1165
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1145
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1166
 	if err != nil {
1146
 	if err != nil {
1199
 				}
1179
 				}
1200
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1180
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1201
 
1181
 
1202
-				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
1203
-					utils.ErrorLog("last_price")
1204
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1205
-					return
1206
-				}
1207
-				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1208
-
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)
1209
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1189
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1210
 
1190
 
1211
 				total := float64(count) * price
1191
 				total := float64(count) * price
1212
-				retail_price_total := float64(count) * last_price
1192
+				retail_price_total := float64(count) * price
1213
 				remark := items["remark"].(string)
1193
 				remark := items["remark"].(string)
1214
 				max_unit := items["max_unit"].(string)
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)
1201
+				var productDates int64
1202
+				var expiryDates int64
1203
+				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
1204
+					expiryDates = 0
1205
+				} else {
1206
+					if len(items["expiry_date"].(string)) == 0 {
1207
+						expiryDates = 0
1208
+
1209
+					} else {
1210
+						expiryDate, _ := items["expiry_date"].(string)
1211
+						expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
1212
+						expiryDates = expiry_date.Unix()
1213
+
1214
+					}
1215
+
1216
+				}
1217
+				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
1218
+					productDates = 0
1219
+				} else {
1220
+					if len(items["product_date"].(string)) == 0 {
1221
+						productDates = 0
1222
+
1223
+					} else {
1224
+						productDate, _ := items["product_date"].(string)
1225
+						product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
1226
+						productDates = product_date.Unix()
1227
+					}
1228
+
1229
+				}
1215
 
1230
 
1216
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1231
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1217
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1232
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1225
 					Remark:                  remark,
1240
 					Remark:                  remark,
1226
 					OrgId:                   adminUserInfo.CurrentOrgId,
1241
 					OrgId:                   adminUserInfo.CurrentOrgId,
1227
 					Type:                    types,
1242
 					Type:                    types,
1228
-					Manufacturer:            manufacturer_id,
1229
-					Dealer:                  dealer_id,
1230
-					RetailPrice:             last_price,
1243
+					Manufacturer:            manufacturer,
1244
+					Dealer:                  dealer,
1245
+					RetailPrice:             price,
1231
 					RetailTotalPrice:        retail_price_total,
1246
 					RetailTotalPrice:        retail_price_total,
1232
 					CountUnit:               max_unit,
1247
 					CountUnit:               max_unit,
1248
+					ExpiryDate:              expiryDates,
1249
+					ProductDate:             productDates,
1250
+					Number:                  number,
1251
+					BatchNumber:             batch_number,
1252
+					IsSys:                   0,
1233
 				}
1253
 				}
1234
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1254
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1235
 
1255
 
1238
 	}
1258
 	}
1239
 
1259
 
1240
 	//调用出库逻辑
1260
 	//调用出库逻辑
1241
-	//for _, item := range warehousingOutInfo {
1242
-	//
1243
-	//	// 出库流程
1244
-	//	// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1245
-	//	drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
1246
-	//	if drup.ID > 0 {
1247
-	//		prescribingNumber := item.Count
1248
-	//
1249
-	//		service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
1250
-	//
1251
-	//	}
1252
-	//
1253
-	//}
1261
+	for _, item := range warehousingOutInfo {
1262
+		//获取药品库存
1263
+		info, _ := service.GetDrugTotalCount(item.DrugId, item.OrgId)
1264
+		if item.Count > info.Count {
1265
+
1266
+			goodObj, _ := service.GetDrugByGoodId(item.DrugId)
1267
+			c.ServeSuccessJSON(map[string]interface{}{
1268
+				"msg":        "1",
1269
+				"drug_name":  goodObj.DrugName,
1270
+				"dose":       goodObj.Dose,
1271
+				"dose_unit":  goodObj.DoseUnit,
1272
+				"min_number": goodObj.MinNumber,
1273
+				"min_unit":   goodObj.MinUnit,
1274
+				"max_unit":   goodObj.MaxUnit,
1275
+			})
1276
+			return
1277
+		} else {
1278
+			service.AddSigleDrugWarehouseOut(&warehouseOut)
1279
+			// 出库流程
1280
+			// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1281
+			drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
1282
+			if drup.ID > 0 {
1283
+				prescribingNumber := item.Count
1284
+				service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
1285
+			}
1286
+		}
1254
 
1287
 
1255
-	errs := service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
1256
-	info, _ := service.FindLastDrugWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
1257
-	if errs != nil {
1258
-		utils.ErrorLog(errs.Error())
1259
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
1260
-		return
1261
 	}
1288
 	}
1262
 
1289
 
1290
+	//errs := service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
1291
+	//info, _ := service.FindLastDrugWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
1292
+	//if errs != nil {
1293
+	//	utils.ErrorLog(errs.Error())
1294
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
1295
+	//	return
1296
+	//}
1297
+
1263
 	c.ServeSuccessJSON(map[string]interface{}{
1298
 	c.ServeSuccessJSON(map[string]interface{}{
1264
-		"info":                  info,
1265
-		"msg":                   "出库成功",
1266
-		"warehousing_out_order": warehousing_out_order,
1299
+		"msg":        "2",
1300
+		"drug_name":  "",
1301
+		"dose":       "",
1302
+		"dose_unit":  "",
1303
+		"min_number": "",
1304
+		"min_unit":   "",
1305
+		"max_unit":   "",
1267
 	})
1306
 	})
1268
 
1307
 
1269
 }
1308
 }
1298
 	}
1337
 	}
1299
 
1338
 
1300
 	adminUserInfo := c.GetAdminUserInfo()
1339
 	adminUserInfo := c.GetAdminUserInfo()
1301
-	warehouseOutList, total, err := service.FindAllDrugWarehouseOutList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
1340
+
1341
+	var ids []int64
1342
+	var goodids []int64
1343
+	if len(keywords) > 0 {
1344
+		//查询商品名称
1345
+		list, _ := service.GetDrugNameByKeyword(keywords, adminUserInfo.CurrentOrgId)
1346
+		for _, item := range list {
1347
+			goodids = append(goodids, item.ID)
1348
+		}
1349
+
1350
+		if len(goodids) > 0 {
1351
+			//出库详情但里面查询
1352
+			info, _ := service.GetDrugWarehouseOrderDetail(goodids, adminUserInfo.CurrentOrgId, startTime, endTime)
1353
+			for _, it := range info {
1354
+				ids = append(ids, it.WarehouseOutId)
1355
+			}
1356
+		}
1357
+
1358
+	}
1359
+
1360
+	warehouseOutList, total, err := service.FindAllDrugWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids)
1302
 	fmt.Println(err)
1361
 	fmt.Println(err)
1303
 	if err == nil {
1362
 	if err == nil {
1304
 		c.ServeSuccessJSON(map[string]interface{}{
1363
 		c.ServeSuccessJSON(map[string]interface{}{
1351
 	warehouseOutInfo, _ := service.FindDrugWarehouseOutInfoById(id, adminInfo.CurrentOrgId)
1410
 	warehouseOutInfo, _ := service.FindDrugWarehouseOutInfoById(id, adminInfo.CurrentOrgId)
1352
 	warehouseOut, _ := service.FindDrugWareHouseOutById(id, adminInfo.CurrentOrgId)
1411
 	warehouseOut, _ := service.FindDrugWareHouseOutById(id, adminInfo.CurrentOrgId)
1353
 	manulist, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
1412
 	manulist, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
1413
+	dealerList, _ := service.GetAllDealerList(adminInfo.CurrentOrgId)
1354
 	c.ServeSuccessJSON(map[string]interface{}{
1414
 	c.ServeSuccessJSON(map[string]interface{}{
1355
-		"list":     warehouseOutInfo,
1356
-		"info":     warehouseOut,
1357
-		"manulist": manulist,
1415
+		"list":       warehouseOutInfo,
1416
+		"info":       warehouseOut,
1417
+		"manulist":   manulist,
1418
+		"dealerList": dealerList,
1358
 	})
1419
 	})
1359
 
1420
 
1360
 }
1421
 }
1362
 	warehouse_out_time := c.GetString("warehouse_out_time")
1423
 	warehouse_out_time := c.GetString("warehouse_out_time")
1363
 	id, _ := c.GetInt64("id", 0)
1424
 	id, _ := c.GetInt64("id", 0)
1364
 	types, _ := c.GetInt64("type", 0)
1425
 	types, _ := c.GetInt64("type", 0)
1365
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1366
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1367
 
1426
 
1368
 	if id == 0 {
1427
 	if id == 0 {
1369
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1428
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1387
 		ID:               warehouseOut.ID,
1446
 		ID:               warehouseOut.ID,
1388
 		Mtime:            mtime,
1447
 		Mtime:            mtime,
1389
 		WarehouseOutTime: warehouseOutDate.Unix(),
1448
 		WarehouseOutTime: warehouseOutDate.Unix(),
1390
-		Manufacturer:     manufacturer_id,
1391
-		Dealer:           dealer_id,
1392
 	}
1449
 	}
1393
 
1450
 
1394
 	service.EditDrugWarehouseOut(tempWarehouseOut)
1451
 	service.EditDrugWarehouseOut(tempWarehouseOut)
1431
 					return
1488
 					return
1432
 				}
1489
 				}
1433
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1490
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1434
-
1491
+				fmt.Println("price23223232323232323232323232322322", price)
1435
 				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
1492
 				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
1436
 					utils.ErrorLog("retail_price")
1493
 					utils.ErrorLog("retail_price")
1437
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1494
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1451
 				}
1508
 				}
1452
 				id := int64(items["id"].(float64))
1509
 				id := int64(items["id"].(float64))
1453
 
1510
 
1511
+				dealer := int64(items["dealer"].(float64))
1512
+				manufacturer := int64(items["manufacturer"].(float64))
1513
+
1514
+				batch_number := items["batch_number"].(string)
1515
+				number := items["number"].(string)
1516
+
1517
+				var productDates int64
1518
+				var expiryDates int64
1519
+				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
1520
+					expiryDates = 0
1521
+				} else {
1522
+					if len(items["expiry_date"].(string)) == 0 {
1523
+						expiryDates = 0
1524
+
1525
+					} else {
1526
+						expiryDate, _ := items["expiry_date"].(string)
1527
+						expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
1528
+						expiryDates = expiry_date.Unix()
1529
+
1530
+					}
1531
+
1532
+				}
1533
+				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
1534
+					productDates = 0
1535
+				} else {
1536
+					if len(items["product_date"].(string)) == 0 {
1537
+						productDates = 0
1538
+
1539
+					} else {
1540
+						productDate, _ := items["product_date"].(string)
1541
+						product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
1542
+						productDates = product_date.Unix()
1543
+					}
1544
+
1545
+				}
1454
 				if id == 0 {
1546
 				if id == 0 {
1455
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1547
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1456
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1548
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1464
 						Remark:                  remark,
1556
 						Remark:                  remark,
1465
 						OrgId:                   adminUserInfo.CurrentOrgId,
1557
 						OrgId:                   adminUserInfo.CurrentOrgId,
1466
 						Type:                    types,
1558
 						Type:                    types,
1467
-						Manufacturer:            manufacturer_id,
1468
-						Dealer:                  dealer_id,
1559
+						Manufacturer:            manufacturer,
1560
+						Dealer:                  dealer,
1469
 						IsSys:                   0,
1561
 						IsSys:                   0,
1470
 						SysRecordTime:           0,
1562
 						SysRecordTime:           0,
1471
 						RetailPrice:             retail_price,
1563
 						RetailPrice:             retail_price,
1472
 						RetailTotalPrice:        retail_price_total,
1564
 						RetailTotalPrice:        retail_price_total,
1565
+						BatchNumber:             batch_number,
1566
+						Number:                  number,
1567
+						ProductDate:             productDates,
1568
+						ExpiryDate:              expiryDates,
1473
 					}
1569
 					}
1474
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1570
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1475
 
1571
 
1502
 						OrgId:                   adminUserInfo.CurrentOrgId,
1598
 						OrgId:                   adminUserInfo.CurrentOrgId,
1503
 						Mtime:                   time.Now().Unix(),
1599
 						Mtime:                   time.Now().Unix(),
1504
 						Type:                    types,
1600
 						Type:                    types,
1505
-						Manufacturer:            manufacturer_id,
1506
-						Dealer:                  dealer_id,
1601
+						Manufacturer:            manufacturer,
1602
+						Dealer:                  dealer,
1507
 						IsSys:                   is_sys,
1603
 						IsSys:                   is_sys,
1508
 						SysRecordTime:           sys_record_time,
1604
 						SysRecordTime:           sys_record_time,
1509
 						RetailPrice:             retail_price,
1605
 						RetailPrice:             retail_price,
1510
 						RetailTotalPrice:        retail_price_total,
1606
 						RetailTotalPrice:        retail_price_total,
1607
+						BatchNumber:             batch_number,
1608
+						Number:                  number,
1609
+						ProductDate:             productDates,
1610
+						ExpiryDate:              expiryDates,
1511
 					}
1611
 					}
1512
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1612
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1513
 				}
1613
 				}

+ 5 - 1
controllers/gobal_config_api_controller.go Datei anzeigen

2023
 	id, _ := c.GetInt64("id")
2023
 	id, _ := c.GetInt64("id")
2024
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2024
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2025
 	list, err := service.GetSingleOrderDetail(id, orgId)
2025
 	list, err := service.GetSingleOrderDetail(id, orgId)
2026
+	dealerList, err := service.GetAllDealerList(orgId)
2027
+	manufacturerList, err := service.GetAllManufacturerList(orgId)
2026
 	if err != nil {
2028
 	if err != nil {
2027
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2029
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2028
 		return
2030
 		return
2029
 	}
2031
 	}
2030
 	c.ServeSuccessJSON(map[string]interface{}{
2032
 	c.ServeSuccessJSON(map[string]interface{}{
2031
-		"list": list,
2033
+		"list":             list,
2034
+		"dealerList":       dealerList,
2035
+		"manufacturerList": manufacturerList,
2032
 	})
2036
 	})
2033
 }
2037
 }
2034
 
2038
 

+ 4 - 0
controllers/manager_center_api_controller.go Datei anzeigen

2198
 
2198
 
2199
 	list, err := service.GetAllDrugList(orgId)
2199
 	list, err := service.GetAllDrugList(orgId)
2200
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2200
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2201
+	dealerList, _ := service.GetAllDealerList(orgId)
2201
 	if err == nil {
2202
 	if err == nil {
2202
 		c.ServeSuccessJSON(map[string]interface{}{
2203
 		c.ServeSuccessJSON(map[string]interface{}{
2203
 			"list":             list,
2204
 			"list":             list,
2204
 			"manufacturerList": manufacturerList,
2205
 			"manufacturerList": manufacturerList,
2206
+			"dealerList":       dealerList,
2205
 		})
2207
 		})
2206
 	} else {
2208
 	} else {
2207
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2209
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2213
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2215
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2214
 	list, err := service.GetSearchDrugList(keyword, orgId)
2216
 	list, err := service.GetSearchDrugList(keyword, orgId)
2215
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2217
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2218
+	dealerList, _ := service.GetAllDealerList(orgId)
2216
 	if err == nil {
2219
 	if err == nil {
2217
 		c.ServeSuccessJSON(map[string]interface{}{
2220
 		c.ServeSuccessJSON(map[string]interface{}{
2218
 			"list":             list,
2221
 			"list":             list,
2219
 			"manufacturerList": manufacturerList,
2222
 			"manufacturerList": manufacturerList,
2223
+			"dealerList":       dealerList,
2220
 		})
2224
 		})
2221
 	} else {
2225
 	} else {
2222
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2226
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 6 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Datei anzeigen

3633
 
3633
 
3634
 		//查询是否有库存
3634
 		//查询是否有库存
3635
 		for _, item := range consumables {
3635
 		for _, item := range consumables {
3636
-			warehouse, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
3637
-			fmt.Println("库存数量00000000000000000000", warehouse.StockCount)
3638
-			if err != nil {
3636
+			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
3637
+
3638
+			if item.Count > warehouse.Count {
3639
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3639
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3640
 				c.ServeSuccessJSON(map[string]interface{}{
3640
 				c.ServeSuccessJSON(map[string]interface{}{
3641
 					"message":            "1",
3641
 					"message":            "1",
4260
 	fmt.Println("前端数据9999999999999", beforePrepares)
4260
 	fmt.Println("前端数据9999999999999", beforePrepares)
4261
 	//查询是否有库存
4261
 	//查询是否有库存
4262
 	for _, item := range beforePrepares {
4262
 	for _, item := range beforePrepares {
4263
-		warehouse, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
4264
-		fmt.Println("库存数量00000000000000000000", warehouse.StockCount)
4265
-		if err != nil {
4263
+		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
4264
+
4265
+		if item.Count > warehouse.Count {
4266
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4266
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4267
 			c.ServeSuccessJSON(map[string]interface{}{
4267
 			c.ServeSuccessJSON(map[string]interface{}{
4268
 				"message":            "1",
4268
 				"message":            "1",

+ 87 - 30
controllers/stock_in_api_controller.go Datei anzeigen

91
 	beego.Router("/api/good/getsingleoutorderdetail", &StockManagerApiController{}, "Get:GetSingleOutOrderDetail")
91
 	beego.Router("/api/good/getsingleoutorderdetail", &StockManagerApiController{}, "Get:GetSingleOutOrderDetail")
92
 	beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
92
 	beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
93
 	beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
93
 	beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
94
+	beego.Router("/api/stock/getsinglecancelorder", &StockManagerApiController{}, "Get:GetSingleCancelOrder")
95
+	beego.Router("/api/stock/getcancelstockorderprint", &StockManagerApiController{}, "Get:GetCancelStockOrderPrint")
94
 
96
 
95
 }
97
 }
96
 
98
 
562
 				var productDates int64
564
 				var productDates int64
563
 				var expiryDates int64
565
 				var expiryDates int64
564
 
566
 
565
-				fmt.Println()
566
-
567
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
567
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
568
 					expiryDates = 0
568
 					expiryDates = 0
569
 				} else {
569
 				} else {
1087
 	operation_time := time.Now().Unix()
1087
 	operation_time := time.Now().Unix()
1088
 	creater := adminUserInfo.AdminUser.Id
1088
 	creater := adminUserInfo.AdminUser.Id
1089
 
1089
 
1090
-	_, errcode := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1091
 	warehouseOut := models.WarehouseOut{
1090
 	warehouseOut := models.WarehouseOut{
1092
 		WarehouseOutOrderNumber: warehousing_out_order,
1091
 		WarehouseOutOrderNumber: warehousing_out_order,
1093
 		OperationTime:           operation_time,
1092
 		OperationTime:           operation_time,
1098
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1097
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1099
 		Type:                    types,
1098
 		Type:                    types,
1100
 	}
1099
 	}
1101
-	if errcode == gorm.ErrRecordNotFound {
1102
-		service.AddSigleWarehouseOut(&warehouseOut)
1103
-	}
1104
 
1100
 
1105
 	dataBody := make(map[string]interface{}, 0)
1101
 	dataBody := make(map[string]interface{}, 0)
1106
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1102
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1146
 					return
1142
 					return
1147
 				}
1143
 				}
1148
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1144
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
1149
-
1145
+				fmt.Println("999999992932323232323223232322323", price)
1150
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1146
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
1151
 
1147
 
1152
 				total := float64(count) * price
1148
 				total := float64(count) * price
1182
 					}
1178
 					}
1183
 					productDate = theTime.Unix()
1179
 					productDate = theTime.Unix()
1184
 				}
1180
 				}
1185
-
1181
+				license_number := items["license_number"].(string)
1186
 				warehouseOutInfo := &models.WarehouseOutInfo{
1182
 				warehouseOutInfo := &models.WarehouseOutInfo{
1187
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1183
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1188
 					WarehouseOutId:          warehouseOut.ID,
1184
 					WarehouseOutId:          warehouseOut.ID,
1201
 					ExpiryDate:              expiryDate,
1197
 					ExpiryDate:              expiryDate,
1202
 					ProductDate:             productDate,
1198
 					ProductDate:             productDate,
1203
 					Dealer:                  dealer,
1199
 					Dealer:                  dealer,
1200
+					LicenseNumber:           license_number,
1204
 				}
1201
 				}
1205
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1202
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1206
 
1203
 
1225
 	//出库逻辑
1222
 	//出库逻辑
1226
 	for _, item := range warehousingOutInfo {
1223
 	for _, item := range warehousingOutInfo {
1227
 		//查询库存
1224
 		//查询库存
1228
-		warehouse, err := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1225
+		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1229
 		fmt.Println("库存数量组吗", warehouse.Count)
1226
 		fmt.Println("库存数量组吗", warehouse.Count)
1230
-		if err != nil {
1227
+		if item.Count > warehouse.Count {
1231
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1228
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1232
 			c.ServeSuccessJSON(map[string]interface{}{
1229
 			c.ServeSuccessJSON(map[string]interface{}{
1233
 				"msg":                "1",
1230
 				"msg":                "1",
1236
 			})
1233
 			})
1237
 			return
1234
 			return
1238
 		} else {
1235
 		} else {
1236
+			fmt.Println("jiage223444444444444444444", item.Price)
1237
+			_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1238
+			if errcodes == gorm.ErrRecordNotFound {
1239
+				service.AddSigleWarehouseOut(&warehouseOut)
1240
+			}
1239
 			parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
1241
 			parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
1240
-			fmt.Println(parseDateErr)
1241
 			if parseDateErr != nil {
1242
 			if parseDateErr != nil {
1242
 				utils.ErrorLog(parseDateErr.Error())
1243
 				utils.ErrorLog(parseDateErr.Error())
1243
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1244
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1461
 
1462
 
1462
 				number := items["number"].(string)
1463
 				number := items["number"].(string)
1463
 
1464
 
1465
+				license_number := items["license_number"].(string)
1466
+				fmt.Println("hhh23h2h32h3h232h3h23h2h3h23h2h3h23h2h3", license_number)
1464
 				timeLayout := "2006-01-02"
1467
 				timeLayout := "2006-01-02"
1465
 				loc, _ := time.LoadLocation("Local")
1468
 				loc, _ := time.LoadLocation("Local")
1466
 				expiry_date := items["expiry_date"].(string)
1469
 				expiry_date := items["expiry_date"].(string)
1507
 						ProductDate:             productDate,
1510
 						ProductDate:             productDate,
1508
 						Dealer:                  dealer,
1511
 						Dealer:                  dealer,
1509
 						Manufacturer:            manufacturer,
1512
 						Manufacturer:            manufacturer,
1513
+						LicenseNumber:           license_number,
1510
 					}
1514
 					}
1511
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1515
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1512
 
1516
 
1547
 						ExpiryDate:              expiryDate,
1551
 						ExpiryDate:              expiryDate,
1548
 						ProductDate:             productDate,
1552
 						ProductDate:             productDate,
1549
 						Dealer:                  dealer,
1553
 						Dealer:                  dealer,
1554
+						LicenseNumber:           license_number,
1550
 					}
1555
 					}
1551
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1556
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1552
 				}
1557
 				}
1672
 		}
1677
 		}
1673
 	}
1678
 	}
1674
 	errs := service.CreateCancelStockInfo(cancelStockInfos)
1679
 	errs := service.CreateCancelStockInfo(cancelStockInfos)
1680
+
1681
+	// 改变入库单的值
1682
+	for _, item := range cancelStockInfos {
1683
+		fmt.Println("经理俄2433444 我认为侮辱侮辱侮辱侮辱侮辱侮辱我无污染武荣", item.GoodId, item.OrgId)
1684
+		//查询该耗材的入库记录
1685
+		list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
1686
+		//调用退库的方法
1687
+		parseDateErr := service.UpdateCancelOut(list, item.Count)
1688
+		fmt.Println("999999999999", parseDateErr)
1689
+	}
1690
+
1675
 	if errs != nil {
1691
 	if errs != nil {
1676
 		utils.ErrorLog(errs.Error())
1692
 		utils.ErrorLog(errs.Error())
1677
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1693
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1776
 func (c *StockManagerApiController) EditCancelStock() {
1792
 func (c *StockManagerApiController) EditCancelStock() {
1777
 	cancel_time := c.GetString("cancel_time")
1793
 	cancel_time := c.GetString("cancel_time")
1778
 	id, _ := c.GetInt64("id", 0)
1794
 	id, _ := c.GetInt64("id", 0)
1779
-	types, _ := c.GetInt64("type", 0)
1780
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1781
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1782
 
1795
 
1783
 	if id == 0 {
1796
 	if id == 0 {
1784
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1797
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1799
 	cancelStock, _ := service.FindCancelStockById(id, c.GetAdminUserInfo().CurrentOrgId)
1812
 	cancelStock, _ := service.FindCancelStockById(id, c.GetAdminUserInfo().CurrentOrgId)
1800
 
1813
 
1801
 	tempCancelStock := models.CancelStock{
1814
 	tempCancelStock := models.CancelStock{
1802
-		ID:           cancelStock.ID,
1803
-		Mtime:        mtime,
1804
-		ReturnTime:   cancelDate.Unix(),
1805
-		Manufacturer: manufacturer_id,
1806
-		Dealer:       dealer_id,
1815
+		ID:         cancelStock.ID,
1816
+		Mtime:      mtime,
1817
+		ReturnTime: cancelDate.Unix(),
1807
 	}
1818
 	}
1808
 
1819
 
1809
 	service.EditCancelStock(tempCancelStock)
1820
 	service.EditCancelStock(tempCancelStock)
1865
 						OrderNumber:   cancelStock.OrderNumber,
1876
 						OrderNumber:   cancelStock.OrderNumber,
1866
 						CancelStockId: cancelStock.ID,
1877
 						CancelStockId: cancelStock.ID,
1867
 						Mtime:         time.Now().Unix(),
1878
 						Mtime:         time.Now().Unix(),
1868
-						Type:          types,
1869
-						Manufacturer:  manufacturer_id,
1870
-						Dealer:        dealer_id,
1871
 					}
1879
 					}
1872
 					cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
1880
 					cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
1873
 
1881
 
1883
 						OrderNumber:   cancelStock.OrderNumber,
1891
 						OrderNumber:   cancelStock.OrderNumber,
1884
 						CancelStockId: cancelStock.ID,
1892
 						CancelStockId: cancelStock.ID,
1885
 						Mtime:         time.Now().Unix(),
1893
 						Mtime:         time.Now().Unix(),
1886
-						Type:          types,
1887
-						Manufacturer:  manufacturer_id,
1888
-						Dealer:        dealer_id,
1889
 					}
1894
 					}
1890
 					upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
1895
 					upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
1891
 				}
1896
 				}
1895
 	var errs error
1900
 	var errs error
1896
 	if len(cancelStockInfos) > 0 {
1901
 	if len(cancelStockInfos) > 0 {
1897
 		errs = service.CreateCancelStockInfo(cancelStockInfos)
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
+		}
1898
 	}
1919
 	}
1899
 
1920
 
1900
 	if len(upDateCancelStockInfos) > 0 {
1921
 	if len(upDateCancelStockInfos) > 0 {
1901
 		for _, item := range upDateCancelStockInfos {
1922
 		for _, item := range upDateCancelStockInfos {
1923
+
1902
 			errs = service.UpDateCancelStockInfo(item)
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
+			})
1903
 		}
1939
 		}
1904
 	}
1940
 	}
1905
 
1941
 
3897
 	count, _ := service.GetStockDrugCount(startTime, endTime, orgId)
3933
 	count, _ := service.GetStockDrugCount(startTime, endTime, orgId)
3898
 	outList, _ := service.GetAutoDiallysisBefor(startTime, endTime, orgId)
3934
 	outList, _ := service.GetAutoDiallysisBefor(startTime, endTime, orgId)
3899
 	autoCount, _ := service.GetOutStockTotalCountFour(startTime, endTime, orgId)
3935
 	autoCount, _ := service.GetOutStockTotalCountFour(startTime, endTime, orgId)
3900
-
3936
+	totalCount, _ := service.GetCancelOutTotalCount(startTime, endTime, orgId)
3901
 	this.ServeSuccessJSON(map[string]interface{}{
3937
 	this.ServeSuccessJSON(map[string]interface{}{
3902
-		"count":     count,
3903
-		"outList":   outList,
3904
-		"autoCount": autoCount,
3938
+		"count":      count,
3939
+		"outList":    outList,
3940
+		"autoCount":  autoCount,
3941
+		"totalCount": totalCount,
3905
 	})
3942
 	})
3906
 }
3943
 }
3907
 
3944
 
3982
 		}
4019
 		}
3983
 		endTime = theTime.Unix()
4020
 		endTime = theTime.Unix()
3984
 	}
4021
 	}
3985
-
4022
+	fmt.Println("ids2222222222222222", ids)
3986
 	list, _ := service.GetExprotStockList(orgId, ids, startTime, endTime)
4023
 	list, _ := service.GetExprotStockList(orgId, ids, startTime, endTime)
3987
 	this.ServeSuccessJSON(map[string]interface{}{
4024
 	this.ServeSuccessJSON(map[string]interface{}{
3988
 		"list": list,
4025
 		"list": list,
4026
 		"count": outCount,
4063
 		"count": outCount,
4027
 	})
4064
 	})
4028
 }
4065
 }
4066
+
4067
+func (this *StockManagerApiController) GetSingleCancelOrder() {
4068
+
4069
+	id, _ := this.GetInt64("id")
4070
+	adminUserInfo := this.GetAdminUserInfo()
4071
+	orgId := adminUserInfo.CurrentOrgId
4072
+	order, _ := service.GetSingleCancelOrder(id, orgId)
4073
+	this.ServeSuccessJSON(map[string]interface{}{
4074
+		"list": order,
4075
+	})
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
+}

+ 2 - 0
models/drug_stock.go Datei anzeigen

102
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
102
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
103
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
103
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
104
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
104
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
105
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
106
+	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
105
 }
107
 }
106
 
108
 
107
 func (DrugWarehouseOutInfo) TableName() string {
109
 func (DrugWarehouseOutInfo) TableName() string {

+ 12 - 0
models/self_drug_models.go Datei anzeigen

451
 	DrugSpec         string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
451
 	DrugSpec         string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
452
 	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
452
 	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
453
 	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
453
 	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
454
+	MaxUnit          string  `json:"max_unit"`
455
+	MinNumber        int64   `json:"min_number"`
456
+	Dose             float64 `json:"dose"`
457
+	DoseUnit         string  `json:"dose_unit"`
454
 }
458
 }
455
 
459
 
456
 type BloodDrugCancelStockInfo struct {
460
 type BloodDrugCancelStockInfo struct {
536
 	DrugSpec                string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
540
 	DrugSpec                string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
537
 	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
541
 	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
538
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
542
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
543
+	MaxUnit                 string  `json:"max_unit"`
544
+	MinNumber               int64   `json:"min_number"`
545
+	Dose                    float64 `json:"dose"`
546
+	DoseUnit                string  `json:"dose_unit"`
539
 }
547
 }
540
 
548
 
541
 type XtMonitorConfig struct {
549
 type XtMonitorConfig struct {
588
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
596
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
589
 	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
597
 	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
590
 	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number"`
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"`
591
 	DrugName         string  `json:"drug_name"`
600
 	DrugName         string  `json:"drug_name"`
592
 	DrugType         int64   `json:"drug_type"`
601
 	DrugType         int64   `json:"drug_type"`
593
 	MaxUnit          string  `json:"max_unit"`
602
 	MaxUnit          string  `json:"max_unit"`
608
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
617
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
609
 	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
618
 	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
610
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
619
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
620
+	BuyPrice                float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
611
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
621
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
612
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
622
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
613
 	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
623
 	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
633
 	DoseUnit                string  `json:"dose_unit"`
643
 	DoseUnit                string  `json:"dose_unit"`
634
 	LastPrice               string  `json:"last_price"`
644
 	LastPrice               string  `json:"last_price"`
635
 	DrugName                string  `json:"drug_name"`
645
 	DrugName                string  `json:"drug_name"`
646
+	Number                  string  `json:"number"`
647
+	BatchNumber             string  `json:"batch_number"`
636
 }
648
 }

+ 10 - 0
models/stock_models.go Datei anzeigen

97
 	PackingUnit       string  `json:"packing_unit"`
97
 	PackingUnit       string  `json:"packing_unit"`
98
 	TotalCount        int64   `json:"total_count"`
98
 	TotalCount        int64   `json:"total_count"`
99
 	SpecificationName string  `json:"specification_name"`
99
 	SpecificationName string  `json:"specification_name"`
100
+	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
100
 }
101
 }
101
 
102
 
102
 func (StWarehousingInfo) TableName() string {
103
 func (StWarehousingInfo) TableName() string {
146
 	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
147
 	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
147
 	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
148
 	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
148
 	Price             float64     `gorm:"column:price" json:"price"`
149
 	Price             float64     `gorm:"column:price" json:"price"`
150
+	BuyPrice          float64     `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
149
 	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
151
 	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
150
 	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
152
 	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
151
 	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
153
 	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
219
 	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
221
 	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
220
 	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
222
 	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
221
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
223
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
224
+	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
222
 }
225
 }
223
 
226
 
224
 func (WarehouseOutInfo) TableName() string {
227
 func (WarehouseOutInfo) TableName() string {
271
 	return "xt_sales_return_info"
274
 	return "xt_sales_return_info"
272
 }
275
 }
273
 
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
+
274
 type CancelStockInfo struct {
283
 type CancelStockInfo struct {
275
 	ID            int64       `gorm:"column:id" json:"id"`
284
 	ID            int64       `gorm:"column:id" json:"id"`
276
 	GoodId        int64       `gorm:"column:good_id" json:"good_id"`
285
 	GoodId        int64       `gorm:"column:good_id" json:"good_id"`
428
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
437
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
429
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
438
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
430
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
439
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
440
+	LicenseNumber           string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
431
 }
441
 }
432
 
442
 
433
 type WarehouseOutInfoTwo struct {
443
 type WarehouseOutInfoTwo struct {

+ 1 - 0
models/stock_query_models.go Datei anzeigen

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

+ 13 - 9
service/gobal_config_service.go Datei anzeigen

256
 
256
 
257
 	if len(keyword) > 0 {
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
 
263
 	if manufacturerId > 0 {
263
 	if manufacturerId > 0 {
264
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
264
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
265
 	} else {
265
 	} else {
266
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
266
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
267
 	}
267
 	}
268
 
268
 
269
 	return drugInfo, total, err
269
 	return drugInfo, total, err
327
 	}
327
 	}
328
 
328
 
329
 	if len(keyword) > 0 {
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
 	if manufacturerId > 0 {
333
 	if manufacturerId > 0 {
334
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_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.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
334
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_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.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
335
 	} else {
335
 	} else {
336
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_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.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
336
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_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.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
337
 	}
337
 	}
338
 
338
 
339
 	return outinfo, total, err
339
 	return outinfo, total, err
540
 func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
540
 func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
541
 
541
 
542
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
542
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
543
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status =1 ")
544
+	fmt.Println(table)
543
 	offset := (page - 1) * limit
545
 	offset := (page - 1) * limit
544
 	if startime > 0 {
546
 	if startime > 0 {
545
 		db = db.Where("x.ctime >=?", startime)
547
 		db = db.Where("x.ctime >=?", startime)
560
 	return list, total, err
562
 	return list, total, err
561
 }
563
 }
562
 
564
 
563
-func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64, stocktype int64) (list []*models.XtDrugWarehouseOutInfo, total int64, err error) {
565
+func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64, stocktype int64) (list []*models.VmDrugWarehouseOutInfo, total int64, err error) {
564
 
566
 
565
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
567
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
568
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
569
+	fmt.Println(table)
566
 	offset := (page - 1) * limit
570
 	offset := (page - 1) * limit
567
 	if startime > 0 {
571
 	if startime > 0 {
568
 		db = db.Where("x.ctime >=?", startime)
572
 		db = db.Where("x.ctime >=?", startime)
584
 	if stocktype == 2 {
588
 	if stocktype == 2 {
585
 		db = db.Where("x.is_sys = 1")
589
 		db = db.Where("x.is_sys = 1")
586
 	}
590
 	}
587
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.warehouse_info_id,x.ctime").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
591
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.warehouse_info_id,x.ctime,t.drug_name,t.drug_type,t.min_number,t.min_unit,t.max_unit").Joins("left join xt_base_drug as t on t.id = x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
588
 	return list, total, err
592
 	return list, total, err
589
 }
593
 }
590
 
594
 
672
 		db = db.Where("x.warehouse_out_id = ?", id)
676
 		db = db.Where("x.warehouse_out_id = ?", id)
673
 	}
677
 	}
674
 
678
 
675
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
679
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
676
 	return info, err
680
 	return info, err
677
 }
681
 }
678
 
682
 

+ 256 - 15
service/stock_service.go Datei anzeigen

418
 	if len(warehousingInfo) > 0 {
418
 	if len(warehousingInfo) > 0 {
419
 		utx := writeDb.Begin()
419
 		utx := writeDb.Begin()
420
 		if len(warehousingInfo) > 0 {
420
 		if len(warehousingInfo) > 0 {
421
-			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit) VALUES "
421
+			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number) VALUES "
422
 			insertParams := make([]string, 0)
422
 			insertParams := make([]string, 0)
423
 			insertData := make([]interface{}, 0)
423
 			insertData := make([]interface{}, 0)
424
 			for _, info := range warehousingInfo {
424
 			for _, info := range warehousingInfo {
425
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
425
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
426
 				insertData = append(insertData, info.WarehousingId)
426
 				insertData = append(insertData, info.WarehousingId)
427
 				insertData = append(insertData, info.DrugId)
427
 				insertData = append(insertData, info.DrugId)
428
 				insertData = append(insertData, info.Number)
428
 				insertData = append(insertData, info.Number)
445
 				insertData = append(insertData, info.StockMaxNumber)
445
 				insertData = append(insertData, info.StockMaxNumber)
446
 				insertData = append(insertData, info.MaxUnit)
446
 				insertData = append(insertData, info.MaxUnit)
447
 				insertData = append(insertData, info.MinUnit)
447
 				insertData = append(insertData, info.MinUnit)
448
+				insertData = append(insertData, info.BatchNumber)
448
 			}
449
 			}
449
 			thisSQL += strings.Join(insertParams, ", ")
450
 			thisSQL += strings.Join(insertParams, ", ")
450
 			err = utx.Exec(thisSQL, insertData...).Error
451
 			err = utx.Exec(thisSQL, insertData...).Error
740
 	return
741
 	return
741
 }
742
 }
742
 
743
 
744
+func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64) (list []*VMDrugWarehouse, total int64, err error) {
745
+	db := readDb.Model(&VMDrugWarehouse{})
746
+	db = db.Where("xt_drug_warehouse.org_id = ? AND xt_drug_warehouse.status = 1", orgId)
747
+	db = db.Preload("Manufacturers", "status = 1 AND org_id = ?", orgId)
748
+	db = db.Preload("Dealers", "status = 1 AND org_id = ?", orgId)
749
+	if len(keywords) > 0 {
750
+		likeKey := "%" + keywords + "%"
751
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse.creater")
752
+		db = db.Where(" sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse.warehousing_order LIKE ?  OR xt_drug_warehouse.id in(?)", likeKey, likeKey, ids).Group("xt_drug_warehouse.id")
753
+	}
754
+	if startTime > 0 {
755
+		db = db.Where("xt_drug_warehouse.operation_time >=?", startTime)
756
+	}
757
+	if endTime > 0 {
758
+		db = db.Where("xt_drug_warehouse.operation_time<= ?", endTime)
759
+	}
760
+	db = db.Count(&total)
761
+	offset := (page - 1) * limit
762
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
763
+	return
764
+}
765
+
743
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
766
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
744
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Preload("GoodInfo").Find(&list).Error
767
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Preload("GoodInfo").Find(&list).Error
745
 	return list, err
768
 	return list, err
766
 	if org_id > 0 {
789
 	if org_id > 0 {
767
 		db = db.Where("x.org_id = ?", org_id)
790
 		db = db.Where("x.org_id = ?", org_id)
768
 	}
791
 	}
769
-	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
792
+	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
770
 	return list, err
793
 	return list, err
771
 }
794
 }
772
 
795
 
963
 }
986
 }
964
 
987
 
965
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
988
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
966
-	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
989
+	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("GoodInfo", "status = 1").Find(&list).Error
967
 	return list, err
990
 	return list, err
968
 }
991
 }
969
 
992
 
1044
 	if len(warehouseOutInfo) > 0 {
1067
 	if len(warehouseOutInfo) > 0 {
1045
 		utx := writeDb.Begin()
1068
 		utx := writeDb.Begin()
1046
 		if len(warehouseOutInfo) > 0 {
1069
 		if len(warehouseOutInfo) > 0 {
1047
-			thisSQL := "INSERT INTO xt_warehouse_out_info (warehouse_out_id, good_id, good_type_id, product_date,expiry_date,count,price,total_price,remark,ctime,status,org_id,warehouse_out_order_number,type,dealer,manufacturer,number) VALUES "
1070
+			thisSQL := "INSERT INTO xt_warehouse_out_info (warehouse_out_id, good_id, good_type_id, product_date,expiry_date,count,price,total_price,remark,ctime,status,org_id,warehouse_out_order_number,type,dealer,manufacturer,number,license_number) VALUES "
1048
 			insertParams := make([]string, 0)
1071
 			insertParams := make([]string, 0)
1049
 			insertData := make([]interface{}, 0)
1072
 			insertData := make([]interface{}, 0)
1050
 			for _, info := range warehouseOutInfo {
1073
 			for _, info := range warehouseOutInfo {
1051
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1074
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1052
 				insertData = append(insertData, info.WarehouseOutId)
1075
 				insertData = append(insertData, info.WarehouseOutId)
1053
 				insertData = append(insertData, info.GoodId)
1076
 				insertData = append(insertData, info.GoodId)
1054
 				insertData = append(insertData, info.GoodTypeId)
1077
 				insertData = append(insertData, info.GoodTypeId)
1066
 				insertData = append(insertData, info.Dealer)
1089
 				insertData = append(insertData, info.Dealer)
1067
 				insertData = append(insertData, info.Manufacturer)
1090
 				insertData = append(insertData, info.Manufacturer)
1068
 				insertData = append(insertData, info.Number)
1091
 				insertData = append(insertData, info.Number)
1092
+				insertData = append(insertData, info.LicenseNumber)
1069
 			}
1093
 			}
1070
 			thisSQL += strings.Join(insertParams, ", ")
1094
 			thisSQL += strings.Join(insertParams, ", ")
1071
 			err = utx.Exec(thisSQL, insertData...).Error
1095
 			err = utx.Exec(thisSQL, insertData...).Error
1084
 	if len(warehouseOutInfo) > 0 {
1108
 	if len(warehouseOutInfo) > 0 {
1085
 		utx := writeDb.Begin()
1109
 		utx := writeDb.Begin()
1086
 		if len(warehouseOutInfo) > 0 {
1110
 		if len(warehouseOutInfo) > 0 {
1087
-			thisSQL := "INSERT INTO xt_drug_warehouse_out_info (warehouse_out_id, drug_id, product_date,expiry_date,count,price,total_price,remark,ctime,status,org_id,warehouse_out_order_number,type,dealer,manufacturer,retail_price,retail_total_price) VALUES "
1111
+			thisSQL := "INSERT INTO xt_drug_warehouse_out_info (warehouse_out_id, drug_id, product_date,expiry_date,count,price,total_price,remark,ctime,status,org_id,warehouse_out_order_number,type,dealer,manufacturer,retail_price,retail_total_price,number,batch_number) VALUES "
1088
 			insertParams := make([]string, 0)
1112
 			insertParams := make([]string, 0)
1089
 			insertData := make([]interface{}, 0)
1113
 			insertData := make([]interface{}, 0)
1090
 			for _, info := range warehouseOutInfo {
1114
 			for _, info := range warehouseOutInfo {
1091
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1115
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1092
 				insertData = append(insertData, info.WarehouseOutId)
1116
 				insertData = append(insertData, info.WarehouseOutId)
1093
 				insertData = append(insertData, info.DrugId)
1117
 				insertData = append(insertData, info.DrugId)
1094
 				insertData = append(insertData, info.ProductDate)
1118
 				insertData = append(insertData, info.ProductDate)
1106
 				insertData = append(insertData, info.Manufacturer)
1130
 				insertData = append(insertData, info.Manufacturer)
1107
 				insertData = append(insertData, info.RetailPrice)
1131
 				insertData = append(insertData, info.RetailPrice)
1108
 				insertData = append(insertData, info.RetailTotalPrice)
1132
 				insertData = append(insertData, info.RetailTotalPrice)
1109
-
1133
+				insertData = append(insertData, info.Number)
1134
+				insertData = append(insertData, info.BatchNumber)
1110
 			}
1135
 			}
1111
 			thisSQL += strings.Join(insertParams, ", ")
1136
 			thisSQL += strings.Join(insertParams, ", ")
1112
 			err = utx.Exec(thisSQL, insertData...).Error
1137
 			err = utx.Exec(thisSQL, insertData...).Error
1207
 
1232
 
1208
 }
1233
 }
1209
 
1234
 
1235
+func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64) (list []*models.DrugWarehouseOut, total int64, err error) {
1236
+	db := readDb.Model(&models.DrugWarehouseOut{})
1237
+	db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
1238
+
1239
+	if len(keywords) > 0 {
1240
+		likeKey := "%" + keywords + "%"
1241
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
1242
+
1243
+		db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse_out.warehouse_out_order_number LIKE ? or xt_drug_warehouse_out.id in(?) ", likeKey, likeKey, ids).Group("xt_drug_warehouse_out.id")
1244
+	}
1245
+
1246
+	if startTime > 0 {
1247
+		db = db.Where("xt_drug_warehouse_out.ctime >=?", startTime)
1248
+	}
1249
+	if endTime > 0 {
1250
+		db = db.Where("xt_drug_warehouse_out.ctime<= ?", endTime)
1251
+	}
1252
+	db = db.Count(&total)
1253
+	offset := (page - 1) * limit
1254
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1255
+	return list, total, err
1256
+
1257
+}
1258
+
1210
 func FindWarehouseOutInfoById(id int64) (list []*models.WarehouseOutInfo, err error) {
1259
 func FindWarehouseOutInfoById(id int64) (list []*models.WarehouseOutInfo, err error) {
1211
 	err = readDb.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? AND status = 1 AND count <> 0 AND good_id <> 0", id).Preload("GoodInfo", "status = 1").Order("good_type_id desc").Find(&list).Error
1260
 	err = readDb.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? AND status = 1 AND count <> 0 AND good_id <> 0", id).Preload("GoodInfo", "status = 1").Order("good_type_id desc").Find(&list).Error
1212
 	return list, err
1261
 	return list, err
1236
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
1285
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
1237
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1286
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1238
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1287
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1288
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
1289
+	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1239
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1290
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1240
 }
1291
 }
1241
 
1292
 
1955
 }
2006
 }
1956
 
2007
 
1957
 func FindCancelStockById(id int64, org_id int64) (cancelStock models.CancelStock, err error) {
2008
 func FindCancelStockById(id int64, org_id int64) (cancelStock models.CancelStock, err error) {
1958
-	err = readDb.Model(&models.CancelStock{}).Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Where("id = ? AND status = 1", id).First(&cancelStock).Error
2009
+	err = readDb.Model(&models.CancelStock{}).Where("id = ? AND status = 1", id).First(&cancelStock).Error
1959
 	return cancelStock, err
2010
 	return cancelStock, err
1960
 
2011
 
1961
 }
2012
 }
2396
 	OrgId                   int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
2447
 	OrgId                   int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
2397
 	DrugId                  int64            `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
2448
 	DrugId                  int64            `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
2398
 	Count                   int64            `gorm:"column:count" json:"count" form:"count"`
2449
 	Count                   int64            `gorm:"column:count" json:"count" form:"count"`
2450
+	CountUnit               string           `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
2399
 	Drug                    *Drug            `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
2451
 	Drug                    *Drug            `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
2400
 	Patients                *models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
2452
 	Patients                *models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
2401
 }
2453
 }
2976
 	if good_id > 0 {
3028
 	if good_id > 0 {
2977
 		db = db.Where("x.good_id = ?", good_id)
3029
 		db = db.Where("x.good_id = ?", good_id)
2978
 	}
3030
 	}
2979
-	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.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit").Joins("left join xt_good_information as t on t.id = x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&info).Error
3031
+	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.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&info).Error
2980
 	return info, total, err
3032
 	return info, total, err
2981
 
3033
 
2982
 }
3034
 }
2985
 	offset := (page - 1) * limit
3037
 	offset := (page - 1) * limit
2986
 
3038
 
2987
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status= 1")
3039
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status= 1")
3040
+
2988
 	if startime > 0 {
3041
 	if startime > 0 {
2989
 		db = db.Where("x.ctime>=?", startime)
3042
 		db = db.Where("x.ctime>=?", startime)
2990
 	}
3043
 	}
3070
 	if orgid > 0 {
3123
 	if orgid > 0 {
3071
 		db = db.Where("x.org_id = ?", orgid)
3124
 		db = db.Where("x.org_id = ?", orgid)
3072
 	}
3125
 	}
3073
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
3126
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
3074
 	return out, err
3127
 	return out, err
3075
 }
3128
 }
3076
 
3129
 
3098
 	if orgid > 0 {
3151
 	if orgid > 0 {
3099
 		db = db.Where("x.org_id = ?", orgid)
3152
 		db = db.Where("x.org_id = ?", orgid)
3100
 	}
3153
 	}
3101
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
3154
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
3102
 	return out, err
3155
 	return out, err
3103
 }
3156
 }
3104
 
3157
 
3139
 	if endtime > 0 {
3192
 	if endtime > 0 {
3140
 		db = db.Where("x.ctime<=?", endtime)
3193
 		db = db.Where("x.ctime<=?", endtime)
3141
 	}
3194
 	}
3142
-	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
3195
+	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
3143
 
3196
 
3144
 	return info, err
3197
 	return info, err
3145
 }
3198
 }
3182
 		db = db.Where("x.ctime<=?", endtime)
3235
 		db = db.Where("x.ctime<=?", endtime)
3183
 	}
3236
 	}
3184
 
3237
 
3185
-	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
3238
+	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
3186
 	return out, err
3239
 	return out, err
3187
 
3240
 
3188
 }
3241
 }
3216
 	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.product_date,x.expiry_date,x.number,x.batch_number,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_name").Joins("left join xt_base_drug as t on t.id =x.drug_id").Scan(&info).Error
3269
 	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.product_date,x.expiry_date,x.number,x.batch_number,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_name").Joins("left join xt_base_drug as t on t.id =x.drug_id").Scan(&info).Error
3217
 	return info, err
3270
 	return info, err
3218
 }
3271
 }
3272
+
3273
+func GetDrugNameByKeyword(keyword string, orgid int64) (basedrug []*models.XtBaseDrug, err error) {
3274
+
3275
+	db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
3276
+	likeKey := "%" + keyword + "%"
3277
+	if len(keyword) > 0 {
3278
+		db = db.Where("x.drug_name like ?", likeKey)
3279
+	}
3280
+	if orgid > 0 {
3281
+		db = db.Where("x.org_id = ?", orgid)
3282
+	}
3283
+	err = db.Find(&basedrug).Error
3284
+
3285
+	return basedrug, err
3286
+
3287
+}
3288
+
3289
+func GetDrugWarehouseOrderDetail(ids []int64, orgid int64, startime int64, endtime int64) (info []*models.XtDrugWarehouseOutInfo, err error) {
3290
+
3291
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
3292
+
3293
+	if len(ids) > 0 {
3294
+		db = db.Where("x.drug_id in(?)", ids)
3295
+	}
3296
+
3297
+	if orgid > 0 {
3298
+		db = db.Where("x.org_id = ?", orgid)
3299
+	}
3300
+	if startime > 0 {
3301
+		db = db.Where("x.ctime>=?", startime)
3302
+	}
3303
+	if endtime > 0 {
3304
+		db = db.Where("x.ctime<=?", endtime)
3305
+	}
3306
+
3307
+	err = db.Find(&info).Error
3308
+	return info, err
3309
+}
3310
+
3311
+func GetDrugWarehouseOrderDetailTwo(ids []int64, orgid int64, startime int64, endtime int64) (info []*models.XtDrugWarehouseInfo, err error) {
3312
+
3313
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3314
+
3315
+	if len(ids) > 0 {
3316
+		db = db.Where("x.drug_id in(?)", ids)
3317
+	}
3318
+
3319
+	if orgid > 0 {
3320
+		db = db.Where("x.org_id = ?", orgid)
3321
+	}
3322
+	if startime > 0 {
3323
+		db = db.Where("x.ctime>=?", startime)
3324
+	}
3325
+	if endtime > 0 {
3326
+		db = db.Where("x.ctime<=?", endtime)
3327
+	}
3328
+
3329
+	err = db.Find(&info).Error
3330
+	return info, err
3331
+}
3332
+
3333
+func GetDrugTotalCount(drugid int64, orgid int64) (info models.VmDrugWarehouseInfo, err error) {
3334
+
3335
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3336
+	if drugid > 0 {
3337
+		db = db.Where("x.drug_id = ?", drugid)
3338
+	}
3339
+	if orgid > 0 {
3340
+		db = db.Where("x.org_id = ?", orgid)
3341
+	}
3342
+	err = db.Select("x.drug_id,sum(x.stock_max_number) as count").Find(&info).Error
3343
+	return info, err
3344
+}
3345
+
3346
+func GetDrugByGoodId(drugid int64) (models.BaseDrugLib, error) {
3347
+
3348
+	lib := models.BaseDrugLib{}
3349
+	err := XTReadDB().Model(&lib).Where("id = ? and status = 1", drugid).Find(&lib).Error
3350
+	return lib, err
3351
+}
3352
+
3353
+func GetWarehoureOrderInfoList(goodid int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3354
+
3355
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
3356
+
3357
+	if goodid > 0 {
3358
+		db = db.Where("x.good_id = ?", goodid)
3359
+	}
3360
+
3361
+	if orgid > 0 {
3362
+		db = db.Where("x.org_id = ?", orgid)
3363
+	}
3364
+
3365
+	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
3366
+	return info, err
3367
+}
3368
+
3369
+func UpdateWarehousingCount(info *models.WarehousingInfo, goodid int64, orgid int64, warehousingId int64) error {
3370
+
3371
+	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
3372
+	return err
3373
+}
3374
+
3375
+func GetSingleCancelOrder(id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
3376
+
3377
+	err = XTReadDB().Where("cancel_stock_id = ? and status = 1 and org_id = ?", id, orgid).Preload("GoodInfo", "status = 1").Find(&info).Error
3378
+	return info, err
3379
+}
3380
+
3381
+func UpdateCancelOut(list []*models.WarehousingInfo, count int64) error {
3382
+
3383
+	//遍历循环入库数据
3384
+	for i, item := range list {
3385
+		//计算每个批次剩余库存与入库数据的差 然后和退库数量比较
3386
+		if (item.WarehousingCount - item.StockCount) >= count {
3387
+			//如果差距大于退库数量,则直接把退库数量增加到该批次中
3388
+			info := models.WarehousingInfo{
3389
+				GoodId:        item.GoodId,
3390
+				OrgId:         item.OrgId,
3391
+				WarehousingId: item.WarehousingId,
3392
+				StockCount:    item.StockCount + count,
3393
+			}
3394
+			UpdateWarehousingCount(&info, item.GoodId, item.OrgId, item.WarehousingId)
3395
+			break
3396
+		}
3397
+
3398
+		if (item.WarehousingCount - item.StockCount) < count {
3399
+
3400
+			//如果该批次小于退库数量,则先出库该相差数量
3401
+			var countOne = item.WarehousingCount - item.StockCount
3402
+
3403
+			infoOne := models.WarehousingInfo{
3404
+				GoodId:        item.GoodId,
3405
+				OrgId:         item.OrgId,
3406
+				WarehousingId: item.WarehousingId,
3407
+				StockCount:    countOne + item.StockCount,
3408
+			}
3409
+
3410
+			err := UpdateWarehousingCount(&infoOne, item.GoodId, item.OrgId, item.WarehousingId)
3411
+			if err == nil {
3412
+				//剩余的出库到第二个批次
3413
+				var countTwo = count - countOne
3414
+				infos := append(list, list[i+1])
3415
+				var idArray []*models.WarehousingInfo
3416
+				for _, it := range infos {
3417
+					if it.WarehousingId != item.WarehousingId {
3418
+						idArray = append(idArray, it)
3419
+					}
3420
+				}
3421
+				//查询更新后的库存
3422
+				UpdateCancelOut(idArray, countTwo)
3423
+				return err
3424
+			} else {
3425
+				return err
3426
+			}
3427
+
3428
+		}
3429
+	}
3430
+
3431
+	return err
3432
+}
3433
+
3434
+func GetCancelStockOrderPrint(idstr []string) (info []*models.CancelStockInfo, err error) {
3435
+
3436
+	if len(idstr) > 0 {
3437
+		err = XTReadDB().Model(&info).Where("cancel_stock_id in(?)", idstr).Preload("GoodInfo", "status = 1").Find(&info).Error
3438
+	} else {
3439
+		err = XTReadDB().Model(&info).Preload("GoodInfo", "status = 1").Find(&info).Error
3440
+	}
3441
+	return info, err
3442
+}
3443
+
3444
+func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3445
+
3446
+	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3447
+
3448
+	if startime > 0 {
3449
+		db = db.Where("x.ctime >=?", startime)
3450
+	}
3451
+	if endtime > 0 {
3452
+		db = db.Where("x.ctime <= ?", endtime)
3453
+	}
3454
+	if orgid > 0 {
3455
+		db = db.Where("x.org_id = ?", orgid)
3456
+	}
3457
+	err = db.Select("x.good_id,sum(x.count) as count").Group("x.good_id").Scan(&info).Error
3458
+	return info, err
3459
+}

+ 74 - 19
service/warhouse_service.go Datei anzeigen

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
-	"XT_New/models/service"
6
 	"XT_New/utils"
5
 	"XT_New/utils"
7
 	"errors"
6
 	"errors"
8
 	"fmt"
7
 	"fmt"
523
 	// 将该批次的剩余库存数量转换为拆零数量
522
 	// 将该批次的剩余库存数量转换为拆零数量
524
 
523
 
525
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
524
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
526
-	fmt.Println("88i8uu7777777777777777777777777777", stock_number)
527
-	fmt.Println("77777544656666666666666666", deliver_number)
525
+
528
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
526
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
529
 	if stock_number >= deliver_number {
527
 	if stock_number >= deliver_number {
528
+		fmt.Println("价格表32322222222222222222232322332", advice.Price)
530
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
529
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
531
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
530
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
532
 			WarehouseOutId:          warehouseout.ID,
531
 			WarehouseOutId:          warehouseout.ID,
533
 			Status:                  1,
532
 			Status:                  1,
534
 			Ctime:                   time.Now().Unix(),
533
 			Ctime:                   time.Now().Unix(),
535
-			Remark:                  "",
534
+			Remark:                  advice.Remark,
536
 			OrgId:                   orgID,
535
 			OrgId:                   orgID,
537
 			Type:                    1,
536
 			Type:                    1,
538
-			Manufacturer:            0,
539
-			Dealer:                  0,
537
+			Manufacturer:            advice.Manufacturer,
538
+			Dealer:                  advice.Dealer,
540
 			IsSys:                   0,
539
 			IsSys:                   0,
541
 			SysRecordTime:           advice.Ctime,
540
 			SysRecordTime:           advice.Ctime,
542
 			DrugId:                  advice.DrugId,
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,
543
 		}
549
 		}
544
 
550
 
545
 		warehouseOutInfo.Count = deliver_number
551
 		warehouseOutInfo.Count = deliver_number
592
 			WarehouseOutId:          warehouseout.ID,
598
 			WarehouseOutId:          warehouseout.ID,
593
 			Status:                  1,
599
 			Status:                  1,
594
 			Ctime:                   time.Now().Unix(),
600
 			Ctime:                   time.Now().Unix(),
595
-			Remark:                  "",
601
+			Remark:                  advice.Remark,
596
 			OrgId:                   orgID,
602
 			OrgId:                   orgID,
597
 			Type:                    1,
603
 			Type:                    1,
598
-			Manufacturer:            0,
599
-			Dealer:                  0,
604
+			Manufacturer:            advice.Manufacturer,
605
+			Dealer:                  advice.Dealer,
600
 			IsSys:                   0,
606
 			IsSys:                   0,
601
 			SysRecordTime:           advice.Ctime,
607
 			SysRecordTime:           advice.Ctime,
602
 			DrugId:                  advice.DrugId,
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,
603
 		}
616
 		}
604
 
617
 
605
 		warehouseOutInfo.Count = stock_number
618
 		warehouseOutInfo.Count = stock_number
748
 	// 如果没有对应的库存,则报错
761
 	// 如果没有对应的库存,则报错
749
 
762
 
750
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
763
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
751
-	fmt.Println("库存数量", warehouse.StockCount)
764
+	fmt.Println("库存数量9999343434343434343434343434343434", warehouse.StockCount)
752
 	if err != nil {
765
 	if err != nil {
753
 		return
766
 		return
754
 	}
767
 	}
829
 
842
 
830
 		return nil
843
 		return nil
831
 	} else {
844
 	} else {
845
+		fmt.Println("中国共产党万岁22322332323232322323232323232323")
846
+		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
847
+		//warehouseOutInfo := &models.WarehouseOutInfo{
848
+		//  WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
849
+		//  WarehouseOutId:          warehouseOut.ID,
850
+		//  WarehouseInfotId:        warehouse.ID,
851
+		//  Status:                  1,
852
+		//  Ctime:                   time.Now().Unix(),
853
+		//  Remark:                  goods.Remark,
854
+		//  OrgId:                   orgID,
855
+		//  Type:                    1,
856
+		//  Manufacturer:            goods.Manufacturer,
857
+		//  Dealer:                  goods.Dealer,
858
+		//  IsSys:                   0,
859
+		//  SysRecordTime:           record_time,
860
+		//  GoodTypeId:              goods.GoodTypeId,
861
+		//  GoodId:                  goods.GoodId,
862
+		//  ExpiryDate:              goods.ExpiryDate,
863
+		//  ProductDate:             goods.ProductDate,
864
+		//  Number:                  goods.Number,
865
+		//  Price:                   goods.Price,
866
+		//  LicenseNumber:           goods.LicenseNumber,
867
+		//}
868
+		//warehouseOutInfo.Count = stock_number
869
+		//stockInInfo, _ :=FindLastStockInInfoRecord(goods.GoodId, orgID)
870
+		//fmt.Println("stockINFO2232232323223322332323223323223",stockInInfo)
871
+		//warehouseOutInfo.Price = stockInInfo.Price
872
+		//
873
+		//errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
874
+		//fmt.Println("errOne2232323232323232333232323",errOne)
875
+		//if errOne != nil {
876
+		//  return errOne
877
+		//}
832
 		// 出库完成后,要将该批次库存清零
878
 		// 出库完成后,要将该批次库存清零
833
 		warehouse.StockCount = 0
879
 		warehouse.StockCount = 0
834
 		warehouse.Mtime = time.Now().Unix()
880
 		warehouse.Mtime = time.Now().Unix()
1098
 	fmt.Println("8888888888888888888", deliver_number)
1144
 	fmt.Println("8888888888888888888", deliver_number)
1099
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1145
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1100
 	if stock_number >= deliver_number {
1146
 	if stock_number >= deliver_number {
1147
+		fmt.Println("g2332232332323232232323322332", goods.Price)
1101
 		warehouseOutInfo := &models.WarehouseOutInfo{
1148
 		warehouseOutInfo := &models.WarehouseOutInfo{
1102
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1149
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1103
 			WarehouseOutId:          warehouseOut.ID,
1150
 			WarehouseOutId:          warehouseOut.ID,
1117
 			ProductDate:             goods.ProductDate,
1164
 			ProductDate:             goods.ProductDate,
1118
 			Number:                  goods.Number,
1165
 			Number:                  goods.Number,
1119
 			Price:                   goods.Price,
1166
 			Price:                   goods.Price,
1167
+			LicenseNumber:           goods.LicenseNumber,
1120
 		}
1168
 		}
1121
 		warehouseOutInfo.Count = goods.Count
1169
 		warehouseOutInfo.Count = goods.Count
1122
-		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1123
-		warehouseOutInfo.Price = stockInInfo.Price
1170
+		//stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1171
+		//warehouseOutInfo.Price = stockInInfo.Price
1124
 
1172
 
1125
 		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1173
 		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1126
 		if errOne != nil {
1174
 		if errOne != nil {
1135
 
1183
 
1136
 		warehouse.StockCount = warehouse.StockCount - maxNumber
1184
 		warehouse.StockCount = warehouse.StockCount - maxNumber
1137
 		warehouse.Mtime = time.Now().Unix()
1185
 		warehouse.Mtime = time.Now().Unix()
1186
+
1138
 		if warehouse.StockCount < 0 {
1187
 		if warehouse.StockCount < 0 {
1139
-			fmt.Println("进来33232323232232323233232", warehouse.StockCount)
1188
+
1140
 			return errors.New("库存数量不足")
1189
 			return errors.New("库存数量不足")
1141
 		}
1190
 		}
1142
-		return nil
1191
+		errThree := UpDateWarehouseInfoByStock(&warehouse)
1192
+		if errThree != nil {
1193
+			return errThree
1194
+		}
1143
 	} else {
1195
 	} else {
1196
+		fmt.Println("中国共产党万岁22322332323232322323232323232323")
1144
 		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1197
 		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1145
 		warehouseOutInfo := &models.WarehouseOutInfo{
1198
 		warehouseOutInfo := &models.WarehouseOutInfo{
1146
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1199
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1161
 			ProductDate:             goods.ProductDate,
1214
 			ProductDate:             goods.ProductDate,
1162
 			Number:                  goods.Number,
1215
 			Number:                  goods.Number,
1163
 			Price:                   goods.Price,
1216
 			Price:                   goods.Price,
1217
+			LicenseNumber:           goods.LicenseNumber,
1164
 		}
1218
 		}
1165
 		warehouseOutInfo.Count = stock_number
1219
 		warehouseOutInfo.Count = stock_number
1166
-		stockInInfo, _ := service.FindLastStockInInfoRecord(goods.GoodId, orgID)
1167
-		warehouseOutInfo.Price = stockInInfo.Price
1168
-
1169
-		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1220
+		//stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1221
+		//fmt.Println("stockINFO2232232323223322332323223323223", stockInInfo)
1222
+		//warehouseOutInfo.Price = stockInInfo.Price
1170
 
1223
 
1224
+		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1225
+		fmt.Println("errOne2232323232323232333232323", errOne)
1171
 		if errOne != nil {
1226
 		if errOne != nil {
1172
 			return errOne
1227
 			return errOne
1173
 		}
1228
 		}
1180
 		}
1235
 		}
1181
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1236
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1182
 		goods.Count = deliver_number - stock_number
1237
 		goods.Count = deliver_number - stock_number
1183
-
1238
+		fmt.Println("goods3333333333333333333333", goods.Count)
1184
 		ConsumablesDeliveryOne(orgID, record_time, goods, warehouseOut, count)
1239
 		ConsumablesDeliveryOne(orgID, record_time, goods, warehouseOut, count)
1185
 
1240
 
1186
 	}
1241
 	}