Ver código fonte

耗材参数

XMLWAN 3 anos atrás
pai
commit
9d182640c4

+ 1 - 1
conf/app.conf Ver arquivo

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

+ 194 - 94
controllers/drug_stock_api_contorller.go Ver arquivo

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 {
1212
 				retail_price_total := float64(count) * last_price
1192
 				retail_price_total := float64(count) * last_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
+				var productDates int64
1196
+				var expiryDates int64
1197
+				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
1198
+					expiryDates = 0
1199
+				} else {
1200
+					if len(items["expiry_date"].(string)) == 0 {
1201
+						expiryDates = 0
1202
+
1203
+					} else {
1204
+						expiryDate, _ := items["expiry_date"].(string)
1205
+						expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
1206
+						expiryDates = expiry_date.Unix()
1207
+
1208
+					}
1209
+
1210
+				}
1211
+				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
1212
+					productDates = 0
1213
+				} else {
1214
+					if len(items["product_date"].(string)) == 0 {
1215
+						productDates = 0
1216
+
1217
+					} else {
1218
+						productDate, _ := items["product_date"].(string)
1219
+						product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
1220
+						productDates = product_date.Unix()
1221
+					}
1222
+
1223
+				}
1224
+
1225
+				dealer := int64(items["dealer"].(float64))
1226
+
1227
+				manufacturer := int64(items["manufacturer"].(float64))
1228
+
1229
+				number := items["number"].(string)
1230
+				batch_number := items["batch_number"].(string)
1215
 
1231
 
1216
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1232
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1217
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1233
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1225
 					Remark:                  remark,
1241
 					Remark:                  remark,
1226
 					OrgId:                   adminUserInfo.CurrentOrgId,
1242
 					OrgId:                   adminUserInfo.CurrentOrgId,
1227
 					Type:                    types,
1243
 					Type:                    types,
1228
-					Manufacturer:            manufacturer_id,
1229
-					Dealer:                  dealer_id,
1244
+					Manufacturer:            manufacturer,
1245
+					Dealer:                  dealer,
1230
 					RetailPrice:             last_price,
1246
 					RetailPrice:             last_price,
1231
 					RetailTotalPrice:        retail_price_total,
1247
 					RetailTotalPrice:        retail_price_total,
1232
 					CountUnit:               max_unit,
1248
 					CountUnit:               max_unit,
1249
+					ExpiryDate:              expiryDates,
1250
+					ProductDate:             productDates,
1251
+					Number:                  number,
1252
+					BatchNumber:             batch_number,
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)
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 Ver arquivo

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 Ver arquivo

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 Ver arquivo

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",

+ 34 - 10
controllers/stock_in_api_controller.go Ver arquivo

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")
94
 
95
 
95
 }
96
 }
96
 
97
 
562
 				var productDates int64
563
 				var productDates int64
563
 				var expiryDates int64
564
 				var expiryDates int64
564
 
565
 
565
-				fmt.Println()
566
-
567
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
566
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
568
 					expiryDates = 0
567
 					expiryDates = 0
569
 				} else {
568
 				} else {
1087
 	operation_time := time.Now().Unix()
1086
 	operation_time := time.Now().Unix()
1088
 	creater := adminUserInfo.AdminUser.Id
1087
 	creater := adminUserInfo.AdminUser.Id
1089
 
1088
 
1090
-	_, errcode := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1091
 	warehouseOut := models.WarehouseOut{
1089
 	warehouseOut := models.WarehouseOut{
1092
 		WarehouseOutOrderNumber: warehousing_out_order,
1090
 		WarehouseOutOrderNumber: warehousing_out_order,
1093
 		OperationTime:           operation_time,
1091
 		OperationTime:           operation_time,
1098
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1096
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1099
 		Type:                    types,
1097
 		Type:                    types,
1100
 	}
1098
 	}
1101
-	if errcode == gorm.ErrRecordNotFound {
1102
-		service.AddSigleWarehouseOut(&warehouseOut)
1103
-	}
1104
 
1099
 
1105
 	dataBody := make(map[string]interface{}, 0)
1100
 	dataBody := make(map[string]interface{}, 0)
1106
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1101
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1182
 					}
1177
 					}
1183
 					productDate = theTime.Unix()
1178
 					productDate = theTime.Unix()
1184
 				}
1179
 				}
1185
-
1180
+				license_number := items["license_number"].(string)
1186
 				warehouseOutInfo := &models.WarehouseOutInfo{
1181
 				warehouseOutInfo := &models.WarehouseOutInfo{
1187
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1182
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1188
 					WarehouseOutId:          warehouseOut.ID,
1183
 					WarehouseOutId:          warehouseOut.ID,
1201
 					ExpiryDate:              expiryDate,
1196
 					ExpiryDate:              expiryDate,
1202
 					ProductDate:             productDate,
1197
 					ProductDate:             productDate,
1203
 					Dealer:                  dealer,
1198
 					Dealer:                  dealer,
1199
+					LicenseNumber:           license_number,
1204
 				}
1200
 				}
1205
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1201
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1206
 
1202
 
1225
 	//出库逻辑
1221
 	//出库逻辑
1226
 	for _, item := range warehousingOutInfo {
1222
 	for _, item := range warehousingOutInfo {
1227
 		//查询库存
1223
 		//查询库存
1228
-		warehouse, err := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1224
+		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1229
 		fmt.Println("库存数量组吗", warehouse.Count)
1225
 		fmt.Println("库存数量组吗", warehouse.Count)
1230
-		if err != nil {
1226
+		if item.Count > warehouse.Count {
1231
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1227
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1232
 			c.ServeSuccessJSON(map[string]interface{}{
1228
 			c.ServeSuccessJSON(map[string]interface{}{
1233
 				"msg":                "1",
1229
 				"msg":                "1",
1236
 			})
1232
 			})
1237
 			return
1233
 			return
1238
 		} else {
1234
 		} else {
1235
+			_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1236
+			if errcodes == gorm.ErrRecordNotFound {
1237
+				service.AddSigleWarehouseOut(&warehouseOut)
1238
+			}
1239
 			parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
1239
 			parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
1240
-			fmt.Println(parseDateErr)
1241
 			if parseDateErr != nil {
1240
 			if parseDateErr != nil {
1242
 				utils.ErrorLog(parseDateErr.Error())
1241
 				utils.ErrorLog(parseDateErr.Error())
1243
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1242
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1461
 
1460
 
1462
 				number := items["number"].(string)
1461
 				number := items["number"].(string)
1463
 
1462
 
1463
+				license_number := items["license_number"].(string)
1464
+				fmt.Println("hhh23h2h32h3h232h3h23h2h3h23h2h3h23h2h3", license_number)
1464
 				timeLayout := "2006-01-02"
1465
 				timeLayout := "2006-01-02"
1465
 				loc, _ := time.LoadLocation("Local")
1466
 				loc, _ := time.LoadLocation("Local")
1466
 				expiry_date := items["expiry_date"].(string)
1467
 				expiry_date := items["expiry_date"].(string)
1507
 						ProductDate:             productDate,
1508
 						ProductDate:             productDate,
1508
 						Dealer:                  dealer,
1509
 						Dealer:                  dealer,
1509
 						Manufacturer:            manufacturer,
1510
 						Manufacturer:            manufacturer,
1511
+						LicenseNumber:           license_number,
1510
 					}
1512
 					}
1511
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1513
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1512
 
1514
 
1547
 						ExpiryDate:              expiryDate,
1549
 						ExpiryDate:              expiryDate,
1548
 						ProductDate:             productDate,
1550
 						ProductDate:             productDate,
1549
 						Dealer:                  dealer,
1551
 						Dealer:                  dealer,
1552
+						LicenseNumber:           license_number,
1550
 					}
1553
 					}
1551
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1554
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1552
 				}
1555
 				}
1672
 		}
1675
 		}
1673
 	}
1676
 	}
1674
 	errs := service.CreateCancelStockInfo(cancelStockInfos)
1677
 	errs := service.CreateCancelStockInfo(cancelStockInfos)
1678
+
1679
+	// 改变入库单的值
1680
+	for _, item := range cancelStockInfos {
1681
+
1682
+		//查询该耗材的入库记录
1683
+		list, _ := service.GetWarehoureOrderInfoList(item.GoodId, item.OrgId)
1684
+		//调用退库的方法
1685
+		service.UpdateCancelOut(list, item.Count)
1686
+	}
1687
+
1675
 	if errs != nil {
1688
 	if errs != nil {
1676
 		utils.ErrorLog(errs.Error())
1689
 		utils.ErrorLog(errs.Error())
1677
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
1690
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
4026
 		"count": outCount,
4039
 		"count": outCount,
4027
 	})
4040
 	})
4028
 }
4041
 }
4042
+
4043
+func (this *StockManagerApiController) GetSingleCancelOrder() {
4044
+
4045
+	id, _ := this.GetInt64("id")
4046
+	adminUserInfo := this.GetAdminUserInfo()
4047
+	orgId := adminUserInfo.CurrentOrgId
4048
+	order, _ := service.GetSingleCancelOrder(id, orgId)
4049
+	this.ServeSuccessJSON(map[string]interface{}{
4050
+		"list": order,
4051
+	})
4052
+}

+ 2 - 0
models/drug_stock.go Ver arquivo

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 {

+ 11 - 0
models/self_drug_models.go Ver arquivo

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 {
608
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
616
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
609
 	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
617
 	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
610
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
618
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
619
+	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"`
620
 	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"`
621
 	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"`
622
 	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
633
 	DoseUnit                string  `json:"dose_unit"`
642
 	DoseUnit                string  `json:"dose_unit"`
634
 	LastPrice               string  `json:"last_price"`
643
 	LastPrice               string  `json:"last_price"`
635
 	DrugName                string  `json:"drug_name"`
644
 	DrugName                string  `json:"drug_name"`
645
+	Number                  string  `json:"number"`
646
+	BatchNumber             string  `json:"batch_number"`
636
 }
647
 }

+ 3 - 0
models/stock_models.go Ver arquivo

146
 	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
146
 	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
147
 	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
147
 	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
148
 	Price             float64     `gorm:"column:price" json:"price"`
148
 	Price             float64     `gorm:"column:price" json:"price"`
149
+	BuyPrice          float64     `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
149
 	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
150
 	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
150
 	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
151
 	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
151
 	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
152
 	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
219
 	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
220
 	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
220
 	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
221
 	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
221
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
222
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
223
+	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
222
 }
224
 }
223
 
225
 
224
 func (WarehouseOutInfo) TableName() string {
226
 func (WarehouseOutInfo) TableName() string {
428
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
430
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
429
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
431
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
430
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
432
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
433
+	LicenseNumber           string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
431
 }
434
 }
432
 
435
 
433
 type WarehouseOutInfoTwo struct {
436
 type WarehouseOutInfoTwo struct {

+ 11 - 7
service/gobal_config_service.go Ver arquivo

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
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
 

+ 212 - 12
service/stock_service.go Ver arquivo

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
694
 	return
695
 	return
695
 }
696
 }
696
 
697
 
698
+func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64) (list []*VMDrugWarehouse, total int64, err error) {
699
+	db := readDb.Model(&VMDrugWarehouse{})
700
+	db = db.Where("xt_drug_warehouse.org_id = ? AND xt_drug_warehouse.status = 1", orgId)
701
+	db = db.Preload("Manufacturers", "status = 1 AND org_id = ?", orgId)
702
+	db = db.Preload("Dealers", "status = 1 AND org_id = ?", orgId)
703
+	if len(keywords) > 0 {
704
+		likeKey := "%" + keywords + "%"
705
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse.creater")
706
+		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")
707
+	}
708
+	if startTime > 0 {
709
+		db = db.Where("xt_drug_warehouse.operation_time >=?", startTime)
710
+	}
711
+	if endTime > 0 {
712
+		db = db.Where("xt_drug_warehouse.operation_time<= ?", endTime)
713
+	}
714
+	db = db.Count(&total)
715
+	offset := (page - 1) * limit
716
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
717
+	return
718
+}
719
+
697
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
720
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
698
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Preload("GoodInfo").Find(&list).Error
721
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Preload("GoodInfo").Find(&list).Error
699
 	return list, err
722
 	return list, err
917
 }
940
 }
918
 
941
 
919
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
942
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
920
-	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
943
+	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("GoodInfo", "status = 1").Find(&list).Error
921
 	return list, err
944
 	return list, err
922
 }
945
 }
923
 
946
 
998
 	if len(warehouseOutInfo) > 0 {
1021
 	if len(warehouseOutInfo) > 0 {
999
 		utx := writeDb.Begin()
1022
 		utx := writeDb.Begin()
1000
 		if len(warehouseOutInfo) > 0 {
1023
 		if len(warehouseOutInfo) > 0 {
1001
-			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 "
1024
+			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 "
1002
 			insertParams := make([]string, 0)
1025
 			insertParams := make([]string, 0)
1003
 			insertData := make([]interface{}, 0)
1026
 			insertData := make([]interface{}, 0)
1004
 			for _, info := range warehouseOutInfo {
1027
 			for _, info := range warehouseOutInfo {
1005
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1028
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1006
 				insertData = append(insertData, info.WarehouseOutId)
1029
 				insertData = append(insertData, info.WarehouseOutId)
1007
 				insertData = append(insertData, info.GoodId)
1030
 				insertData = append(insertData, info.GoodId)
1008
 				insertData = append(insertData, info.GoodTypeId)
1031
 				insertData = append(insertData, info.GoodTypeId)
1020
 				insertData = append(insertData, info.Dealer)
1043
 				insertData = append(insertData, info.Dealer)
1021
 				insertData = append(insertData, info.Manufacturer)
1044
 				insertData = append(insertData, info.Manufacturer)
1022
 				insertData = append(insertData, info.Number)
1045
 				insertData = append(insertData, info.Number)
1046
+				insertData = append(insertData, info.LicenseNumber)
1023
 			}
1047
 			}
1024
 			thisSQL += strings.Join(insertParams, ", ")
1048
 			thisSQL += strings.Join(insertParams, ", ")
1025
 			err = utx.Exec(thisSQL, insertData...).Error
1049
 			err = utx.Exec(thisSQL, insertData...).Error
1038
 	if len(warehouseOutInfo) > 0 {
1062
 	if len(warehouseOutInfo) > 0 {
1039
 		utx := writeDb.Begin()
1063
 		utx := writeDb.Begin()
1040
 		if len(warehouseOutInfo) > 0 {
1064
 		if len(warehouseOutInfo) > 0 {
1041
-			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 "
1065
+			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 "
1042
 			insertParams := make([]string, 0)
1066
 			insertParams := make([]string, 0)
1043
 			insertData := make([]interface{}, 0)
1067
 			insertData := make([]interface{}, 0)
1044
 			for _, info := range warehouseOutInfo {
1068
 			for _, info := range warehouseOutInfo {
1045
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1069
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1046
 				insertData = append(insertData, info.WarehouseOutId)
1070
 				insertData = append(insertData, info.WarehouseOutId)
1047
 				insertData = append(insertData, info.DrugId)
1071
 				insertData = append(insertData, info.DrugId)
1048
 				insertData = append(insertData, info.ProductDate)
1072
 				insertData = append(insertData, info.ProductDate)
1060
 				insertData = append(insertData, info.Manufacturer)
1084
 				insertData = append(insertData, info.Manufacturer)
1061
 				insertData = append(insertData, info.RetailPrice)
1085
 				insertData = append(insertData, info.RetailPrice)
1062
 				insertData = append(insertData, info.RetailTotalPrice)
1086
 				insertData = append(insertData, info.RetailTotalPrice)
1063
-
1087
+				insertData = append(insertData, info.Number)
1088
+				insertData = append(insertData, info.BatchNumber)
1064
 			}
1089
 			}
1065
 			thisSQL += strings.Join(insertParams, ", ")
1090
 			thisSQL += strings.Join(insertParams, ", ")
1066
 			err = utx.Exec(thisSQL, insertData...).Error
1091
 			err = utx.Exec(thisSQL, insertData...).Error
1161
 
1186
 
1162
 }
1187
 }
1163
 
1188
 
1189
+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) {
1190
+	db := readDb.Model(&models.DrugWarehouseOut{})
1191
+	db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
1192
+
1193
+	if len(keywords) > 0 {
1194
+		likeKey := "%" + keywords + "%"
1195
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
1196
+
1197
+		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")
1198
+	}
1199
+
1200
+	if startTime > 0 {
1201
+		db = db.Where("xt_drug_warehouse_out.ctime >=?", startTime)
1202
+	}
1203
+	if endTime > 0 {
1204
+		db = db.Where("xt_drug_warehouse_out.ctime<= ?", endTime)
1205
+	}
1206
+	db = db.Count(&total)
1207
+	offset := (page - 1) * limit
1208
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1209
+	return list, total, err
1210
+
1211
+}
1212
+
1164
 func FindWarehouseOutInfoById(id int64) (list []*models.WarehouseOutInfo, err error) {
1213
 func FindWarehouseOutInfoById(id int64) (list []*models.WarehouseOutInfo, err error) {
1165
 	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
1214
 	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
1166
 	return list, err
1215
 	return list, err
1190
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
1239
 	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
1191
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1240
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1192
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1241
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1242
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
1243
+	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1193
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1244
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1194
 }
1245
 }
1195
 
1246
 
1909
 }
1960
 }
1910
 
1961
 
1911
 func FindCancelStockById(id int64, org_id int64) (cancelStock models.CancelStock, err error) {
1962
 func FindCancelStockById(id int64, org_id int64) (cancelStock models.CancelStock, err error) {
1912
-	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
1963
+	err = readDb.Model(&models.CancelStock{}).Where("id = ? AND status = 1", id).First(&cancelStock).Error
1913
 	return cancelStock, err
1964
 	return cancelStock, err
1914
 
1965
 
1915
 }
1966
 }
2350
 	OrgId                   int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
2401
 	OrgId                   int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
2351
 	DrugId                  int64            `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
2402
 	DrugId                  int64            `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
2352
 	Count                   int64            `gorm:"column:count" json:"count" form:"count"`
2403
 	Count                   int64            `gorm:"column:count" json:"count" form:"count"`
2404
+	CountUnit               string           `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
2353
 	Drug                    *Drug            `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
2405
 	Drug                    *Drug            `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
2354
 	Patients                *models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
2406
 	Patients                *models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
2355
 }
2407
 }
2930
 	if good_id > 0 {
2982
 	if good_id > 0 {
2931
 		db = db.Where("x.good_id = ?", good_id)
2983
 		db = db.Where("x.good_id = ?", good_id)
2932
 	}
2984
 	}
2933
-	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
2985
+	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
2934
 	return info, total, err
2986
 	return info, total, err
2935
 
2987
 
2936
 }
2988
 }
2939
 	offset := (page - 1) * limit
2991
 	offset := (page - 1) * limit
2940
 
2992
 
2941
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status= 1")
2993
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status= 1")
2994
+
2942
 	if startime > 0 {
2995
 	if startime > 0 {
2943
 		db = db.Where("x.ctime>=?", startime)
2996
 		db = db.Where("x.ctime>=?", startime)
2944
 	}
2997
 	}
3024
 	if orgid > 0 {
3077
 	if orgid > 0 {
3025
 		db = db.Where("x.org_id = ?", orgid)
3078
 		db = db.Where("x.org_id = ?", orgid)
3026
 	}
3079
 	}
3027
-	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
3080
+	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
3028
 	return out, err
3081
 	return out, err
3029
 }
3082
 }
3030
 
3083
 
3052
 	if orgid > 0 {
3105
 	if orgid > 0 {
3053
 		db = db.Where("x.org_id = ?", orgid)
3106
 		db = db.Where("x.org_id = ?", orgid)
3054
 	}
3107
 	}
3055
-	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
3108
+	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
3056
 	return out, err
3109
 	return out, err
3057
 }
3110
 }
3058
 
3111
 
3170
 	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
3223
 	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
3171
 	return info, err
3224
 	return info, err
3172
 }
3225
 }
3226
+
3227
+func GetDrugNameByKeyword(keyword string, orgid int64) (basedrug []*models.XtBaseDrug, err error) {
3228
+
3229
+	db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
3230
+	likeKey := "%" + keyword + "%"
3231
+	if len(keyword) > 0 {
3232
+		db = db.Where("x.drug_name like ?", likeKey)
3233
+	}
3234
+	if orgid > 0 {
3235
+		db = db.Where("x.org_id = ?", orgid)
3236
+	}
3237
+	err = db.Find(&basedrug).Error
3238
+
3239
+	return basedrug, err
3240
+
3241
+}
3242
+
3243
+func GetDrugWarehouseOrderDetail(ids []int64, orgid int64, startime int64, endtime int64) (info []*models.XtDrugWarehouseOutInfo, err error) {
3244
+
3245
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
3246
+
3247
+	if len(ids) > 0 {
3248
+		db = db.Where("x.drug_id in(?)", ids)
3249
+	}
3250
+
3251
+	if orgid > 0 {
3252
+		db = db.Where("x.org_id = ?", orgid)
3253
+	}
3254
+	if startime > 0 {
3255
+		db = db.Where("x.ctime>=?", startime)
3256
+	}
3257
+	if endtime > 0 {
3258
+		db = db.Where("x.ctime<=?", endtime)
3259
+	}
3260
+
3261
+	err = db.Find(&info).Error
3262
+	return info, err
3263
+}
3264
+
3265
+func GetDrugWarehouseOrderDetailTwo(ids []int64, orgid int64, startime int64, endtime int64) (info []*models.XtDrugWarehouseInfo, err error) {
3266
+
3267
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3268
+
3269
+	if len(ids) > 0 {
3270
+		db = db.Where("x.drug_id in(?)", ids)
3271
+	}
3272
+
3273
+	if orgid > 0 {
3274
+		db = db.Where("x.org_id = ?", orgid)
3275
+	}
3276
+	if startime > 0 {
3277
+		db = db.Where("x.ctime>=?", startime)
3278
+	}
3279
+	if endtime > 0 {
3280
+		db = db.Where("x.ctime<=?", endtime)
3281
+	}
3282
+
3283
+	err = db.Find(&info).Error
3284
+	return info, err
3285
+}
3286
+
3287
+func GetDrugTotalCount(drugid int64, orgid int64) (info models.VmDrugWarehouseInfo, err error) {
3288
+
3289
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3290
+	if drugid > 0 {
3291
+		db = db.Where("x.drug_id = ?", drugid)
3292
+	}
3293
+	if orgid > 0 {
3294
+		db = db.Where("x.org_id = ?", orgid)
3295
+	}
3296
+	err = db.Select("x.drug_id,sum(x.stock_max_number) as count").Find(&info).Error
3297
+	return info, err
3298
+}
3299
+
3300
+func GetDrugByGoodId(drugid int64) (models.BaseDrugLib, error) {
3301
+
3302
+	lib := models.BaseDrugLib{}
3303
+	err := XTReadDB().Model(&lib).Where("id = ? and status = 1", drugid).Find(&lib).Error
3304
+	return lib, err
3305
+}
3306
+
3307
+func GetWarehoureOrderInfoList(goodid int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3308
+
3309
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
3310
+
3311
+	if goodid > 0 {
3312
+		db = db.Where("x.good_id = ?", goodid)
3313
+	}
3314
+
3315
+	if orgid > 0 {
3316
+		db = db.Where("x.org_id = ?", orgid)
3317
+	}
3318
+
3319
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number").Order("x.ctime desc").Find(&info).Error
3320
+	return info, err
3321
+}
3322
+
3323
+func UpdateWarehousingCount(info *models.WarehousingInfo, goodid int64, orgid int64, warehousingId int64) error {
3324
+
3325
+	err := XTWriteDB().Model(&info).Where("good_id = ? and org_id = ? and status =1 and warehousing_id = ?", goodid, orgid, warehousingId).Updates(map[string]interface{}{"stock_cout": info.StockCount}).Error
3326
+	return err
3327
+}
3328
+
3329
+func GetSingleCancelOrder(id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
3330
+
3331
+	err = XTReadDB().Where("cancel_stock_id = ? and status = 1 and org_id = ?", id, orgid).Preload("GoodInfo", "status = 1").Find(&info).Error
3332
+	return info, err
3333
+}
3334
+
3335
+func UpdateCancelOut(list []*models.WarehousingInfo, count int64) {
3336
+
3337
+	//遍历循环入库数据
3338
+	for _, item := range list {
3339
+
3340
+		//计算每个批次剩余库存与入库数据的差 然后和退库数量比较
3341
+		if (item.WarehousingCount - item.StockCount) >= count {
3342
+			//如果差距大于退库数量,则直接把退库数量增加到该批次中
3343
+			info := models.WarehousingInfo{
3344
+				GoodId:        item.GoodId,
3345
+				OrgId:         item.OrgId,
3346
+				WarehousingId: item.WarehousingId,
3347
+				StockCount:    count,
3348
+			}
3349
+			UpdateWarehousingCount(&info, item.GoodId, item.OrgId, item.WarehousingId)
3350
+			break
3351
+		}
3352
+
3353
+		if (item.WarehousingCount - item.StockCount) < count {
3354
+
3355
+			//如果该批次小于退库数量,则先出库该相差数量
3356
+			var countOne = item.WarehousingCount - item.StockCount
3357
+			infoOne := models.WarehousingInfo{
3358
+				GoodId:        item.GoodId,
3359
+				OrgId:         item.OrgId,
3360
+				WarehousingId: item.WarehousingId,
3361
+				StockCount:    countOne,
3362
+			}
3363
+
3364
+			UpdateWarehousingCount(&infoOne, item.GoodId, item.OrgId, item.WarehousingId)
3365
+
3366
+			//剩余的出库到第二个批次
3367
+			var countTwo = count - countOne
3368
+			UpdateCancelOut(list, countTwo)
3369
+		}
3370
+	}
3371
+
3372
+}

+ 48 - 8
service/warhouse_service.go Ver arquivo

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"
748
 	// 如果没有对应的库存,则报错
747
 	// 如果没有对应的库存,则报错
749
 
748
 
750
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
749
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
751
-	fmt.Println("库存数量", warehouse.StockCount)
750
+	fmt.Println("库存数量9999343434343434343434343434343434", warehouse.StockCount)
752
 	if err != nil {
751
 	if err != nil {
753
 		return
752
 		return
754
 	}
753
 	}
829
 
828
 
830
 		return nil
829
 		return nil
831
 	} else {
830
 	} else {
831
+		fmt.Println("中国共产党万岁22322332323232322323232323232323")
832
+		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
833
+		//warehouseOutInfo := &models.WarehouseOutInfo{
834
+		//  WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
835
+		//  WarehouseOutId:          warehouseOut.ID,
836
+		//  WarehouseInfotId:        warehouse.ID,
837
+		//  Status:                  1,
838
+		//  Ctime:                   time.Now().Unix(),
839
+		//  Remark:                  goods.Remark,
840
+		//  OrgId:                   orgID,
841
+		//  Type:                    1,
842
+		//  Manufacturer:            goods.Manufacturer,
843
+		//  Dealer:                  goods.Dealer,
844
+		//  IsSys:                   0,
845
+		//  SysRecordTime:           record_time,
846
+		//  GoodTypeId:              goods.GoodTypeId,
847
+		//  GoodId:                  goods.GoodId,
848
+		//  ExpiryDate:              goods.ExpiryDate,
849
+		//  ProductDate:             goods.ProductDate,
850
+		//  Number:                  goods.Number,
851
+		//  Price:                   goods.Price,
852
+		//  LicenseNumber:           goods.LicenseNumber,
853
+		//}
854
+		//warehouseOutInfo.Count = stock_number
855
+		//stockInInfo, _ :=FindLastStockInInfoRecord(goods.GoodId, orgID)
856
+		//fmt.Println("stockINFO2232232323223322332323223323223",stockInInfo)
857
+		//warehouseOutInfo.Price = stockInInfo.Price
858
+		//
859
+		//errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
860
+		//fmt.Println("errOne2232323232323232333232323",errOne)
861
+		//if errOne != nil {
862
+		//  return errOne
863
+		//}
832
 		// 出库完成后,要将该批次库存清零
864
 		// 出库完成后,要将该批次库存清零
833
 		warehouse.StockCount = 0
865
 		warehouse.StockCount = 0
834
 		warehouse.Mtime = time.Now().Unix()
866
 		warehouse.Mtime = time.Now().Unix()
1117
 			ProductDate:             goods.ProductDate,
1149
 			ProductDate:             goods.ProductDate,
1118
 			Number:                  goods.Number,
1150
 			Number:                  goods.Number,
1119
 			Price:                   goods.Price,
1151
 			Price:                   goods.Price,
1152
+			LicenseNumber:           goods.LicenseNumber,
1120
 		}
1153
 		}
1121
 		warehouseOutInfo.Count = goods.Count
1154
 		warehouseOutInfo.Count = goods.Count
1122
 		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1155
 		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1135
 
1168
 
1136
 		warehouse.StockCount = warehouse.StockCount - maxNumber
1169
 		warehouse.StockCount = warehouse.StockCount - maxNumber
1137
 		warehouse.Mtime = time.Now().Unix()
1170
 		warehouse.Mtime = time.Now().Unix()
1171
+
1138
 		if warehouse.StockCount < 0 {
1172
 		if warehouse.StockCount < 0 {
1139
-			fmt.Println("进来33232323232232323233232", warehouse.StockCount)
1173
+
1140
 			return errors.New("库存数量不足")
1174
 			return errors.New("库存数量不足")
1141
 		}
1175
 		}
1142
-		return nil
1176
+		errThree := UpDateWarehouseInfoByStock(&warehouse)
1177
+		if errThree != nil {
1178
+			return errThree
1179
+		}
1143
 	} else {
1180
 	} else {
1181
+		fmt.Println("中国共产党万岁22322332323232322323232323232323")
1144
 		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1182
 		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1145
 		warehouseOutInfo := &models.WarehouseOutInfo{
1183
 		warehouseOutInfo := &models.WarehouseOutInfo{
1146
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1184
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1161
 			ProductDate:             goods.ProductDate,
1199
 			ProductDate:             goods.ProductDate,
1162
 			Number:                  goods.Number,
1200
 			Number:                  goods.Number,
1163
 			Price:                   goods.Price,
1201
 			Price:                   goods.Price,
1202
+			LicenseNumber:           goods.LicenseNumber,
1164
 		}
1203
 		}
1165
 		warehouseOutInfo.Count = stock_number
1204
 		warehouseOutInfo.Count = stock_number
1166
-		stockInInfo, _ := service.FindLastStockInInfoRecord(goods.GoodId, orgID)
1205
+		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1206
+		fmt.Println("stockINFO2232232323223322332323223323223", stockInInfo)
1167
 		warehouseOutInfo.Price = stockInInfo.Price
1207
 		warehouseOutInfo.Price = stockInInfo.Price
1168
 
1208
 
1169
-		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1170
-
1209
+		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1210
+		fmt.Println("errOne2232323232323232333232323", errOne)
1171
 		if errOne != nil {
1211
 		if errOne != nil {
1172
 			return errOne
1212
 			return errOne
1173
 		}
1213
 		}
1180
 		}
1220
 		}
1181
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1221
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1182
 		goods.Count = deliver_number - stock_number
1222
 		goods.Count = deliver_number - stock_number
1183
-
1223
+		fmt.Println("goods3333333333333333333333", goods.Count)
1184
 		ConsumablesDeliveryOne(orgID, record_time, goods, warehouseOut, count)
1224
 		ConsumablesDeliveryOne(orgID, record_time, goods, warehouseOut, count)
1185
 
1225
 
1186
 	}
1226
 	}