Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
1df9e073fb

+ 1 - 1
conf/app.conf View File

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

+ 1 - 0
controllers/drug_stock_api_contorller.go View File

@@ -70,6 +70,7 @@ func DrugStockManagerApiRegistRouters() {
70 70
 	beego.Router("/api/drug/drugcancelexportlist", &StockDrugApiController{}, "get:GetDrugCancelExportList")
71 71
 	beego.Router("/api/drug/getdrugwarehouseinfoprint", &StockDrugApiController{}, "get:GetDrugWarehouseInfoPrint")
72 72
 	beego.Router("/api/drug/getdrugoutorderprint", &StockDrugApiController{}, "get:GetDrugOutOrderPrint")
73
+
73 74
 }
74 75
 
75 76
 func (c *StockDrugApiController) CreateDrugWarehouse() {

+ 192 - 23
controllers/self_drug_api_congtroller.go View File

@@ -77,6 +77,7 @@ func SelfDrugRouters() {
77 77
 	beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Delete:DeleteDrugInventory")
78 78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
79 79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
80
+	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
80 81
 }
81 82
 
82 83
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -1196,13 +1197,19 @@ func (this *SelfDrugApiController) SaveCheckDrugPrice() {
1196 1197
 	}
1197 1198
 	err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
1198 1199
 	fmt.Println("err", err)
1200
+	list, _ := service.GetDrugAdjuestPrice(ids)
1201
+	for _, item := range list {
1202
+		drug := models.BaseDrugLib{
1203
+			RetailPrice: item.RetailPrice,
1204
+		}
1205
+		service.UpdateBaseDrugOne(drug, item.DrugId)
1206
+	}
1199 1207
 	this.ServeSuccessJSON(map[string]interface{}{
1200 1208
 		"adjustPrice": adjustPrice,
1201 1209
 	})
1202 1210
 }
1203 1211
 
1204 1212
 func (this *SelfDrugApiController) SaveDrugDamage() {
1205
-	fmt.Println("999999999999999999999")
1206 1213
 	timeLayout := "2006-01-02"
1207 1214
 	loc, _ := time.LoadLocation("Local")
1208 1215
 	dataBody := make(map[string]interface{}, 0)
@@ -1243,12 +1250,12 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
1243 1250
 			}
1244 1251
 			number := items["number"].(string)
1245 1252
 
1246
-			//if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
1247
-			//  utils.ErrorLog("dealer")
1248
-			//  this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1249
-			//  return
1250
-			//}
1251
-			//dealer := items["dealer"].(string)
1253
+			if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
1254
+				utils.ErrorLog("dealer")
1255
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1256
+				return
1257
+			}
1258
+			dealer := items["dealer"].(string)
1252 1259
 
1253 1260
 			if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
1254 1261
 				utils.ErrorLog("manufacturer")
@@ -1257,12 +1264,12 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
1257 1264
 			}
1258 1265
 			manufacturer := items["manufacturer"].(string)
1259 1266
 
1260
-			//if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
1261
-			//  utils.ErrorLog("specification_name")
1262
-			//  this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1263
-			//  return
1264
-			//}
1265
-			//specification_name := items["specification_name"].(string)
1267
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
1268
+				utils.ErrorLog("specification_name")
1269
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1270
+				return
1271
+			}
1272
+			specification_name := items["specification_name"].(string)
1266 1273
 
1267 1274
 			if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
1268 1275
 				utils.ErrorLog("remark")
@@ -1322,19 +1329,48 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
1322 1329
 				}
1323 1330
 				startTime = theTime.Unix()
1324 1331
 			}
1332
+
1333
+			if items["warehousing_info_id"] == nil || reflect.TypeOf(items["warehousing_info_id"]).String() != "float64" {
1334
+				utils.ErrorLog("warehousing_info_id")
1335
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1336
+				return
1337
+			}
1338
+			warehousing_info_id := int64(items["warehousing_info_id"].(float64))
1339
+
1340
+			if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
1341
+				utils.ErrorLog("expiry_date")
1342
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1343
+				return
1344
+			}
1345
+			expiry_date := int64(items["expiry_date"].(float64))
1346
+
1347
+			if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
1348
+				utils.ErrorLog("product_date")
1349
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1350
+				return
1351
+			}
1352
+			product_date := int64(items["product_date"].(float64))
1353
+
1354
+			if items["drug_origin_place"] == nil || reflect.TypeOf(items["drug_origin_place"]).String() != "string" {
1355
+				utils.ErrorLog("drug_origin_place")
1356
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1357
+				return
1358
+			}
1359
+			drug_origin_place := items["drug_origin_place"].(string)
1360
+
1325 1361
 			orgId := this.GetAdminUserInfo().CurrentOrgId
1326 1362
 			Creater := this.GetAdminUserInfo().AdminUser.Id
1327 1363
 
1328 1364
 			drugDamage := models.XtDrugDamage{
1329 1365
 				DrugName:          drug_name,
1330
-				SpecificationName: "",
1366
+				SpecificationName: specification_name,
1331 1367
 				WarehousingUnit:   warehousing_unit,
1332 1368
 				Count:             count,
1333 1369
 				LastPrice:         last_price,
1334 1370
 				RetailPrice:       retail_price,
1335 1371
 				NewPrice:          new_price,
1336 1372
 				Manufacturer:      manufacturer,
1337
-				Dealer:            "",
1373
+				Dealer:            dealer,
1338 1374
 				Remark:            remark,
1339 1375
 				DrugId:            drug_id,
1340 1376
 				UserOrgId:         orgId,
@@ -1348,6 +1384,10 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
1348 1384
 				Checker:           0,
1349 1385
 				CheckerStatus:     2,
1350 1386
 				CheckerTime:       0,
1387
+				ExpiryDate:        expiry_date,
1388
+				ProductDate:       product_date,
1389
+				WarehousingInfoId: warehousing_info_id,
1390
+				DrugOriginPlace:   drug_origin_place,
1351 1391
 			}
1352 1392
 
1353 1393
 			err := service.CreateDrugDamage(drugDamage)
@@ -1435,6 +1475,98 @@ func (this *SelfDrugApiController) SaveDrugDamagePrice() {
1435 1475
 	}
1436 1476
 	err = service.UpdateDrugDamage(ids, damage)
1437 1477
 	fmt.Println(err)
1478
+	list, _ := service.GetDrugDamage(ids)
1479
+	ctime := time.Now().Unix()
1480
+	adminUserInfo := this.GetAdminUserInfo()
1481
+	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1482
+	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
1483
+	var manufacturer_id int64
1484
+	var dealer_id int64
1485
+	for _, item := range list {
1486
+		for _, it := range manufacturerList {
1487
+			if item.Manufacturer == it.ManufacturerName {
1488
+				manufacturer_id = it.ID
1489
+			}
1490
+		}
1491
+
1492
+		for _, its := range dealerList {
1493
+			if its.DealerName == item.Dealer {
1494
+				dealer_id = its.ID
1495
+			}
1496
+		}
1497
+
1498
+		timeStr := time.Now().Format("2006-01-02")
1499
+		timeArr := strings.Split(timeStr, "-")
1500
+		total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1501
+
1502
+		total = total + 1
1503
+		warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1504
+		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1505
+		number = number + total
1506
+		warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1507
+		operation_time := time.Now().Unix()
1508
+		creater := adminUserInfo.AdminUser.Id
1509
+
1510
+		warehouseOut := models.DrugWarehouseOut{
1511
+			WarehouseOutOrderNumber: warehousing_out_order,
1512
+			OperationTime:           operation_time,
1513
+			OrgId:                   adminUserInfo.CurrentOrgId,
1514
+			Creater:                 creater,
1515
+			Ctime:                   ctime,
1516
+			Status:                  1,
1517
+			WarehouseOutTime:        time.Now().Unix(),
1518
+			Type:                    1,
1519
+		}
1520
+
1521
+		warehouseOutInfo := models.XtDrugWarehouseOutInfo{
1522
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1523
+			WarehouseOutId:          warehouseOut.ID,
1524
+			DrugId:                  item.DrugId,
1525
+			Count:                   item.Count,
1526
+			Price:                   item.RetailPrice,
1527
+			Status:                  1,
1528
+			Ctime:                   ctime,
1529
+			Remark:                  item.Remark,
1530
+			OrgId:                   adminUserInfo.CurrentOrgId,
1531
+			Type:                    1,
1532
+			Manufacturer:            manufacturer_id,
1533
+			Dealer:                  dealer_id,
1534
+			RetailPrice:             item.RetailPrice,
1535
+			CountUnit:               item.WarehousingUnit,
1536
+			ExpiryDate:              item.ExpiryDate,
1537
+			ProductDate:             item.ProductDate,
1538
+			Number:                  item.Number,
1539
+			BatchNumber:             item.BatchNumber,
1540
+			IsSys:                   0,
1541
+			WarehouseInfoId:         item.WarehousingInfoId,
1542
+		}
1543
+
1544
+		drugflow := models.DrugFlow{
1545
+			WarehouseOutId:          warehouseOut.ID,
1546
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1547
+			DrugId:                  item.DrugId,
1548
+			Number:                  item.Number,
1549
+			ProductDate:             item.ProductDate,
1550
+			ExpireDate:              item.ExpiryDate,
1551
+			Count:                   item.Count,
1552
+			Price:                   item.RetailPrice,
1553
+			Status:                  1,
1554
+			Ctime:                   ctime,
1555
+			UserOrgId:               adminUserInfo.CurrentOrgId,
1556
+			Manufacturer:            manufacturer_id,
1557
+			Dealer:                  dealer_id,
1558
+			BatchNumber:             item.BatchNumber,
1559
+			MaxUnit:                 item.WarehousingUnit,
1560
+			ConsumableType:          5,
1561
+			IsEdit:                  1,
1562
+			Creator:                 adminUserInfo.AdminUser.Id,
1563
+			IsSys:                   0,
1564
+		}
1565
+		service.CreateWareHouseOutInfo(&warehouseOutInfo)
1566
+		service.AddSigleDrugWarehouseOut(&warehouseOut)
1567
+		service.CreateDrugFlowOne(drugflow)
1568
+
1569
+	}
1438 1570
 	this.ServeSuccessJSON(map[string]interface{}{
1439 1571
 		"damage": damage,
1440 1572
 	})
@@ -1576,7 +1708,7 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1576 1708
 		for _, item := range tableData {
1577 1709
 			items := item.(map[string]interface{})
1578 1710
 			drug_name := items["drug_name"].(string)
1579
-			fmt.Println("durg_nae232333223332232323323223232323", drug_name)
1711
+
1580 1712
 			if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
1581 1713
 				utils.ErrorLog("drug_name")
1582 1714
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1700,14 +1832,20 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1700 1832
 
1701 1833
 			numbers := items["number"].(string)
1702 1834
 
1703
-			if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
1704
-				utils.ErrorLog("batch_number")
1835
+			//if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
1836
+			//	utils.ErrorLog("batch_number")
1837
+			//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1838
+			//	return
1839
+			//}
1840
+			//
1841
+			//batch_number := items["batch_number"].(string)
1842
+
1843
+			if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
1844
+				utils.ErrorLog("warehouse_info_id")
1705 1845
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1706 1846
 				return
1707 1847
 			}
1708
-
1709
-			batch_number := items["batch_number"].(string)
1710
-
1848
+			warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1711 1849
 			inventory := models.XtDrugInventory{
1712 1850
 
1713 1851
 				DrugName:          drug_name,
@@ -1735,7 +1873,8 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1735 1873
 				ExpiryDate:        expiry_date,
1736 1874
 				ProductDate:       product_date,
1737 1875
 				Number:            numbers,
1738
-				BatchNumber:       batch_number,
1876
+				//BatchNumber:       batch_number,
1877
+				WarehouseInfoId: warehouse_info_id,
1739 1878
 			}
1740 1879
 			err = service.CreateDrugInventory(inventory)
1741 1880
 			fmt.Println(err)
@@ -1854,7 +1993,7 @@ func (this *SelfDrugApiController) ModifyInventory() {
1854 1993
 	manufacturer := this.GetString("manufacturer")
1855 1994
 	remark := this.GetString("remark")
1856 1995
 	warehousing_unit := this.GetString("warehousing_unit")
1857
-	total, _ := this.GetInt64("total")
1996
+	total := this.GetString("total")
1858 1997
 	lastPrice := this.GetString("last_price")
1859 1998
 	last_price, _ := strconv.ParseFloat(lastPrice, 64)
1860 1999
 	count, _ := this.GetInt64("count")
@@ -1931,3 +2070,33 @@ func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
1931 2070
 		"doctorList": doctorList,
1932 2071
 	})
1933 2072
 }
2073
+
2074
+func (this *SelfDrugApiController) SaveDrugProofInventory() {
2075
+
2076
+	id, _ := this.GetInt64("id")
2077
+	warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
2078
+	warehousing_unit := this.GetString("warehousing_unit")
2079
+	remark := this.GetString("remark")
2080
+	//total := this.GetString("total")
2081
+	prof_count, _ := this.GetInt64("prof_count")
2082
+
2083
+	inventory := models.XtDrugInventory{
2084
+		WarehouseInfoId: warehouse_info_id,
2085
+		ProofCount:      prof_count,
2086
+		WarehousingUnit: warehousing_unit,
2087
+		Remark:          remark,
2088
+	}
2089
+	err := service.UpdateDrugProofInventory(warehouse_info_id, &inventory)
2090
+	info := models.XtDrugWarehouseInfo{
2091
+		StockMaxNumber: prof_count,
2092
+	}
2093
+	service.UpdateDrugWarehouseInfoById(id, &info)
2094
+	if err != nil {
2095
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2096
+		return
2097
+	}
2098
+
2099
+	this.ServeSuccessJSON(map[string]interface{}{
2100
+		"inventory": inventory,
2101
+	})
2102
+}

+ 35 - 2
models/self_drug_models.go View File

@@ -700,6 +700,33 @@ func (XtDrugAdjustPrice) TableName() string {
700 700
 	return "xt_drug_adjust_price"
701 701
 }
702 702
 
703
+type VmDrugAdjustPrice struct {
704
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
705
+	DrugName          string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
706
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
707
+	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
708
+	Count             int64   `gorm:"column:count" json:"count" form:"count"`
709
+	LastPrice         float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
710
+	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
711
+	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
712
+	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
713
+	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
714
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
715
+	DrugId            int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
716
+	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
717
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
718
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
719
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
720
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
721
+	Number            string  `gorm:"column:number" json:"number" form:"number"`
722
+	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
723
+	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
724
+	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
725
+	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
726
+	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
727
+	UserName          string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
728
+}
729
+
703 730
 type XtDrugDamage struct {
704 731
 	ID                int64   `gorm:"column:id" json:"id" form:"id"`
705 732
 	DrugName          string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
@@ -724,6 +751,11 @@ type XtDrugDamage struct {
724 751
 	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
725 752
 	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
726 753
 	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
754
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
755
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
756
+	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
757
+	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
758
+	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
727 759
 }
728 760
 
729 761
 func (XtDrugDamage) TableName() string {
@@ -758,9 +790,10 @@ type XtDrugInventory struct {
758 790
 	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
759 791
 	Number            string  `gorm:"column:number" json:"number" form:"number"`
760 792
 	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
761
-	UserName          string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
762
-	Total             int64   `gorm:"column:total" json:"total" form:"total"`
793
+	Total             string  `gorm:"column:total" json:"total" form:"total"`
763 794
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
795
+	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
796
+	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
764 797
 }
765 798
 
766 799
 func (XtDrugInventory) TableName() string {

+ 52 - 13
service/self_drug_service.go View File

@@ -817,7 +817,7 @@ func PostSearchDrugWarehouseList(keyword string, orgid int64) (info []*models.Bl
817 817
 	if orgid > 0 {
818 818
 		db = db.Where("x.org_id = ?", orgid)
819 819
 	}
820
-	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,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_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").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
820
+	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,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_origin_place").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
821 821
 	return info, err
822 822
 
823 823
 }
@@ -828,24 +828,39 @@ func CreateDrugPrice(price models.XtDrugAdjustPrice) error {
828 828
 	return err
829 829
 }
830 830
 
831
-func GetDrugPriceList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.XtDrugAdjustPrice, total int64, err error) {
831
+func GetDrugPriceList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugAdjustPrice, total int64, err error) {
832
+	//likeKey := "%" + keyword + "%"
833
+	//offset := (page - 1) * limit
834
+	//db := XTReadDB().Model(&adjust).Where("status = 1")
835
+	//if startime > 0 {
836
+	//	db = db.Where("ctime >=?", startime)
837
+	//}
838
+	//if endtime > 0 {
839
+	//	db = db.Where("ctime<=?", endtime)
840
+	//}
841
+	//if orgId > 0 {
842
+	//	db = db.Where("user_org_id = ?", orgId)
843
+	//}
844
+	//if len(keyword) > 0 {
845
+	//	db = db.Where("warehousing_order like ?", likeKey)
846
+	//}
847
+	//err = db.Count(&total).Offset(offset).Limit(limit).Find(&adjust).Error
848
+	//return adjust, total, err
832 849
 	likeKey := "%" + keyword + "%"
833 850
 	offset := (page - 1) * limit
834
-	db := XTReadDB().Model(&adjust).Where("status = 1")
835
-	if startime > 0 {
836
-		db = db.Where("ctime >=?", startime)
837
-	}
838
-	if endtime > 0 {
839
-		db = db.Where("ctime<=?", endtime)
851
+	db := XTReadDB().Table("xt_drug_adjust_price as x").Where("x.status = 1")
852
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
853
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
854
+	fmt.Println(table, tab)
855
+	if len(keyword) > 0 {
856
+		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
840 857
 	}
841 858
 	if orgId > 0 {
842
-		db = db.Where("user_org_id = ?", orgId)
843
-	}
844
-	if len(keyword) > 0 {
845
-		db = db.Where("warehousing_order like ?", likeKey)
859
+		db = db.Where("x.user_org_id = ?", orgId)
846 860
 	}
847
-	err = db.Count(&total).Offset(offset).Limit(limit).Find(&adjust).Error
861
+	err = db.Group("x.id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
848 862
 	return adjust, total, err
863
+
849 864
 }
850 865
 
851 866
 func UpdateDrugAdjuestPrice(ids []string, info models.XtDrugAdjustPrice) error {
@@ -853,6 +868,18 @@ func UpdateDrugAdjuestPrice(ids []string, info models.XtDrugAdjustPrice) error {
853 868
 	return err
854 869
 }
855 870
 
871
+func GetDrugAdjuestPrice(ids []string) (info []*models.XtDrugAdjustPrice, err error) {
872
+
873
+	err = XTReadDB().Model(&info).Where("id in(?) and status = 1", ids).Find(&info).Error
874
+	return info, err
875
+}
876
+
877
+func GetDrugDamage(ids []string) (info []*models.XtDrugDamage, err error) {
878
+
879
+	err = XTReadDB().Model(&info).Where("id in(?) and status = 1", ids).Find(&info).Error
880
+	return info, err
881
+}
882
+
856 883
 func CreateDrugDamage(damage models.XtDrugDamage) error {
857 884
 
858 885
 	err := XTWriteDB().Create(&damage).Error
@@ -1012,3 +1039,15 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1012 1039
 	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1013 1040
 	return list, total, err
1014 1041
 }
1042
+
1043
+func UpdateDrugProofInventory(id int64, inventory *models.XtDrugInventory) error {
1044
+
1045
+	err := XTWriteDB().Model(&inventory).Where("id=? and status = 1", id).Updates(map[string]interface{}{"warehouse_info_id": inventory.WarehouseInfoId, "proof_count": inventory.ProofCount, "warehousing_unit": inventory.WarehousingUnit, "remark": inventory.Remark}).Error
1046
+	return err
1047
+}
1048
+
1049
+func UpdateDrugWarehouseInfoById(id int64, inventory *models.XtDrugWarehouseInfo) error {
1050
+
1051
+	err := XTWriteDB().Model(&inventory).Where("id = ?", id).Updates(map[string]interface{}{"stock_max_number": inventory.StockMaxNumber}).Error
1052
+	return err
1053
+}

+ 6 - 0
service/stock_service.go View File

@@ -505,6 +505,12 @@ func UpdateBaseDrug(lib *models.BaseDrugLib, id int64) error {
505 505
 	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"total": lib.Total}).Error
506 506
 	return err
507 507
 }
508
+
509
+func UpdateBaseDrugOne(lib models.BaseDrugLib, id int64) error {
510
+
511
+	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"retail_price": lib.RetailPrice}).Error
512
+	return err
513
+}
508 514
 func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
509 515
 	info := models.DrugWarehouseInfo{}
510 516
 	err := XTReadDB().Model(&info).Where("id=? and status = 1", id).Find(&info).Error