Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
5ef0a506f0

+ 1 - 0
controllers/drug_stock_api_contorller.go View File

@@ -1998,6 +1998,7 @@ func (this *StockDrugApiController) GetUserDetailInfo() {
1998 1998
 	}
1999 1999
 	adminUserInfo := this.GetAdminUserInfo()
2000 2000
 	userDetails, err, total := service.FindDrugStockUserDetailById(adminUserInfo.CurrentOrgId, order_id)
2001
+
2001 2002
 	if err == nil {
2002 2003
 		this.ServeSuccessJSON(map[string]interface{}{
2003 2004
 			"list":  userDetails,

+ 5 - 3
controllers/gobal_config_api_controller.go View File

@@ -1787,14 +1787,16 @@ func (c *GobalConfigApiController) GetDrugAutoMaticList() {
1787 1787
 	drugConfig, _ := service.GetDrugStockConfig(orgId)
1788 1788
 	list, err := service.GetDrugAutoMaticList(orgId, warehous_out_id, record_time, warehouse_out_order_number)
1789 1789
 	drugList, err := service.GetAllBaseDrugList(orgId)
1790
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1790 1791
 	if err != nil {
1791 1792
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1792 1793
 		return
1793 1794
 	}
1794 1795
 	c.ServeSuccessJSON(map[string]interface{}{
1795
-		"list":       list,
1796
-		"drugConfig": drugConfig,
1797
-		"drugList":   drugList,
1796
+		"list":             list,
1797
+		"drugConfig":       drugConfig,
1798
+		"drugList":         drugList,
1799
+		"manufacturerList": manufacturerList,
1798 1800
 	})
1799 1801
 }
1800 1802
 

+ 24 - 29
controllers/stock_in_api_controller.go View File

@@ -93,8 +93,6 @@ func StockManagerApiRegistRouters() {
93 93
 func (c *StockManagerApiController) CreateWarehouse() {
94 94
 
95 95
 	warehousing_time := c.GetString("warehousing_time")
96
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
97
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
98 96
 
99 97
 	types, _ := c.GetInt64("type", 0)
100 98
 
@@ -122,8 +120,6 @@ func (c *StockManagerApiController) CreateWarehouse() {
122 120
 		Ctime:            ctime,
123 121
 		Status:           1,
124 122
 		WarehousingTime:  warehousingDate.Unix(),
125
-		Dealer:           dealer_id,
126
-		Manufacturer:     manufacturer_id,
127 123
 		Type:             types,
128 124
 	}
129 125
 	service.AddSigleWarehouse(&warehousing)
@@ -210,6 +206,8 @@ func (c *StockManagerApiController) CreateWarehouse() {
210 206
 
211 207
 				remark, _ := items["remark"].(string)
212 208
 
209
+				manufacturer := int64(items["manufacturer"].(float64))
210
+				dealer := int64(items["dealer"].(float64))
213 211
 				warehouseInfo := &models.WarehousingInfo{
214 212
 					WarehousingOrder: warehousing.WarehousingOrder,
215 213
 					WarehousingId:    warehousing.ID,
@@ -226,9 +224,9 @@ func (c *StockManagerApiController) CreateWarehouse() {
226 224
 					Remark:           remark,
227 225
 					OrgId:            adminUserInfo.CurrentOrgId,
228 226
 					Type:             types,
229
-					Manufacturer:     manufacturer_id,
230
-					Dealer:           dealer_id,
227
+					Manufacturer:     manufacturer,
231 228
 					StockCount:       warehousing_count,
229
+					Dealer:           dealer,
232 230
 				}
233 231
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
234 232
 
@@ -464,8 +462,6 @@ func (c *StockManagerApiController) EditWarehouse() {
464 462
 	warehousing_time := c.GetString("warehousing_time")
465 463
 	id, _ := c.GetInt64("id", 0)
466 464
 	types, _ := c.GetInt64("type", 0)
467
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
468
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
469 465
 
470 466
 	if id == 0 {
471 467
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -493,8 +489,6 @@ func (c *StockManagerApiController) EditWarehouse() {
493 489
 		Status:           1,
494 490
 		WarehousingTime:  warehousingDate.Unix(),
495 491
 		Type:             warehouse.Type,
496
-		Dealer:           dealer_id,
497
-		Manufacturer:     manufacturer_id,
498 492
 	}
499 493
 
500 494
 	service.EditWarehousing(warehousing)
@@ -583,6 +577,9 @@ func (c *StockManagerApiController) EditWarehouse() {
583 577
 
584 578
 				remark, _ := items["remark"].(string)
585 579
 
580
+				manufacturer := int64(items["manufacturer"].(float64))
581
+				dealer := int64(items["dealer"].(float64))
582
+
586 583
 				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
587 584
 					utils.ErrorLog("id")
588 585
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -607,8 +604,9 @@ func (c *StockManagerApiController) EditWarehouse() {
607 604
 						Remark:           remark,
608 605
 						OrgId:            adminUserInfo.CurrentOrgId,
609 606
 						Type:             types,
610
-						Manufacturer:     manufacturer_id,
611
-						Dealer:           dealer_id,
607
+						Manufacturer:     manufacturer,
608
+						Dealer:           dealer,
609
+						StockCount:       warehousing_count,
612 610
 					}
613 611
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
614 612
 
@@ -630,8 +628,9 @@ func (c *StockManagerApiController) EditWarehouse() {
630 628
 						Remark:           remark,
631 629
 						OrgId:            adminUserInfo.CurrentOrgId,
632 630
 						Type:             types,
633
-						Manufacturer:     manufacturer_id,
634
-						Dealer:           dealer_id,
631
+						Manufacturer:     manufacturer,
632
+						Dealer:           dealer,
633
+						StockCount:       warehousing_count,
635 634
 					}
636 635
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
637 636
 				}
@@ -1042,8 +1041,7 @@ func (c *StockManagerApiController) EditReturnInfo() {
1042 1041
 }
1043 1042
 
1044 1043
 func (c *StockManagerApiController) CreateWarehouseOut() {
1045
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1046
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1044
+
1047 1045
 	types, _ := c.GetInt64("type", 0)
1048 1046
 
1049 1047
 	ctime := time.Now().Unix()
@@ -1076,8 +1074,6 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1076 1074
 		Ctime:                   ctime,
1077 1075
 		Status:                  1,
1078 1076
 		WarehouseOutTime:        warehousingOutDate.Unix(),
1079
-		Dealer:                  dealer_id,
1080
-		Manufacturer:            manufacturer_id,
1081 1077
 		Type:                    types,
1082 1078
 	}
1083 1079
 	service.AddSigleWarehouseOut(&warehouseOut)
@@ -1105,7 +1101,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1105 1101
 				}
1106 1102
 
1107 1103
 				good_id := int64(items["good_id"].(float64))
1108
-				fmt.Println("stockout223232324343445456465656565565665", good_id)
1104
+
1109 1105
 				if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
1110 1106
 					utils.ErrorLog("good_type_id")
1111 1107
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1131,6 +1127,8 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1131 1127
 				total := float64(count) * price
1132 1128
 				remark := items["remark"].(string)
1133 1129
 
1130
+				manufacturer := int64(items["manufacturer"].(float64))
1131
+
1134 1132
 				warehouseOutInfo := &models.WarehouseOutInfo{
1135 1133
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1136 1134
 					WarehouseOutId:          warehouseOut.ID,
@@ -1144,8 +1142,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1144 1142
 					Remark:                  remark,
1145 1143
 					OrgId:                   adminUserInfo.CurrentOrgId,
1146 1144
 					Type:                    types,
1147
-					Manufacturer:            manufacturer_id,
1148
-					Dealer:                  dealer_id,
1145
+					Manufacturer:            manufacturer,
1149 1146
 				}
1150 1147
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1151 1148
 
@@ -1284,8 +1281,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1284 1281
 	warehouse_out_time := c.GetString("warehouse_out_time")
1285 1282
 	id, _ := c.GetInt64("id", 0)
1286 1283
 	types, _ := c.GetInt64("type", 0)
1287
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
1288
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
1289 1284
 
1290 1285
 	if id == 0 {
1291 1286
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1309,8 +1304,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1309 1304
 		ID:               warehouseOut.ID,
1310 1305
 		Mtime:            mtime,
1311 1306
 		WarehouseOutTime: warehouseOutDate.Unix(),
1312
-		Manufacturer:     manufacturer_id,
1313
-		Dealer:           dealer_id,
1314 1307
 	}
1315 1308
 
1316 1309
 	service.EditWarehouseOut(tempWarehouseOut)
@@ -1371,6 +1364,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1371 1364
 				}
1372 1365
 				id := int64(items["id"].(float64))
1373 1366
 
1367
+				manufacturer := int64(items["manufacturer"].(float64))
1374 1368
 				if id == 0 {
1375 1369
 					warehouseOutInfo := &models.WarehouseOutInfo{
1376 1370
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1385,8 +1379,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1385 1379
 						Remark:                  remark,
1386 1380
 						OrgId:                   adminUserInfo.CurrentOrgId,
1387 1381
 						Type:                    types,
1388
-						Manufacturer:            manufacturer_id,
1389
-						Dealer:                  dealer_id,
1390 1382
 						IsSys:                   0,
1391 1383
 						SysRecordTime:           0,
1392 1384
 					}
@@ -1422,8 +1414,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1422 1414
 						OrgId:                   adminUserInfo.CurrentOrgId,
1423 1415
 						Mtime:                   time.Now().Unix(),
1424 1416
 						Type:                    types,
1425
-						Manufacturer:            manufacturer_id,
1426
-						Dealer:                  dealer_id,
1417
+						Manufacturer:            manufacturer,
1427 1418
 						IsSys:                   is_sys,
1428 1419
 						SysRecordTime:           sys_record_time,
1429 1420
 					}
@@ -3615,9 +3606,11 @@ func (this *StockManagerApiController) PostSearchGoodList() {
3615 3606
 	orgId := adminUserInfo.CurrentOrgId
3616 3607
 	list, _ := service.GetSearchGoodList(keyword, orgId)
3617 3608
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3609
+	dealerList, _ := service.GetAllDealerList(orgId)
3618 3610
 	this.ServeSuccessJSON(map[string]interface{}{
3619 3611
 		"list":             list,
3620 3612
 		"manufacturerList": manufacturerList,
3613
+		"dealerList":       dealerList,
3621 3614
 	})
3622 3615
 }
3623 3616
 
@@ -3695,10 +3688,12 @@ func (this *StockManagerApiController) GetStockListById() {
3695 3688
 	}
3696 3689
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3697 3690
 	list, total, _ := service.GetStockListById(id, orgId, limit, page, startTime, endTime)
3691
+	outList, _, _ := service.GetStockOutList(id, orgId, limit, page, startTime, endTime)
3698 3692
 	this.ServeSuccessJSON(map[string]interface{}{
3699 3693
 		"list":             list,
3700 3694
 		"total":            total,
3701 3695
 		"manufacturerList": manufacturerList,
3696
+		"outList":          outList,
3702 3697
 	})
3703 3698
 }
3704 3699
 

+ 2 - 2
service/gobal_config_service.go View File

@@ -548,7 +548,7 @@ func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, l
548 548
 		db = db.Where("x.drug_id = ?", drugid)
549 549
 	}
550 550
 
551
-	err = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status = 1 and t.org_id = ?", orgid).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.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
551
+	err = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status = 1 and t.org_id = ?", orgid).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.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,x.ctime,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
552 552
 	return list, total, err
553 553
 }
554 554
 
@@ -576,7 +576,7 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
576 576
 	if stocktype == 2 {
577 577
 		db = db.Where("x,is_sys = 1")
578 578
 	}
579
-	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").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
579
+	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").Offset(offset).Count(&total).Order("x.ctime desc").Scan(&list).Error
580 580
 	return list, total, err
581 581
 }
582 582
 

+ 13 - 3
service/stock_service.go View File

@@ -2782,7 +2782,7 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
2782 2782
 	if good_id > 0 {
2783 2783
 		db = db.Where("x.good_id = ?", good_id)
2784 2784
 	}
2785
-	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,x.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
2785
+	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
2786 2786
 	return info, total, err
2787 2787
 
2788 2788
 }
@@ -2804,7 +2804,7 @@ func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, starti
2804 2804
 	if good_id > 0 {
2805 2805
 		db = db.Where("x.good_id = ?", good_id)
2806 2806
 	}
2807
-	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_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").Offset(offset).Count(&total).Scan(&info).Error
2807
+	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_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.warehouse_out_order_number").Offset(offset).Count(&total).Scan(&info).Error
2808 2808
 	return info, total, err
2809 2809
 }
2810 2810
 
@@ -2843,7 +2843,17 @@ func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*
2843 2843
 
2844 2844
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
2845 2845
 
2846
-	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
2846
+	if startime > 0 {
2847
+		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=?  and `status` = 1)  as b GROUP BY good_id", orgid, startime).Scan(&autoMatic).Error
2848
+	} else {
2849
+		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
2850
+	}
2851
+
2852
+	if endtime > 0 {
2853
+		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time <=?  and `status` = 1)  as b GROUP BY good_id", orgid, endtime).Scan(&autoMatic).Error
2854
+	} else {
2855
+		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
2856
+	}
2847 2857
 
2848 2858
 	return autoMatic, err
2849 2859
 

+ 5 - 6
service/warhouse_service.go View File

@@ -879,9 +879,8 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
879 879
 			}
880 880
 		}
881 881
 		fmt.Println("newcount9999999999999999999999999999999", goods.NewCount)
882
-		
882
+
883 883
 		maxNumber = goods.Count
884
-		
885 884
 
886 885
 		if warehouse.StockCount < maxNumber {
887 886
 			return errors.New("库存数量不足")
@@ -1019,7 +1018,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1019 1018
 		goods.Count = deliver_number - stock_number
1020 1019
 
1021 1020
 		ConsumablesDelivery(orgID, patient_id, record_time, goods, warehouseOut, count)
1022
-		
1021
+
1023 1022
 	}
1024 1023
 	return nil
1025 1024
 }
@@ -1280,7 +1279,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1280 1279
 			Type:                    1,
1281 1280
 			Manufacturer:            0,
1282 1281
 			Dealer:                  0,
1283
-			IsSys:                   2,
1282
+			IsSys:                   1,
1284 1283
 			SysRecordTime:           record_time,
1285 1284
 			GoodTypeId:              goods.GoodTypeId,
1286 1285
 			GoodId:                  goods.GoodId,
@@ -1308,7 +1307,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1308 1307
 				Type:                    1,
1309 1308
 				Manufacturer:            0,
1310 1309
 				Dealer:                  0,
1311
-				IsSys:                   2,
1310
+				IsSys:                   1,
1312 1311
 				SysRecordTime:           record_time,
1313 1312
 				GoodTypeId:              goods.GoodTypeId,
1314 1313
 				GoodId:                  goods.GoodId,
@@ -1431,7 +1430,7 @@ func ConsumablesDeliveryDeleteOne(orgID int64, record_time int64, good_yc *model
1431 1430
 			Type:          1,
1432 1431
 			Manufacturer:  0,
1433 1432
 			Dealer:        0,
1434
-			IsSys:         2,
1433
+			IsSys:         1,
1435 1434
 			SysRecordTime: record_time,
1436 1435
 			GoodTypeId:    good_yc.GoodTypeId,
1437 1436
 			GoodId:        good_yc.GoodId,