|
@@ -734,8 +734,13 @@ func UpdateDrugWarehouseingInfo(id int64, info models.XtDrugWarehouseInfo) error
|
734
|
734
|
}
|
735
|
735
|
|
736
|
736
|
func CreateDrugFlowOne(flow models.DrugFlow) error {
|
737
|
|
-
|
738
|
|
- err := XTWriteDB().Create(&flow).Error
|
|
737
|
+ ut := writeDb.Begin()
|
|
738
|
+ err := ut.Create(&flow).Error
|
|
739
|
+ if err != nil {
|
|
740
|
+ ut.Rollback()
|
|
741
|
+ return err
|
|
742
|
+ }
|
|
743
|
+ ut.Commit()
|
739
|
744
|
return err
|
740
|
745
|
}
|
741
|
746
|
|
|
@@ -748,7 +753,7 @@ func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice
|
748
|
753
|
|
749
|
754
|
func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64) (models.DrugFlow, error) {
|
750
|
755
|
flow := models.DrugFlow{}
|
751
|
|
- 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
|
|
756
|
+ 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{}{"is_read": 1}).Error
|
752
|
757
|
return flow, err
|
753
|
758
|
}
|
754
|
759
|
|
|
@@ -3179,7 +3184,7 @@ func GetStockInRecoredByGoodIdOne(goodid int64, goodtypeid int64, recordtime int
|
3179
|
3184
|
|
3180
|
3185
|
func UpdateAutoMaticReduceDetail(goodid int64, goodtypeid int64, recordtime int64, patientid int64, orgid int64, prepare *models.WarehouseOutInfo) error {
|
3181
|
3186
|
|
3182
|
|
- err := XTWriteDB().Model(&prepare).Where("good_id = ? and good_type_id = ? and sys_record_time = ? and patient_id = ? and org_id = ? and status =1", goodid, goodtypeid, recordtime, patientid, orgid).Updates(map[string]interface{}{"count": prepare.Count}).Error
|
|
3187
|
+ err := XTWriteDB().Model(&prepare).Where("good_id = ? and good_type_id = ? and sys_record_time = ? and patient_id = ? and org_id = ? and status =1", goodid, goodtypeid, recordtime, patientid, orgid).Updates(map[string]interface{}{"count": prepare.Count, "over_count": prepare.OverCount}).Error
|
3183
|
3188
|
return err
|
3184
|
3189
|
}
|
3185
|
3190
|
|
|
@@ -3837,6 +3842,12 @@ func GetAutoMaticReduceDetail(orgid int64, patient_id int64, recordtime int64, g
|
3837
|
3842
|
return &autoreduece, nil
|
3838
|
3843
|
}
|
3839
|
3844
|
|
|
3845
|
+func GetAutoMaticReduceDetailTwenty(orgid int64, patient_id int64, recordtime int64, goodid int64, goodtypeid int64) (models.BloodAutomaticReduceDetail, error) {
|
|
3846
|
+ auto := models.BloodAutomaticReduceDetail{}
|
|
3847
|
+ err = XTReadDB().Model(&auto).Where("org_id = ? and patient_id = ? and status = 1 and record_time = ? and good_id = ? and good_type_id = ? and count>0", orgid, patient_id, recordtime, goodid, goodtypeid).Find(&auto).Error
|
|
3848
|
+ return auto, err
|
|
3849
|
+}
|
|
3850
|
+
|
3840
|
3851
|
func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64, goodid int64, goodtypeid int64) error {
|
3841
|
3852
|
|
3842
|
3853
|
detail := models.BloodAutomaticReduceDetail{}
|
|
@@ -3850,6 +3861,16 @@ func GetWarehosueOutByStockFlow(patient_id int64, recrod_date int64, goodid int6
|
3850
|
3861
|
return stockflow, err
|
3851
|
3862
|
}
|
3852
|
3863
|
|
|
3864
|
+func UpdateAutoGood(orgid int64, patient_id int64, recordtime int64, goodid int64, project_id int64, count int64) (err error) {
|
|
3865
|
+
|
|
3866
|
+ err = XTWriteDB().Model(models.BloodAutomaticReduceDetail{}).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ?", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
|
|
3867
|
+ err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
|
|
3868
|
+ //err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("over_count", gorm.Expr("over_count + ?", count)).Error
|
|
3869
|
+ err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
|
|
3870
|
+ err = XTWriteDB().Model(&models.VmStockFlow{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1 and project_id = ?", orgid, patient_id, recordtime, goodid, project_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
|
|
3871
|
+ return err
|
|
3872
|
+}
|
|
3873
|
+
|
3853
|
3874
|
func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
|
3854
|
3875
|
|
3855
|
3876
|
detail := models.BloodAutomaticReduceDetail{}
|
|
@@ -3859,14 +3880,15 @@ func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64,
|
3859
|
3880
|
prepare := models.DialysisBeforePrepare{}
|
3860
|
3881
|
err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
|
3861
|
3882
|
flow := models.VmStockFlow{}
|
3862
|
|
- err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
|
|
3883
|
+ err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"is_read": 1}).Error
|
3863
|
3884
|
return err
|
3864
|
3885
|
|
3865
|
3886
|
}
|
3866
|
3887
|
|
3867
|
|
-func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
|
|
3888
|
+func UpDateWarehouseInfoByStockDelete(id int64, count int64, patient_id int64, record_time int64, goodid int64) (err error) {
|
3868
|
3889
|
|
3869
|
3890
|
err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
|
3891
|
+ err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", id, patient_id, record_time, goodid).UpdateColumn("over_count", gorm.Expr("over_count + ?", count)).Error
|
3870
|
3892
|
return err
|
3871
|
3893
|
}
|
3872
|
3894
|
|
|
@@ -3932,18 +3954,11 @@ func GetHisProjectPrescriptionByPatientIdOne(id int64) (models.HisPrescriptionPr
|
3932
|
3954
|
|
3933
|
3955
|
func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfoNight, err error) {
|
3934
|
3956
|
|
3935
|
|
- err = XTReadDB().Select("count,warehouse_info_id,good_id,org_id").Where(" patient_id = ? and sys_record_time = ? and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error
|
|
3957
|
+ err = XTReadDB().Select("count,warehouse_info_id,good_id,org_id,sys_record_time,patient_id,project_id,warehouse_info_id,warehouse_out_order_number,storehouse_id,price,dealer,manufacturer,good_type_id,product_date,expiry_date,number,license_number").Where(" patient_id = ? and sys_record_time = ? and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error
|
3936
|
3958
|
return auto, err
|
3937
|
3959
|
|
3938
|
3960
|
}
|
3939
|
3961
|
|
3940
|
|
-//func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.VmStockFlow, err error) {
|
3941
|
|
-//
|
3942
|
|
-// err = XTReadDB().Select("count,warehousing_id").Where(" patient_id = ? and system_time = ? and status = 1 and is_sys = 1 and count>0",patientid,recorddate).Find(&auto).Error
|
3943
|
|
-// return auto, err
|
3944
|
|
-//
|
3945
|
|
-//}
|
3946
|
|
-
|
3947
|
3962
|
func ModefyWarehouseInfo(count int64, id int64) error {
|
3948
|
3963
|
|
3949
|
3964
|
err := XTWriteDB().Model(models.WarehousingInfo{}).Where(" id =? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
|
@@ -3954,9 +3969,9 @@ func DeleteAutoWarehouse(patient_id int64, record_time int64) error {
|
3954
|
3969
|
|
3955
|
3970
|
err := XTWriteDB().Model(models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
|
3956
|
3971
|
err = XTWriteDB().Model(models.DialysisBeforePrepare{}).Where("patient_id = ? and record_date = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
|
3957
|
|
- err = XTWriteDB().Model(models.VmStockFlow{}).Where("patient_id = ? and system_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
|
3958
|
|
- err = XTWriteDB().Model(models.WarehouseOutInfoNight{}).Where("patient_id = ? and sys_record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
|
3959
|
|
- fmt.Println("err2332332322323322323232323232332", err)
|
|
3972
|
+ err = XTWriteDB().Model(models.VmStockFlow{}).Where("patient_id = ? and system_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"is_read": 1}).Error
|
|
3973
|
+ //err = XTWriteDB().Model(models.WarehouseOutInfoNight{}).Where("patient_id = ? and sys_record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
|
|
3974
|
+
|
3960
|
3975
|
return err
|
3961
|
3976
|
}
|
3962
|
3977
|
|
|
@@ -4069,7 +4084,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
|
4069
|
4084
|
return info, total, err
|
4070
|
4085
|
}
|
4071
|
4086
|
|
4072
|
|
-func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
|
|
4087
|
+func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64, startfirsttime int64, endfirsttime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
|
4073
|
4088
|
|
4074
|
4089
|
offset := (page - 1) * limit
|
4075
|
4090
|
db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1 and x.is_check = 1")
|
|
@@ -4082,6 +4097,12 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
|
4082
|
4097
|
if endtime > 0 {
|
4083
|
4098
|
db = db.Where("x.ctime<=?", endtime)
|
4084
|
4099
|
}
|
|
4100
|
+ if startfirsttime > 0 {
|
|
4101
|
+ db = db.Where("x.expiry_date >=?", startfirsttime)
|
|
4102
|
+ }
|
|
4103
|
+ if endfirsttime > 0 {
|
|
4104
|
+ db = db.Where("x.expiry_date <=?", endfirsttime)
|
|
4105
|
+ }
|
4085
|
4106
|
|
4086
|
4107
|
if orgid > 0 {
|
4087
|
4108
|
db = db.Where("x.org_id = ?", orgid)
|
|
@@ -4089,7 +4110,7 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
|
4089
|
4110
|
if good_id > 0 {
|
4090
|
4111
|
db = db.Where("x.good_id = ?", good_id)
|
4091
|
4112
|
}
|
4092
|
|
- err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price,f.batch_number_count").Joins("left join xt_good_information as t on t.id = x.good_id").Joins("left join xt_stock_flow as f on f.warehousing_detail_id = x.id").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Scan(&info).Error
|
|
4113
|
+ err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price,f.batch_number_count").Joins("left join xt_good_information as t on t.id = x.good_id").Joins("left join xt_stock_flow as f on f.warehousing_detail_id = x.id").Count(&total).Offset(offset).Limit(limit).Group("x.id").Order("x.id desc").Scan(&info).Error
|
4093
|
4114
|
return info, total, err
|
4094
|
4115
|
|
4095
|
4116
|
}
|
|
@@ -4199,9 +4220,7 @@ func GetWarehouseOutOrder(id []string, orgid int64) (out []*models.WarehouseOut,
|
4199
|
4220
|
if orgid > 0 {
|
4200
|
4221
|
db = db.Where("x.org_id= ?", orgid)
|
4201
|
4222
|
}
|
4202
|
|
- 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 {
|
4203
|
|
- return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid)
|
4204
|
|
- }).Find(&out).Error
|
|
4223
|
+ 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
|
4205
|
4224
|
return out, err
|
4206
|
4225
|
}
|
4207
|
4226
|
|
|
@@ -4218,7 +4237,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
|
4218
|
4237
|
db = db.Where("x.org_id = ?", orgid)
|
4219
|
4238
|
}
|
4220
|
4239
|
|
4221
|
|
- 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
|
|
4240
|
+ 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,x.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,x.warehouse_info_id,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
|
4222
|
4241
|
|
4223
|
4242
|
return out, err
|
4224
|
4243
|
}
|
|
@@ -4727,7 +4746,24 @@ func GetStockFlowBatchNumber(id int64, goodid int64) (stock []*models.VmStockFlo
|
4727
|
4746
|
|
4728
|
4747
|
func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
|
4729
|
4748
|
|
4730
|
|
- db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and count > 0")
|
|
4749
|
+ db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and x.count > 0 and (x.consumable_type = 3 or x.consumable_type = 2")
|
|
4750
|
+ table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
|
|
4751
|
+ fmt.Println(table)
|
|
4752
|
+ tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
|
|
4753
|
+ fmt.Println(tableone)
|
|
4754
|
+ if id > 0 {
|
|
4755
|
+ db = db.Where("x.warehouse_out_id = ?", id)
|
|
4756
|
+ }
|
|
4757
|
+ if goodid > 0 {
|
|
4758
|
+ db = db.Where("x.good_id = ?", goodid)
|
|
4759
|
+ }
|
|
4760
|
+
|
|
4761
|
+ err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
|
|
4762
|
+ return stock, err
|
|
4763
|
+}
|
|
4764
|
+
|
|
4765
|
+func GetStockFlowCancelInfo(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
|
|
4766
|
+ db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and x.count > 0 and x.consumable_type = 7")
|
4731
|
4767
|
table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
|
4732
|
4768
|
fmt.Println(table)
|
4733
|
4769
|
tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
|
|
@@ -4740,7 +4776,6 @@ func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStock
|
4740
|
4776
|
}
|
4741
|
4777
|
|
4742
|
4778
|
err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
|
4743
|
|
- //err =XTReadDB()()()()().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
|
4744
|
4779
|
return stock, err
|
4745
|
4780
|
}
|
4746
|
4781
|
|
|
@@ -4901,13 +4936,13 @@ func CreateStockFlow(warehousingInfo []*models.VmStockFlow) (err error) {
|
4901
|
4936
|
}
|
4902
|
4937
|
|
4903
|
4938
|
func CreateStockFlowOne(flow models.VmStockFlow) error {
|
4904
|
|
- tx := XTWriteDB().Begin()
|
4905
|
|
- err := tx.Create(&flow).Error
|
|
4939
|
+ utx := XTWriteDB().Begin()
|
|
4940
|
+ err := utx.Create(&flow).Error
|
4906
|
4941
|
if err != nil {
|
4907
|
|
- tx.Rollback()
|
|
4942
|
+ utx.Rollback()
|
4908
|
4943
|
return err
|
4909
|
4944
|
}
|
4910
|
|
- tx.Commit()
|
|
4945
|
+ utx.Commit()
|
4911
|
4946
|
return err
|
4912
|
4947
|
}
|
4913
|
4948
|
|
|
@@ -4924,7 +4959,7 @@ func UpdatedStockFlow(flow models.VmStockFlow) error {
|
4924
|
4959
|
|
4925
|
4960
|
func UpdatedStockFlowOne(flow models.VmStockFlow, warehousing_id int64, patient_id int64, record_time int64, good_id int64) error {
|
4926
|
4961
|
|
4927
|
|
- err = XTWriteDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer}).Error
|
|
4962
|
+ err = XTWriteDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "over_count": flow.OverCount}).Error
|
4928
|
4963
|
return err
|
4929
|
4964
|
}
|
4930
|
4965
|
|
|
@@ -4932,7 +4967,7 @@ func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int
|
4932
|
4967
|
|
4933
|
4968
|
stock := models.VmStockFlow{}
|
4934
|
4969
|
var err error
|
4935
|
|
- err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
|
|
4970
|
+ err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1 and is_read = 0", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
|
4936
|
4971
|
if err == gorm.ErrRecordNotFound {
|
4937
|
4972
|
return nil, err
|
4938
|
4973
|
}
|
|
@@ -4942,6 +4977,24 @@ func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int
|
4942
|
4977
|
return &stock, nil
|
4943
|
4978
|
}
|
4944
|
4979
|
|
|
4980
|
+func GetStockFlowIsBatchNumber(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (flow []*models.VmStockFlow, err error) {
|
|
4981
|
+
|
|
4982
|
+ err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and status = 1 and consumable_type = 3", patient_id, record_time, good_id).Find(&flow).Error
|
|
4983
|
+ return flow, nil
|
|
4984
|
+}
|
|
4985
|
+
|
|
4986
|
+func GetStockFlowIsBatchNumberTwo(patient_id int64, record_time int64, good_id int64) (flow []*models.WarehouseOutInfo, err error) {
|
|
4987
|
+
|
|
4988
|
+ err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and good_id = ? and status = 1 ", patient_id, record_time, good_id).Find(&flow).Error
|
|
4989
|
+ return flow, nil
|
|
4990
|
+}
|
|
4991
|
+
|
|
4992
|
+func GetStockFlowIsBatchNumberThree(patient_id int64, record_time int64, good_id int64) (flow []*models.VmStockFlow, err error) {
|
|
4993
|
+
|
|
4994
|
+ err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and status = 1 and consumable_type =7", patient_id, record_time, good_id).Find(&flow).Error
|
|
4995
|
+ return flow, nil
|
|
4996
|
+}
|
|
4997
|
+
|
4945
|
4998
|
func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
|
4946
|
4999
|
|
4947
|
5000
|
info := models.WarehouseOutInfo{}
|
|
@@ -4956,7 +5009,7 @@ func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
|
4956
|
5009
|
return &info, nil
|
4957
|
5010
|
}
|
4958
|
5011
|
|
4959
|
|
-func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time int64) (*models.WarehouseOutInfo, error) {
|
|
5012
|
+func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time int64, project_id int64) (*models.WarehouseOutInfo, error) {
|
4960
|
5013
|
|
4961
|
5014
|
info := models.WarehouseOutInfo{}
|
4962
|
5015
|
var err error
|
|
@@ -4970,6 +5023,12 @@ func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time
|
4970
|
5023
|
return &info, nil
|
4971
|
5024
|
}
|
4972
|
5025
|
|
|
5026
|
+func GetWarehouseOutInfoIsExistTwo(good_id int64, patient_id int64, record_time int64, project_id int64) (models.WarehouseOutInfo, error) {
|
|
5027
|
+ info := models.WarehouseOutInfo{}
|
|
5028
|
+ err := XTReadDB().Where("good_id = ? and sys_record_time = ? and status = 1 and patient_id = ?", good_id, record_time, patient_id).Find(&info).Error
|
|
5029
|
+ return info, err
|
|
5030
|
+}
|
|
5031
|
+
|
4973
|
5032
|
func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int64, startTime int64, endTime int64, good_id int64) (flow []*models.VmStockFlow, total int64, err error) {
|
4974
|
5033
|
|
4975
|
5034
|
offset := (page - 1) * limit
|
|
@@ -4994,6 +5053,10 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
|
4994
|
5053
|
if consumable_type == 4 {
|
4995
|
5054
|
db = db.Where(" consumable_type = ?", consumable_type)
|
4996
|
5055
|
}
|
|
5056
|
+ //自动退库
|
|
5057
|
+ if consumable_type == 7 {
|
|
5058
|
+ db = db.Where(" consumable_type = ?", consumable_type)
|
|
5059
|
+ }
|
4997
|
5060
|
|
4998
|
5061
|
if consumable_type == 10 {
|
4999
|
5062
|
db = db.Where(" consumable_type = ?", consumable_type)
|
|
@@ -5047,7 +5110,14 @@ func GetLastGoodListByPatientIdOne(recordtime int64, patientid int64, goodid int
|
5047
|
5110
|
return detail, err
|
5048
|
5111
|
}
|
5049
|
5112
|
|
5050
|
|
-func UpdatedWarehouseOutInfo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64) error {
|
|
5113
|
+func UpdatedWarehouseOutInfo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64, project_id int64) error {
|
|
5114
|
+
|
|
5115
|
+ outInfo := models.WarehouseOutInfo{}
|
|
5116
|
+ err := XTWriteDB().Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time =? and status = 1", good_id, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": info.WarehouseOutId, "WarehouseOutOrderNumber": info.WarehouseOutOrderNumber, "sys_record_time": info.SysRecordTime, "good_type_id": info.GoodTypeId, "patient_id": info.PatientId, "consumable_type": info.ConsumableType, "count": info.Count, "price": info.Price, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "over_count": info.OverCount}).Error
|
|
5117
|
+ return err
|
|
5118
|
+}
|
|
5119
|
+
|
|
5120
|
+func UpdatedWarehouseOutInfoTwo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64) error {
|
5051
|
5121
|
|
5052
|
5122
|
outInfo := models.WarehouseOutInfo{}
|
5053
|
5123
|
err := XTWriteDB().Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time =? and status = 1", good_id, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": info.WarehouseOutId, "WarehouseOutOrderNumber": info.WarehouseOutOrderNumber, "sys_record_time": info.SysRecordTime, "good_type_id": info.GoodTypeId, "patient_id": info.PatientId, "consumable_type": info.ConsumableType, "count": info.Count, "price": info.Price, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber}).Error
|
|
@@ -5286,8 +5356,8 @@ func DeleteDrugAutoWarehouse(drugid int64, patient_id int64, record_time int64)
|
5286
|
5356
|
func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
|
5287
|
5357
|
|
5288
|
5358
|
err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
5289
|
|
- err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
5290
|
|
- err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
|
5359
|
+ //err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
|
5360
|
+ //err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
5291
|
5361
|
return err
|
5292
|
5362
|
}
|
5293
|
5363
|
|
|
@@ -5977,7 +6047,7 @@ func ModifyDrugWarehouseInfoSix(info *models.DrugWarehouseInfo, id int64) error
|
5977
|
6047
|
|
5978
|
6048
|
func GetGoodInventoryWarehouseList(id int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
|
5979
|
6049
|
|
5980
|
|
- err = XTReadDB().Model(&info).Where("good_id = ? and status = 1 and storehouse_id=?", id, storehouse_id).Preload("GoodInfo", "status = 1").Find(&info).Error
|
|
6050
|
+ err = XTReadDB().Model(&info).Where("good_id = ? and status = 1 and storehouse_id=? and is_check= 1", id, storehouse_id).Preload("GoodInfo", "status = 1").Find(&info).Error
|
5981
|
6051
|
return info, err
|
5982
|
6052
|
}
|
5983
|
6053
|
|
|
@@ -7019,8 +7089,13 @@ func UpdatedWarehouseOut(id int64) error {
|
7019
|
7089
|
|
7020
|
7090
|
func UpdatedSigleWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
|
7021
|
7091
|
|
7022
|
|
- err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
|
7023
|
|
-
|
|
7092
|
+ tx := XTWriteDB().Begin()
|
|
7093
|
+ err := tx.Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
|
|
7094
|
+ if err != nil {
|
|
7095
|
+ tx.Rollback()
|
|
7096
|
+ return err
|
|
7097
|
+ }
|
|
7098
|
+ tx.Commit()
|
7024
|
7099
|
return err
|
7025
|
7100
|
|
7026
|
7101
|
}
|
|
@@ -7059,17 +7134,40 @@ func GetLastGoodWarehouseOutTwenty(orgid int64) (models.WarehouseOut, error) {
|
7059
|
7134
|
|
7060
|
7135
|
func UpdateaGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64) error {
|
7061
|
7136
|
|
7062
|
|
- 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
|
7063
|
|
-
|
|
7137
|
+ ut := writeDb.Begin()
|
|
7138
|
+ err := ut.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
|
|
7139
|
+ if err != nil {
|
|
7140
|
+ ut.Rollback()
|
|
7141
|
+ return err
|
|
7142
|
+ }
|
|
7143
|
+ ut.Commit()
|
7064
|
7144
|
return err
|
|
7145
|
+
|
7065
|
7146
|
}
|
7066
|
7147
|
|
7067
|
7148
|
func ModifyGoodWarehouseOut(id int64) error {
|
7068
|
|
-
|
7069
|
|
- err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
7070
|
|
- err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
7071
|
|
- err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
|
7072
|
|
-
|
|
7149
|
+ ut := writeDb.Begin()
|
|
7150
|
+ err := ut.Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7151
|
+ if err != nil {
|
|
7152
|
+ ut.Rollback()
|
|
7153
|
+ return err
|
|
7154
|
+ }
|
|
7155
|
+ err = ut.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7156
|
+ if err != nil {
|
|
7157
|
+ ut.Rollback()
|
|
7158
|
+ return err
|
|
7159
|
+ }
|
|
7160
|
+ err = ut.Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
|
|
7161
|
+ if err != nil {
|
|
7162
|
+ ut.Rollback()
|
|
7163
|
+ return err
|
|
7164
|
+ }
|
|
7165
|
+ err = ut.Model(&models.XtWarehouseFlushInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
|
|
7166
|
+ if err != nil {
|
|
7167
|
+ ut.Rollback()
|
|
7168
|
+ return err
|
|
7169
|
+ }
|
|
7170
|
+ ut.Commit()
|
7073
|
7171
|
return err
|
7074
|
7172
|
}
|
7075
|
7173
|
|
|
@@ -7095,6 +7193,15 @@ func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
|
7095
|
7193
|
}
|
7096
|
7194
|
|
7097
|
7195
|
func UpdateCheckWarehouseInfo(id int64) error {
|
|
7196
|
+
|
|
7197
|
+ tx := XTWriteDB().Begin()
|
|
7198
|
+ err := tx.Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7199
|
+ if err != nil {
|
|
7200
|
+ tx.Rollback()
|
|
7201
|
+ return err
|
|
7202
|
+ }
|
|
7203
|
+ tx.Commit()
|
|
7204
|
+ return err
|
7098
|
7205
|
tx := XTWriteDB().Begin()
|
7099
|
7206
|
err := tx.Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
7100
|
7207
|
if err != nil {
|
|
@@ -7112,6 +7219,20 @@ func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo
|
7112
|
7219
|
}
|
7113
|
7220
|
|
7114
|
7221
|
func UpdateWarehouseInfoByIdList(count int64, id int64) error {
|
|
7222
|
+
|
|
7223
|
+ tx := XTWriteDB().Begin()
|
|
7224
|
+ err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
|
7225
|
+ if err != nil {
|
|
7226
|
+ tx.Rollback()
|
|
7227
|
+ return err
|
|
7228
|
+ }
|
|
7229
|
+ err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7230
|
+ if err != nil {
|
|
7231
|
+ tx.Rollback()
|
|
7232
|
+ return err
|
|
7233
|
+ }
|
|
7234
|
+ tx.Commit()
|
|
7235
|
+ return err
|
7115
|
7236
|
tx := XTWriteDB().Begin()
|
7116
|
7237
|
err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
7117
|
7238
|
if err != nil {
|
|
@@ -7128,6 +7249,16 @@ func UpdateWarehouseInfoByIdList(count int64, id int64) error {
|
7128
|
7249
|
}
|
7129
|
7250
|
|
7130
|
7251
|
func ReturnCheckWarehouseInfo(id int64) error {
|
|
7252
|
+
|
|
7253
|
+ tx := XTWriteDB().Begin()
|
|
7254
|
+ err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7255
|
+ if err != nil {
|
|
7256
|
+ tx.Rollback()
|
|
7257
|
+ return err
|
|
7258
|
+ }
|
|
7259
|
+ err = tx.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7260
|
+ tx.Commit()
|
|
7261
|
+ return err
|
7131
|
7262
|
tx := XTWriteDB().Begin()
|
7132
|
7263
|
err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
7133
|
7264
|
if err != nil {
|
|
@@ -7140,6 +7271,20 @@ func ReturnCheckWarehouseInfo(id int64) error {
|
7140
|
7271
|
}
|
7141
|
7272
|
|
7142
|
7273
|
func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
|
|
7274
|
+
|
|
7275
|
+ tx := XTWriteDB().Begin()
|
|
7276
|
+ err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
|
|
7277
|
+ if err != nil {
|
|
7278
|
+ tx.Rollback()
|
|
7279
|
+ return err
|
|
7280
|
+ }
|
|
7281
|
+ err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7282
|
+ if err != nil {
|
|
7283
|
+ tx.Rollback()
|
|
7284
|
+ return err
|
|
7285
|
+ }
|
|
7286
|
+ tx.Commit()
|
|
7287
|
+ return err
|
7143
|
7288
|
tx := XTWriteDB().Begin()
|
7144
|
7289
|
err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
|
7145
|
7290
|
if err != nil {
|
|
@@ -7156,8 +7301,9 @@ func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
|
7156
|
7301
|
}
|
7157
|
7302
|
|
7158
|
7303
|
func UpdateWarehouseInfoFlow(id int64) error {
|
|
7304
|
+
|
7159
|
7305
|
tx := XTWriteDB().Begin()
|
7160
|
|
- err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id = ?", id).Update(map[string]interface{}{"status": 0}).Error
|
|
7306
|
+ err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id = ?", id).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
|
7161
|
7307
|
|
7162
|
7308
|
if err != nil {
|
7163
|
7309
|
tx.Rollback()
|
|
@@ -7165,6 +7311,12 @@ func UpdateWarehouseInfoFlow(id int64) error {
|
7165
|
7311
|
}
|
7166
|
7312
|
tx.Commit()
|
7167
|
7313
|
return err
|
|
7314
|
+ if err != nil {
|
|
7315
|
+ tx.Rollback()
|
|
7316
|
+ return err
|
|
7317
|
+ }
|
|
7318
|
+ tx.Commit()
|
|
7319
|
+ return err
|
7168
|
7320
|
}
|
7169
|
7321
|
|
7170
|
7322
|
func FindLastWarehousingSix(org_id int64) (info models.Warehousing, err error) {
|
|
@@ -7414,6 +7566,14 @@ func UpdateGoodInfoSumCount(goodid int64, sum_count int64, orgid int64) error {
|
7414
|
7566
|
}
|
7415
|
7567
|
|
7416
|
7568
|
func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) error {
|
|
7569
|
+ tx := XTWriteDB().Begin()
|
|
7570
|
+ err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7571
|
+ if err != nil {
|
|
7572
|
+ tx.Rollback()
|
|
7573
|
+ return err
|
|
7574
|
+ }
|
|
7575
|
+ tx.Commit()
|
|
7576
|
+ return err
|
7417
|
7577
|
|
7418
|
7578
|
err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
7419
|
7579
|
return err
|
|
@@ -7430,6 +7590,18 @@ func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64) error
|
7430
|
7590
|
return err
|
7431
|
7591
|
}
|
7432
|
7592
|
|
|
7593
|
+func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
|
|
7594
|
+
|
|
7595
|
+ tx := XTWriteDB().Begin()
|
|
7596
|
+ err := tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
|
|
7597
|
+ if err != nil {
|
|
7598
|
+ tx.Rollback()
|
|
7599
|
+ return err
|
|
7600
|
+ }
|
|
7601
|
+ tx.Commit()
|
|
7602
|
+ return err
|
|
7603
|
+}
|
|
7604
|
+
|
7433
|
7605
|
func GetCancelStockInfo(id int64, orgid int64) (stock []*models.CancelStockInfo, err error) {
|
7434
|
7606
|
|
7435
|
7607
|
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
|
|
@@ -7461,9 +7633,18 @@ func GetCancelWarehouseList(orgId int64, goodId int64, warehouseInfoId int64) (i
|
7461
|
7633
|
}
|
7462
|
7634
|
|
7463
|
7635
|
func CheckCancelStock(stock models.CancelStock, cancel_stock_id int64, orgid int64) error {
|
7464
|
|
-
|
7465
|
|
- 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
|
7466
|
|
- 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
|
|
7636
|
+ ut := writeDb.Begin()
|
|
7637
|
+ err := ut.Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
7638
|
+ if err != nil {
|
|
7639
|
+ ut.Rollback()
|
|
7640
|
+ return err
|
|
7641
|
+ }
|
|
7642
|
+ err = ut.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
|
|
7643
|
+ if err != nil {
|
|
7644
|
+ ut.Rollback()
|
|
7645
|
+ return err
|
|
7646
|
+ }
|
|
7647
|
+ ut.Commit()
|
7467
|
7648
|
return err
|
7468
|
7649
|
}
|
7469
|
7650
|
|
|
@@ -7474,33 +7655,67 @@ func GetCancelStockInfoById(cancel_stock_id int64, orgid int64) (info []*models.
|
7474
|
7655
|
}
|
7475
|
7656
|
|
7476
|
7657
|
func UpdateCancelStockNumber(stock_count int64, warehouse_info_id int64, orgid int64) error {
|
7477
|
|
-
|
7478
|
|
- 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
|
|
7658
|
+ ut := writeDb.Begin()
|
|
7659
|
+ err := ut.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
|
|
7660
|
+ if err != nil {
|
|
7661
|
+ ut.Rollback()
|
|
7662
|
+ return err
|
|
7663
|
+ }
|
|
7664
|
+ ut.Commit()
|
7479
|
7665
|
return err
|
7480
|
7666
|
}
|
7481
|
7667
|
|
7482
|
7668
|
func UpdateGoodSumCount(sum_count int64, good_id int64, orgid int64) error {
|
7483
|
|
-
|
7484
|
|
- 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
|
|
7669
|
+ ut := writeDb.Begin()
|
|
7670
|
+ err := ut.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
7671
|
+ if err != nil {
|
|
7672
|
+ ut.Rollback()
|
|
7673
|
+ return err
|
|
7674
|
+ }
|
|
7675
|
+ ut.Commit()
|
7485
|
7676
|
return err
|
7486
|
7677
|
}
|
7487
|
7678
|
|
7488
|
7679
|
func UpdateStockWarehouseInfo(cancel_stock_id int64, orgid int64, stock models.CancelStock) error {
|
7489
|
|
-
|
7490
|
|
- 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
|
7491
|
|
- 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
|
|
7680
|
+ ut := writeDb.Begin()
|
|
7681
|
+ err := ut.Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
7682
|
+ if err != nil {
|
|
7683
|
+ ut.Rollback()
|
|
7684
|
+ return err
|
|
7685
|
+ }
|
|
7686
|
+ err = ut.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
|
|
7687
|
+ if err != nil {
|
|
7688
|
+ ut.Rollback()
|
|
7689
|
+ return err
|
|
7690
|
+ }
|
|
7691
|
+ ut.Commit()
|
7492
|
7692
|
return err
|
7493
|
7693
|
}
|
7494
|
7694
|
|
7495
|
7695
|
func UpdateStockWarehouseInfoStockFlow(id int64, orgid int64, goodid int64) error {
|
7496
|
|
- 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
|
|
7696
|
+ ut := writeDb.Begin()
|
|
7697
|
+ err = ut.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
|
|
7698
|
+ if err != nil {
|
|
7699
|
+ ut.Rollback()
|
|
7700
|
+ return err
|
|
7701
|
+ }
|
|
7702
|
+ ut.Commit()
|
7497
|
7703
|
return err
|
7498
|
7704
|
}
|
7499
|
7705
|
|
7500
|
7706
|
func UpdateStockNumberWarehouseInfo(warehouse_info_id int64, good_id int64, org_id int64, stock_count int64) error {
|
7501
|
|
-
|
|
7707
|
+ ut := writeDb.Begin()
|
7502
|
7708
|
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
|
|
7709
|
+ if err != nil {
|
|
7710
|
+ ut.Rollback()
|
|
7711
|
+ return err
|
|
7712
|
+ }
|
7503
|
7713
|
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
|
|
7714
|
+ if err != nil {
|
|
7715
|
+ ut.Rollback()
|
|
7716
|
+ return err
|
|
7717
|
+ }
|
|
7718
|
+ ut.Commit()
|
7504
|
7719
|
return err
|
7505
|
7720
|
}
|
7506
|
7721
|
|
|
@@ -7531,6 +7746,18 @@ func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info [
|
7531
|
7746
|
}
|
7532
|
7747
|
|
7533
|
7748
|
func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
|
|
7749
|
+ ut := XTWriteDB().Begin()
|
|
7750
|
+ err := ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7751
|
+ if err != nil {
|
|
7752
|
+ ut.Rollback()
|
|
7753
|
+ return err
|
|
7754
|
+ }
|
|
7755
|
+ err = ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
|
7756
|
+ if err != nil {
|
|
7757
|
+ ut.Rollback()
|
|
7758
|
+ return err
|
|
7759
|
+ }
|
|
7760
|
+ ut.Commit()
|
7534
|
7761
|
tx := XTWriteDB().Begin()
|
7535
|
7762
|
err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
7536
|
7763
|
if err != nil {
|
|
@@ -7547,8 +7774,13 @@ func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_co
|
7547
|
7774
|
}
|
7548
|
7775
|
|
7549
|
7776
|
func UpdateBaseDrugSumTwo(drugid int64, sum_count int64, orgid int64) error {
|
7550
|
|
-
|
7551
|
|
- err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7777
|
+ ut := writeDb.Begin()
|
|
7778
|
+ err = ut.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
7779
|
+ if err != nil {
|
|
7780
|
+ ut.Rollback()
|
|
7781
|
+ return err
|
|
7782
|
+ }
|
|
7783
|
+ ut.Commit()
|
7552
|
7784
|
return err
|
7553
|
7785
|
}
|
7554
|
7786
|
|
|
@@ -7632,9 +7864,15 @@ func ModifyDrugFlowByCancelId(cancelstock_id int64, drugId int64, orgid int64) e
|
7632
|
7864
|
}
|
7633
|
7865
|
|
7634
|
7866
|
func ModifyDrugMaxNumberWarehouseInfo(id int64, count int64, orgid int64) error {
|
7635
|
|
-
|
7636
|
|
- 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
|
|
7867
|
+ ut := XTWriteDB().Begin()
|
|
7868
|
+ err := ut.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
|
|
7869
|
+ if err != nil {
|
|
7870
|
+ ut.Rollback()
|
|
7871
|
+ return err
|
|
7872
|
+ }
|
|
7873
|
+ ut.Commit()
|
7637
|
7874
|
return err
|
|
7875
|
+
|
7638
|
7876
|
}
|
7639
|
7877
|
|
7640
|
7878
|
func ModifyDrugMinNumberWarehouseInfo(id int64, count int64, orgid int64) error {
|
|
@@ -7664,3 +7902,10 @@ func GetPrintList(storehouse_id int64, good_name string, orgid int64, limit int6
|
7664
|
7902
|
err = XTReadDB().Preload("GoodInfo", "status = 1 and org_id = ?", orgid).Preload("WarehousingInfo", "status = 1 and org_id=?", orgid).Find(&storeinventory).Error
|
7665
|
7903
|
return storeinventory, err
|
7666
|
7904
|
}
|
|
7905
|
+
|
|
7906
|
+func GetGoodDialysisOutInfo(orgid int64, patient_id int64, sys_record_time int64, good_id int64) (models.AutomaticReduceDetail, error) {
|
|
7907
|
+
|
|
7908
|
+ detail := models.AutomaticReduceDetail{}
|
|
7909
|
+ err := XTReadDB().Where("org_id =? and patient_id = ? and record_time = ? and good_id = ? and status= 1", orgid, patient_id, sys_record_time, good_id).Find(&detail).Error
|
|
7910
|
+ return detail, err
|
|
7911
|
+}
|