|
@@ -534,11 +534,11 @@ func CreateDrugWarehousingInfoSix(warehousingInfo []*models.DrugWarehouseInfo) (
|
534
|
534
|
if len(warehousingInfo) > 0 {
|
535
|
535
|
utx := writeDb.Begin()
|
536
|
536
|
if len(warehousingInfo) > 0 {
|
537
|
|
- 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,stock_min_number,supply_warehouse_id,supply_warehouse_detail_info,storehouse_id) VALUES "
|
|
537
|
+ 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,stock_min_number,supply_warehouse_id,supply_warehouse_detail_info,storehouse_id,is_check) VALUES "
|
538
|
538
|
insertParams := make([]string, 0)
|
539
|
539
|
insertData := make([]interface{}, 0)
|
540
|
540
|
for _, info := range warehousingInfo {
|
541
|
|
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
|
|
541
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
|
542
|
542
|
insertData = append(insertData, info.WarehousingId)
|
543
|
543
|
insertData = append(insertData, info.DrugId)
|
544
|
544
|
insertData = append(insertData, info.Number)
|
|
@@ -566,6 +566,7 @@ func CreateDrugWarehousingInfoSix(warehousingInfo []*models.DrugWarehouseInfo) (
|
566
|
566
|
insertData = append(insertData, info.SupplyWarehouseId)
|
567
|
567
|
insertData = append(insertData, info.SupplyWarehouseDetailInfo)
|
568
|
568
|
insertData = append(insertData, info.StorehouseId)
|
|
569
|
+ insertData = append(insertData, info.IsCheck)
|
569
|
570
|
}
|
570
|
571
|
thisSQL += strings.Join(insertParams, ", ")
|
571
|
572
|
err = utx.Exec(thisSQL, insertData...).Error
|
|
@@ -728,15 +729,14 @@ func CreateDrugFlowOne(flow models.DrugFlow) error {
|
728
|
729
|
return err
|
729
|
730
|
}
|
730
|
731
|
|
731
|
|
-func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64) (models.DrugAutomaticReduceDetail, error) {
|
732
|
|
-
|
|
732
|
+func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64, id int64, warhouse_out_id int64) (models.DrugAutomaticReduceDetail, error) {
|
733
|
733
|
detail := models.DrugAutomaticReduceDetail{}
|
734
|
|
- err := XTWriteDB().Model(&detail).Where("patient_id = ? and record_time = ? and drug_id = ? and status= 1 and advice_id =?", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
735
|
|
- err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id =? and sys_record_time =? and drug_id = ? and status = 1 and advice_id =?", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
|
734
|
+ err := XTWriteDB().Model(&detail).Where("patient_id = ? and record_time = ? and drug_id = ? and status= 1 and advice_id =? ", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
|
735
|
+ err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id =? and sys_record_time =? and drug_id = ? and status = 1 and advice_id =? and id = ?", patientid, recorddate, drugid, advice_id, id).Updates(map[string]interface{}{"status": 0}).Error
|
736
|
736
|
return detail, err
|
737
|
737
|
}
|
738
|
738
|
|
739
|
|
-func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64) (models.DrugFlow, error) {
|
|
739
|
+func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64, id int64) (models.DrugFlow, error) {
|
740
|
740
|
flow := models.DrugFlow{}
|
741
|
741
|
err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1 and advice_id =?", patientid, warehouse_out_number, drug_id, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
742
|
742
|
return flow, err
|
|
@@ -802,10 +802,10 @@ func FindWarehousingInfoTen(goodId int64, storehouse_id int64) (models.Warehousi
|
802
|
802
|
info := models.WarehousingInfo{}
|
803
|
803
|
var err error
|
804
|
804
|
if storehouse_id == 0 {
|
805
|
|
- err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1", goodId).Find(&info).Error
|
|
805
|
+ err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and is_check = 1", goodId).Find(&info).Error
|
806
|
806
|
}
|
807
|
807
|
if storehouse_id > 0 {
|
808
|
|
- err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and storehouse_id = ?", goodId, storehouse_id).Find(&info).Error
|
|
808
|
+ err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and storehouse_id = ? and is_check = 1", goodId, storehouse_id).Find(&info).Error
|
809
|
809
|
}
|
810
|
810
|
|
811
|
811
|
return info, err
|
|
@@ -814,7 +814,7 @@ func FindWarehousingInfoTen(goodId int64, storehouse_id int64) (models.Warehousi
|
814
|
814
|
|
815
|
815
|
|
816
|
816
|
func FindLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64) (info models.XtDrugWarehouseInfo, err error) {
|
817
|
|
- err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ?", drug_id, storehouse_id).Order("ctime").First(&info).Error
|
|
817
|
+ err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
|
818
|
818
|
return info, err
|
819
|
819
|
}
|
820
|
820
|
|
|
@@ -849,7 +849,7 @@ func FindLastDrugWarehousingInfo(order string) (info models.DrugWarehouseInfo, e
|
849
|
849
|
|
850
|
850
|
}
|
851
|
851
|
|
852
|
|
-func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*models.Warehousing, total int64, err error) {
|
|
852
|
+func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, check_type int64) (list []*models.Warehousing, total int64, err error) {
|
853
|
853
|
db := readDb.Model(&models.Warehousing{})
|
854
|
854
|
db = db.Where("xt_warehouse.org_id = ? AND xt_warehouse.status = 1 AND xt_warehouse.type = ?", orgId, types)
|
855
|
855
|
|
|
@@ -871,6 +871,13 @@ func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int6
|
871
|
871
|
db = db.Where("xt_warehouse.storehouse_id = ?", storehouse_id)
|
872
|
872
|
}
|
873
|
873
|
|
|
874
|
+ if check_type == 0 {
|
|
875
|
+ db = db.Where("xt_warehouse.is_check = 0 or xt_warehouse.is_check = 1 or xt_warehouse.is_check = 2")
|
|
876
|
+ }
|
|
877
|
+ if check_type > 0 {
|
|
878
|
+ db = db.Where("xt_warehouse.is_check = ?", check_type)
|
|
879
|
+ }
|
|
880
|
+
|
874
|
881
|
db = db.Count(&total)
|
875
|
882
|
offset := (page - 1) * limit
|
876
|
883
|
err = db.Offset(offset).Limit(limit).Order("xt_warehouse.ctime desc").Find(&list).Error
|
|
@@ -955,6 +962,7 @@ type VMDrugWarehouse struct {
|
955
|
962
|
SupplyWarehouseId int64 `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
|
956
|
963
|
StorehouseId int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
|
957
|
964
|
IsSys int64 `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
|
|
965
|
+ IsCheck int64 `gorm:"column:is_check" json:"is_check" form:"is_check"`
|
958
|
966
|
}
|
959
|
967
|
|
960
|
968
|
func (VMDrugWarehouse) TableName() string {
|
|
@@ -1094,7 +1102,7 @@ func FindAllDrugWarehousingList(orgId int64, page int64, limit int64, startTime
|
1094
|
1102
|
return
|
1095
|
1103
|
}
|
1096
|
1104
|
|
1097
|
|
-func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*VMDrugWarehouse, total int64, err error) {
|
|
1105
|
+func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, check_type int64) (list []*VMDrugWarehouse, total int64, err error) {
|
1098
|
1106
|
db := readDb.Model(&VMDrugWarehouse{})
|
1099
|
1107
|
db = db.Where("xt_drug_warehouse.org_id = ? AND xt_drug_warehouse.status = 1", orgId)
|
1100
|
1108
|
db = db.Preload("Manufacturers", "status = 1 AND org_id = ?", orgId)
|
|
@@ -1113,6 +1121,9 @@ func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTi
|
1113
|
1121
|
if storehouse_id > 0 {
|
1114
|
1122
|
db = db.Where("xt_drug_warehouse.storehouse_id = ?", storehouse_id)
|
1115
|
1123
|
}
|
|
1124
|
+ if check_type > 0 {
|
|
1125
|
+ db = db.Where("xt_drug_warehouse.is_check = ?", check_type)
|
|
1126
|
+ }
|
1116
|
1127
|
db = db.Count(&total)
|
1117
|
1128
|
offset := (page - 1) * limit
|
1118
|
1129
|
err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
|
|
@@ -1352,32 +1363,33 @@ func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err erro
|
1352
|
1363
|
}
|
1353
|
1364
|
|
1354
|
1365
|
type DrugCancelStockInfo struct {
|
1355
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
1356
|
|
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
1357
|
|
- CancelStockId int64 `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
|
1358
|
|
- Count int64 `gorm:"column:count" json:"count" form:"count"`
|
1359
|
|
- Price float64 `gorm:"column:price" json:"price" form:"price"`
|
1360
|
|
- Total float64 `gorm:"column:total" json:"total" form:"total"`
|
1361
|
|
- ProductDate int64 `gorm:"column:product_date" json:"product_date" form:"product_date"`
|
1362
|
|
- ExpiryDate int64 `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
|
1363
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
1364
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
1365
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
1366
|
|
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
1367
|
|
- OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
|
1368
|
|
- Type int64 `gorm:"column:type" json:"type" form:"type"`
|
1369
|
|
- Dealer string `gorm:"column:dealer" json:"dealer" form:"dealer"`
|
1370
|
|
- Manufacturer string `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
|
1371
|
|
- RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
|
1372
|
|
- RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
|
1373
|
|
- Number string `gorm:"column:number" json:"number" form:"number"`
|
1374
|
|
- RegisterAccount string `gorm:"column:register_account" json:"register_account" form:"register_account"`
|
1375
|
|
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
1376
|
|
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
|
1377
|
|
- MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
|
1378
|
|
- Drug *Drug `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
|
1379
|
|
- BatchNumberId int64 `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
|
1380
|
|
- StorehouseId int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
|
|
1366
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1367
|
+ DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
|
1368
|
+ CancelStockId int64 `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
|
|
1369
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
1370
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
1371
|
+ Total float64 `gorm:"column:total" json:"total" form:"total"`
|
|
1372
|
+ ProductDate int64 `gorm:"column:product_date" json:"product_date" form:"product_date"`
|
|
1373
|
+ ExpiryDate int64 `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
|
|
1374
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
1375
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
1376
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1377
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
1378
|
+ OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
|
|
1379
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
1380
|
+ Dealer string `gorm:"column:dealer" json:"dealer" form:"dealer"`
|
|
1381
|
+ Manufacturer string `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
|
|
1382
|
+ RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
|
|
1383
|
+ RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
|
|
1384
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
1385
|
+ RegisterAccount string `gorm:"column:register_account" json:"register_account" form:"register_account"`
|
|
1386
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
1387
|
+ BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
|
|
1388
|
+ MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
|
|
1389
|
+ Drug *Drug `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
|
|
1390
|
+ BatchNumberId int64 `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
|
|
1391
|
+ StorehouseId int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
|
|
1392
|
+ DrugWarehouseInfo []*models.XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"drug_warehouse_info"`
|
1381
|
1393
|
}
|
1382
|
1394
|
|
1383
|
1395
|
func (DrugCancelStockInfo) TableName() string {
|
|
@@ -1385,7 +1397,7 @@ func (DrugCancelStockInfo) TableName() string {
|
1385
|
1397
|
}
|
1386
|
1398
|
|
1387
|
1399
|
func FindDrugCancelStockInfoById(id int64, org_id int64) (list []*DrugCancelStockInfo, err error) {
|
1388
|
|
- err = readDb.Model(&DrugCancelStockInfo{}).Preload("Drug", "status = 1 AND org_id = ? ", org_id).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
|
|
1400
|
+ err = readDb.Model(&DrugCancelStockInfo{}).Preload("Drug", "status = 1 AND org_id = ? ", org_id).Preload("DrugWarehouseInfo", "status = 1 AND org_id = ? ", org_id).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
|
1389
|
1401
|
return list, err
|
1390
|
1402
|
}
|
1391
|
1403
|
|
|
@@ -1552,7 +1564,7 @@ func FindAllWarehouseOutList(orgId int64, page int64, limit int64, startTime int
|
1552
|
1564
|
|
1553
|
1565
|
}
|
1554
|
1566
|
|
1555
|
|
-func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.WarehouseOut, total int64, err error) {
|
|
1567
|
+func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64, check_type int64) (list []*models.WarehouseOut, total int64, err error) {
|
1556
|
1568
|
db := readDb.Model(&models.WarehouseOut{})
|
1557
|
1569
|
db = db.Where("xt_warehouse_out.org_id = ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.type = ?", orgId, types)
|
1558
|
1570
|
|
|
@@ -1572,7 +1584,7 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
|
1572
|
1584
|
db = db.Where("xt_warehouse_out.storehouse_id = ?", storehouse_id)
|
1573
|
1585
|
}
|
1574
|
1586
|
if way_type == 0 {
|
1575
|
|
- db = db.Where("xt_warehouse_out.is_sys = 0 || xt_warehouse_out.is_sys = 1 || xt_warehouse_out.is_sys = 12")
|
|
1587
|
+ db = db.Where("xt_warehouse_out.is_sys = 0 or xt_warehouse_out.is_sys = 1 or xt_warehouse_out.is_sys = 12")
|
1576
|
1588
|
}
|
1577
|
1589
|
if way_type == 1 {
|
1578
|
1590
|
db = db.Where("xt_warehouse_out.is_sys = 0")
|
|
@@ -1583,6 +1595,12 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
|
1583
|
1595
|
if way_type == 3 {
|
1584
|
1596
|
db = db.Where("xt_warehouse_out.is_sys = 12")
|
1585
|
1597
|
}
|
|
1598
|
+ if check_type > 0 {
|
|
1599
|
+ db = db.Where("xt_warehouse_out.is_check = ?", check_type)
|
|
1600
|
+ }
|
|
1601
|
+ if check_type == 0 {
|
|
1602
|
+ db = db.Where("xt_warehouse_out.is_check = 1 or xt_warehouse_out.is_check = 2")
|
|
1603
|
+ }
|
1586
|
1604
|
db = db.Count(&total)
|
1587
|
1605
|
offset := (page - 1) * limit
|
1588
|
1606
|
if orgId == 10191 {
|
|
@@ -1620,7 +1638,7 @@ func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime
|
1620
|
1638
|
|
1621
|
1639
|
}
|
1622
|
1640
|
|
1623
|
|
-func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.DrugWarehouseOut, total int64, err error) {
|
|
1641
|
+func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64, check_type int64) (list []*models.DrugWarehouseOut, total int64, err error) {
|
1624
|
1642
|
db := readDb.Model(&models.DrugWarehouseOut{})
|
1625
|
1643
|
db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
|
1626
|
1644
|
|
|
@@ -1640,6 +1658,9 @@ func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startT
|
1640
|
1658
|
if storehouse_id > 0 {
|
1641
|
1659
|
db = db.Where("xt_drug_warehouse_out.storehouse_id = ?", storehouse_id)
|
1642
|
1660
|
}
|
|
1661
|
+ if check_type > 0 {
|
|
1662
|
+ db = db.Where("xt_drug_warehouse_out.is_check = ?", check_type)
|
|
1663
|
+ }
|
1643
|
1664
|
|
1644
|
1665
|
if way_type == 0 {
|
1645
|
1666
|
db = db.Where("xt_drug_warehouse_out.is_sys = 0 || xt_drug_warehouse_out.is_sys = 1 || xt_drug_warehouse_out.is_sys = 12")
|
|
@@ -2535,7 +2556,7 @@ func UpdateDrugFlowSix(warehousoutid int64, drugid int64, warehouse_out_order_nu
|
2535
|
2556
|
return err
|
2536
|
2557
|
}
|
2537
|
2558
|
|
2538
|
|
-func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehouse_id int64) (list []*models.CancelStock, total int64, err error) {
|
|
2559
|
+func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehouse_id int64, check_type int64) (list []*models.CancelStock, total int64, err error) {
|
2539
|
2560
|
db := readDb.Model(&models.CancelStock{})
|
2540
|
2561
|
db = db.Where("xt_cancel_stock.org_id = ? AND xt_cancel_stock.status = 1 AND xt_cancel_stock.type = ?", orgId, types)
|
2541
|
2562
|
if len(keywords) > 0 {
|
|
@@ -2554,13 +2575,16 @@ func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, en
|
2554
|
2575
|
if storehouse_id > 0 {
|
2555
|
2576
|
db = db.Where("xt_cancel_stock.storehouse_id = ?", storehouse_id)
|
2556
|
2577
|
}
|
|
2578
|
+ if check_type > 0 {
|
|
2579
|
+ db = db.Where("xt_cancel_stock.is_check = ?", check_type)
|
|
2580
|
+ }
|
2557
|
2581
|
db = db.Count(&total)
|
2558
|
2582
|
offset := (page - 1) * limit
|
2559
|
2583
|
err = db.Offset(offset).Limit(limit).Order("xt_cancel_stock.ctime desc").Find(&list).Error
|
2560
|
2584
|
return
|
2561
|
2585
|
}
|
2562
|
2586
|
|
2563
|
|
-func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehoue_id int64) (list []*models.DrugCancelStock, total int64, err error) {
|
|
2587
|
+func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehoue_id int64, check_type int64) (list []*models.DrugCancelStock, total int64, err error) {
|
2564
|
2588
|
db := readDb.Model(&models.DrugCancelStock{})
|
2565
|
2589
|
db = db.Where("xt_drug_cancel_stock.org_id = ? AND xt_drug_cancel_stock.status = 1", orgId)
|
2566
|
2590
|
if len(keywords) > 0 {
|
|
@@ -2579,6 +2603,9 @@ func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64
|
2579
|
2603
|
if storehoue_id > 0 {
|
2580
|
2604
|
db = db.Where("xt_drug_cancel_stock.storehouse_id = ?", storehoue_id)
|
2581
|
2605
|
}
|
|
2606
|
+ if check_type > 0 {
|
|
2607
|
+ db = db.Where("xt_drug_cancel_stock.is_check = ?", check_type)
|
|
2608
|
+ }
|
2582
|
2609
|
db = db.Count(&total)
|
2583
|
2610
|
offset := (page - 1) * limit
|
2584
|
2611
|
err = db.Offset(offset).Limit(limit).Order("xt_drug_cancel_stock.ctime desc").Find(&list).Error
|
|
@@ -2738,7 +2765,7 @@ type StockDetailModel struct {
|
2738
|
2765
|
func FindStockInDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehousingInfo, total int64, err error) {
|
2739
|
2766
|
|
2740
|
2767
|
db := readDb.Model(&models.WarehousingInfo{})
|
2741
|
|
- db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1", orgId)
|
|
2768
|
+ db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1 AND xt_warehouse_info.is_check = 1", orgId)
|
2742
|
2769
|
if len(keywords) > 0 {
|
2743
|
2770
|
likeKey := "%" + keywords + "%"
|
2744
|
2771
|
|
|
@@ -2814,7 +2841,7 @@ func FloatRound(f float64, n int) float64 {
|
2814
|
2841
|
|
2815
|
2842
|
func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehouseOutInfo, total int64, err error) {
|
2816
|
2843
|
db := readDb.Model(&models.WarehouseOutInfo{})
|
2817
|
|
- db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
|
|
2844
|
+ db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
|
2818
|
2845
|
|
2819
|
2846
|
if len(keywords) > 0 {
|
2820
|
2847
|
likeKey := "%" + keywords + "%"
|
|
@@ -3943,7 +3970,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
|
3943
|
3970
|
if storehouse_id > 0 {
|
3944
|
3971
|
db = db.Where("storehouse_id = ?", storehouse_id)
|
3945
|
3972
|
}
|
3946
|
|
- return db.Where("status = 1")
|
|
3973
|
+ return db.Where("status = 1 and is_check = 1")
|
3947
|
3974
|
}).Preload("WarehousingInfo", func(db *gorm.DB) *gorm.DB {
|
3948
|
3975
|
if startime > 0 {
|
3949
|
3976
|
db = db.Where("ctime>=?", startime)
|
|
@@ -3973,7 +4000,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
|
3973
|
4000
|
func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
|
3974
|
4001
|
|
3975
|
4002
|
offset := (page - 1) * limit
|
3976
|
|
- db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1")
|
|
4003
|
+ db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1 and x.is_check = 1")
|
3977
|
4004
|
table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
|
3978
|
4005
|
fmt.Println(table)
|
3979
|
4006
|
if startime > 0 {
|
|
@@ -4099,7 +4126,9 @@ func GetWarehouseOutOrder(id []string, orgid int64) (out []*models.WarehouseOut,
|
4099
|
4126
|
if orgid > 0 {
|
4100
|
4127
|
db = db.Where("x.org_id= ?", orgid)
|
4101
|
4128
|
}
|
4102
|
|
- err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Find(&out).Error
|
|
4129
|
+ err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Preload("WarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
|
|
4130
|
+ return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid)
|
|
4131
|
+ }).Find(&out).Error
|
4103
|
4132
|
return out, err
|
4104
|
4133
|
}
|
4105
|
4134
|
|
|
@@ -4107,7 +4136,8 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
|
4107
|
4136
|
|
4108
|
4137
|
db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
|
4109
|
4138
|
table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
|
4110
|
|
- fmt.Println(table)
|
|
4139
|
+ tableOne := XTReadDB().Table("xt_warehouse_info as n").Where("n.status = 1")
|
|
4140
|
+ fmt.Println(table, tableOne)
|
4111
|
4141
|
if len(id) > 0 {
|
4112
|
4142
|
db = db.Where("x.warehouse_out_id in (?)", id)
|
4113
|
4143
|
}
|
|
@@ -4115,7 +4145,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
|
4115
|
4145
|
db = db.Where("x.org_id = ?", orgid)
|
4116
|
4146
|
}
|
4117
|
4147
|
|
4118
|
|
- 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,t.social_security_directory_code,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
|
|
4148
|
+ 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,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
|
4119
|
4149
|
return out, err
|
4120
|
4150
|
}
|
4121
|
4151
|
|
|
@@ -4690,10 +4720,9 @@ func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehou
|
4690
|
4720
|
|
4691
|
4721
|
func GetDrugWarehouseOutTenty(warehouse_out_id []string, orgid int64) (out []*models.DrugWarehouseOutTwenty, err error) {
|
4692
|
4722
|
|
4693
|
|
- err = XTReadDB().Where("id in(?)", warehouse_out_id).
|
4694
|
|
- Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
|
4695
|
|
- return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid)
|
4696
|
|
- }).Find(&out).Error
|
|
4723
|
+ err = XTReadDB().Where("id in(?)", warehouse_out_id).Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
|
|
4724
|
+ return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid).Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid)
|
|
4725
|
+ }).Find(&out).Error
|
4697
|
4726
|
|
4698
|
4727
|
return out, err
|
4699
|
4728
|
}
|
|
@@ -5107,9 +5136,9 @@ func GetDrugWarehouseInfoPrescription(drugid int64, orgid int64) (info []*models
|
5107
|
5136
|
return info, err
|
5108
|
5137
|
}
|
5109
|
5138
|
|
5110
|
|
-func GetDrugWarehouseInfoPrescriptionSeven(drugid int64, orgid int64) (info []*models.DrugWarehouseInfoSeven, err error) {
|
|
5139
|
+func GetDrugWarehouseInfoPrescriptionSeven(drugid int64, orgid int64, storehouse_id int64) (info []*models.DrugWarehouseInfoSeven, err error) {
|
5111
|
5140
|
|
5112
|
|
- err = XTReadDB().Select("id,stock_max_number,stock_min_number").Where("drug_id = ? and org_id =? and status = 1", drugid, orgid).Find(&info).Error
|
|
5141
|
+ err = XTReadDB().Select("id,stock_max_number,stock_min_number").Where("drug_id = ? and org_id =? and status = 1 and storehouse_id = ? and is_check = 1", drugid, orgid, storehouse_id).Find(&info).Error
|
5113
|
5142
|
return info, err
|
5114
|
5143
|
}
|
5115
|
5144
|
|
|
@@ -5120,6 +5149,12 @@ func GetHisAdviceListByDrugId(drugid int64, patient_id int64, advice_date int64)
|
5120
|
5149
|
return info, err
|
5121
|
5150
|
}
|
5122
|
5151
|
|
|
5152
|
+func GetHisAdviceListByDrugIdTwo(patient_id int64, advice_date int64, orgid int64) (info []*models.HisDoctorAdviceInfo, err error) {
|
|
5153
|
+
|
|
5154
|
+ err = XTReadDB().Where("patient_id = ? and advice_date = ? and status = 1 and user_org_id = ?", patient_id, advice_date, orgid).Find(&info).Error
|
|
5155
|
+ return info, err
|
|
5156
|
+}
|
|
5157
|
+
|
5123
|
5158
|
func GetHisAdviceListByDrugIdEight(drugid int64, patient_id int64, advice_date int64, advice_id int64) (models.HisDoctorAdviceInfo, error) {
|
5124
|
5159
|
|
5125
|
5160
|
info := models.HisDoctorAdviceInfo{}
|
|
@@ -5133,6 +5168,12 @@ func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date
|
5133
|
5168
|
return detail, err
|
5134
|
5169
|
}
|
5135
|
5170
|
|
|
5171
|
+func GetLastDrugWarehouseOutByDrugIdTwenty(drugid int64, patient_id int64, advice_date int64, advice_id int64) (out []*models.DrugWarehouseOutInfo, err error) {
|
|
5172
|
+
|
|
5173
|
+ err = XTReadDB().Where("advice_id = ? and drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and is_check = 1", advice_id, drugid, patient_id, advice_date).Find(&out).Error
|
|
5174
|
+ return out, err
|
|
5175
|
+}
|
|
5176
|
+
|
5136
|
5177
|
func ModefyDrugByWarehouseInfo(id int64, stock_max_number int64) error {
|
5137
|
5178
|
|
5138
|
5179
|
err := XTWriteDB().Model(models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", stock_max_number)).Error
|
|
@@ -5393,7 +5434,7 @@ func GetTemplatePlan(orgid int64) (config []*models.Dataconfig, err error) {
|
5393
|
5434
|
|
5394
|
5435
|
func GetSearchGoodWarehouseList(keyword string, orgid int64, storehouse_id int64) (info []*models.BloodWarehouseInfo, err error) {
|
5395
|
5436
|
|
5396
|
|
- db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
|
|
5437
|
+ db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
|
5397
|
5438
|
table := XTReadDB().Table("xt_goood_information as t").Where("t.status")
|
5398
|
5439
|
fmt.Println(table)
|
5399
|
5440
|
likeKey := "%" + keyword + "%"
|
|
@@ -5911,7 +5952,7 @@ func UpdateWarehouseInfoByGoodId(info models.WarehousingInfo, id int64) error {
|
5911
|
5952
|
return err
|
5912
|
5953
|
}
|
5913
|
5954
|
|
5914
|
|
-func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
|
|
5955
|
+func UpdateWarehouseInfoByGoodIdOne(info *models.WarehousingInfo, id int64) error {
|
5915
|
5956
|
|
5916
|
5957
|
err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark, "packing_price": info.PackingPrice, "storehouse_id": info.StorehouseId}).Error
|
5917
|
5958
|
return err
|
|
@@ -6178,8 +6219,6 @@ func ModifyGoodReduceInformationTwo(good_id int64, sum_count int64, orgid int64)
|
6178
|
6219
|
func ModifyGoodReduceInformationSix(good_id int64, sum_count int64, orgid int64, retail_price float64) (models.GoodInfo, error) {
|
6179
|
6220
|
|
6180
|
6221
|
info := models.GoodInfo{}
|
6181
|
|
-
|
6182
|
|
- err = XTWriteDB().Model(&info).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", sum_count)).Error
|
6183
|
6222
|
err = XTWriteDB().Model(&info).Where("id = ? and org_id = ? and status = 1", good_id, orgid).Update(map[string]interface{}{"batch_retai_price": retail_price}).Error
|
6184
|
6223
|
return info, err
|
6185
|
6224
|
}
|
|
@@ -6812,6 +6851,14 @@ func GetDrugOpenConfig(orgid int64) (*models.DrugOutConfig, error) {
|
6812
|
6851
|
return &config, nil
|
6813
|
6852
|
}
|
6814
|
6853
|
|
|
6854
|
+func GetDrugOpenConfigOne(orgid int64) (models.DrugOutConfig, error) {
|
|
6855
|
+
|
|
6856
|
+ config := models.DrugOutConfig{}
|
|
6857
|
+ err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
|
|
6858
|
+
|
|
6859
|
+ return config, err
|
|
6860
|
+}
|
|
6861
|
+
|
6815
|
6862
|
func CreateDrugOutConfig(config models.DrugOutConfig) error {
|
6816
|
6863
|
|
6817
|
6864
|
err := XTWriteDB().Create(&config).Error
|
|
@@ -6830,3 +6877,536 @@ func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
|
6830
|
6877
|
err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
|
6831
|
6878
|
return config, err
|
6832
|
6879
|
}
|
|
6880
|
+
|
|
6881
|
+func UpdatedWarehouseOut(id int64) error {
|
|
6882
|
+
|
|
6883
|
+ err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
6884
|
+ err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
6885
|
+ return err
|
|
6886
|
+}
|
|
6887
|
+
|
|
6888
|
+func UpdatedSigleWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
|
|
6889
|
+
|
|
6890
|
+ err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
|
|
6891
|
+
|
|
6892
|
+ return err
|
|
6893
|
+
|
|
6894
|
+}
|
|
6895
|
+
|
|
6896
|
+func GetLastGoodWarehouseOutInfo(orgid int64, id int64) (info []*models.WarehouseOutInfo, err error) {
|
|
6897
|
+
|
|
6898
|
+ err = XTReadDB().Where("org_id = ? and status = 1 and warehouse_out_id = ?", orgid, id).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
|
|
6899
|
+ return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("GoodsType", "status = 1")
|
|
6900
|
+ }).Find(&info).Error
|
|
6901
|
+ return info, err
|
|
6902
|
+}
|
|
6903
|
+
|
|
6904
|
+func GetLastGoodWarehouseOutInfoById(orgid int64) (models.WarehouseOutInfo, error) {
|
|
6905
|
+ info := models.WarehouseOutInfo{}
|
|
6906
|
+ err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&info).Error
|
|
6907
|
+ return info, err
|
|
6908
|
+}
|
|
6909
|
+
|
|
6910
|
+func ModifyWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
|
|
6911
|
+
|
|
6912
|
+ err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount}).Error
|
|
6913
|
+ return err
|
|
6914
|
+}
|
|
6915
|
+
|
|
6916
|
+func UpdateWarehouseOutFlow(info models.VmStockFlow, id int64) error {
|
|
6917
|
+
|
|
6918
|
+ err := XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_detail_id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "number": info.Number, "license_number": info.LicenseNumber, "count": info.Count, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "price": info.Price, "expire_date": info.ExpireDate, "product_date": info.ProductDate, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount}).Error
|
|
6919
|
+ return err
|
|
6920
|
+}
|
|
6921
|
+
|
|
6922
|
+func GetLastGoodWarehouseOutTwenty(orgid int64) (models.WarehouseOut, error) {
|
|
6923
|
+ out := models.WarehouseOut{}
|
|
6924
|
+ err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&out).Error
|
|
6925
|
+ return out, err
|
|
6926
|
+}
|
|
6927
|
+
|
|
6928
|
+func UpdateaGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64) error {
|
|
6929
|
+
|
|
6930
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("good_id = ? and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
|
6931
|
+
|
|
6932
|
+ return err
|
|
6933
|
+}
|
|
6934
|
+
|
|
6935
|
+func ModifyGoodWarehouseOut(id int64) error {
|
|
6936
|
+
|
|
6937
|
+ err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
6938
|
+ err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
6939
|
+ err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
|
|
6940
|
+
|
|
6941
|
+ return err
|
|
6942
|
+}
|
|
6943
|
+
|
|
6944
|
+func GetGoodWarehouseInfoById(waresing_id int64, orgid int64) (info []*models.VmWarehousingInfoSix, err error) {
|
|
6945
|
+
|
|
6946
|
+ err = XTReadDB().Where("org_id = ? and status = 1 and warehousing_id = ?", orgid, waresing_id).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
|
|
6947
|
+ return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("GoodsType", "status = 1")
|
|
6948
|
+ }).Find(&info).Error
|
|
6949
|
+ return info, err
|
|
6950
|
+}
|
|
6951
|
+
|
|
6952
|
+func FindLastWarehousing(order string) (info models.Warehousing, err error) {
|
|
6953
|
+ err = readDb.Model(&models.Warehousing{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
|
|
6954
|
+
|
|
6955
|
+ return info, err
|
|
6956
|
+
|
|
6957
|
+}
|
|
6958
|
+
|
|
6959
|
+func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
|
|
6960
|
+
|
|
6961
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "warehousing_unit": info.WarehousingUnit, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "license_number": info.LicenseNumber, "packing_price": info.PackingPrice}).Error
|
|
6962
|
+ return err
|
|
6963
|
+}
|
|
6964
|
+
|
|
6965
|
+func UpdateCheckWarehouseInfo(id int64) error {
|
|
6966
|
+
|
|
6967
|
+ err := XTWriteDB().Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
6968
|
+ return err
|
|
6969
|
+}
|
|
6970
|
+
|
|
6971
|
+func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
|
|
6972
|
+
|
|
6973
|
+ err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
|
|
6974
|
+ return info, err
|
|
6975
|
+}
|
|
6976
|
+
|
|
6977
|
+func UpdateWarehouseInfoByIdList(count int64, id int64) error {
|
|
6978
|
+
|
|
6979
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
|
6980
|
+ err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
6981
|
+ return err
|
|
6982
|
+}
|
|
6983
|
+
|
|
6984
|
+func ReturnCheckWarehouseInfo(id int64) error {
|
|
6985
|
+
|
|
6986
|
+ err := XTWriteDB().Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
6987
|
+ err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
6988
|
+ return err
|
|
6989
|
+}
|
|
6990
|
+
|
|
6991
|
+func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
|
|
6992
|
+
|
|
6993
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
|
|
6994
|
+ err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
6995
|
+ return err
|
|
6996
|
+}
|
|
6997
|
+
|
|
6998
|
+func UpdateWarehouseInfoFlow(id int64) error {
|
|
6999
|
+
|
|
7000
|
+ err := XTWriteDB().Model(models.VmStockFlow{}).Where("warehousing_detail_id = ?", id).Update(map[string]interface{}{"status": 0}).Error
|
|
7001
|
+ return err
|
|
7002
|
+}
|
|
7003
|
+
|
|
7004
|
+func FindLastWarehousingSix(org_id int64) (info models.Warehousing, err error) {
|
|
7005
|
+ err = readDb.Model(&models.Warehousing{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
|
|
7006
|
+
|
|
7007
|
+ return info, err
|
|
7008
|
+
|
|
7009
|
+}
|
|
7010
|
+
|
|
7011
|
+func FindLastWarehousingSeven(org_id int64) (info models.DrugWarehouse, err error) {
|
|
7012
|
+ err = readDb.Model(&models.DrugWarehouse{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
|
|
7013
|
+
|
|
7014
|
+ return info, err
|
|
7015
|
+
|
|
7016
|
+}
|
|
7017
|
+
|
|
7018
|
+func FindLastDrugWarehousingInfoTwenty(org_id int64) (info models.DrugWarehouseInfo, err error) {
|
|
7019
|
+ err = readDb.Model(&models.DrugWarehouseInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
|
|
7020
|
+
|
|
7021
|
+ return info, err
|
|
7022
|
+
|
|
7023
|
+}
|
|
7024
|
+
|
|
7025
|
+func FindDrugWarehouseInfoListById(id int64, orgid int64) (info []*models.DrugWarehouseInfoTwenty, err error) {
|
|
7026
|
+
|
|
7027
|
+ err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Preload("BaseDrugLib", "status = 1 and org_id =?", orgid).Find(&info).Error
|
|
7028
|
+ return info, err
|
|
7029
|
+}
|
|
7030
|
+
|
|
7031
|
+func CreatedWarehouseing(info *models.DrugWarehouseInfo) error {
|
|
7032
|
+
|
|
7033
|
+ err := XTWriteDB().Create(&info).Error
|
|
7034
|
+ return err
|
|
7035
|
+}
|
|
7036
|
+
|
|
7037
|
+func UpdateWarehouseing(info *models.DrugWarehouseInfo) error {
|
|
7038
|
+
|
|
7039
|
+ err := XTWriteDB().Save(&info).Error
|
|
7040
|
+ return err
|
|
7041
|
+}
|
|
7042
|
+
|
|
7043
|
+func CheckWarehousingInfo(id int64, orgid int64) error {
|
|
7044
|
+
|
|
7045
|
+ err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7046
|
+ return err
|
|
7047
|
+}
|
|
7048
|
+
|
|
7049
|
+func GetWarehousingInfoByList(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
|
|
7050
|
+
|
|
7051
|
+ err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
|
|
7052
|
+ return info, err
|
|
7053
|
+}
|
|
7054
|
+
|
|
7055
|
+func AddDrugWarehouseStockMaxNumber(count int64, id int64) error {
|
|
7056
|
+
|
|
7057
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
|
|
7058
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7059
|
+ return err
|
|
7060
|
+}
|
|
7061
|
+
|
|
7062
|
+func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
|
|
7063
|
+
|
|
7064
|
+ err := XTWriteDB().Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
|
|
7065
|
+ return err
|
|
7066
|
+}
|
|
7067
|
+
|
|
7068
|
+func AddDrugWarehouseStockMinNumber(count int64, id int64) error {
|
|
7069
|
+
|
|
7070
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
|
|
7071
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7072
|
+ return err
|
|
7073
|
+}
|
|
7074
|
+
|
|
7075
|
+func ReturnCheckWarehouseingInfo(id int64, orgid int64) error {
|
|
7076
|
+
|
|
7077
|
+ err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7078
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("warehousing_id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7079
|
+ return err
|
|
7080
|
+}
|
|
7081
|
+
|
|
7082
|
+func AddDrugReturnWarehouseStockMaxNumber(count int64, id int64) error {
|
|
7083
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
|
|
7084
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7085
|
+ return err
|
|
7086
|
+}
|
|
7087
|
+
|
|
7088
|
+func AddDrugReturnWarehouseStockMinNumber(count int64, id int64) error {
|
|
7089
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
|
|
7090
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7091
|
+ return err
|
|
7092
|
+}
|
|
7093
|
+
|
|
7094
|
+func UpdateDrugWarehouseInfoTwenty(id int64, info *models.DrugWarehouseInfo) error {
|
|
7095
|
+
|
|
7096
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "retail_price": info.RetailPrice, "max_unit": info.MaxUnit, "min_unit": info.MinUnit}).Error
|
|
7097
|
+ return err
|
|
7098
|
+}
|
|
7099
|
+
|
|
7100
|
+func UpdatedDrugWarehouseInfo(info *models.DrugWarehouseOutInfo, id int64) error {
|
|
7101
|
+
|
|
7102
|
+ err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount}).Error
|
|
7103
|
+ return err
|
|
7104
|
+}
|
|
7105
|
+
|
|
7106
|
+func GetDrugLastWarehouseOut(orgid int64) (models.DrugWarehouseOut, error) {
|
|
7107
|
+ out := models.DrugWarehouseOut{}
|
|
7108
|
+ err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&out).Error
|
|
7109
|
+ return out, err
|
|
7110
|
+}
|
|
7111
|
+
|
|
7112
|
+func GetDrugWarehouseOutListById(warehouse_out_id int64, orgId int64) (info []*models.DrugWarehouseOutInfo, err error) {
|
|
7113
|
+
|
|
7114
|
+ err = XTReadDB().Where("warehouse_out_id = ? and org_id =? and status = 1", warehouse_out_id, orgId).Preload("BaseDrugLib", "status=1").Find(&info).Error
|
|
7115
|
+ return info, err
|
|
7116
|
+}
|
|
7117
|
+
|
|
7118
|
+func UpdateCheckDrugOut(out models.DrugWarehouseOut, id int64) error {
|
|
7119
|
+
|
|
7120
|
+ err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": out.IsCheck}).Error
|
|
7121
|
+ err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7122
|
+ return err
|
|
7123
|
+}
|
|
7124
|
+
|
|
7125
|
+func UpdateCheckDrugOutInfoList(info models.DrugWarehouseOutInfo, warehouse_out_id int64) error {
|
|
7126
|
+
|
|
7127
|
+ err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", warehouse_out_id).Update(map[string]interface{}{"is_check": info.IsCheck}).Error
|
|
7128
|
+ return err
|
|
7129
|
+}
|
|
7130
|
+
|
|
7131
|
+func UpdateCheckDrugOutInfo(info models.DrugWarehouseOutInfo, warehouse_out_id int64) error {
|
|
7132
|
+
|
|
7133
|
+ err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ?", warehouse_out_id).Update(map[string]interface{}{"is_check": info.IsCheck}).Error
|
|
7134
|
+ return err
|
|
7135
|
+}
|
|
7136
|
+
|
|
7137
|
+func GetDrugWarehouseOutByLastId(id int64) (models.DrugWarehouseOut, error) {
|
|
7138
|
+ out := models.DrugWarehouseOut{}
|
|
7139
|
+ err := XTReadDB().Where("id = ? and status = 1", id).Find(&out).Error
|
|
7140
|
+ return out, err
|
|
7141
|
+}
|
|
7142
|
+
|
|
7143
|
+func UpdateDrugMaxNumber(count int64, id int64) error {
|
|
7144
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
|
|
7145
|
+ return err
|
|
7146
|
+}
|
|
7147
|
+
|
|
7148
|
+func UpdateDrugMinNumber(count int64, id int64) error {
|
|
7149
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
|
|
7150
|
+ return err
|
|
7151
|
+}
|
|
7152
|
+
|
|
7153
|
+func DeleteDrugOutFlow(id int64, orgid int64) error {
|
|
7154
|
+
|
|
7155
|
+ err := XTWriteDB().Model(models.DrugFlow{}).Where("warehouse_out_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
|
|
7156
|
+ return err
|
|
7157
|
+}
|
|
7158
|
+
|
|
7159
|
+func GetWarehouseOutByWarehouseInfoId(warehouse_info_id int64, good_id int64, orgid int64) (outInfo []*models.WarehouseOutInfo, err error) {
|
|
7160
|
+
|
|
7161
|
+ err = XTReadDB().Where("warehouse_info_id = ? and good_id = ? and org_id = ? and is_check = 1 and status = 1", warehouse_info_id, good_id, orgid).Find(&outInfo).Error
|
|
7162
|
+ return outInfo, err
|
|
7163
|
+}
|
|
7164
|
+
|
|
7165
|
+func GetDrugWarehouseOutByWarehouseInfoId(warehouse_info_id int64, drug_id int64, orgid int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
|
|
7166
|
+
|
|
7167
|
+ err = XTReadDB().Where("warehouse_info_id = ? and drug_id = ? and org_id = ? and is_check = 1 and status = 1", warehouse_info_id, drug_id, orgid).Find(&outInfo).Error
|
|
7168
|
+ return outInfo, err
|
|
7169
|
+}
|
|
7170
|
+
|
|
7171
|
+func GetAllStockInList(id int64, orgid int64) (info []*models.VmWarehousingInfoSix, err error) {
|
|
7172
|
+
|
|
7173
|
+ err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Preload("GoodInfo", "status = 1 and org_id =?", orgid).Find(&info).Error
|
|
7174
|
+ return info, err
|
|
7175
|
+}
|
|
7176
|
+
|
|
7177
|
+func GetDrugWarehouseInfoList(id int64, orgid int64) (info []*models.DrugWarehouseInfoTwenty, err error) {
|
|
7178
|
+
|
|
7179
|
+ err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Preload("BaseDrugLib", "org_id = ? and status = 1", orgid).Find(&info).Error
|
|
7180
|
+
|
|
7181
|
+ return info, err
|
|
7182
|
+}
|
|
7183
|
+
|
|
7184
|
+func GetStockCountByGoodId(goodid int64, storehouse_id int64, orgId int64) (info []*models.WarehousingInfo, err error) {
|
|
7185
|
+
|
|
7186
|
+ err = XTReadDB().Where("good_id = ? and storehouse_id = ? and org_id = ? and status = 1 and is_check = 1", goodid, storehouse_id, orgId).Find(&info).Error
|
|
7187
|
+ return info, err
|
|
7188
|
+}
|
|
7189
|
+
|
|
7190
|
+func UpdateGoodInfoSumCount(goodid int64, sum_count int64, orgid int64) error {
|
|
7191
|
+
|
|
7192
|
+ err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
7193
|
+ err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_count)).Error
|
|
7194
|
+ return err
|
|
7195
|
+}
|
|
7196
|
+
|
|
7197
|
+func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) error {
|
|
7198
|
+
|
|
7199
|
+ err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7200
|
+ return err
|
|
7201
|
+}
|
|
7202
|
+
|
|
7203
|
+func GetCancelStockInfo(id int64, orgid int64) (stock []*models.CancelStockInfo, err error) {
|
|
7204
|
+
|
|
7205
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", id, orgid).Preload("GoodInfo", "status = 1 and org_id = ?", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid).Find(&stock).Error
|
|
7206
|
+ return stock, err
|
|
7207
|
+}
|
|
7208
|
+
|
|
7209
|
+func ModifyCancelStockInfo(id int64, info *models.CancelStockInfo) error {
|
|
7210
|
+
|
|
7211
|
+ err := XTWriteDB().Model(&models.CancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark}).Error
|
|
7212
|
+ return err
|
|
7213
|
+}
|
|
7214
|
+
|
|
7215
|
+func GetCancelStockInfoListById(cancel_stock_id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
|
|
7216
|
+
|
|
7217
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&info).Error
|
|
7218
|
+ return info, err
|
|
7219
|
+}
|
|
7220
|
+
|
|
7221
|
+func GetWarehouseOutList(orgId int64, goodId int64, warehouseInfoId int64) (info []*models.WarehouseOutInfo, err error) {
|
|
7222
|
+
|
|
7223
|
+ err = XTReadDB().Where("org_id = ? and good_id = ? and warehouse_info_id = ? and status = 1", orgId, goodId, warehouseInfoId).Find(&info).Error
|
|
7224
|
+ return info, err
|
|
7225
|
+}
|
|
7226
|
+
|
|
7227
|
+func GetCancelWarehouseList(orgId int64, goodId int64, warehouseInfoId int64) (info []*models.CancelStockInfo, err error) {
|
|
7228
|
+
|
|
7229
|
+ err = XTReadDB().Where("org_id = ? and good_id = ? and warehouse_info_id = ? and status = 1", orgId, goodId, warehouseInfoId).Find(&info).Error
|
|
7230
|
+ return info, err
|
|
7231
|
+}
|
|
7232
|
+
|
|
7233
|
+func CheckCancelStock(stock models.CancelStock, cancel_stock_id int64, orgid int64) error {
|
|
7234
|
+
|
|
7235
|
+ err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7236
|
+ err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7237
|
+ return err
|
|
7238
|
+}
|
|
7239
|
+
|
|
7240
|
+func GetCancelStockInfoById(cancel_stock_id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
|
|
7241
|
+
|
|
7242
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 and is_check = 1", cancel_stock_id, orgid).Find(&info).Error
|
|
7243
|
+ return info, err
|
|
7244
|
+}
|
|
7245
|
+
|
|
7246
|
+func UpdateCancelStockNumber(stock_count int64, warehouse_info_id int64, orgid int64) error {
|
|
7247
|
+
|
|
7248
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
|
|
7249
|
+ return err
|
|
7250
|
+}
|
|
7251
|
+
|
|
7252
|
+func UpdateGoodSumCount(sum_count int64, good_id int64, orgid int64) error {
|
|
7253
|
+
|
|
7254
|
+ err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
7255
|
+ return err
|
|
7256
|
+}
|
|
7257
|
+
|
|
7258
|
+func UpdateStockWarehouseInfo(cancel_stock_id int64, orgid int64, stock models.CancelStock) error {
|
|
7259
|
+
|
|
7260
|
+ err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7261
|
+ err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7262
|
+ return err
|
|
7263
|
+}
|
|
7264
|
+
|
|
7265
|
+func UpdateStockWarehouseInfoStockFlow(id int64, orgid int64, goodid int64) error {
|
|
7266
|
+ err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
|
|
7267
|
+ return err
|
|
7268
|
+}
|
|
7269
|
+
|
|
7270
|
+func UpdateStockNumberWarehouseInfo(warehouse_info_id int64, good_id int64, org_id int64, stock_count int64) error {
|
|
7271
|
+
|
|
7272
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and good_id = ? and org_id = ? and status = 1", warehouse_info_id, good_id, org_id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", stock_count)).Error
|
|
7273
|
+ err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and status = 1 and org_id = ?", good_id, org_id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", stock_count)).Error
|
|
7274
|
+ return err
|
|
7275
|
+}
|
|
7276
|
+
|
|
7277
|
+func UpdateDrugSumCount(drugid int64, sum_count int64, sum_in_count int64, orgid int64) error {
|
|
7278
|
+
|
|
7279
|
+ err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ?", drugid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
7280
|
+ err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ?", drugid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_in_count)).Error
|
|
7281
|
+ return err
|
|
7282
|
+}
|
|
7283
|
+
|
|
7284
|
+func GetDrugStockWarehouseInfo(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
|
|
7285
|
+
|
|
7286
|
+ err = XTReadDB().Where("id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
|
|
7287
|
+ return info, err
|
|
7288
|
+}
|
|
7289
|
+
|
|
7290
|
+func UpdateBaseDrugSum(drugid int64, orgid int64, sum_count int64, sum_in_count int64) error {
|
|
7291
|
+
|
|
7292
|
+ err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
7293
|
+ err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_in_count)).Error
|
|
7294
|
+ return err
|
|
7295
|
+}
|
|
7296
|
+
|
|
7297
|
+func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info []*models.DrugWarehouseInfo, err error) {
|
|
7298
|
+
|
|
7299
|
+ err = XTReadDB().Where("storehouse_id = ? and org_id = ? and status = 1 and drug_id = ? and is_check = 1", storehouse_id, orgid, drugid).Find(&info).Error
|
|
7300
|
+ return info, err
|
|
7301
|
+}
|
|
7302
|
+
|
|
7303
|
+func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
|
|
7304
|
+
|
|
7305
|
+ err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7306
|
+ err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
|
7307
|
+ return err
|
|
7308
|
+}
|
|
7309
|
+
|
|
7310
|
+func UpdateBaseDrugSumTwo(drugid int64, sum_count int64, orgid int64) error {
|
|
7311
|
+
|
|
7312
|
+ err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7313
|
+ return err
|
|
7314
|
+}
|
|
7315
|
+
|
|
7316
|
+func GetLastCancelStockByList(id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
|
|
7317
|
+
|
|
7318
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", id, orgid).Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid).Find(&info).Error
|
|
7319
|
+ return info, err
|
|
7320
|
+}
|
|
7321
|
+
|
|
7322
|
+func GetCancelDrugStockList(cancel_stock_id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
|
|
7323
|
+
|
|
7324
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&info).Error
|
|
7325
|
+ return info, err
|
|
7326
|
+}
|
|
7327
|
+
|
|
7328
|
+func ModifyCancelStock(cancel_stock_id int64, stock models.DrugCancelStock, orgid int64) error {
|
|
7329
|
+
|
|
7330
|
+ err := XTWriteDB().Model(&models.DrugCancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7331
|
+ err = XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7332
|
+ return err
|
|
7333
|
+}
|
|
7334
|
+
|
|
7335
|
+func GetCancelDrugStock(cancel_stock_id int64, orgid int64) (models.DrugCancelStock, error) {
|
|
7336
|
+ stock := models.DrugCancelStock{}
|
|
7337
|
+ err := XTReadDB().Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&stock).Error
|
|
7338
|
+ return stock, err
|
|
7339
|
+}
|
|
7340
|
+
|
|
7341
|
+func GetDrugCancelCheckById(cancel_stock_id int64, orgid int64) (stock []*models.DrugCancelStockInfo, err error) {
|
|
7342
|
+
|
|
7343
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 and is_check = 1", cancel_stock_id, orgid).Find(&stock).Error
|
|
7344
|
+ return stock, err
|
|
7345
|
+}
|
|
7346
|
+
|
|
7347
|
+func GetDrugCancelCheckByIdTwenty(cancel_stock_id int64, orgid int64) (stock []*models.DrugCancelStockInfo, err error) {
|
|
7348
|
+
|
|
7349
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 ", cancel_stock_id, orgid).Find(&stock).Error
|
|
7350
|
+ return stock, err
|
|
7351
|
+}
|
|
7352
|
+
|
|
7353
|
+func GetDrugWarehouseOutList(batch_number_id int64, drugId int64, orgid int64) (info []*models.DrugWarehouseOutInfo, err error) {
|
|
7354
|
+
|
|
7355
|
+ err = XTReadDB().Where("warehouse_info_id = ? and drug_id = ? and org_id = ? and status = 1", batch_number_id, drugId, orgid).Find(&info).Error
|
|
7356
|
+ return info, err
|
|
7357
|
+}
|
|
7358
|
+
|
|
7359
|
+func ModifyDrugWarehouseInfoStockMaxNumber(count int64, drugid int64, orgid int64, id int64) error {
|
|
7360
|
+
|
|
7361
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
|
|
7362
|
+ return err
|
|
7363
|
+}
|
|
7364
|
+
|
|
7365
|
+func ModifyDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64) error {
|
|
7366
|
+
|
|
7367
|
+ err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
|
|
7368
|
+ return err
|
|
7369
|
+}
|
|
7370
|
+
|
|
7371
|
+func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
|
|
7372
|
+
|
|
7373
|
+ err := XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "batch_number_id": info.BatchNumberId, "storehouse_id": info.StorehouseId}).Error
|
|
7374
|
+ return err
|
|
7375
|
+}
|
|
7376
|
+
|
|
7377
|
+func ReturnDrugCancelStock(cancelstock_id int64, stock models.DrugCancelStock) error {
|
|
7378
|
+
|
|
7379
|
+ err := XTWriteDB().Model(&models.DrugCancelStock{}).Where("id = ? and status = 1", cancelstock_id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7380
|
+ err = XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id = ? and status = 1", cancelstock_id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7381
|
+ return err
|
|
7382
|
+}
|
|
7383
|
+
|
|
7384
|
+func GetDrugCancelStockInfo(cancelstock_id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
|
|
7385
|
+
|
|
7386
|
+ err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancelstock_id, orgid).Find(&info).Error
|
|
7387
|
+ return info, err
|
|
7388
|
+}
|
|
7389
|
+
|
|
7390
|
+func ModifyDrugFlowByCancelId(cancelstock_id int64, drugId int64, orgid int64) error {
|
|
7391
|
+ err := XTWriteDB().Model(&models.DrugFlow{}).Where("cancel_out_detail_id = ? and drug_id = ? and user_org_id = ? and status = 1", cancelstock_id, drugId, orgid).Update(map[string]interface{}{"status": 0}).Error
|
|
7392
|
+ return err
|
|
7393
|
+}
|
|
7394
|
+
|
|
7395
|
+func ModifyDrugMaxNumberWarehouseInfo(id int64, count int64, orgid int64) error {
|
|
7396
|
+
|
|
7397
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
|
|
7398
|
+ return err
|
|
7399
|
+}
|
|
7400
|
+
|
|
7401
|
+func ModifyDrugMinNumberWarehouseInfo(id int64, count int64, orgid int64) error {
|
|
7402
|
+
|
|
7403
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
|
|
7404
|
+ return err
|
|
7405
|
+}
|
|
7406
|
+
|
|
7407
|
+func GetDrugInfoSix(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
|
|
7408
|
+
|
|
7409
|
+ info := models.DrugWarehouseInfo{}
|
|
7410
|
+ err := XTReadDB().Where("id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
|
|
7411
|
+ return info, err
|
|
7412
|
+}
|