Browse Source

提交代码

陈少旭 8 months ago
parent
commit
31f7edc9db

+ 88 - 0
controllers/his_charge_api_controller.go View File

@@ -343,6 +343,94 @@ func (c *HisChargeApiController) GetChargeStatisticsDetail() {
343 343
 		}
344 344
 		writer.Close()
345 345
 
346
+		// 设置响应头,表明数据经过了 Gzip 压缩
347
+		c.Ctx.Output.Header("Content-Encoding", "gzip")
348
+		// 发送压缩后的数据
349
+		c.Ctx.ResponseWriter.Write(compressedData.Bytes())
350
+		break
351
+	case 4:
352
+		//chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
353
+		chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
354
+		//chargeDrug = append(chargeDrug, chargeProject...)
355
+		b, _ := structToBytes(chargeProject)
356
+		//cd, _ := compressData(b)
357
+		// 使用 Gzip 压缩数据
358
+		var compressedData bytes.Buffer
359
+		writer := gzip.NewWriter(&compressedData)
360
+		_, err = writer.Write(b)
361
+		if err != nil {
362
+			c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
363
+			c.Ctx.WriteString(err.Error())
364
+			return
365
+		}
366
+		writer.Close()
367
+
368
+		// 设置响应头,表明数据经过了 Gzip 压缩
369
+		c.Ctx.Output.Header("Content-Encoding", "gzip")
370
+		// 发送压缩后的数据
371
+		c.Ctx.ResponseWriter.Write(compressedData.Bytes())
372
+		break
373
+	case 5:
374
+		//chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
375
+		chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
376
+		//chargeDrug = append(chargeDrug, chargeProject...)
377
+		b, _ := structToBytes(chargeProject)
378
+		//cd, _ := compressData(b)
379
+		// 使用 Gzip 压缩数据
380
+		var compressedData bytes.Buffer
381
+		writer := gzip.NewWriter(&compressedData)
382
+		_, err = writer.Write(b)
383
+		if err != nil {
384
+			c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
385
+			c.Ctx.WriteString(err.Error())
386
+			return
387
+		}
388
+		writer.Close()
389
+
390
+		// 设置响应头,表明数据经过了 Gzip 压缩
391
+		c.Ctx.Output.Header("Content-Encoding", "gzip")
392
+		// 发送压缩后的数据
393
+		c.Ctx.ResponseWriter.Write(compressedData.Bytes())
394
+		break
395
+	case 6:
396
+		//chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
397
+		chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
398
+		//chargeDrug = append(chargeDrug, chargeProject...)
399
+		b, _ := structToBytes(chargeProject)
400
+		//cd, _ := compressData(b)
401
+		// 使用 Gzip 压缩数据
402
+		var compressedData bytes.Buffer
403
+		writer := gzip.NewWriter(&compressedData)
404
+		_, err = writer.Write(b)
405
+		if err != nil {
406
+			c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
407
+			c.Ctx.WriteString(err.Error())
408
+			return
409
+		}
410
+		writer.Close()
411
+
412
+		// 设置响应头,表明数据经过了 Gzip 压缩
413
+		c.Ctx.Output.Header("Content-Encoding", "gzip")
414
+		// 发送压缩后的数据
415
+		c.Ctx.ResponseWriter.Write(compressedData.Bytes())
416
+		break
417
+	case 7:
418
+		//chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
419
+		chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
420
+		//chargeDrug = append(chargeDrug, chargeProject...)
421
+		b, _ := structToBytes(chargeProject)
422
+		//cd, _ := compressData(b)
423
+		// 使用 Gzip 压缩数据
424
+		var compressedData bytes.Buffer
425
+		writer := gzip.NewWriter(&compressedData)
426
+		_, err = writer.Write(b)
427
+		if err != nil {
428
+			c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
429
+			c.Ctx.WriteString(err.Error())
430
+			return
431
+		}
432
+		writer.Close()
433
+
346 434
 		// 设置响应头,表明数据经过了 Gzip 压缩
347 435
 		c.Ctx.Output.Header("Content-Encoding", "gzip")
348 436
 		// 发送压缩后的数据

+ 2 - 0
models/new_stock.go View File

@@ -31,6 +31,8 @@ type DrugWarehouseInfoTenOne struct {
31 31
 	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
32 32
 	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
33 33
 	PcDate                    int64       `gorm:"column:pc_date" json:"pc_date" form:"pc_date"`
34
+	IsPc                      int64       `gorm:"column:is_pc" json:"is_pc" form:"is_pc"`
35
+	IsBg                      int64       `gorm:"column:is_bg" json:"is_bg" form:"is_bg"`
34 36
 }
35 37
 
36 38
 func (DrugWarehouseInfoTenOne) TableName() string {

+ 289 - 80
service/app_version.go View File

@@ -4,6 +4,8 @@ import (
4 4
 	"XT_New/models"
5 5
 	"fmt"
6 6
 	"github.com/jinzhu/gorm"
7
+	"math"
8
+	"strconv"
7 9
 	"time"
8 10
 )
9 11
 
@@ -484,82 +486,82 @@ func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
484 486
 //}
485 487
 
486 488
 type HisOrderTen struct {
487
-	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
488
-	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
489
-	HisPatientId          int64                 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
490
-	SettleAccountsDate    int64                 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
491
-	Ctime                 int64                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
492
-	Mtime                 int64                 `gorm:"column:mtime" json:"mtime" form:"mtime"`
493
-	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
494
-	Number                string                `gorm:"column:number" json:"number" form:"number"`
495
-	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
496
-	Infcode               int64                 `gorm:"column:infcode" json:"infcode" form:"infcode"`
497
-	WarnMsg               string                `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
498
-	Cainfo                string                `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
499
-	ErrMsg                string                `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
500
-	RespondTime           string                `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
501
-	InfRefmsgid           string                `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
502
-	OrderStatus           int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
503
-	MdtrtId               string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
504
-	SetlId                string                `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
505
-	PsnNo                 string                `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
506
-	PsnName               string                `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
507
-	PsnCertType           string                `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
508
-	Certno                string                `gorm:"column:certno" json:"certno" form:"certno"`
509
-	Gend                  string                `gorm:"column:gend" json:"gend" form:"gend"`
510
-	Naty                  string                `gorm:"column:naty" json:"naty" form:"naty"`
511
-	Brdy                  time.Time             `gorm:"column:brdy" json:"brdy" form:"brdy"`
512
-	Age                   float64               `gorm:"column:age" json:"age" form:"age"`
513
-	Insutype              string                `gorm:"column:insutype" json:"insutype" form:"insutype"`
514
-	PsnType               string                `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
515
-	CvlservFlag           string                `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
516
-	SetlTime              string                `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
517
-	MdtrtCertType         string                `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
518
-	MedType               string                `gorm:"column:med_type" json:"med_type" form:"med_type"`
519
-	MedfeeSumamt          float64               `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
520
-	FulamtOwnpayAmt       float64               `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
521
-	OverlmtSelfPay        float64               `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
522
-	PreselfpayAmt         float64               `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
523
-	InscpScpAmt           float64               `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
524
-	ActPayDedc            float64               `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
525
-	HifpPay               float64               `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
526
-	CvlservPay            float64               `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
527
-	PoolPropSelfpay       float64               `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
528
-	HifesPay              float64               `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
529
-	HifmiPay              float64               `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
530
-	HifobPay              float64               `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
531
-	MafPay                float64               `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
532
-	OthPay                float64               `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
533
-	FundPaySumamt         float64               `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
534
-	PsnPartAmt            float64               `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
535
-	AcctPay               float64               `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
536
-	PsnCashPay            float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
537
-	HospPartAmt           float64               `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
538
-	Balc                  float64               `gorm:"column:balc" json:"balc" form:"balc"`
539
-	AcctMulaidPay         float64               `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
540
-	MedinsSetlId          string                `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
541
-	ClrOptins             string                `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
542
-	ClrWay                string                `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
543
-	ClrType               string                `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
544
-	SetlDetail            string                `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
545
-	IsMedicineInsurance   int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
546
-	PayWay                int64                 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
547
-	PayPrice              float64               `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
548
-	PayCardNo             string                `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
549
-	DiscountPrice         float64               `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
550
-	PreferentialPrice     float64               `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
551
-	RealityPrice          float64               `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
552
-	FoundPrice            float64               `gorm:"column:found_price" json:"found_price" form:"found_price"`
553
-	MedicalInsurancePrice float64               `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
554
-	PrivatePrice          float64               `gorm:"column:private_price" json:"private_price" form:"private_price"`
555
-	DepartmentName        string                `gorm:"-" json:"department_name" form:"department_name"`
556
-	DoctorName            string                `gorm:"-" json:"doctor_name" form:"doctor_name"`
557
-	Creator               int64                 `gorm:"column:creator" json:"creator" form:"creator"`
558
-	PType                 int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
559
-	Decimal               float64               `gorm:"column:decimal" json:"decimal" form:"decimal"`
560
-	VmHisOrderInfo9504    []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
561
-	//HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
562
-	Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
489
+	ID                    int64     `gorm:"column:id" json:"id" form:"id"`
490
+	UserOrgId             int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
491
+	HisPatientId          int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
492
+	SettleAccountsDate    int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
493
+	Ctime                 int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
494
+	Mtime                 int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
495
+	Status                int64     `gorm:"column:status" json:"status" form:"status"`
496
+	Number                string    `gorm:"column:number" json:"number" form:"number"`
497
+	PatientId             int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
498
+	Infcode               int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
499
+	WarnMsg               string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
500
+	Cainfo                string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
501
+	ErrMsg                string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
502
+	RespondTime           string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
503
+	InfRefmsgid           string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
504
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
505
+	MdtrtId               string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
506
+	SetlId                string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
507
+	PsnNo                 string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
508
+	PsnName               string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
509
+	PsnCertType           string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
510
+	Certno                string    `gorm:"column:certno" json:"certno" form:"certno"`
511
+	Gend                  string    `gorm:"column:gend" json:"gend" form:"gend"`
512
+	Naty                  string    `gorm:"column:naty" json:"naty" form:"naty"`
513
+	Brdy                  time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
514
+	Age                   float64   `gorm:"column:age" json:"age" form:"age"`
515
+	Insutype              string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
516
+	PsnType               string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
517
+	CvlservFlag           string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
518
+	SetlTime              string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
519
+	MdtrtCertType         string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
520
+	MedType               string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
521
+	MedfeeSumamt          float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
522
+	FulamtOwnpayAmt       float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
523
+	OverlmtSelfPay        float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
524
+	PreselfpayAmt         float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
525
+	InscpScpAmt           float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
526
+	ActPayDedc            float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
527
+	HifpPay               float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
528
+	CvlservPay            float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
529
+	PoolPropSelfpay       float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
530
+	HifesPay              float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
531
+	HifmiPay              float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
532
+	HifobPay              float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
533
+	MafPay                float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
534
+	OthPay                float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
535
+	FundPaySumamt         float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
536
+	PsnPartAmt            float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
537
+	AcctPay               float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
538
+	PsnCashPay            float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
539
+	HospPartAmt           float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
540
+	Balc                  float64   `gorm:"column:balc" json:"balc" form:"balc"`
541
+	AcctMulaidPay         float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
542
+	MedinsSetlId          string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
543
+	ClrOptins             string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
544
+	ClrWay                string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
545
+	ClrType               string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
546
+	SetlDetail            string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
547
+	IsMedicineInsurance   int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
548
+	PayWay                int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
549
+	PayPrice              float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
550
+	PayCardNo             string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
551
+	DiscountPrice         float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
552
+	PreferentialPrice     float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
553
+	RealityPrice          float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
554
+	FoundPrice            float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
555
+	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
556
+	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
557
+	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
558
+	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
559
+	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
560
+	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
561
+	Decimal               float64   `gorm:"column:decimal" json:"decimal" form:"decimal"`
562
+	//VmHisOrderInfo9504    []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
563
+	HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
564
+	Patients           Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
563 565
 }
564 566
 
565 567
 func (HisOrderTen) TableName() string {
@@ -597,14 +599,17 @@ func (HisPrescriptionTen) TableName() string {
597 599
 	return "his_prescription"
598 600
 }
599 601
 
600
-func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
602
+func GetHisOrderDetailThree(start_time string, end_time string, org_id int64) (order []*HisOrderTen, err error) {
603
+	start_time = start_time + " 00:00:00"
604
+	end_time = end_time + " 23:59:00"
605
+
601 606
 	err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
602 607
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
603 608
 			return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
604 609
 		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
605 610
 			return db.Where("status = 1").Preload("Drug", "status = 1")
606 611
 		})
607
-	}).Where("setl_time >= '2024-01-01 00:00:00' AND setl_time <= '2024-01-31 23:59:00' AND status = 1 AND order_status =2  AND user_org_id = 10485").Find(&order).Order("patient_id").Error
612
+	}).Where("setl_time >= ? AND setl_time <= ? AND status = 1 AND order_status =2  AND user_org_id = ?", start_time, end_time, org_id).Find(&order).Order("patient_id").Error
608 613
 	return
609 614
 }
610 615
 
@@ -686,7 +691,7 @@ func (HisPrescriptionProjectTen) TableName() string {
686 691
 
687 692
 func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
688 693
 
689
-	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2024-04-01 00:00:00' AND in_hosptial_time <= '2024-05-31 23:59:59'", orgid).Find(&paitent).Error
694
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2024-06-01 00:00:00' AND in_hosptial_time <= '2024-06-30 23:59:59'", orgid).Find(&paitent).Error
690 695
 	return paitent, err
691 696
 }
692 697
 
@@ -902,7 +907,7 @@ func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
902 907
 		return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
903 908
 			return db.Where("status = 1").Preload("VMHisProject")
904 909
 		})
905
-	}).Where("setl_time >= '2024-01-01 00:00:00' AND setl_time <= '2024-03-31 23:00:00' AND status = 1 AND order_status =2  AND user_org_id = 10138").Find(&order).Error
910
+	}).Where("setl_time >= '2024-04-01 00:00:00' AND setl_time <= '2024-06-30 23:00:00' AND status = 1 AND order_status =2  AND user_org_id = 10278").Find(&order).Error
906 911
 	return
907 912
 }
908 913
 
@@ -1402,3 +1407,207 @@ func GetOrderinfo(org_id int64) (info []models.HisOrderInfo, err error) {
1402 1407
 	}
1403 1408
 	return
1404 1409
 }
1410
+
1411
+type Result22 struct {
1412
+	InspectDate           string
1413
+	Inspect               int64
1414
+	PatientID             int64
1415
+	ItemID1               int64
1416
+	ItemID2               int64
1417
+	ItemName1             string
1418
+	ItemName2             string
1419
+	InspectValue1         string
1420
+	InspectValue2         string
1421
+	WeightAfter           float64
1422
+	ActualUltrafiltration float64
1423
+	ActualTreatmentHour   int64
1424
+	ActualTreatmentHours  float64
1425
+	WeightBefore          float64
1426
+}
1427
+
1428
+func Aaa() {
1429
+
1430
+	var inspections []Result22
1431
+	readDb.Raw(`
1432
+        SELECT 
1433
+            DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
1434
+            xts.inspect,
1435
+            xts.patient_id,
1436
+            xts.item_id AS item_id_1,
1437
+            b.item_id AS item_id_2,
1438
+            xts.item_name AS item_name_1,
1439
+            b.item_name AS item_name_2,
1440
+            xts.inspect_value AS inspect_value1,
1441
+            b.inspect_value AS inspect_value2,
1442
+            b.weight_after,
1443
+            b.actual_ultrafiltration,
1444
+            b.actual_treatment_hour,
1445
+            b.actual_treatment_minute / 60.0 AS actual_treatment_hours,
1446
+            xts.weight_before
1447
+        FROM
1448
+            (SELECT 
1449
+                DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
1450
+            	xts.inspect_date as inspect,
1451
+                xts.patient_id,
1452
+                xts.item_id,
1453
+                xts.item_name,
1454
+                xts.inspect_value,
1455
+                be.weight_before
1456
+             FROM xt_inspection xts 
1457
+             JOIN xt_assessment_before_dislysis be 
1458
+             ON be.patient_id = xts.patient_id 
1459
+             AND DATE(FROM_UNIXTIME(xts.inspect_date)) = DATE(FROM_UNIXTIME(be.assessment_date))
1460
+             WHERE xts.org_id = 10677 AND xts.item_id = 106770503) xts
1461
+        JOIN
1462
+            (SELECT 
1463
+                DATE(FROM_UNIXTIME(xt.inspect_date)) AS inspect_date,
1464
+            	xt.inspect_date as inspect,
1465
+                xt.patient_id,
1466
+                xt.item_id,
1467
+                xt.item_name,
1468
+                xt.inspect_value,
1469
+                ad.weight_after,
1470
+                ad.actual_ultrafiltration,
1471
+                ad.actual_treatment_hour,
1472
+                ad.actual_treatment_minute
1473
+             FROM xt_inspection xt
1474
+             JOIN xt_assessment_after_dislysis ad 
1475
+             ON DATE(FROM_UNIXTIME(xt.inspect_date)) = DATE(FROM_UNIXTIME(ad.assessment_date)) 
1476
+             AND xt.patient_id = ad.patient_id 
1477
+             WHERE xt.org_id = 10677 AND xt.item_id = 106771301 
1478
+             AND ad.weight_after > 0 
1479
+             AND ad.actual_ultrafiltration > 0) b 
1480
+        ON xts.inspect_date = b.inspect_date 
1481
+        AND xts.patient_id = b.patient_id;
1482
+    `).Scan(&inspections)
1483
+
1484
+	for _, item := range inspections {
1485
+		// 定义一个日期字符串
1486
+		timestamp := item.Inspect
1487
+		var ins models.Inspection
1488
+		ins.Status = 1
1489
+		ins.PatientId = item.PatientID
1490
+		ins.OrgId = 10677
1491
+		ins.ItemName = "透析前尿素氮"
1492
+		ins.CreatedTime = time.Now().Unix()
1493
+		ins.UpdatedTime = time.Now().Unix()
1494
+		ins.ProjectName = "KT/V"
1495
+		ins.InspectType = 3
1496
+		ins.InspectDate = timestamp
1497
+		ins.InspectValue = item.InspectValue1
1498
+		ins.ProjectId = 1014
1499
+		ins.ItemId = 10879
1500
+		writeDb.Create(&ins)
1501
+
1502
+		var ins2 models.Inspection
1503
+		ins2.Status = 1
1504
+		ins2.PatientId = item.PatientID
1505
+		ins2.OrgId = 10677
1506
+		ins2.ItemName = "透析后尿素氮"
1507
+		ins2.CreatedTime = time.Now().Unix()
1508
+		ins2.UpdatedTime = time.Now().Unix()
1509
+		ins2.ProjectName = "KT/V"
1510
+		ins2.InspectType = 3
1511
+		ins2.InspectDate = timestamp
1512
+		ins2.InspectValue = item.InspectValue2
1513
+		ins2.ProjectId = 1014
1514
+		ins2.ItemId = 10878
1515
+		writeDb.Create(&ins2)
1516
+
1517
+		var ins3 models.Inspection
1518
+		ins3.Status = 1
1519
+		ins3.PatientId = item.PatientID
1520
+		ins3.OrgId = 10677
1521
+		ins3.ItemName = "透析时间"
1522
+		ins3.CreatedTime = time.Now().Unix()
1523
+		ins3.UpdatedTime = time.Now().Unix()
1524
+		ins3.ProjectName = "KT/V"
1525
+		ins3.InspectType = 3
1526
+		ins3.InspectDate = timestamp
1527
+		strValue := fmt.Sprintf("%f", float64(item.ActualTreatmentHour)+item.ActualTreatmentHours)
1528
+		ins3.InspectValue = strValue
1529
+		ins3.ProjectId = 1014
1530
+		ins3.ItemId = 10877
1531
+		writeDb.Create(&ins3)
1532
+
1533
+		var ins4 models.Inspection
1534
+
1535
+		ins4.Status = 1
1536
+		ins4.PatientId = item.PatientID
1537
+		ins4.OrgId = 10677
1538
+		ins4.ItemName = "实际超滤量"
1539
+		ins4.CreatedTime = time.Now().Unix()
1540
+		ins4.UpdatedTime = time.Now().Unix()
1541
+		ins4.ProjectName = "KT/V"
1542
+		ins4.InspectType = 3
1543
+		ins4.InspectDate = timestamp
1544
+		strValue2 := fmt.Sprintf("%f", item.ActualUltrafiltration/1000)
1545
+		ins4.InspectValue = strValue2
1546
+		ins4.ProjectId = 1014
1547
+		ins4.ItemId = 10876
1548
+		writeDb.Create(&ins4)
1549
+
1550
+		var ins7 models.Inspection
1551
+		ins7.Status = 1
1552
+		ins7.PatientId = item.PatientID
1553
+		ins7.OrgId = 10677
1554
+		ins7.ItemName = "透后体重"
1555
+		ins7.CreatedTime = time.Now().Unix()
1556
+		ins7.UpdatedTime = time.Now().Unix()
1557
+		ins7.ProjectName = "KT/V"
1558
+		ins7.InspectType = 3
1559
+		ins7.InspectDate = timestamp
1560
+		strValue5 := fmt.Sprintf("%f", item.WeightAfter)
1561
+		ins7.InspectValue = strValue5
1562
+		ins7.ProjectId = 1014
1563
+		ins7.ItemId = 10874
1564
+		writeDb.Create(&ins7)
1565
+
1566
+		var ins8 models.Inspection
1567
+		ins8.Status = 1
1568
+		ins8.PatientId = item.PatientID
1569
+		ins8.OrgId = 10677
1570
+		ins8.ItemName = "KT/V"
1571
+		ins8.CreatedTime = time.Now().Unix()
1572
+		ins8.UpdatedTime = time.Now().Unix()
1573
+		ins8.ProjectName = "KT/V"
1574
+		ins8.InspectType = 3
1575
+		ins8.InspectDate = timestamp
1576
+		ins8.InspectValue = ""
1577
+		ins8.ProjectId = 1014
1578
+		ins8.ItemId = 10950
1579
+
1580
+		C0, _ := strconv.ParseFloat(item.InspectValue1, 64)
1581
+		Ct, _ := strconv.ParseFloat(item.InspectValue2, 64)
1582
+
1583
+		a := math.Log((Ct/C0 - (0.008 * (float64(item.ActualTreatmentHour) + item.ActualTreatmentHours))))
1584
+		b := (4 - 3.5*(Ct/C0)) * ((item.ActualUltrafiltration / 1000) / item.WeightAfter)
1585
+		c := -a + b
1586
+
1587
+		// 格式化输出,保留5位小数
1588
+		valueFormatted := fmt.Sprintf("%.5f", c)
1589
+
1590
+		ins8.InspectValue = valueFormatted
1591
+		writeDb.Create(&ins8)
1592
+
1593
+		var ins9 models.Inspection
1594
+		ins9.Status = 1
1595
+		ins9.PatientId = item.PatientID
1596
+		ins9.OrgId = 10677
1597
+		ins9.ItemName = "URR(%)"
1598
+		ins9.CreatedTime = time.Now().Unix()
1599
+		ins9.UpdatedTime = time.Now().Unix()
1600
+		ins9.ProjectName = "KT/V"
1601
+		ins9.InspectType = 3
1602
+		ins9.InspectDate = timestamp
1603
+		before, _ := strconv.ParseFloat(item.InspectValue1, 64)
1604
+		after, _ := strconv.ParseFloat(item.InspectValue2, 64)
1605
+		value2 := (((before - after) / before) * 100)
1606
+		rounded := math.Round(value2*100) / 100
1607
+		strValue6 := fmt.Sprintf("%f", rounded)
1608
+		ins9.InspectValue = strValue6
1609
+		ins9.ProjectId = 1014
1610
+		ins9.ItemId = 10951
1611
+		writeDb.Create(&ins9)
1612
+	}
1613
+}

+ 169 - 0
service/his_charge_service.go View File

@@ -339,6 +339,91 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
339 339
 
340 340
 			}
341 341
 
342
+			break
343
+		case 4:
344
+			if time_type == "0" {
345
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
346
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
347
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
348
+					Joins("left join xt_his_project project on  p.project_id = project.id").
349
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
350
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
351
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 3", org_id, start_time, end_time).Scan(&patients).Error
352
+
353
+			} else {
354
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
355
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
356
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
357
+					Joins("left join xt_his_project project on  p.project_id = project.id").
358
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
359
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
360
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ?  and oi.status = 1 and project.cost_classify = 3 ", org_id, start_time, end_time).Scan(&patients).Error
361
+
362
+			}
363
+
364
+			break
365
+		case 5:
366
+			if time_type == "0" {
367
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
368
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
369
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
370
+					Joins("left join xt_his_project project on  p.project_id = project.id").
371
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
372
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
373
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1  and project.cost_classify = 2", org_id, start_time, end_time).Scan(&patients).Error
374
+
375
+			} else {
376
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
377
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
378
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
379
+					Joins("left join xt_his_project project on  p.project_id = project.id").
380
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
381
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
382
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ?  and oi.status = 1  and project.cost_classify = 2", org_id, start_time, end_time).Scan(&patients).Error
383
+
384
+			}
385
+
386
+			break
387
+		case 6:
388
+			if time_type == "0" {
389
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
390
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
391
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
392
+					Joins("left join xt_his_project project on  p.project_id = project.id").
393
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
394
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
395
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 6", org_id, start_time, end_time).Scan(&patients).Error
396
+
397
+			} else {
398
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
399
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
400
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
401
+					Joins("left join xt_his_project project on  p.project_id = project.id").
402
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
403
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
404
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ?  and oi.status = 1  and project.cost_classify = 6", org_id, start_time, end_time).Scan(&patients).Error
405
+			}
406
+			break
407
+		case 7:
408
+			if time_type == "0" {
409
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
410
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
411
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
412
+					Joins("left join xt_his_project project on  p.project_id = project.id").
413
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
414
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
415
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
416
+
417
+			} else {
418
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
419
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
420
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
421
+					Joins("left join xt_his_project project on  p.project_id = project.id").
422
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
423
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
424
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ?  and oi.status = 1  and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
425
+
426
+			}
342 427
 			break
343 428
 		}
344 429
 	} else {
@@ -413,6 +498,90 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
413 498
 					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
414 499
 
415 500
 			}
501
+		case 4:
502
+			if time_type == "0" {
503
+
504
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
505
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
506
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
507
+					Joins("left join xt_his_project project on  p.project_id = project.id").
508
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
509
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
510
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 and project.cost_classify = 3 ", org_id, start_time, end_time).Scan(&patients).Error
511
+
512
+			} else {
513
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
514
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
515
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
516
+					Joins("left join xt_his_project project on  p.project_id = project.id").
517
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
518
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
519
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ? and oi.status = 1 and project.cost_classify = 3 ", org_id, start_time, end_time).Scan(&patients).Error
520
+
521
+			}
522
+		case 5:
523
+			if time_type == "0" {
524
+
525
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
526
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
527
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
528
+					Joins("left join xt_his_project project on  p.project_id = project.id").
529
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
530
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
531
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1  and project.cost_classify = 2", org_id, start_time, end_time).Scan(&patients).Error
532
+
533
+			} else {
534
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
535
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
536
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
537
+					Joins("left join xt_his_project project on  p.project_id = project.id").
538
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
539
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
540
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ? and oi.status = 1  and project.cost_classify = 2 ", org_id, start_time, end_time).Scan(&patients).Error
541
+
542
+			}
543
+		case 6:
544
+			if time_type == "0" {
545
+
546
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
547
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
548
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
549
+					Joins("left join xt_his_project project on  p.project_id = project.id").
550
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
551
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
552
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1  and project.cost_classify = 10", org_id, start_time, end_time).Scan(&patients).Error
553
+
554
+			} else {
555
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
556
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
557
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
558
+					Joins("left join xt_his_project project on  p.project_id = project.id").
559
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
560
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
561
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ? and oi.status = 1 and project.cost_classify = 10", org_id, start_time, end_time).Scan(&patients).Error
562
+
563
+			}
564
+		case 7:
565
+			if time_type == "0" {
566
+
567
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
568
+					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
569
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
570
+					Joins("left join xt_his_project project on  p.project_id = project.id").
571
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
572
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
573
+					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1   and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
574
+
575
+			} else {
576
+				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
577
+					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
578
+					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
579
+					Joins("left join xt_his_project project on  p.project_id = project.id").
580
+					Joins("left join  xt_good_information good on  p.project_id = good.id").
581
+					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
582
+					Where("oi.project_id > 0 and oi.user_org_id = ? and oi.upload_date >= ?  and oi.upload_date <= ? and oi.status = 1 and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
583
+
584
+			}
416 585
 
417 586
 			break
418 587
 		}

+ 9 - 2
service/new_stock_medical_insurance_service.go View File

@@ -4,12 +4,19 @@ import "XT_New/models"
4 4
 
5 5
 func FindAllDrugWarehousingInfo(org_id int64, is_pc int64, is_bg int64, start_time int64, end_time int64) (list []*models.DrugWarehouseInfoTenOne, err error) {
6 6
 	db := readDb.Model(&models.DrugWarehouseInfoTenOne{}).Preload("BaseDrugLib", "org_id = ?", org_id)
7
-	if is_pc != 0 {
7
+	if is_pc == 1 {
8 8
 		db = db.Where("is_pc = ?", is_pc)
9 9
 	}
10
-	if is_bg != 0 {
10
+	if is_bg == 1 {
11 11
 		db = db.Where("is_bg = ?", is_bg)
12 12
 	}
13
+	if is_pc == 2 {
14
+		db = db.Where("is_pc = ?", 0)
15
+	}
16
+	if is_bg == 2 {
17
+		db = db.Where("is_bg = ?", 0)
18
+	}
19
+
13 20
 	if start_time != 0 {
14 21
 		db = db.Where("ctime >= ?", start_time)
15 22