陈少旭 1 ay önce
ebeveyn
işleme
c2d7449900

+ 4 - 2
controllers/sg/his_api_controller.go Dosyayı Görüntüle

@@ -3023,7 +3023,7 @@ func (c *HisApiController) ChangeDrugfour() {
3023 3023
 	advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
3024 3024
 	var flows []*models.DrugFlow
3025 3025
 	for _, item := range advicelist {
3026
-		flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
3026
+		flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
3027 3027
 		flows = append(flows, flow...)
3028 3028
 	}
3029 3029
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
@@ -4443,7 +4443,9 @@ func (c *HisApiController) ChangeDrugTen() {
4443 4443
 
4444 4444
 	//ids := c.GetString("ids")
4445 4445
 	//id_arr := strings.Split(ids, ",")
4446
-	flows, _ := service.GetNewDrugFlowInforTen()
4446
+	now := time.Now()
4447
+	timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
4448
+	flows, _ := service.GetNewDrugFlowInforTen(timestamp)
4447 4449
 	admin_user_id, _ := c.GetInt64("admin_user_id")
4448 4450
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
4449 4451
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)

+ 7 - 10
models/new_stock_models.go Dosyayı Görüntüle

@@ -261,13 +261,12 @@ type NewDrugWarehouseInfo struct {
261 261
 	SecondWarehouseInfoId     int64  `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
262 262
 	IsCheck                   int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
263 263
 
264
-	IsPc    int64  `gorm:"column:is_pc" json:"is_pc" form:"is_pc"`
265
-	IsBg    int64  `gorm:"column:is_bg" json:"is_bg" form:"is_bg"`
266
-	Bchno   string `gorm:"column:bchno" json:"bchno" form:"bchno"`
267
-	PcDate  int64 `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
268
-	BgBchno string `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
264
+	IsPc     int64  `gorm:"column:is_pc" json:"is_pc" form:"is_pc"`
265
+	IsBg     int64  `gorm:"column:is_bg" json:"is_bg" form:"is_bg"`
266
+	Bchno    string `gorm:"column:bchno" json:"bchno" form:"bchno"`
267
+	PcDate   int64  `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
268
+	BgBchno  string `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
269 269
 	DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
270
-
271 270
 }
272 271
 
273 272
 func (NewDrugWarehouseInfo) TableName() string {
@@ -424,7 +423,7 @@ type DrugFlow struct {
424 423
 	LastStockMaxNumber        int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
425 424
 	LastStockMinNumber        int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
426 425
 	AdviceId                  int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
427
-	HisDoctorAdviceInfo       HisDoctorAdviceInfo  `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
426
+	HisDoctorAdviceInfo       HisDoctorAdviceInfo  `gorm:"ForeignKey:PatientID,RecordDate;AssociationForeignKey,DrugId:PatientID,SystemTime,DrugId" json:"advice"`
428 427
 	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
429 428
 	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
430 429
 	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
@@ -445,9 +444,7 @@ type DrugFlow struct {
445 444
 	Bchno                     string               `gorm:"column:bchno" json:"bchno" form:"bchno"`
446 445
 	SaleDate                  string               `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
447 446
 	BgBchno                   string               `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
448
-	DrugCode 	string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
449
-
450
-
447
+	DrugCode                  string               `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
451 448
 }
452 449
 
453 450
 func (DrugFlow) TableName() string {

+ 4 - 4
service/his_service.go Dosyayı Görüntüle

@@ -1739,8 +1739,8 @@ func GetNewDrugFlowInfo(org_id int64, id_arr []string) (flows []*models.DrugFlow
1739 1739
 	return
1740 1740
 }
1741 1741
 
1742
-func GetNewDrugFlowInfoByPatient(patient_id int64, advice_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
1743
-	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and id in (?) and patinet_id = ? and advice_id = ? and system_time = ?", org_id, patient_id, advice_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1742
+func GetNewDrugFlowInfoByPatient(patient_id int64, advdrug_idice_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
1743
+	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and id in (?) and patinet_id = ? and drug_id = ? and system_time = ?", org_id, patient_id, drug_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1744 1744
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1745 1745
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1746 1746
 	return
@@ -1767,8 +1767,8 @@ func GetNewDrugFlowInfothree() (flows []*models.DrugFlow, err error) {
1767 1767
 	return
1768 1768
 }
1769 1769
 
1770
-func GetNewDrugFlowInforTen() (flows []*models.DrugFlow, err error) {
1771
-	err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = 10318 and status = 1 and drug_code != '' and consumable_type = 3 and is_sale = 0").Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1770
+func GetNewDrugFlowInforTen(system_time int64) (flows []*models.DrugFlow, err error) {
1771
+	err = readDb.Model(&models.DrugFlow{}).Joins("join his_doctor_advice_info info on info.patient_id = xt_drug_flow.patient_id and info.drug_id = xt_drug_flow.drug_id and info.record_date = xt_drug_flow.system_time").Where("user_org_id = 10318 and status = 1 and consumable_type = 3 and is_sale = 0 and system_time = ?", system_time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1772 1772
 		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1773 1773
 	}).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
1774 1774
 	return