浏览代码

历史排班

28169 1年前
父节点
当前提交
87e821243f

+ 1 - 1
controllers/gobal_config_api_controller.go 查看文件

@@ -2426,7 +2426,7 @@ func (c *GobalConfigApiController) GetExportOutOrderDrugList() {
2426 2426
 	orderId := c.GetString("order_id")
2427 2427
 	ids := strings.Split(orderId, ",")
2428 2428
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2429
-	//list, _ := service.GetExportOutOrderDrugList(ids)
2429
+
2430 2430
 	list, _ := service.GetExportOutOrderDrugListOne(ids)
2431 2431
 	outInfoList, _ := service.GetDrugOutListFlow(ids, orgId)
2432 2432
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)

+ 11 - 8
controllers/his_api_controller.go 查看文件

@@ -1999,7 +1999,7 @@ func (c *HisApiController) CreateHisPrescription() {
1999 1999
 												return
2000 2000
 											}
2001 2001
 
2002
-											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2002
+											if adminInfo.CurrentOrgId == 10215 {
2003 2003
 												if prescribing_number > batch_number_all_count {
2004 2004
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2005 2005
 													return
@@ -2016,7 +2016,7 @@ func (c *HisApiController) CreateHisPrescription() {
2016 2016
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2017 2017
 												return
2018 2018
 											}
2019
-											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2019
+											if adminInfo.CurrentOrgId == 10215 {
2020 2020
 												if num > batch_number_all_count {
2021 2021
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2022 2022
 													return
@@ -2085,7 +2085,7 @@ func (c *HisApiController) CreateHisPrescription() {
2085 2085
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2086 2086
 														return
2087 2087
 													}
2088
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2088
+													if adminInfo.CurrentOrgId == 10215 {
2089 2089
 														if prescribing_number > batch_number_all_count {
2090 2090
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2091 2091
 															return
@@ -2103,7 +2103,7 @@ func (c *HisApiController) CreateHisPrescription() {
2103 2103
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2104 2104
 															return
2105 2105
 														}
2106
-														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2106
+														if adminInfo.CurrentOrgId == 10215 {
2107 2107
 															if prescribing_number > batch_number_all_count {
2108 2108
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2109 2109
 																return
@@ -2159,7 +2159,7 @@ func (c *HisApiController) CreateHisPrescription() {
2159 2159
 														c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2160 2160
 														return
2161 2161
 													}
2162
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2162
+													if adminInfo.CurrentOrgId == 10215 {
2163 2163
 														// 查询该药品最后一次出库记录
2164 2164
 														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
2165 2165
 
@@ -2319,7 +2319,7 @@ func (c *HisApiController) CreateHisPrescription() {
2319 2319
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2320 2320
 														return
2321 2321
 													}
2322
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2322
+													if adminInfo.CurrentOrgId == 10215 {
2323 2323
 														if prescribing_number > batch_number_all_count {
2324 2324
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2325 2325
 															return
@@ -2337,7 +2337,7 @@ func (c *HisApiController) CreateHisPrescription() {
2337 2337
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2338 2338
 															return
2339 2339
 														}
2340
-														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2340
+														if adminInfo.CurrentOrgId == 10215 {
2341 2341
 															if prescribing_number > batch_number_all_count {
2342 2342
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2343 2343
 																return
@@ -2386,7 +2386,7 @@ func (c *HisApiController) CreateHisPrescription() {
2386 2386
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2387 2387
 														return
2388 2388
 													}
2389
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
2389
+													if adminInfo.CurrentOrgId == 10215 {
2390 2390
 														if (number_count - device_number) > batch_number_count {
2391 2391
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2392 2392
 															return
@@ -3068,6 +3068,9 @@ func (c *HisApiController) CreateHisPrescription() {
3068 3068
 									if p.Price != lastWarehouse.PackingPrice {
3069 3069
 										p.Price = lastWarehouse.PackingPrice
3070 3070
 									}
3071
+									if p.Unit == "" {
3072
+										p.Unit = lastWarehouse.WarehousingUnit
3073
+									}
3071 3074
 								}
3072 3075
 
3073 3076
 							}

+ 0 - 5
controllers/self_drug_api_congtroller.go 查看文件

@@ -2770,11 +2770,6 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2770 2770
 		ids = append(ids, it.ID)
2771 2771
 	}
2772 2772
 
2773
-	//infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId, storehouse_id)
2774
-	//for _, it := range infoList {
2775
-	//	goodIds = append(goodIds, it.GoodId)
2776
-	//}
2777
-
2778 2773
 	stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
2779 2774
 
2780 2775
 	if err != nil {

+ 34 - 30
models/self_drug_models.go 查看文件

@@ -586,6 +586,8 @@ type BloodDrugWarehouseOutInfo struct {
586 586
 	DoseUnit                string  `json:"dose_unit"`
587 587
 	LastPrice               float64 `json:"last_price"`
588 588
 	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
589
+	InPrice                 float64 `gorm:"column:price" json:"in_price" form:"price"`
590
+	WarehousingInfoId       int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
589 591
 }
590 592
 
591 593
 type XtMonitorConfig struct {
@@ -650,6 +652,7 @@ type StDrugWarehouseInfo struct {
650 652
 	PackingUnit      string  `json:"packing_unit"`
651 653
 	Dosage           int64   `json:"dosage"`
652 654
 	LimaxUnit        string  `json:"limax_unit"`
655
+	WarehousingTime  int64   `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
653 656
 }
654 657
 
655 658
 type VmDrugWarehouseOutInfo struct {
@@ -929,36 +932,37 @@ type VmDrugInventory struct {
929 932
 }
930 933
 
931 934
 type SgjDrugWarehouseOutInfo struct {
932
-	ID                      int64      `gorm:"column:id" json:"id" form:"id"`
933
-	WarehouseOutId          int64      `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
934
-	DrugId                  int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
935
-	WarehousingOutTarget    int64      `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
936
-	Count                   int64      `gorm:"column:count" json:"count" form:"count"`
937
-	CountUnit               string     `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
938
-	Price                   float64    `gorm:"column:price" json:"price" form:"price"`
939
-	TotalPrice              float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
940
-	ProductDate             int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
941
-	ExpiryDate              int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
942
-	Mtime                   int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
943
-	Ctime                   int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
944
-	Status                  int64      `gorm:"column:status" json:"status" form:"status"`
945
-	OrgId                   int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
946
-	Remark                  string     `gorm:"column:remark" json:"remark" form:"remark"`
947
-	IsCancel                int64      `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
948
-	WarehouseOutOrderNumber string     `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
949
-	Type                    int64      `gorm:"column:type" json:"type" form:"type"`
950
-	Dealer                  int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
951
-	Manufacturer            int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
952
-	IsSys                   int64      `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
953
-	SysRecordTime           int64      `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
954
-	RetailPrice             float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
955
-	RetailTotalPrice        float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
956
-	WarehouseInfoId         int64      `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
957
-	Number                  string     `gorm:"column:number" json:"number" form:"number"`
958
-	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
959
-	PatientId               int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
960
-	IsCheck                 int64      `gorm:"column:is_check" json:"is_check" form:"is_check"`
961
-	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
935
+	ID                      int64               `gorm:"column:id" json:"id" form:"id"`
936
+	WarehouseOutId          int64               `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
937
+	DrugId                  int64               `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
938
+	WarehousingOutTarget    int64               `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
939
+	Count                   int64               `gorm:"column:count" json:"count" form:"count"`
940
+	CountUnit               string              `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
941
+	Price                   float64             `gorm:"column:price" json:"price" form:"price"`
942
+	TotalPrice              float64             `gorm:"column:total_price" json:"total_price" form:"total_price"`
943
+	ProductDate             int64               `gorm:"column:product_date" json:"product_date" form:"product_date"`
944
+	ExpiryDate              int64               `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
945
+	Mtime                   int64               `gorm:"column:mtime" json:"mtime" form:"mtime"`
946
+	Ctime                   int64               `gorm:"column:ctime" json:"ctime" form:"ctime"`
947
+	Status                  int64               `gorm:"column:status" json:"status" form:"status"`
948
+	OrgId                   int64               `gorm:"column:org_id" json:"org_id" form:"org_id"`
949
+	Remark                  string              `gorm:"column:remark" json:"remark" form:"remark"`
950
+	IsCancel                int64               `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
951
+	WarehouseOutOrderNumber string              `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
952
+	Type                    int64               `gorm:"column:type" json:"type" form:"type"`
953
+	Dealer                  int64               `gorm:"column:dealer" json:"dealer" form:"dealer"`
954
+	Manufacturer            int64               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
955
+	IsSys                   int64               `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
956
+	SysRecordTime           int64               `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
957
+	RetailPrice             float64             `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
958
+	RetailTotalPrice        float64             `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
959
+	WarehouseInfoId         int64               `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
960
+	Number                  string              `gorm:"column:number" json:"number" form:"number"`
961
+	BatchNumber             string              `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
962
+	PatientId               int64               `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
963
+	IsCheck                 int64               `gorm:"column:is_check" json:"is_check" form:"is_check"`
964
+	XtBaseDrug              XtBaseDrug          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
965
+	XtDrugWarehouseInfo     XtDrugWarehouseInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfoId"`
962 966
 }
963 967
 
964 968
 func (SgjDrugWarehouseOutInfo) TableName() string {

+ 15 - 0
models/stock_models.go 查看文件

@@ -106,12 +106,26 @@ type StWarehousingInfo struct {
106 106
 	LicenseNumber         string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
107 107
 	StorehouseId          int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
108 108
 	SecondWarehouseInfoId int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
109
+	WarehousingTime       string  `json:"warehousing_time"`
109 110
 }
110 111
 
111 112
 func (StWarehousingInfo) TableName() string {
112 113
 	return "xt_warehouse_info"
113 114
 }
114 115
 
116
+type XtWarehouse struct {
117
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
118
+	WarehousingOrder string `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
119
+	OperationTime    int64  `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
120
+	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
121
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
122
+	WarehousingTime  int64  `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
123
+}
124
+
125
+func (XtWarehouse) TableName() string {
126
+	return "xt_warehouse"
127
+}
128
+
115 129
 type WarehousingInfo struct {
116 130
 	ID                        int64       `gorm:"column:id" json:"id"`
117 131
 	WarehousingId             int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
@@ -542,6 +556,7 @@ type WarehouseOutInfoOne struct {
542 556
 	BuyPrice                    float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
543 557
 	StockCount                  string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
544 558
 	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
559
+	WarehouseOutTime            int64   `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
545 560
 }
546 561
 
547 562
 type WarehouseOutInfoTwo struct {

+ 1 - 1
service/drug_stock_service.go 查看文件

@@ -273,6 +273,6 @@ func GetDrugOutOrderInfoPrintList(startime int64, endtime int64, orgid int64) (l
273 273
 	if orgid > 0 {
274 274
 		db = db.Where("org_id = ?", orgid)
275 275
 	}
276
-	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
276
+	err = db.Preload("XtDrugWarehouseInfo", "status=1 and org_id =?", orgid).Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
277 277
 	return list, err
278 278
 }

+ 8 - 6
service/gobal_config_service.go 查看文件

@@ -366,10 +366,11 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
366 366
 
367 367
 	likeKey := "%" + keyword + "%"
368 368
 	offset := (page - 1) * limit
369
-	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status =1 and x.is_check = 1")
370
-	dbOne := XTReadDB().Table("xt_base_drug as b").Where("b.status =1")
371
-	dbTwo := XTReadDB().Table("xt_drug_warehouse_out as t").Where("t.status = 1")
372
-	fmt.Print(dbOne, dbTwo)
369
+	db := XTReadDB().Table("sgj_xt.xt_drug_warehouse_out_info as x").Where("x.status =1 and x.is_check = 1")
370
+	dbOne := XTReadDB().Table("sgj_xt.xt_base_drug as b").Where("b.status =1")
371
+	dbTwo := XTReadDB().Table("sgj_xt.xt_drug_warehouse_out as t").Where("t.status = 1")
372
+	dbThree := XTReadDB().Table("sgj_xt.xt_drug_warehouse_info as p").Where("p.status=1")
373
+	fmt.Print(dbOne, dbTwo, dbThree)
373 374
 	if startime > 0 {
374 375
 		db = db.Where("x.sys_record_time >=?", startime)
375 376
 	}
@@ -393,10 +394,11 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
393 394
 		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ?  or r.user_name like ?", likeKey, likeKey, likeKey)
394 395
 	}
395 396
 
397
+	db = db.Joins("left join sgj_xt.xt_drug_warehouse_info as p on p.id =x.warehouse_info_id")
396 398
 	if manufacturerId > 0 {
397
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
399
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
398 400
 	} else {
399
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
401
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
400 402
 	}
401 403
 
402 404
 	return outinfo, total, err

+ 5 - 1
service/new_stock_service.go 查看文件

@@ -119,7 +119,11 @@ func GetGoodStockList(orgId int64, storehouse_id int64, good_type int64, keyword
119 119
 		return db.Where("status = 1 and org_id = ? and is_check = 1", orgId)
120 120
 	})
121 121
 
122
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Find(&good).Error
122
+	if orgId == 10489 {
123
+		err = db.Count(&total).Offset(offset).Limit(limit).Order("x.sum_count desc").Find(&good).Error
124
+	} else {
125
+		err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Find(&good).Error
126
+	}
123 127
 
124 128
 	return good, total, err
125 129
 }

+ 20 - 39
service/new_warehouse_service.go 查看文件

@@ -51,9 +51,9 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
51 51
 			return errThree
52 52
 		}
53 53
 
54
-		if orgID == 10265 {
55
-			UpdateGoodInfoByPrice(warehouse.GoodId, orgID, warehouse.Price, warehouse.PackingPrice)
56
-		}
54
+		//if orgID == 10265 {
55
+		//	UpdateGoodInfoByPrice(warehouse.GoodId, orgID, warehouse.Price, warehouse.PackingPrice)
56
+		//}
57 57
 
58 58
 		//更新his_prescripton_project出库状态值
59 59
 		UpdateHisPrescriptionProjectStatus(goods.GoodId, record_time, orgID, patient_id)
@@ -1268,7 +1268,7 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
1268 1268
 }
1269 1269
 
1270 1270
 // 药品自动出库 递归方式
1271
-func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64) (err error) {
1271
+func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64, unit string) (err error) {
1272 1272
 
1273 1273
 	drugError := models.XtDrugError{
1274 1274
 		UserOrgId:             orgID,
@@ -1304,7 +1304,10 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1304 1304
 
1305 1305
 	}
1306 1306
 
1307
-	if advice.PrescribingNumberUnit == drup.MaxUnit {
1307
+	fmt.Println("总数量", countone)
1308
+	fmt.Println("单位1", unit)
1309
+	fmt.Println("单位2", drup.MaxUnit)
1310
+	if unit == drup.MaxUnit {
1308 1311
 		deliver_number_one = countone * drup.MinNumber
1309 1312
 
1310 1313
 	} else {
@@ -1312,8 +1315,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1312 1315
 
1313 1316
 	}
1314 1317
 
1315
-	fmt.Println(deliver_number_one)
1316
-
1317 1318
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1318 1319
 		drug_price = drup.RetailPrice
1319 1320
 	}
@@ -1389,6 +1390,8 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1389 1390
 
1390 1391
 	}
1391 1392
 
1393
+	fmt.Println("库存数量2嚄噢嚄噢噢哦哦嚄噢嚄o", stock_number)
1394
+	fmt.Println("出库数咯哦我我我我嚄嚄嚄嚄", deliver_number)
1392 1395
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1393 1396
 	if stock_number >= deliver_number {
1394 1397
 
@@ -1567,7 +1570,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1567 1570
 					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1568 1571
 				}
1569 1572
 				CreateDrugError(drugError)
1570
-				return errOne
1571 1573
 			}
1572 1574
 		}
1573 1575
 		if lastDrugOutInfo.ID > 0 {
@@ -1577,35 +1579,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1577 1579
 
1578 1580
 			AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1579 1581
 
1580
-			//var his_count int64
1581
-			//if lastDrugOutInfo.CountUnit == drup.MaxUnit {
1582
-			//	his_count = lastDrugOutInfo.Count * drup.MinNumber
1583
-			//}
1584
-			//if lastDrugOutInfo.CountUnit == drup.MinUnit {
1585
-			//	his_count = lastDrugOutInfo.Count
1586
-			//}
1587
-			//fmt.Println("deliver_number", deliver_number)
1588
-			//fmt.Println("his_countwowowoowow", his_count)
1589
-			//if deliver_number != his_count {
1590
-			//	errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1591
-			//	if errThree != nil {
1592
-			//		drugError := models.XtDrugError{
1593
-			//			UserOrgId:             orgID,
1594
-			//			DrugId:                advice.DrugId,
1595
-			//			RecordDate:            advice.AdviceDate,
1596
-			//			PatientId:             advice.PatientId,
1597
-			//			Remark:                "更新出库单失败",
1598
-			//			Status:                1,
1599
-			//			Ctime:                 time.Now().Unix(),
1600
-			//			Mtime:                 0,
1601
-			//			SumCount:              0,
1602
-			//			Prescribingnumber:     advice.PrescribingNumber,
1603
-			//			PrescribingNumberUnit: advice.PrescribingNumberUnit,
1604
-			//		}
1605
-			//		CreateDrugError(drugError)
1606
-			//		return errThree
1607
-			//	}
1608
-			//}
1609 1582
 		}
1610 1583
 
1611 1584
 		var out_count int64
@@ -1622,8 +1595,13 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1622 1595
 			cancel_count += item.Count
1623 1596
 		}
1624 1597
 
1598
+		fmt.Println("总出口数量", deliver_number_one)
1599
+		fmt.Println("出库数量", out_count)
1600
+		fmt.Println("退款数来的发阿道夫", cancel_count)
1601
+
1602
+		fmt.Println("查收嗖嗖嗖哦", deliver_number_one-(out_count-cancel_count))
1625 1603
 		if deliver_number_one-(out_count-cancel_count) >= 0 {
1626
-			if (deliver_number - out_count - cancel_count) != 0 {
1604
+			if (deliver_number_one - out_count - cancel_count) != 0 {
1627 1605
 				drugflow := models.DrugFlow{
1628 1606
 					WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1629 1607
 					WarehouseOutId:          warehouseout.ID,
@@ -1947,6 +1925,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1947 1925
 			StockMinNumber:    0,
1948 1926
 			BatchNumber:       warehouse.BatchNumber,
1949 1927
 			MaxUnit:           warehouse.MaxUnit,
1928
+			MinUnit:           drup.MinUnit,
1950 1929
 			WarehousingInfoId: warehouse.WarehousingInfoId,
1951 1930
 			SupplyWarehouseId: warehouse.SupplyWarehouseId,
1952 1931
 			StorehouseId:      storeConfig.DrugStorehouseOut,
@@ -2140,6 +2119,8 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2140 2119
 			cancel_count += item.Count
2141 2120
 		}
2142 2121
 
2122
+		fmt.Println("deliver_nbumbwowowoowowow", deliver_number)
2123
+		fmt.Println("out_coutnwoowowowowowow", out_count)
2143 2124
 		//如果本次出库数据大于历史出库数据 新增1条流水
2144 2125
 		if deliver_number > (out_count - cancel_count) {
2145 2126
 
@@ -2372,7 +2353,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2372 2353
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
2373 2354
 		advice.PrescribingNumberUnit = drup.MinUnit
2374 2355
 
2375
-		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, hisprescribingNumber)
2356
+		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, hisprescribingNumber, unit)
2376 2357
 	}
2377 2358
 
2378 2359
 	return

+ 7 - 6
service/patient_schedule_template_service.go 查看文件

@@ -890,12 +890,13 @@ func SavePatientScheduleTemplateMode4To3(templateMode *models.PatientScheduleTem
890 890
 }
891 891
 
892 892
 type SchTemplatePatient struct {
893
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
894
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
895
-	Name       string `gorm:"column:name" json:"name" form:"name"`
896
-	Lapseto    int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
897
-	Status     int64  `gorm:"column:status" json:"status" form:"status"`
898
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
893
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
894
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
895
+	Name         string `gorm:"column:name" json:"name" form:"name"`
896
+	Lapseto      int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
897
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
898
+	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
899
+	IsInfectious int64  `gorm:"column:is_infectious" json:"is_infectious"`
899 900
 }
900 901
 
901 902
 func (SchTemplatePatient) TableName() string {

+ 4 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go 查看文件

@@ -302,7 +302,10 @@ func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (o
302 302
 
303 303
 	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
304 304
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
305
+
306
+	tableOne := p_service.XTReadDB().Table("xt_warehouse_info as p").Where("p.status = 1")
305 307
 	fmt.Println(table)
308
+	fmt.Println("tableOne", tableOne)
306 309
 	if orgid > 0 {
307 310
 		db = db.Where("x.org_id = ?", orgid)
308 311
 	}
@@ -312,7 +315,7 @@ func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (o
312 315
 	if endtime > 0 {
313 316
 		db = db.Where("x.sys_record_time<=?", endtime)
314 317
 	}
315
-	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,x.ctime,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price,t.manufacturer,t.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
318
+	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,x.ctime,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price,t.manufacturer,t.dealer,p.price").Joins("left join xt_warehouse_info as p on p.id =x.warehouse_info_id").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
316 319
 	return out, err
317 320
 }
318 321
 

+ 29 - 15
service/self_drug_service.go 查看文件

@@ -1850,10 +1850,6 @@ func GetDrugStockCountList(orgId int64, storehouse_id int64, good_type int64, ke
1850 1850
 		db = db.Preload("DrugWarehouseInfo", "org_id = ? and status = 1 and is_check = 1", orgId)
1851 1851
 	}
1852 1852
 
1853
-	//if len(goodIds) > 0 {
1854
-	//	db = db.Where("id in(?)", goodIds)
1855
-	//}
1856
-
1857 1853
 	if len(keyword) > 0 {
1858 1854
 		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
1859 1855
 	}
@@ -1861,19 +1857,36 @@ func GetDrugStockCountList(orgId int64, storehouse_id int64, good_type int64, ke
1861 1857
 	if orgId > 0 {
1862 1858
 		db = db.Where("x.org_id = ?", orgId)
1863 1859
 	}
1864
-	err = db.Preload("XtDrugStockCount", func(db *gorm.DB) *gorm.DB {
1865
-		if storehouse_id > 0 {
1866
-			db = db.Where("storehouse_id = ?", storehouse_id)
1867
-		}
1868
-		return db.Where("status = 1 and user_org_id = ?", orgId)
1869 1860
 
1870
-	}).Preload("DrugStockCount", func(db *gorm.DB) *gorm.DB {
1871
-		if storehouse_id > 0 {
1872
-			db = db.Where("storehouse_id = ?", storehouse_id)
1873
-		}
1874
-		return db.Where("status = 1 and user_org_id = ?", orgId).Group("drug_id,storehouse_id")
1861
+	if orgId == 10489 {
1862
+		err = db.Preload("XtDrugStockCount", func(db *gorm.DB) *gorm.DB {
1863
+			if storehouse_id > 0 {
1864
+				db = db.Where("storehouse_id = ?", storehouse_id)
1865
+			}
1866
+			return db.Where("status = 1 and user_org_id = ?", orgId)
1867
+
1868
+		}).Preload("DrugStockCount", func(db *gorm.DB) *gorm.DB {
1869
+			if storehouse_id > 0 {
1870
+				db = db.Where("storehouse_id = ?", storehouse_id)
1871
+			}
1872
+			return db.Where("status = 1 and user_org_id = ?", orgId).Group("drug_id,storehouse_id")
1873
+
1874
+		}).Count(&total).Offset(offset).Limit(limit).Order("x.sum_count desc").Find(&drug).Error
1875
+	} else {
1876
+		err = db.Preload("XtDrugStockCount", func(db *gorm.DB) *gorm.DB {
1877
+			if storehouse_id > 0 {
1878
+				db = db.Where("storehouse_id = ?", storehouse_id)
1879
+			}
1880
+			return db.Where("status = 1 and user_org_id = ?", orgId)
1875 1881
 
1876
-	}).Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Find(&drug).Error
1882
+		}).Preload("DrugStockCount", func(db *gorm.DB) *gorm.DB {
1883
+			if storehouse_id > 0 {
1884
+				db = db.Where("storehouse_id = ?", storehouse_id)
1885
+			}
1886
+			return db.Where("status = 1 and user_org_id = ?", orgId).Group("drug_id,storehouse_id")
1887
+
1888
+		}).Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Find(&drug).Error
1889
+	}
1877 1890
 
1878 1891
 	return drug, total, err
1879 1892
 }
@@ -1904,6 +1917,7 @@ func GetDrugWarehouseOutInfoByIdList(good_id int64, limit int64, page int64, org
1904 1917
 func GetAllGoodListSeven(orgid int64) (good []*models.GoodInfoSeven, err error) {
1905 1918
 
1906 1919
 	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&good).Error
1920
+
1907 1921
 	return good, err
1908 1922
 }
1909 1923
 

+ 9 - 4
service/stock_service.go 查看文件

@@ -4422,7 +4422,8 @@ func GetExprotStockListTwenty(orgid int64, orderid []string, startime int64, end
4422 4422
 	if storehouse_id > 0 {
4423 4423
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
4424 4424
 	}
4425
-	err = db.Select("x.id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.dealer,x.manufacturer,x.remark,x.license_number,t.good_name,t.packing_unit,t.specification_name").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&info).Error
4425
+
4426
+	err = db.Select("x.id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.dealer,x.manufacturer,x.remark,x.license_number,t.good_name,t.packing_unit,t.specification_name,p.warehousing_time").Joins("left join xt_warehouse as p on p.id =x.warehousing_id").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&info).Error
4426 4427
 
4427 4428
 	return info, err
4428 4429
 }
@@ -4450,7 +4451,8 @@ func GetOutExprotList(orgid int64, ids []string, startime int64, endtime int64)
4450 4451
 
4451 4452
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status =1 ")
4452 4453
 	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4453
-	fmt.Println(table)
4454
+	tableOne := XTReadDB().Table("xt_warehouse_out as p").Where("p.status=1")
4455
+	fmt.Println(table, tableOne)
4454 4456
 	if orgid > 0 {
4455 4457
 		db = db.Where("x.org_id = ?", orgid)
4456 4458
 	}
@@ -4465,7 +4467,7 @@ func GetOutExprotList(orgid int64, ids []string, startime int64, endtime int64)
4465 4467
 		db = db.Where("x.ctime<=?", endtime)
4466 4468
 	}
4467 4469
 
4468
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,x.manufacturer,x.dealer").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&out).Error
4470
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,x.manufacturer,x.dealer,p.warehouse_out_time").Joins("left join xt_warehouse_out as p on p.id =x.warehouse_out_id").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&out).Error
4469 4471
 	return out, err
4470 4472
 
4471 4473
 }
@@ -4889,11 +4891,14 @@ func ExportDrugList(warehouse_out_id []string) (out []*models.StDrugWarehouseInf
4889 4891
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status =1")
4890 4892
 
4891 4893
 	table := XTReadDB().Table("xt_base_drug as b").Where("b.status = 1")
4894
+
4895
+	tableOne := XTReadDB().Table("xt_drug_warehouse as p")
4892 4896
 	fmt.Println("table", table)
4897
+	fmt.Println("tableOne", tableOne)
4893 4898
 	if len(warehouse_out_id) > 0 {
4894 4899
 		db = db.Where("x.warehousing_id in(?)", warehouse_out_id)
4895 4900
 	}
4896
-	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.dealer,x.manufacturer,x.warehousing_order,x.batch_number,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4901
+	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.dealer,x.manufacturer,x.warehousing_order,x.batch_number,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,p.warehousing_time").Joins("left join xt_drug_warehouse as p on p.id =x.warehousing_id").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4897 4902
 	return out, err
4898 4903
 }
4899 4904
 

+ 1 - 1
service/warhouse_service.go 查看文件

@@ -619,7 +619,7 @@ func HisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvice
619 619
 		if drup.ID > 0 {
620 620
 			prescribingNumber := advice.PrescribingNumber
621 621
 
622
-			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber)
622
+			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit)
623 623
 
624 624
 		} else {
625 625
 			return errors.New("药品信息不存在")