28169 10 ヶ月 前
コミット
69115c85ef
共有34 個のファイルを変更した1977 個の追加719 個の削除を含む
  1. 6 6
      controllers/base_api_controller.go
  2. 55 6
      controllers/dialysis_api_controller.go
  3. 10 1
      controllers/dialysis_record_api_controller.go
  4. 7 0
      controllers/drug_stock_api_contorller.go
  5. 7 5
      controllers/gobal_config_api_controller.go
  6. 13 4
      controllers/his_api_controller.go
  7. 8 7
      controllers/manage_api_controller.go
  8. 145 403
      controllers/mobile_api_controllers/dialysis_api_controller.go
  9. 13 4
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  10. 1 1
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  11. 48 0
      controllers/patient_api_controller.go
  12. 7 3
      controllers/print_data_api_controller.go
  13. 707 0
      controllers/self_drug_api_congtroller.go
  14. 1 1
      controllers/sign_api_controller.go
  15. 8 266
      controllers/stock_in_api_controller.go
  16. 3 0
      models/dialysis.go
  17. 182 0
      models/drug.go
  18. 2 0
      models/drug_stock.go
  19. 0 1
      models/new_stock_models.go
  20. 14 0
      models/patient_models.go
  21. 1 0
      models/self_drug_models.go
  22. 2 0
      models/stock_models.go
  23. 52 1
      service/dialysis_service.go
  24. 1 1
      service/gobal_config_service.go
  25. 1 1
      service/his_project_service.go
  26. 35 4
      service/his_service.go
  27. 2 1
      service/mobile_dialysis_service.go
  28. 31 0
      service/new_stock_service.go
  29. 23 0
      service/patient_service.go
  30. 3 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  31. 293 0
      service/self_drug_service.go
  32. 1 1
      service/sign_service.go
  33. 3 2
      service/stock_service.go
  34. 292 0
      service/warhouse_service.go

+ 6 - 6
controllers/base_api_controller.go ファイルの表示

83
 		userAdmin.ModifyTime = 1530786071
83
 		userAdmin.ModifyTime = 1530786071
84
 		var subscibe models.ServeSubscibe
84
 		var subscibe models.ServeSubscibe
85
 		subscibe.ID = 11
85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10489 //机构id
86
+		subscibe.OrgId = 10666 //机构id
87
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodStart = 1547447814
88
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.PeriodEnd = 1550039814
89
 		subscibe.State = 1
89
 		subscibe.State = 1
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94
 		subscibes[4] = &subscibe
94
 		subscibes[4] = &subscibe
95
 		var adminUserInfo service.AdminUserInfo
95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 14655 //4
96
+		adminUserInfo.CurrentOrgId = 10666 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 17876 //4
98
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.AdminUser = &userAdmin
99
 		adminUserInfo.Subscibes = subscibes
99
 		adminUserInfo.Subscibes = subscibes
100
 		this.SetSession("admin_user_info", &adminUserInfo)
100
 		this.SetSession("admin_user_info", &adminUserInfo)
329
 		userAdmin.ModifyTime = 1530786071
329
 		userAdmin.ModifyTime = 1530786071
330
 		var subscibe models.ServeSubscibe
330
 		var subscibe models.ServeSubscibe
331
 		subscibe.ID = 11
331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10489 //机构id小英9675或4
332
+		subscibe.OrgId = 10666 //机构id小英9675或4
333
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodStart = 1538035409
334
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.PeriodEnd = 1569571409
335
 		subscibe.State = 1
335
 		subscibe.State = 1
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
 		subscibes[4] = &subscibe
340
 		subscibes[4] = &subscibe
341
 		var adminUserInfo service.AdminUserInfo
341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 14655 //4
342
+		adminUserInfo.CurrentOrgId = 10666 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 17876 //4
344
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.AdminUser = &userAdmin
345
 		adminUserInfo.Subscibes = subscibes
345
 		adminUserInfo.Subscibes = subscibes
346
 		this.SetSession("admin_user_info", &adminUserInfo)
346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 55 - 6
controllers/dialysis_api_controller.go ファイルの表示

4421
 	//获取上次的透后体重
4421
 	//获取上次的透后体重
4422
 	//	assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4422
 	//	assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4423
 	assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4423
 	assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4424
+
4424
 	//获取透析次数
4425
 	//获取透析次数
4425
 	_, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
4426
 	_, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
4426
 
4427
 
4470
 
4471
 
4471
 	//相关操作对应的操作人
4472
 	//相关操作对应的操作人
4472
 	//operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
4473
 	//operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
4473
-	operators, err := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
4474
+	operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
4474
 
4475
 
4475
-	fmt.Println("operators", operators)
4476
+	//fmt.Println("operators------------------------------------", operators)
4476
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4477
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4477
 
4478
 
4478
 	//获取当前日期月份的第一天
4479
 	//获取当前日期月份的第一天
4481
 	//获取当前月份的病人透析次数
4482
 	//获取当前月份的病人透析次数
4482
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.CurrentOrgId)
4483
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.CurrentOrgId)
4483
 
4484
 
4485
+	var hisAdvice []*models.HisDoctorAdviceInfo
4486
+
4487
+	var his_advices_one []*models.HisDoctorAdviceInfo
4484
 	//获取his数据
4488
 	//获取his数据
4485
-	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4489
+	hisAdvice, _ = service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4490
+
4491
+	//针对茂名舒和
4492
+	if adminUserInfo.CurrentOrgId == 10666 || adminUserInfo.CurrentOrgId == 10644 {
4493
+		if len(hisAdvice) > 0 {
4494
+			for _, item := range hisAdvice {
4495
+				drug, _ := service.GetDrugIsShow(item.DrugId, adminUserInfo.CurrentOrgId)
4496
+				if drug.IsShow == 1 {
4497
+					his_advices_one = append(his_advices_one, item)
4498
+				}
4499
+			}
4500
+		}
4501
+	} else {
4502
+		if len(hisAdvice) > 0 {
4503
+			for _, item := range hisAdvice {
4504
+				his_advices_one = append(his_advices_one, item)
4505
+			}
4506
+		}
4507
+	}
4486
 
4508
 
4487
 	//hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4509
 	//hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4488
 	config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
4510
 	config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
4489
 
4511
 
4490
 	project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
4512
 	project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
4491
-	projects, _ := service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4513
+
4514
+	var projects []*models.HisPrescriptionProject
4515
+	projects, _ = service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4516
+
4517
+	var projectsOne []*models.HisPrescriptionProject
4518
+
4519
+	//针对茂名舒和
4520
+	if adminUserInfo.CurrentOrgId == 10666 || adminUserInfo.CurrentOrgId == 10644 {
4521
+		if len(projects) > 0 {
4522
+			for _, item := range projects {
4523
+				if item.Type == 2 {
4524
+					if item.HisProject.IsShow == 1 {
4525
+						projectsOne = append(projectsOne, item)
4526
+					}
4527
+				}
4528
+
4529
+				if item.Type == 3 {
4530
+					if item.GoodInfo.IsShow == 1 {
4531
+						projectsOne = append(projectsOne, item)
4532
+					}
4533
+				}
4534
+			}
4535
+		}
4536
+	} else {
4537
+		for _, item := range projects {
4538
+			projectsOne = append(projectsOne, item)
4539
+		}
4540
+	}
4492
 
4541
 
4493
 	//获取诊断
4542
 	//获取诊断
4494
 	prescriptionInfo, _ := service.GetPrescriptionInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4543
 	prescriptionInfo, _ := service.GetPrescriptionInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4525
 			"PredialysisEvaluation":     PredialysisEvaluation,
4574
 			"PredialysisEvaluation":     PredialysisEvaluation,
4526
 			"AssessmentAfterDislysis":   AssessmentAfterDislysis,
4575
 			"AssessmentAfterDislysis":   AssessmentAfterDislysis,
4527
 			"dialysisPrescription":      dialysisPrescription,
4576
 			"dialysisPrescription":      dialysisPrescription,
4528
-			"advices":                   hisAdvice,
4577
+			"advices":                   his_advices_one,
4529
 			"monitors":                  Record,
4578
 			"monitors":                  Record,
4530
 			"summary":                   TreatmentSummary,
4579
 			"summary":                   TreatmentSummary,
4531
 			"receiverTreatmentAccess":   receiverTreatmentAccess,
4580
 			"receiverTreatmentAccess":   receiverTreatmentAccess,
4550
 			"dialysiscount":             dialysiscount,
4599
 			"dialysiscount":             dialysiscount,
4551
 			"last_order":                lastOrder,
4600
 			"last_order":                lastOrder,
4552
 			"project_config":            project_config,
4601
 			"project_config":            project_config,
4553
-			"projects":                  projects,
4602
+			"projects":                  projectsOne,
4554
 			"prescriptionInfo":          prescriptionInfo,
4603
 			"prescriptionInfo":          prescriptionInfo,
4555
 			"patientDiagnose":           patientDiagnose,
4604
 			"patientDiagnose":           patientDiagnose,
4556
 			"lastSchedule":              lastSchedule,
4605
 			"lastSchedule":              lastSchedule,

+ 10 - 1
controllers/dialysis_record_api_controller.go ファイルの表示

584
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
584
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
585
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
585
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
586
 	IsPressure                  string  `gorm:"column:is_pressure" json:"is_pressure" form:"is_pressure"`
586
 	IsPressure                  string  `gorm:"column:is_pressure" json:"is_pressure" form:"is_pressure"`
587
+	UltrafiltrationRateOne      string  `gorm:"column:ultrafiltration_rate_one" json:"ultrafiltration_rate_one" form:"ultrafiltration_rate_one"`
588
+	HeparinOne                  string  `gorm:"column:heparin_one" json:"heparin_one" form:"heparin_one"`
587
 }
589
 }
588
 
590
 
589
 // /api/dislysis/monitor/edit [post]
591
 // /api/dislysis/monitor/edit [post]
733
 			ReplacementSpeed:            monitorParam.ReplacementSpeed,
735
 			ReplacementSpeed:            monitorParam.ReplacementSpeed,
734
 			Dicarbonate:                 monitorParam.Dicarbonate,
736
 			Dicarbonate:                 monitorParam.Dicarbonate,
735
 			IsPressure:                  monitorParam.IsPressure,
737
 			IsPressure:                  monitorParam.IsPressure,
738
+			UltrafiltrationRateOne:      monitorParam.UltrafiltrationRateOne,
739
+			HeparinOne:                  monitorParam.HeparinOne,
736
 		}
740
 		}
737
 		createErr := service.CreateMonitor(&monitor)
741
 		createErr := service.CreateMonitor(&monitor)
738
 
742
 
853
 		monitor.ReplacementSpeed = monitorParam.ReplacementSpeed
857
 		monitor.ReplacementSpeed = monitorParam.ReplacementSpeed
854
 		monitor.Dicarbonate = monitorParam.Dicarbonate
858
 		monitor.Dicarbonate = monitorParam.Dicarbonate
855
 		monitor.IsPressure = monitorParam.IsPressure
859
 		monitor.IsPressure = monitorParam.IsPressure
860
+		monitor.UltrafiltrationRateOne = monitorParam.UltrafiltrationRateOne
861
+		monitor.HeparinOne = monitorParam.HeparinOne
856
 		updateErr := service.UpdateMonitor(monitor)
862
 		updateErr := service.UpdateMonitor(monitor)
857
 		//记录日志
863
 		//记录日志
858
 		byterequest, _ := json.Marshal(monitor)
864
 		byterequest, _ := json.Marshal(monitor)
916
 	order_remark := this.GetString("order_remark")
922
 	order_remark := this.GetString("order_remark")
917
 	catheter_operation := this.GetString("catheter_operation")
923
 	catheter_operation := this.GetString("catheter_operation")
918
 	blood_flow_volume := this.GetString("blood_flow_volume")
924
 	blood_flow_volume := this.GetString("blood_flow_volume")
925
+	dialysis_strainer := this.GetString("dialysis_strainer")
919
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
926
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
920
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
927
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
921
 		return
928
 		return
1162
 		CatheterOperation:      catheter_operation,
1169
 		CatheterOperation:      catheter_operation,
1163
 		BloodFlowVolume:        blood_flow_volume,
1170
 		BloodFlowVolume:        blood_flow_volume,
1164
 		BloodDrawing:           blood_drawing,
1171
 		BloodDrawing:           blood_drawing,
1172
+		DialysisStrainer:       dialysis_strainer,
1165
 	}
1173
 	}
1166
 
1174
 
1167
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1175
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1884
 	catheter_operation := this.GetString("catheter_operation")
1892
 	catheter_operation := this.GetString("catheter_operation")
1885
 	blood_flow_volume := this.GetString("blood_flow_volume")
1893
 	blood_flow_volume := this.GetString("blood_flow_volume")
1886
 	blood_drawing, _ := this.GetInt64("blood_drawing")
1894
 	blood_drawing, _ := this.GetInt64("blood_drawing")
1895
+	dialysis_strainer := this.GetString("dialysis_strainer")
1887
 	if record_id == 0 {
1896
 	if record_id == 0 {
1888
 		this.ErrorLog("id:%v", record_id)
1897
 		this.ErrorLog("id:%v", record_id)
1889
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1898
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1968
 
1977
 
1969
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
1978
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
1970
 
1979
 
1971
-	fmt.Println("schedule-----------------------------", schedule)
1972
 	daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
1980
 	daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
1973
 
1981
 
1974
 	if daySchedule.BedId != bedID || daySchedule.ScheduleType != schedual_type {
1982
 	if daySchedule.BedId != bedID || daySchedule.ScheduleType != schedual_type {
2058
 		CatheterOperation:      catheter_operation,
2066
 		CatheterOperation:      catheter_operation,
2059
 		BloodFlowVolume:        blood_flow_volume,
2067
 		BloodFlowVolume:        blood_flow_volume,
2060
 		BloodDrawing:           blood_drawing,
2068
 		BloodDrawing:           blood_drawing,
2069
+		DialysisStrainer:       dialysis_strainer,
2061
 	}
2070
 	}
2062
 
2071
 
2063
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2072
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)

+ 7 - 0
controllers/drug_stock_api_contorller.go ファイルの表示

1275
 
1275
 
1276
 				id := int64(items["id"].(float64))
1276
 				id := int64(items["id"].(float64))
1277
 
1277
 
1278
+				class_type, _ := items["class_type"].(string)
1279
+
1278
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1280
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1279
 					ID:                      id,
1281
 					ID:                      id,
1280
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1282
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1306
 					IsCheck:                 2,
1308
 					IsCheck:                 2,
1307
 					SysRecordTime:           warehousingOutDate.Unix(),
1309
 					SysRecordTime:           warehousingOutDate.Unix(),
1308
 					PatientId:               patient_id,
1310
 					PatientId:               patient_id,
1311
+					ClassType:               class_type,
1309
 				}
1312
 				}
1310
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1313
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1311
 
1314
 
1685
 
1688
 
1686
 				stock_count, _ := items["stock_count"].(string)
1689
 				stock_count, _ := items["stock_count"].(string)
1687
 
1690
 
1691
+				class_type, _ := items["class_type"].(string)
1692
+
1688
 				if id == 0 {
1693
 				if id == 0 {
1689
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1694
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1690
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1695
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1715
 						AdminUserId:             admin_user_id,
1720
 						AdminUserId:             admin_user_id,
1716
 						StockCount:              stock_count,
1721
 						StockCount:              stock_count,
1717
 						PatientId:               patient_id,
1722
 						PatientId:               patient_id,
1723
+						ClassType:               class_type,
1718
 					}
1724
 					}
1719
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1725
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1720
 
1726
 
1794
 						AdminUserId:             admin_user_id,
1800
 						AdminUserId:             admin_user_id,
1795
 						StockCount:              stock_count,
1801
 						StockCount:              stock_count,
1796
 						PatientId:               patient_id,
1802
 						PatientId:               patient_id,
1803
+						ClassType:               class_type,
1797
 					}
1804
 					}
1798
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1805
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1799
 
1806
 

+ 7 - 5
controllers/gobal_config_api_controller.go ファイルの表示

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
-	"XT_New/utils"
8
 	"bytes"
4
 	"bytes"
9
 	"encoding/json"
5
 	"encoding/json"
10
 	"fmt"
6
 	"fmt"
11
-	"github.com/jinzhu/gorm"
12
 	"io/ioutil"
7
 	"io/ioutil"
13
 	"log"
8
 	"log"
14
 	"os"
9
 	"os"
20
 	"strings"
15
 	"strings"
21
 	"time"
16
 	"time"
22
 
17
 
18
+	"XT_New/enums"
19
+	"XT_New/models"
20
+	"XT_New/service"
21
+	"XT_New/utils"
22
+	"github.com/jinzhu/gorm"
23
+
23
 	"github.com/astaxie/beego"
24
 	"github.com/astaxie/beego"
24
 )
25
 )
25
 
26
 
2316
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2317
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2317
 
2318
 
2318
 	list, err := service.GetSingleOrderDetail(id, orgId)
2319
 	list, err := service.GetSingleOrderDetail(id, orgId)
2320
+	fmt.Println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH", list)
2319
 	drugoutlist, _ := service.GetDrugWarehouseOutDetailNighty(id, orgId)
2321
 	drugoutlist, _ := service.GetDrugWarehouseOutDetailNighty(id, orgId)
2320
 	dealerList, err := service.GetAllDealerList(orgId)
2322
 	dealerList, err := service.GetAllDealerList(orgId)
2321
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2323
 	manufacturerList, err := service.GetAllManufacturerList(orgId)

+ 13 - 4
controllers/his_api_controller.go ファイルの表示

2993
 
2993
 
2994
 											}
2994
 											}
2995
 
2995
 
2996
-											//service.DeleteAutoWarehouse(patient_id, recordDateTime)
2996
+											service.DeleteAutoWarehouse(patient_id, recordDateTime)
2997
 
2997
 
2998
 										}
2998
 										}
2999
 
2999
 
3046
 													service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, item.OrgId)
3046
 													service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, item.OrgId)
3047
 												}
3047
 												}
3048
 
3048
 
3049
-												//service.DeleteAutoWarehouse(patient_id, recordDateTime)
3049
+												service.DeleteAutoWarehouse(patient_id, recordDateTime)
3050
 
3050
 
3051
 											}
3051
 											}
3052
 
3052
 
3176
 	var adviceList []models.HisDoctorAdviceInfo
3176
 	var adviceList []models.HisDoctorAdviceInfo
3177
 	var projectList []models.HisPrescriptionProject
3177
 	var projectList []models.HisPrescriptionProject
3178
 
3178
 
3179
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10666 {
3179
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10666 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 9675 {
3180
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3180
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3181
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3181
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3182
 
3182
 
4437
 										s.Price = lastWarehouse.RetailPrice
4437
 										s.Price = lastWarehouse.RetailPrice
4438
 									}
4438
 									}
4439
 									if s.Price == 0 {
4439
 									if s.Price == 0 {
4440
-										s.Price = lastWarehouse.RetailPrice
4440
+										if lastWarehouse.ID == 0 {
4441
+											lastWarehouseTwo, _ := service.FindLastDrugWarehousingInfoByIDTwo(s.DrugId, storeConfig.DrugStorehouseOut)
4442
+											s.Price = lastWarehouseTwo.RetailPrice
4443
+										}
4444
+
4441
 									}
4445
 									}
4442
 								}
4446
 								}
4443
 
4447
 
4524
 										if p.Price != lastWarehouse.PackingPrice {
4528
 										if p.Price != lastWarehouse.PackingPrice {
4525
 											p.Price = lastWarehouse.PackingPrice
4529
 											p.Price = lastWarehouse.PackingPrice
4526
 										}
4530
 										}
4531
+										if p.Price == 0 {
4532
+											lastWarehouseTwo, _ := service.FindFirstWarehousingInfoByStockFour(p.ProjectId, storeConfig.DrugStorehouseOut)
4533
+											p.Price = lastWarehouseTwo.PackingPrice
4534
+										}
4535
+
4527
 										if p.Unit == "" {
4536
 										if p.Unit == "" {
4528
 											goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4537
 											goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4529
 											p.Unit = goodInfoOne.PackingUnit
4538
 											p.Unit = goodInfoOne.PackingUnit

+ 8 - 7
controllers/manage_api_controller.go ファイルの表示

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+	"unsafe"
9
+
4
 	"XT_New/enums"
10
 	"XT_New/enums"
5
 	"XT_New/models"
11
 	"XT_New/models"
6
 	"XT_New/service"
12
 	"XT_New/service"
7
 	"XT_New/utils"
13
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10
 	"github.com/astaxie/beego"
14
 	"github.com/astaxie/beego"
11
 	"github.com/jinzhu/gorm"
15
 	"github.com/jinzhu/gorm"
12
-	"strconv"
13
-	"time"
14
-	"unsafe"
15
 )
16
 )
16
 
17
 
17
 type MachineApiController struct {
18
 type MachineApiController struct {
5400
 
5401
 
5401
 func (this *MachineApiController) GetInformationmanalist() {
5402
 func (this *MachineApiController) GetInformationmanalist() {
5402
 
5403
 
5403
-	//获取2022年8月1日到10月16日的上机患者
5404
+	//获取2022年8月1日到12日的上机患者
5404
 
5405
 
5405
-	list, _ := service.GetDialysisOrderPatient(10101)
5406
+	list, _ := service.GetDialysisOrderPatient(9538)
5406
 
5407
 
5407
 	for _, dialysisOrder := range list {
5408
 	for _, dialysisOrder := range list {
5408
 
5409
 

+ 145 - 403
controllers/mobile_api_controllers/dialysis_api_controller.go ファイルの表示

505
 	go func() {
505
 	go func() {
506
 		// 先走redis,没有走数据库
506
 		// 先走redis,没有走数据库
507
 		projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
507
 		projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
508
+
508
 		ch <- struct{}{}
509
 		ch <- struct{}{}
509
 	}()
510
 	}()
510
 
511
 
561
 
562
 
562
 	projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
563
 	projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
563
 
564
 
565
+	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
566
+
567
+	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminInfo.Org.Id)
568
+
569
+	var team_projects []*models.HisPrescriptionProject
570
+	//var index int64 = 0
571
+	for _, item := range temp_team_projects {
572
+		//组套里面非检验项目的
573
+		if item.HisProject.CostClassify != 3 {
574
+			projects = append(projects, item)
575
+		}
576
+		//组套里面检验项目的
577
+		if item.HisProject.CostClassify == 3 {
578
+			team_projects = append(team_projects, item)
579
+		}
580
+	}
581
+
564
 	//针对茂名舒和
582
 	//针对茂名舒和
565
 	if adminInfo.Org.Id == 10666 || adminInfo.Org.Id == 10644 {
583
 	if adminInfo.Org.Id == 10666 || adminInfo.Org.Id == 10644 {
566
 		if len(projects) > 0 {
584
 		if len(projects) > 0 {
584
 		}
602
 		}
585
 	}
603
 	}
586
 
604
 
587
-	fmt.Print("projectOne------------------------", projectsOne)
588
-
589
-	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
590
-
591
-	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminInfo.Org.Id)
592
-
593
-	var team_projects []*models.HisPrescriptionProject
594
-	//var index int64 = 0
595
-	for _, item := range temp_team_projects {
596
-		//组套里面非检验项目的
597
-		if item.HisProject.CostClassify != 3 {
598
-			projects = append(projects, item)
599
-		}
600
-		//组套里面检验项目的
601
-		if item.HisProject.CostClassify == 3 {
602
-			team_projects = append(team_projects, item)
603
-		}
604
-	}
605
-
606
 	team_projects = RemoveRepeatedCheckRecod(team_projects)
605
 	team_projects = RemoveRepeatedCheckRecod(team_projects)
607
 
606
 
608
 	stockType, _ = service.GetStockType(adminInfo.Org.Id)
607
 	stockType, _ = service.GetStockType(adminInfo.Org.Id)
3169
 	order_remark := this.GetString("order_remark")
3168
 	order_remark := this.GetString("order_remark")
3170
 	catheter_operation := this.GetString("catheter_operation")
3169
 	catheter_operation := this.GetString("catheter_operation")
3171
 	blood_flow_volume := this.GetString("blood_flow_volume")
3170
 	blood_flow_volume := this.GetString("blood_flow_volume")
3171
+	dialysis_strainer := this.GetString("dialysis_strainer")
3172
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
3172
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
3173
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3173
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3174
 		return
3174
 		return
3390
 		CatheterOperation:      catheter_operation,
3390
 		CatheterOperation:      catheter_operation,
3391
 		BloodFlowVolume:        blood_flow_volume,
3391
 		BloodFlowVolume:        blood_flow_volume,
3392
 		BloodDrawing:           blood_drawing,
3392
 		BloodDrawing:           blood_drawing,
3393
+		DialysisStrainer:       dialysis_strainer,
3393
 	}
3394
 	}
3394
 	//查询该床位是否有人用了
3395
 	//查询该床位是否有人用了
3395
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3396
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3461
 	//}
3462
 	//}
3462
 
3463
 
3463
 	var ultrafiltration_rate float64
3464
 	var ultrafiltration_rate float64
3465
+
3466
+	var ultrafiltration_rate_one string
3464
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3467
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3465
 	//后期预增脱水量
3468
 	//后期预增脱水量
3466
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3469
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3558
 			if adminUserInfo.Org.Id == 10693 {
3561
 			if adminUserInfo.Org.Id == 10693 {
3559
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3562
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3560
 				ultrafiltration_rate = ultrafiltration_rate
3563
 				ultrafiltration_rate = ultrafiltration_rate
3564
+				ultrafiltration_rate_one = strconv.FormatFloat(ultrafiltration_rate, 'f', -1, 64)
3565
+
3561
 			}
3566
 			}
3562
 
3567
 
3563
 			if adminUserInfo.Org.Id == 10694 || adminUserInfo.Org.Id == 10697 {
3568
 			if adminUserInfo.Org.Id == 10694 || adminUserInfo.Org.Id == 10697 {
3564
-				fmt.Println("hahahahhahahahahah")
3569
+
3565
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3570
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3566
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3571
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3567
 			}
3572
 			}
3576
 		MonitoringDate:  schedulestartTime,
3581
 		MonitoringDate:  schedulestartTime,
3577
 		OperateTime:     startDate.Unix(),
3582
 		OperateTime:     startDate.Unix(),
3578
 		// MonitoringTime:            recordTime,
3583
 		// MonitoringTime:            recordTime,
3579
-		MonitoringNurse:       nurseID,
3580
-		Dispose:               tempdispose,
3581
-		UltrafiltrationRate:   ultrafiltration_rate,
3582
-		UltrafiltrationVolume: 0,
3583
-		Status:                1,
3584
-		CreatedTime:           time.Now().Unix(),
3585
-		UpdatedTime:           time.Now().Unix(),
3584
+		MonitoringNurse:        nurseID,
3585
+		Dispose:                tempdispose,
3586
+		UltrafiltrationRate:    ultrafiltration_rate,
3587
+		UltrafiltrationVolume:  0,
3588
+		Status:                 1,
3589
+		CreatedTime:            time.Now().Unix(),
3590
+		UpdatedTime:            time.Now().Unix(),
3591
+		UltrafiltrationRateOne: ultrafiltration_rate_one,
3586
 	}
3592
 	}
3587
 
3593
 
3588
 	//只针对广慈医院
3594
 	//只针对广慈医院
4737
 	catheter_operation := this.GetString("catheter_operation")
4743
 	catheter_operation := this.GetString("catheter_operation")
4738
 	blood_flow_volume := this.GetString("blood_flow_volume")
4744
 	blood_flow_volume := this.GetString("blood_flow_volume")
4739
 	blood_drawing, _ := this.GetInt64("blood_drawing")
4745
 	blood_drawing, _ := this.GetInt64("blood_drawing")
4746
+	dialysis_strainer := this.GetString("dialysis_strainer")
4740
 	if record_id == 0 {
4747
 	if record_id == 0 {
4741
 		this.ErrorLog("id:%v", record_id)
4748
 		this.ErrorLog("id:%v", record_id)
4742
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4749
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4904
 		CatheterOperation:      catheter_operation,
4911
 		CatheterOperation:      catheter_operation,
4905
 		BloodFlowVolume:        blood_flow_volume,
4912
 		BloodFlowVolume:        blood_flow_volume,
4906
 		BloodDrawing:           blood_drawing,
4913
 		BloodDrawing:           blood_drawing,
4914
+		DialysisStrainer:       dialysis_strainer,
4907
 	}
4915
 	}
4908
 
4916
 
4909
 	//修改床位号需要重新消毒
4917
 	//修改床位号需要重新消毒
6242
 						service.CreateGoodErrcode(goodErrcode)
6250
 						service.CreateGoodErrcode(goodErrcode)
6243
 						utils.TraceLog("创建出库单失败 err = %v", err)
6251
 						utils.TraceLog("创建出库单失败 err = %v", err)
6244
 					}
6252
 					}
6253
+					service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6245
 				}
6254
 				}
6246
 
6255
 
6247
 				if item.Count < his_count {
6256
 				if item.Count < his_count {
6259
 						Mtime:      time.Now().Unix(),
6268
 						Mtime:      time.Now().Unix(),
6260
 						PatientId:  item.PatientId,
6269
 						PatientId:  item.PatientId,
6261
 						RecordDate: record_time,
6270
 						RecordDate: record_time,
6271
+						Count:      strconv.FormatInt(item.Count, 10),
6262
 					}
6272
 					}
6263
 
6273
 
6264
-					service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6274
+					service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6265
 
6275
 
6266
-					service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6276
+					service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6277
+
6278
+					service.ModfiyReduceDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6267
 				}
6279
 				}
6268
 
6280
 
6269
 				if item.Count == his_count {
6281
 				if item.Count == his_count {
6290
 						}
6302
 						}
6291
 						//出库
6303
 						//出库
6292
 						service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6304
 						service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6305
+						service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6293
 					}
6306
 					}
6294
 				}
6307
 				}
6295
 
6308
 
6424
 						service.CreateGoodErrcode(goodErrcode)
6437
 						service.CreateGoodErrcode(goodErrcode)
6425
 						utils.TraceLog("创建出库单失败 err = %v", err)
6438
 						utils.TraceLog("创建出库单失败 err = %v", err)
6426
 					}
6439
 					}
6440
+					service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6427
 				}
6441
 				}
6428
 
6442
 
6429
 				if item.Count < his_count {
6443
 				if item.Count < his_count {
6441
 						Mtime:      time.Now().Unix(),
6455
 						Mtime:      time.Now().Unix(),
6442
 						PatientId:  item.PatientId,
6456
 						PatientId:  item.PatientId,
6443
 						RecordDate: record_time,
6457
 						RecordDate: record_time,
6458
+						Count:      strconv.FormatInt(item.Count, 10),
6444
 					}
6459
 					}
6445
 
6460
 
6446
-					service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6461
+					service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6462
+
6463
+					service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6447
 
6464
 
6448
-					service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6465
+					service.ModfiyReduceDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6449
 				}
6466
 				}
6450
 
6467
 
6451
 				if item.Count == his_count {
6468
 				if item.Count == his_count {
6472
 						}
6489
 						}
6473
 						//出库
6490
 						//出库
6474
 						service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6491
 						service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6492
+
6493
+						service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
6475
 					}
6494
 					}
6476
 				}
6495
 				}
6477
 
6496
 
6611
 				}
6630
 				}
6612
 				count := int64(items["new_count"].(float64))
6631
 				count := int64(items["new_count"].(float64))
6613
 
6632
 
6633
+				if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
6634
+					utils.ErrorLog("project_id")
6635
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6636
+					return
6637
+				}
6638
+				project_id := int64(items["project_id"].(float64))
6639
+
6614
 				prepare := &models.DialysisBeforePrepare{
6640
 				prepare := &models.DialysisBeforePrepare{
6615
 					GoodTypeId:   good_type_id,
6641
 					GoodTypeId:   good_type_id,
6616
 					GoodId:       good_id,
6642
 					GoodId:       good_id,
6622
 					Ctime:        time.Now().Unix(),
6648
 					Ctime:        time.Now().Unix(),
6623
 					Creater:      adminInfo.AdminUser.Id,
6649
 					Creater:      adminInfo.AdminUser.Id,
6624
 					StorehouseId: houseConfig.StorehouseOutInfo,
6650
 					StorehouseId: houseConfig.StorehouseOutInfo,
6651
+					ProjectId:    project_id,
6625
 				}
6652
 				}
6626
 
6653
 
6627
 				consumables = append(consumables, prepare)
6654
 				consumables = append(consumables, prepare)
6636
 		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6663
 		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6637
 		//查询是否有库存
6664
 		//查询是否有库存
6638
 		for _, item := range consumables {
6665
 		for _, item := range consumables {
6639
-			good, _ := service.GetGoodInformationByGoodId(item.ProjectId)
6640
-			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.ProjectId, good.GoodTypeId, houseConfig.StorehouseOutInfo)
6666
+			good, _ := service.GetGoodInformationByGoodId(item.GoodId)
6667
+			warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, good.GoodTypeId, houseConfig.StorehouseOutInfo)
6641
 
6668
 
6642
 			if item.Count > warehouse.Count {
6669
 			if item.Count > warehouse.Count {
6643
 				goodErrcode := models.XtGoodErrcode{
6670
 				goodErrcode := models.XtGoodErrcode{
6655
 				}
6682
 				}
6656
 				service.CreateGoodErrcode(goodErrcode)
6683
 				service.CreateGoodErrcode(goodErrcode)
6657
 
6684
 
6658
-				goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
6685
+				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
6659
 				c.ServeSuccessJSON(map[string]interface{}{
6686
 				c.ServeSuccessJSON(map[string]interface{}{
6660
 					"message":            "1",
6687
 					"message":            "1",
6661
 					"good_name":          goodObj.GoodName,
6688
 					"good_name":          goodObj.GoodName,
6668
 		//查询是否有出库单
6695
 		//查询是否有出库单
6669
 		_, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
6696
 		_, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
6670
 
6697
 
6671
-		fmt.Println("err000000000000000000000000000000000000000000", err)
6672
 		if err == gorm.ErrRecordNotFound {
6698
 		if err == gorm.ErrRecordNotFound {
6673
 			//没有记录,则创建出库单
6699
 			//没有记录,则创建出库单
6674
 			timeStr := time.Now().Format("2006-01-02")
6700
 			timeStr := time.Now().Format("2006-01-02")
6727
 					}
6753
 					}
6728
 				}()
6754
 				}()
6729
 				for _, item := range consumables {
6755
 				for _, item := range consumables {
6730
-
6731
 					//出库
6756
 					//出库
6732
 					if item.Count > 0 {
6757
 					if item.Count > 0 {
6733
 						timeStr := time.Now().Format("2006-01-02")
6758
 						timeStr := time.Now().Format("2006-01-02")
6769
 
6794
 
6770
 						lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6795
 						lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6771
 
6796
 
6772
-						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6797
+						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
6773
 						houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6798
 						houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6774
 
6799
 
6775
 						dialyPrepareOne := models.DialysisBeforePrepare{
6800
 						dialyPrepareOne := models.DialysisBeforePrepare{
6776
 							GoodTypeId:   goodObj.GoodTypeId,
6801
 							GoodTypeId:   goodObj.GoodTypeId,
6777
-							GoodId:       item.ProjectId,
6778
-							PatientId:    item.PatientId,
6802
+							GoodId:       item.GoodId,
6803
+							PatientId:    patient_id,
6779
 							RecordDate:   record_time,
6804
 							RecordDate:   record_time,
6780
 							UserOrgId:    adminInfo.Org.Id,
6805
 							UserOrgId:    adminInfo.Org.Id,
6781
 							Count:        item.Count,
6806
 							Count:        item.Count,
6805
 							service.CreateGoodErrcode(goodErrcode)
6830
 							service.CreateGoodErrcode(goodErrcode)
6806
 							utils.TraceLog("创建出库单失败 err = %v", err)
6831
 							utils.TraceLog("创建出库单失败 err = %v", err)
6807
 						}
6832
 						}
6833
+
6834
+						//添加
6835
+						service.ModfiyAddDialysisAuto(item.PatientId, record_time, item.Count, item.GoodId, tx)
6808
 					}
6836
 					}
6809
 
6837
 
6810
 					//退库
6838
 					//退库
6811
 					if item.Count < 0 {
6839
 					if item.Count < 0 {
6812
-						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6840
+						count := math.Abs(float64(item.Count))
6841
+						item.Count = int64(count)
6842
+
6843
+						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
6813
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
6844
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
6814
 
6845
 
6815
 						newPrescriptionProject := &models.HisPrescriptionProject{
6846
 						newPrescriptionProject := &models.HisPrescriptionProject{
6816
 							ID:         item.ProjectId,
6847
 							ID:         item.ProjectId,
6817
-							ProjectId:  item.ProjectId,
6848
+							ProjectId:  item.GoodId,
6818
 							UserOrgId:  adminInfo.Org.Id,
6849
 							UserOrgId:  adminInfo.Org.Id,
6819
 							Status:     1,
6850
 							Status:     1,
6820
 							Ctime:      time.Now().Unix(),
6851
 							Ctime:      time.Now().Unix(),
6821
 							Mtime:      time.Now().Unix(),
6852
 							Mtime:      time.Now().Unix(),
6822
-							PatientId:  item.PatientId,
6853
+							PatientId:  patient_id,
6823
 							RecordDate: record_time,
6854
 							RecordDate: record_time,
6824
 						}
6855
 						}
6825
 
6856
 
6826
-						service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
6827
-
6828
-						service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
6829
-					}
6857
+						fmt.Println("item.Count---------------------------------------", item.Count)
6858
+						service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
6830
 
6859
 
6831
-					//var his_count int64
6832
-					////查询该耗材今日出库了多少
6833
-					//outInfo, _ := service.GetHistoryWarehouseOutInfo(item.PatientId, adminInfo.Org.Id, record_time, item.ProjectId, tx)
6834
-					//
6835
-					//for _, it := range outInfo {
6836
-					//	his_count += it.Count
6837
-					//}
6838
-					//
6839
-					//if item.Count > his_count {
6840
-					//	//如果当前出库数据 大于历史出库数据,那么需要出库
6841
-					//	var cha_count int64
6842
-					//	cha_count = item.Count - his_count
6843
-					//
6844
-					//	timeStr := time.Now().Format("2006-01-02")
6845
-					//	timeArr := strings.Split(timeStr, "-")
6846
-					//	total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
6847
-					//
6848
-					//	total = total + 1
6849
-					//	warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
6850
-					//	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
6851
-					//	number = number + total
6852
-					//	warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
6853
-					//
6854
-					//	operation_time := time.Now().Unix()
6855
-					//	creater := c.GetMobileAdminUserInfo().AdminUser.Id
6856
-					//
6857
-					//	recordDateStr := time.Now().Format("2006-01-02")
6858
-					//	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
6859
-					//	nowtime := recordDate.Unix()
6860
-					//	//查询默认出库仓库库存
6861
-					//	storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6862
-					//	warehouseOut := models.WarehouseOut{
6863
-					//		WarehouseOutOrderNumber: warehousing_out_order,
6864
-					//		OperationTime:           operation_time,
6865
-					//		OrgId:                   adminInfo.Org.Id,
6866
-					//		Creater:                 creater,
6867
-					//		Ctime:                   time.Now().Unix(),
6868
-					//		Status:                  1,
6869
-					//		WarehouseOutTime:        nowtime,
6870
-					//		Type:                    1,
6871
-					//		StorehouseId:            storeConfig.StorehouseOutInfo,
6872
-					//		IsCheck:                 1,
6873
-					//		IsSys:                   1,
6874
-					//	}
6875
-					//	//查询是否生成出库单
6876
-					//	out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6877
-					//	if out.ID == 0 {
6878
-					//		service.AddNewSigleWarehouseOut(&warehouseOut, tx)
6879
-					//	}
6880
-					//
6881
-					//	lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6882
-					//
6883
-					//	goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6884
-					//	houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6885
-					//
6886
-					//	dialyPrepareOne := models.DialysisBeforePrepare{
6887
-					//		GoodTypeId:   goodObj.GoodTypeId,
6888
-					//		GoodId:       item.ProjectId,
6889
-					//		PatientId:    item.PatientId,
6890
-					//		RecordDate:   record_time,
6891
-					//		UserOrgId:    adminInfo.Org.Id,
6892
-					//		Count:        cha_count,
6893
-					//		Ctime:        time.Now().Unix(),
6894
-					//		Creater:      creater,
6895
-					//		Status:       1,
6896
-					//		StorehouseId: houseConfig.StorehouseOutInfo,
6897
-					//		ProjectId:    item.ProjectId,
6898
-					//	}
6899
-					//	//出库
6900
-					//	service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, item.PatientId, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6901
-					//
6902
-					//	if err == nil {
6903
-					//		goodErrcode := models.XtGoodErrcode{
6904
-					//			UserOrgId:      adminInfo.Org.Id,
6905
-					//			Errcode:        "自动出库接口报错",
6906
-					//			GoodId:         0,
6907
-					//			Status:         1,
6908
-					//			Ctime:          time.Now().Unix(),
6909
-					//			Mtime:          0,
6910
-					//			Count:          0,
6911
-					//			StockCount:     0,
6912
-					//			Creater:        creator,
6913
-					//			BatchNumberId:  0,
6914
-					//			WarehouseOutId: 0,
6915
-					//		}
6916
-					//		service.CreateGoodErrcode(goodErrcode)
6917
-					//		utils.TraceLog("创建出库单失败 err = %v", err)
6918
-					//	}
6919
-					//}
6920
-					//
6921
-					//if item.Count < his_count {
6922
-					//	var cha_count int64
6923
-					//	cha_count = his_count - item.Count
6924
-					//	goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6925
-					//	creater := c.GetMobileAdminUserInfo().AdminUser.Id
6926
-					//
6927
-					//	newPrescriptionProject := &models.HisPrescriptionProject{
6928
-					//		ID:         item.ProjectId,
6929
-					//		ProjectId:  item.ProjectId,
6930
-					//		UserOrgId:  adminInfo.Org.Id,
6931
-					//		Status:     1,
6932
-					//		Ctime:      time.Now().Unix(),
6933
-					//		Mtime:      time.Now().Unix(),
6934
-					//		PatientId:  item.PatientId,
6935
-					//		RecordDate: record_time,
6936
-					//	}
6937
-					//
6938
-					//	service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6939
-					//
6940
-					//	service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
6941
-					//}
6942
-					//
6943
-					//if item.Count == his_count {
6944
-					//	if his_count == 0 {
6945
-					//		recordDateStr := time.Now().Format("2006-01-02")
6946
-					//		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
6947
-					//		nowtime := recordDate.Unix()
6948
-					//		lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6949
-					//		goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6950
-					//		houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6951
-					//		creater := c.GetMobileAdminUserInfo().AdminUser.Id
6952
-					//		dialyPrepareOne := models.DialysisBeforePrepare{
6953
-					//			GoodTypeId:   goodObj.GoodTypeId,
6954
-					//			GoodId:       item.ProjectId,
6955
-					//			PatientId:    item.PatientId,
6956
-					//			RecordDate:   record_time,
6957
-					//			UserOrgId:    adminInfo.Org.Id,
6958
-					//			Count:        item.Count,
6959
-					//			Ctime:        time.Now().Unix(),
6960
-					//			Creater:      creater,
6961
-					//			Status:       1,
6962
-					//			StorehouseId: houseConfig.StorehouseOutInfo,
6963
-					//			ProjectId:    item.ProjectId,
6964
-					//		}
6965
-					//		//出库
6966
-					//		service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
6967
-					//	}
6968
-					//}
6860
+						service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
6969
 
6861
 
6862
+						//减少
6863
+						service.ModfiyReduceDialysisAuto(item.PatientId, record_time, item.Count, item.GoodId, tx)
6864
+					}
6970
 					//查询剩余库存
6865
 					//查询剩余库存
6971
-					goodList, _ := service.GetNewAllGoodSumCount(item.ProjectId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo, tx)
6866
+					goodList, _ := service.GetNewAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo, tx)
6972
 					var sum_count int64
6867
 					var sum_count int64
6973
 					for _, item := range goodList {
6868
 					for _, item := range goodList {
6974
 						sum_count += item.StockCount
6869
 						sum_count += item.StockCount
6975
 					}
6870
 					}
6976
 
6871
 
6977
 					//更新剩余库存
6872
 					//更新剩余库存
6978
-					service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.Org.Id, sum_count, tx)
6873
+					service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id, sum_count, tx)
6979
 
6874
 
6980
 					//耗材
6875
 					//耗材
6981
-					service.UpdateNewGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.Org.Id, tx)
6876
+					service.UpdateNewGoodSumCountSeven(sum_count, item.GoodId, adminInfo.Org.Id, tx)
6982
 
6877
 
6983
 				}
6878
 				}
6984
 
6879
 
6999
 						tx.Commit()
6894
 						tx.Commit()
7000
 					}
6895
 					}
7001
 				}()
6896
 				}()
7002
-				//var his_count int64
7003
-				////查询该耗材今日出库了多少
7004
-				//outInfo, _ := service.GetHistoryWarehouseOutInfo(item.PatientId, adminInfo.Org.Id, record_time, item.ProjectId, tx)
7005
-				//fmt.Println("outInfo", outInfo)
7006
-				//for _, it := range outInfo {
7007
-				//	his_count += it.Count
7008
-				//}
7009
-				//if item.Count > his_count {
7010
-				//	//如果当前出库数据 大于历史出库数据,那么需要出库
7011
-				//
7012
-				//	var cha_count int64
7013
-				//	cha_count = item.Count - his_count
7014
-				//
7015
-				//	timeStr := time.Now().Format("2006-01-02")
7016
-				//	timeArr := strings.Split(timeStr, "-")
7017
-				//	total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
7018
-				//
7019
-				//	total = total + 1
7020
-				//	warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
7021
-				//	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
7022
-				//	number = number + total
7023
-				//	warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
7024
-				//
7025
-				//	operation_time := time.Now().Unix()
7026
-				//	creater := c.GetMobileAdminUserInfo().AdminUser.Id
7027
-				//
7028
-				//	recordDateStr := time.Now().Format("2006-01-02")
7029
-				//	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
7030
-				//	nowtime := recordDate.Unix()
7031
-				//	//查询默认出库仓库库存
7032
-				//	storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
7033
-				//	warehouseOut := models.WarehouseOut{
7034
-				//		WarehouseOutOrderNumber: warehousing_out_order,
7035
-				//		OperationTime:           operation_time,
7036
-				//		OrgId:                   adminInfo.Org.Id,
7037
-				//		Creater:                 creater,
7038
-				//		Ctime:                   time.Now().Unix(),
7039
-				//		Status:                  1,
7040
-				//		WarehouseOutTime:        nowtime,
7041
-				//		Type:                    1,
7042
-				//		StorehouseId:            storeConfig.StorehouseOutInfo,
7043
-				//		IsCheck:                 1,
7044
-				//		IsSys:                   1,
7045
-				//	}
7046
-				//	//查询是否生成出库单
7047
-				//	out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
7048
-				//	if out.ID == 0 {
7049
-				//		service.AddNewSigleWarehouseOut(&warehouseOut, tx)
7050
-				//	}
7051
-				//
7052
-				//	lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
7053
-				//
7054
-				//	goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
7055
-				//	houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
7056
-				//
7057
-				//	dialyPrepareOne := models.DialysisBeforePrepare{
7058
-				//		GoodTypeId:   goodObj.GoodTypeId,
7059
-				//		GoodId:       item.ProjectId,
7060
-				//		PatientId:    item.PatientId,
7061
-				//		RecordDate:   record_time,
7062
-				//		UserOrgId:    adminInfo.Org.Id,
7063
-				//		Count:        cha_count,
7064
-				//		Ctime:        time.Now().Unix(),
7065
-				//		Creater:      creater,
7066
-				//		Status:       1,
7067
-				//		StorehouseId: houseConfig.StorehouseOutInfo,
7068
-				//		ProjectId:    item.ProjectId,
7069
-				//	}
7070
-				//	//出库
7071
-				//	service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, item.PatientId, record_time, &dialyPrepareOne, &lastOut, creater, tx)
7072
-				//
7073
-				//	if err == nil {
7074
-				//		goodErrcode := models.XtGoodErrcode{
7075
-				//			UserOrgId:      adminInfo.Org.Id,
7076
-				//			Errcode:        "自动出库接口报错",
7077
-				//			GoodId:         0,
7078
-				//			Status:         1,
7079
-				//			Ctime:          time.Now().Unix(),
7080
-				//			Mtime:          0,
7081
-				//			Count:          0,
7082
-				//			StockCount:     0,
7083
-				//			Creater:        creator,
7084
-				//			BatchNumberId:  0,
7085
-				//			WarehouseOutId: 0,
7086
-				//		}
7087
-				//		service.CreateGoodErrcode(goodErrcode)
7088
-				//		utils.TraceLog("创建出库单失败 err = %v", err)
7089
-				//	}
7090
-				//}
7091
-				//
7092
-				//if item.Count < his_count {
7093
-				//	var cha_count int64
7094
-				//	cha_count = his_count - item.Count
7095
-				//	goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
7096
-				//	creater := c.GetMobileAdminUserInfo().AdminUser.Id
7097
-				//
7098
-				//	newPrescriptionProject := &models.HisPrescriptionProject{
7099
-				//		ID:         item.ProjectId,
7100
-				//		ProjectId:  item.ProjectId,
7101
-				//		UserOrgId:  adminInfo.Org.Id,
7102
-				//		Status:     1,
7103
-				//		Ctime:      time.Now().Unix(),
7104
-				//		Mtime:      time.Now().Unix(),
7105
-				//		PatientId:  item.PatientId,
7106
-				//		RecordDate: record_time,
7107
-				//	}
7108
-				//
7109
-				//	service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7110
-				//
7111
-				//	service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7112
-				//}
7113
-				//
7114
-				//if item.Count == his_count {
7115
-				//	if his_count == 0 {
7116
-				//		recordDateStr := time.Now().Format("2006-01-02")
7117
-				//		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
7118
-				//		nowtime := recordDate.Unix()
7119
-				//		lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
7120
-				//		goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
7121
-				//		houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
7122
-				//		creater := c.GetMobileAdminUserInfo().AdminUser.Id
7123
-				//		dialyPrepareOne := models.DialysisBeforePrepare{
7124
-				//			GoodTypeId:   goodObj.GoodTypeId,
7125
-				//			GoodId:       item.ProjectId,
7126
-				//			PatientId:    item.PatientId,
7127
-				//			RecordDate:   record_time,
7128
-				//			UserOrgId:    adminInfo.Org.Id,
7129
-				//			Count:        item.Count,
7130
-				//			Ctime:        time.Now().Unix(),
7131
-				//			Creater:      creater,
7132
-				//			Status:       1,
7133
-				//			StorehouseId: houseConfig.StorehouseOutInfo,
7134
-				//			ProjectId:    item.ProjectId,
7135
-				//		}
7136
-				//		//出库
7137
-				//		service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
7138
-				//	}
7139
-				//}
7140
 
6897
 
7141
 				//出库
6898
 				//出库
7142
 				if item.Count > 0 {
6899
 				if item.Count > 0 {
7179
 
6936
 
7180
 					lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
6937
 					lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.Org.Id, nowtime, tx)
7181
 
6938
 
7182
-					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6939
+					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
7183
 					houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6940
 					houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
7184
 
6941
 
7185
 					dialyPrepareOne := models.DialysisBeforePrepare{
6942
 					dialyPrepareOne := models.DialysisBeforePrepare{
7186
 						GoodTypeId:   goodObj.GoodTypeId,
6943
 						GoodTypeId:   goodObj.GoodTypeId,
7187
-						GoodId:       item.ProjectId,
7188
-						PatientId:    item.PatientId,
6944
+						GoodId:       item.GoodId,
6945
+						PatientId:    patient_id,
7189
 						RecordDate:   record_time,
6946
 						RecordDate:   record_time,
7190
 						UserOrgId:    adminInfo.Org.Id,
6947
 						UserOrgId:    adminInfo.Org.Id,
7191
 						Count:        item.Count,
6948
 						Count:        item.Count,
7215
 						service.CreateGoodErrcode(goodErrcode)
6972
 						service.CreateGoodErrcode(goodErrcode)
7216
 						utils.TraceLog("创建出库单失败 err = %v", err)
6973
 						utils.TraceLog("创建出库单失败 err = %v", err)
7217
 					}
6974
 					}
6975
+					//减少
6976
+					service.ModfiyAddDialysisAuto(item.PatientId, record_time, item.Count, item.GoodId, tx)
7218
 				}
6977
 				}
7219
 
6978
 
7220
 				//退库
6979
 				//退库
7221
 				if item.Count < 0 {
6980
 				if item.Count < 0 {
7222
-					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6981
+					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
7223
 					creater := c.GetMobileAdminUserInfo().AdminUser.Id
6982
 					creater := c.GetMobileAdminUserInfo().AdminUser.Id
7224
-
6983
+					count := math.Abs(float64(item.Count))
6984
+					item.Count = int64(count)
6985
+					fmt.Println("item.Count---------------------------------------", item.Count)
6986
+					fmt.Println("item.GoodId-----------------------------------", item.GoodId)
7225
 					newPrescriptionProject := &models.HisPrescriptionProject{
6987
 					newPrescriptionProject := &models.HisPrescriptionProject{
7226
 						ID:         item.ProjectId,
6988
 						ID:         item.ProjectId,
7227
-						ProjectId:  item.ProjectId,
6989
+						ProjectId:  item.GoodId,
7228
 						UserOrgId:  adminInfo.Org.Id,
6990
 						UserOrgId:  adminInfo.Org.Id,
7229
 						Status:     1,
6991
 						Status:     1,
7230
 						Ctime:      time.Now().Unix(),
6992
 						Ctime:      time.Now().Unix(),
7231
 						Mtime:      time.Now().Unix(),
6993
 						Mtime:      time.Now().Unix(),
7232
 						PatientId:  item.PatientId,
6994
 						PatientId:  item.PatientId,
7233
 						RecordDate: record_time,
6995
 						RecordDate: record_time,
6996
+						Count:      strconv.FormatInt(item.Count, 10),
7234
 					}
6997
 					}
7235
 
6998
 
7236
-					service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
6999
+					service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
7000
+
7001
+					service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
7237
 
7002
 
7238
-					service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, item.Count, goodObj, tx)
7003
+					//减少
7004
+					service.ModfiyReduceDialysisAuto(item.PatientId, record_time, item.Count, item.GoodId, tx)
7239
 				}
7005
 				}
7240
 
7006
 
7241
 				//查询剩余库存
7007
 				//查询剩余库存
7242
-				goodList, _ := service.GetNewAllGoodSumCount(item.ProjectId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo, tx)
7008
+				goodList, _ := service.GetNewAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo, tx)
7243
 				var sum_count int64
7009
 				var sum_count int64
7244
 				for _, item := range goodList {
7010
 				for _, item := range goodList {
7245
 					sum_count += item.StockCount
7011
 					sum_count += item.StockCount
7246
 				}
7012
 				}
7247
 
7013
 
7248
 				//更新剩余库存
7014
 				//更新剩余库存
7249
-				service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.Org.Id, sum_count, tx)
7015
+				service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id, sum_count, tx)
7250
 
7016
 
7251
 				//耗材
7017
 				//耗材
7252
-				service.UpdateNewGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.Org.Id, tx)
7018
+				service.UpdateNewGoodSumCountSeven(sum_count, item.GoodId, adminInfo.Org.Id, tx)
7253
 			}
7019
 			}
7254
 		}
7020
 		}
7255
 		c.ServeSuccessJSON(map[string]interface{}{
7021
 		c.ServeSuccessJSON(map[string]interface{}{
7321
 	//判断是否开启自动出库
7087
 	//判断是否开启自动出库
7322
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
7088
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
7323
 
7089
 
7090
+	fmt.Println("record.IsOpen====================================", record)
7324
 	if record.IsOpen == 1 {
7091
 	if record.IsOpen == 1 {
7325
 
7092
 
7326
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
7093
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
7395
 					var his_count int64
7162
 					var his_count int64
7396
 					//查询该耗材今日出库了多少
7163
 					//查询该耗材今日出库了多少
7397
 					outInfo, _ := service.GetHistoryWarehouseOutInfo(item.PatientId, adminInfo.Org.Id, record_time, item.GoodId, tx)
7164
 					outInfo, _ := service.GetHistoryWarehouseOutInfo(item.PatientId, adminInfo.Org.Id, record_time, item.GoodId, tx)
7398
-
7165
+					fmt.Println("outInfo---------------------------------------", outInfo)
7399
 					for _, it := range outInfo {
7166
 					for _, it := range outInfo {
7400
 						his_count += it.Count
7167
 						his_count += it.Count
7401
 					}
7168
 					}
7480
 							service.CreateGoodErrcode(goodErrcode)
7247
 							service.CreateGoodErrcode(goodErrcode)
7481
 							utils.TraceLog("创建出库单失败 err = %v", err)
7248
 							utils.TraceLog("创建出库单失败 err = %v", err)
7482
 						}
7249
 						}
7250
+						service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
7483
 					}
7251
 					}
7484
 
7252
 
7485
 					if item.Count < his_count {
7253
 					if item.Count < his_count {
7486
 						var cha_count int64
7254
 						var cha_count int64
7487
 						cha_count = his_count - item.Count
7255
 						cha_count = his_count - item.Count
7488
-						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
7256
+						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
7489
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
7257
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
7490
 
7258
 
7491
 						newPrescriptionProject := &models.HisPrescriptionProject{
7259
 						newPrescriptionProject := &models.HisPrescriptionProject{
7499
 							RecordDate: record_time,
7267
 							RecordDate: record_time,
7500
 						}
7268
 						}
7501
 
7269
 
7502
-						service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7270
+						service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7503
 
7271
 
7504
-						service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7272
+						service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7273
+
7274
+						service.ModfiyReduceDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
7505
 					}
7275
 					}
7506
 
7276
 
7507
 					if item.Count == his_count {
7277
 					if item.Count == his_count {
7528
 							}
7298
 							}
7529
 							//出库
7299
 							//出库
7530
 							service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
7300
 							service.ConsumableNewHisPrescriptionDelivery(adminInfo.Org.Id, patient_id, record_time, &dialyPrepareOne, &lastOut, creater, tx)
7301
+
7302
+							service.ModfiyAddDialysisAuto(item.PatientId, item.RecordDate, item.Count, item.GoodId, tx)
7531
 						}
7303
 						}
7532
 					}
7304
 					}
7533
 
7305
 
8010
 				Mtime:      time.Now().Unix(),
7782
 				Mtime:      time.Now().Unix(),
8011
 				PatientId:  item.PatientId,
7783
 				PatientId:  item.PatientId,
8012
 				RecordDate: record_time,
7784
 				RecordDate: record_time,
7785
+				Count:      strconv.FormatInt(item.Count, 10),
8013
 			}
7786
 			}
8014
 
7787
 
8015
-			service.NewHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7788
+			service.NewMobileHisGoodCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
8016
 
7789
 
8017
-			service.NewHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
7790
+			service.NewMobileHisGoodAutoCancelInfo(adminInfo.Org.Id, creater, newPrescriptionProject, cha_count, goodObj, tx)
8018
 
7791
 
8019
 		}
7792
 		}
8020
 
7793
 
8060
 		//耗材
7833
 		//耗材
8061
 		service.UpdateNewGoodSumCountSeven(sum_count, item.GoodId, adminInfo.Org.Id, tx)
7834
 		service.UpdateNewGoodSumCountSeven(sum_count, item.GoodId, adminInfo.Org.Id, tx)
8062
 
7835
 
7836
+		//查询总共出库了多少支
7837
+		autoGoodInfo, _ := service.GetDialysisAutoGoodInfo(patient_id, record_time, adminInfo.Org.Id, tx, item.GoodId)
7838
+		if len(autoGoodInfo) > 0 {
7839
+			var out_count int64
7840
+			for _, item := range autoGoodInfo {
7841
+				out_count += item.Count
7842
+			}
7843
+			dialysisBeforePrepare := models.DialysisBeforePrepare{
7844
+				UserOrgId:    adminInfo.Org.Id,
7845
+				PatientId:    patient_id,
7846
+				RecordDate:   record_time,
7847
+				GoodId:       item.GoodId,
7848
+				GoodTypeId:   item.GoodTypeId,
7849
+				Count:        out_count,
7850
+				Ctime:        time.Now().Unix(),
7851
+				Mtime:        time.Now().Unix(),
7852
+				Creater:      adminInfo.AdminUser.Id,
7853
+				Modifier:     adminInfo.AdminUser.Id,
7854
+				Status:       1,
7855
+				CommdityCode: "",
7856
+				NewCount:     0,
7857
+				Children:     nil,
7858
+				ProjectId:    item.ProjectId,
7859
+				StorehouseId: houseConfig.StorehouseOutInfo,
7860
+			}
7861
+
7862
+			service.CreateDialysisPrepare(dialysisBeforePrepare, tx)
7863
+
7864
+		}
7865
+
8063
 	}
7866
 	}
8064
 
7867
 
8065
 	finish := models.XtDialysisFinish{
7868
 	finish := models.XtDialysisFinish{
8079
 		service.CreateDialysisFinish(finish)
7882
 		service.CreateDialysisFinish(finish)
8080
 	}
7883
 	}
8081
 
7884
 
8082
-	//查询当天出库的数据
8083
-	//list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
8084
-	//
8085
-	//for _, item := range list {
8086
-	//	prepare := models.DialysisBeforePrepare{
8087
-	//		UserOrgId:    item.OrgId,
8088
-	//		PatientId:    item.PatientId,
8089
-	//		RecordDate:   item.RecordTime,
8090
-	//		GoodId:       item.GoodId,
8091
-	//		GoodTypeId:   item.GoodTypeId,
8092
-	//		Count:        item.Count,
8093
-	//		Creater:      adminInfo.AdminUser.Id,
8094
-	//		Status:       1,
8095
-	//		Ctime:        time.Now().Unix(),
8096
-	//		ProjectId:    item.ProjectId,
8097
-	//		StorehouseId: houseConfig.StorehouseOutInfo,
8098
-	//	}
8099
-	//	//清空准备表的数据
8100
-	//	err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
8101
-	//	//插入准备表数据
8102
-	//	service.CreateDialysisBeforePrepareOne(&prepare)
8103
-	//
8104
-	//	//查询默认仓库
8105
-	//
8106
-	//	//查询默认仓库
8107
-	//	storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
8108
-	//	stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
8109
-	//	var total_count int64
8110
-	//	for _, it := range stockList {
8111
-	//		total_count += it.StockCount
8112
-	//	}
8113
-	//	//基础库插入数据
8114
-	//	service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
8115
-	//
8116
-	//	////更新剩余库存
8117
-	//
8118
-	//	goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
8119
-	//	var flush_count int64
8120
-	//	for _, it := range goodList {
8121
-	//		flush_count += it.StockCount
8122
-	//	}
8123
-	//	errs := service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
8124
-	//	if errs != nil {
8125
-	//		goodErrcode := models.XtGoodErrcode{
8126
-	//			UserOrgId:      item.OrgId,
8127
-	//			Errcode:        "手动出库更新剩余出库失败",
8128
-	//			GoodId:         item.GoodId,
8129
-	//			Status:         1,
8130
-	//			Ctime:          time.Now().Unix(),
8131
-	//			Mtime:          0,
8132
-	//			Count:          0,
8133
-	//			StockCount:     0,
8134
-	//			Creater:        adminInfo.AdminUser.Id,
8135
-	//			BatchNumberId:  0,
8136
-	//			WarehouseOutId: 0,
8137
-	//		}
8138
-	//		service.CreateGoodErrcode(goodErrcode)
8139
-	//	}
8140
-	//
8141
-	//}
8142
-
8143
 	//更新自动出库的地方
7885
 	//更新自动出库的地方
8144
 	var errs error
7886
 	var errs error
8145
 	if errs == nil {
7887
 	if errs == nil {

+ 13 - 4
controllers/mobile_api_controllers/dialysis_api_controller_extend.go ファイルの表示

1
 package mobile_api_controllers
1
 package mobile_api_controllers
2
 
2
 
3
 import (
3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+
4
 	"XT_New/enums"
9
 	"XT_New/enums"
5
 	"XT_New/models"
10
 	"XT_New/models"
6
 	"XT_New/service"
11
 	"XT_New/service"
7
 	"XT_New/utils"
12
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10
 	"github.com/jinzhu/gorm"
13
 	"github.com/jinzhu/gorm"
11
-	"strconv"
12
-	"time"
13
 )
14
 )
14
 
15
 
15
 // /m/api/monitor/add [post]
16
 // /m/api/monitor/add [post]
110
 	replacement_speed, _ := this.GetFloat("replacement_speed")
111
 	replacement_speed, _ := this.GetFloat("replacement_speed")
111
 	dicarbonate, _ := this.GetFloat("dicarbonate")
112
 	dicarbonate, _ := this.GetFloat("dicarbonate")
112
 	is_pressure := this.GetString("is_pressure")
113
 	is_pressure := this.GetString("is_pressure")
114
+	heparin_one := this.GetString("heparin_one")
115
+	ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
113
 	adminInfo := this.GetMobileAdminUserInfo()
116
 	adminInfo := this.GetMobileAdminUserInfo()
114
 	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
117
 	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
115
 	if getPatientErr != nil {
118
 	if getPatientErr != nil {
203
 		Dicarbonate:                 dicarbonate,
206
 		Dicarbonate:                 dicarbonate,
204
 		ReplacementSpeed:            replacement_speed,
207
 		ReplacementSpeed:            replacement_speed,
205
 		IsPressure:                  is_pressure,
208
 		IsPressure:                  is_pressure,
209
+		HeparinOne:                  heparin_one,
210
+		UltrafiltrationRateOne:      ultrafiltration_rate_one,
206
 	}
211
 	}
207
 
212
 
208
 	err := service.CreateMonitor(&record)
213
 	err := service.CreateMonitor(&record)
353
 	replacement_speed, _ := this.GetFloat("replacement_speed")
358
 	replacement_speed, _ := this.GetFloat("replacement_speed")
354
 	dicarbonate, _ := this.GetFloat("dicarbonate")
359
 	dicarbonate, _ := this.GetFloat("dicarbonate")
355
 	is_pressure := this.GetString("is_pressure")
360
 	is_pressure := this.GetString("is_pressure")
361
+	ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
362
+	heparin_one := this.GetString("heparin_one")
356
 	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
363
 	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
357
 	if err != nil {
364
 	if err != nil {
358
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
365
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
413
 	monitor.Dehydration = dehydration
420
 	monitor.Dehydration = dehydration
414
 	monitor.FilterPressure = filter_pressure
421
 	monitor.FilterPressure = filter_pressure
415
 	monitor.IsPressure = is_pressure
422
 	monitor.IsPressure = is_pressure
423
+	monitor.UltrafiltrationRateOne = ultrafiltration_rate_one
424
+	monitor.HeparinOne = heparin_one
416
 
425
 
417
 	// 查询信息规挡的设置天数
426
 	// 查询信息规挡的设置天数
418
 
427
 

+ 1 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go ファイルの表示

2996
 
2996
 
2997
 	patient, _ := service.GetPatientDetailTwo(patient_id)
2997
 	patient, _ := service.GetPatientDetailTwo(patient_id)
2998
 	inspection, _ := service.GetInspectionGroup(patient.BloodId, org_id)
2998
 	inspection, _ := service.GetInspectionGroup(patient.BloodId, org_id)
2999
-
2999
+	fmt.Println("inspection+++++++++=============", inspection)
3000
 	if len(inspection) > 0 {
3000
 	if len(inspection) > 0 {
3001
 		for _, item := range inspection {
3001
 		for _, item := range inspection {
3002
 			lastInspection, _ := service.GetLastInspectionProject(item.PatientId, org_id, item.ProjectId)
3002
 			lastInspection, _ := service.GetLastInspectionProject(item.PatientId, org_id, item.ProjectId)

+ 48 - 0
controllers/patient_api_controller.go ファイルの表示

130
 
130
 
131
 	beego.Router("/api/patient/savetheapyinformed", &PatientApiController{}, "Post:SaveTheapyInformed")
131
 	beego.Router("/api/patient/savetheapyinformed", &PatientApiController{}, "Post:SaveTheapyInformed")
132
 
132
 
133
+	beego.Router("/api/patient/savetreamentplan", &PatientApiController{}, "Post:SaveTreatmentPlan")
134
+
133
 	beego.Router("api/patient/gettherapyinformed", &PatientApiController{}, "Get:GetTherapyInformed")
135
 	beego.Router("api/patient/gettherapyinformed", &PatientApiController{}, "Get:GetTherapyInformed")
134
 
136
 
135
 	beego.Router("/api/patient/savemedicalhistory", &PatientApiController{}, "Post:SaveMedicalHistory")
137
 	beego.Router("/api/patient/savemedicalhistory", &PatientApiController{}, "Post:SaveMedicalHistory")
144
 
146
 
145
 	beego.Router("/api/patient/deletesolution", &PatientApiController{}, "Get:DeleteSolution")
147
 	beego.Router("/api/patient/deletesolution", &PatientApiController{}, "Get:DeleteSolution")
146
 
148
 
149
+	beego.Router("/api/patient/gettreamentplan", &PatientApiController{}, "Get:GetTreatMentPlanList")
150
+
147
 }
151
 }
148
 func (c *PatientApiController) GetExportList() {
152
 func (c *PatientApiController) GetExportList() {
149
 	startTime := c.GetString("start_time")
153
 	startTime := c.GetString("start_time")
7040
 		"solution": solution,
7044
 		"solution": solution,
7041
 	})
7045
 	})
7042
 }
7046
 }
7047
+
7048
+func (c *PatientApiController) SaveTreatmentPlan() {
7049
+
7050
+	orgId := c.GetAdminUserInfo().CurrentOrgId
7051
+	dataBody := make(map[string]interface{}, 0)
7052
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
7053
+	fmt.Println("err", err)
7054
+	content := dataBody["content"].(string)
7055
+
7056
+	theapyinformedPrint := models.XtTreatmentPlan{
7057
+		Content:   content,
7058
+		UserOrgId: orgId,
7059
+		Status:    1,
7060
+		Ctime:     time.Now().Unix(),
7061
+		Mtime:     time.Now().Unix(),
7062
+	}
7063
+
7064
+	treamentPlan, _ := service.GetTreamentPland(orgId)
7065
+
7066
+	if treamentPlan.ID == 0 {
7067
+
7068
+		service.CreateTreatqmentPland(theapyinformedPrint)
7069
+	}
7070
+
7071
+	if treamentPlan.ID > 0 {
7072
+
7073
+		service.UpdateTheatmentPland(treamentPlan.ID, content)
7074
+	}
7075
+
7076
+	c.ServeSuccessJSON(map[string]interface{}{
7077
+		"list": theapyinformedPrint,
7078
+	})
7079
+}
7080
+
7081
+func (c *PatientApiController) GetTreatMentPlanList() {
7082
+
7083
+	orgId := c.GetAdminUserInfo().CurrentOrgId
7084
+
7085
+	treamentPlan, _ := service.GetTreamentPland(orgId)
7086
+
7087
+	c.ServeSuccessJSON(map[string]interface{}{
7088
+		"treamentPlan": treamentPlan,
7089
+	})
7090
+}

+ 7 - 3
controllers/print_data_api_controller.go ファイルの表示

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	service "XT_New/service/print_data_service/schedule_dialysis"
6
-	"XT_New/utils"
7
 	"fmt"
4
 	"fmt"
8
 	"strings"
5
 	"strings"
9
 	"time"
6
 	"time"
10
 
7
 
8
+	"XT_New/enums"
9
+	service "XT_New/service/print_data_service/schedule_dialysis"
10
+	"XT_New/utils"
11
+
11
 	"github.com/astaxie/beego"
12
 	"github.com/astaxie/beego"
12
 )
13
 )
13
 
14
 
195
 					item.Count = listOne.Count
196
 					item.Count = listOne.Count
196
 				}
197
 				}
197
 			}
198
 			}
199
+			//上次透后体重
200
+			lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
201
+			item.LastAfterWeight = lastAfterWeight
198
 
202
 
199
 		}
203
 		}
200
 		if getScheduleErr != nil {
204
 		if getScheduleErr != nil {

+ 707 - 0
controllers/self_drug_api_congtroller.go ファイルの表示

129
 	beego.Router("/api/good/getcheckgoodbatchlist", &SelfDrugApiController{}, "Get:GetCheckGoodBatchList")
129
 	beego.Router("/api/good/getcheckgoodbatchlist", &SelfDrugApiController{}, "Get:GetCheckGoodBatchList")
130
 
130
 
131
 	beego.Router("/api/drug/getdrugpatientname", &SelfDrugApiController{}, "Get:GetDrugPatientName")
131
 	beego.Router("/api/drug/getdrugpatientname", &SelfDrugApiController{}, "Get:GetDrugPatientName")
132
+
133
+	//自备药的接口
134
+	beego.Router("/api/drug/getallselfdruginfolist", &SelfDrugApiController{}, "Get:GetAllSelfDrugInfoList")
135
+
136
+	beego.Router("/api/drug/getallpatientlist", &SelfDrugApiController{}, "Get:GetAllPatientList")
137
+
138
+	beego.Router("/api/drug/postsearchselfdruglist", &SelfDrugApiController{}, "Get:PostSearchSelfDrugList")
139
+
140
+	beego.Router("/api/drug/postselfdrugwarehouse", &SelfDrugApiController{}, "Post:PostSelfDrugWarehouse")
141
+
142
+	beego.Router("/api/drug/getallselfdrugwarehosueinfolist", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouseInfoList")
143
+
144
+	beego.Router("/api/drug/getselfdrugwarehouseinfobyid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseInfoByID")
145
+
146
+	beego.Router("/api/drug/modifyselfdrugwarehouse", &SelfDrugApiController{}, "Post:ModifySelfDrugWarehouse")
147
+
148
+	beego.Router("/api/drug/deleteselfwarehouseinfo", &SelfDrugApiController{}, "Get:DeleteSelfDrugWarehouse")
149
+
150
+	beego.Router("/api/drug/tocheckselfwarehouseinginfo", &SelfDrugApiController{}, "Get:TocheckSelfWarehouseingInfo")
132
 }
151
 }
133
 
152
 
134
 func (this *SelfDrugApiController) GetCurrentPatient() {
153
 func (this *SelfDrugApiController) GetCurrentPatient() {
3838
 			//期间减少
3857
 			//期间减少
3839
 			banceOutList, _ := service.GetInitOutBanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3858
 			banceOutList, _ := service.GetInitOutBanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3840
 
3859
 
3860
+			//banceOutList, _ := service.GetInitOutBanceTenty(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3841
 			for _, it := range banceOutList {
3861
 			for _, it := range banceOutList {
3842
 				item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
3862
 				item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
3843
 			}
3863
 			}
4427
 	})
4447
 	})
4428
 
4448
 
4429
 }
4449
 }
4450
+
4451
+func (this *SelfDrugApiController) GetAllSelfDrugInfoList() {
4452
+
4453
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4454
+
4455
+	drugInfoList, _ := service.GetAllSelfDrugInfoList(orgId)
4456
+
4457
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4458
+
4459
+	dealerList, _ := service.GetAllDealerList(orgId)
4460
+
4461
+	this.ServeSuccessJSON(map[string]interface{}{
4462
+		"drugInfoList":     drugInfoList,
4463
+		"manufacturerList": manufacturerList,
4464
+		"dealerList":       dealerList,
4465
+	})
4466
+}
4467
+
4468
+func (this *SelfDrugApiController) GetAllPatientList() {
4469
+
4470
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4471
+
4472
+	patient, _ := service.GetAllPatientListByUserOrg(orgId)
4473
+
4474
+	this.ServeSuccessJSON(map[string]interface{}{
4475
+		"patient": patient,
4476
+	})
4477
+}
4478
+
4479
+func (this *SelfDrugApiController) PostSearchSelfDrugList() {
4480
+
4481
+	keyword := this.GetString("keyword")
4482
+
4483
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4484
+
4485
+	drugList, _ := service.PostSearchSelfDrugList(keyword, orgId)
4486
+
4487
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4488
+
4489
+	dealerList, _ := service.GetAllDealerList(orgId)
4490
+
4491
+	var drugType = "药品类型"
4492
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4493
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
4494
+
4495
+	this.ServeSuccessJSON(map[string]interface{}{
4496
+		"manufacturerList": manufacturerList,
4497
+		"dealerList":       dealerList,
4498
+		"list":             drugList,
4499
+		"drugTypeList":     drugTypeList,
4500
+	})
4501
+}
4502
+
4503
+func (c *SelfDrugApiController) PostSelfDrugWarehouse() {
4504
+
4505
+	patient_id, _ := c.GetInt64("patient_id")
4506
+	warehousing_time := c.GetString("warehousing_time")
4507
+	warehousing_id, _ := c.GetInt64("warehousing_id")
4508
+	adminUserInfo := c.GetAdminUserInfo()
4509
+
4510
+	warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
4511
+
4512
+	if parseDateErr != nil {
4513
+		c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
4514
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4515
+		return
4516
+	}
4517
+	// 开始主事务
4518
+	db := service.XTWriteDB()
4519
+	tx := db.Begin()
4520
+
4521
+	// 在函数结束时处理事务回滚
4522
+	defer func() {
4523
+		if r := recover(); r != nil {
4524
+			tx.Rollback()
4525
+		} else {
4526
+			tx.Commit()
4527
+		}
4528
+	}()
4529
+	timeStr := time.Now().Format("2006-01-02")
4530
+	timeArr := strings.Split(timeStr, "-")
4531
+	total, _ := service.FindSelfAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
4532
+	total = total + 1
4533
+
4534
+	operation_time := time.Now().Unix()
4535
+	creater := adminUserInfo.AdminUser.Id
4536
+
4537
+	warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
4538
+
4539
+	warehousing := models.XtSelfDrugWarehouse{
4540
+		ID:               warehousing_id,
4541
+		WarehousingOrder: warehousing_order,
4542
+		OperationTime:    operation_time,
4543
+		OrgId:            adminUserInfo.CurrentOrgId,
4544
+		Creater:          creater,
4545
+		Ctime:            time.Now().Unix(),
4546
+		Status:           1,
4547
+		WarehousingTime:  warehousingDate.Unix(),
4548
+		Type:             0,
4549
+		StorehouseId:     0,
4550
+		IsCheck:          2,
4551
+		PatientId:        patient_id,
4552
+	}
4553
+	if warehousing_id == 0 {
4554
+		service.AddSelfDrugWarehouse(&warehousing, tx)
4555
+	}
4556
+	if warehousing_id > 0 {
4557
+		service.UpdateSelfDrugWarehouse(&warehousing, tx)
4558
+	}
4559
+	info, _ := service.FindLastSelfWarehousing(adminUserInfo.CurrentOrgId, patient_id, tx)
4560
+	dataBody := make(map[string]interface{}, 0)
4561
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
4562
+	if err != nil {
4563
+		utils.ErrorLog(err.Error())
4564
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4565
+		return
4566
+	}
4567
+	var warehousingInfo []*models.XtSelfDrugWarehouseInfo
4568
+	if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
4569
+		thisStockIn, _ := dataBody["stockIn"].([]interface{})
4570
+		if len(thisStockIn) > 0 {
4571
+			for _, item := range thisStockIn {
4572
+				items := item.(map[string]interface{})
4573
+
4574
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
4575
+					utils.ErrorLog("id")
4576
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4577
+					return
4578
+				}
4579
+				id := int64(items["id"].(float64))
4580
+
4581
+				if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
4582
+					utils.ErrorLog("drug_id")
4583
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4584
+					return
4585
+				}
4586
+				drug_id := int64(items["drug_id"].(float64))
4587
+
4588
+				if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
4589
+					utils.ErrorLog("warehousing_count")
4590
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4591
+					return
4592
+				}
4593
+
4594
+				warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
4595
+
4596
+				var productDates int64
4597
+				var expiryDates int64
4598
+
4599
+				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
4600
+					expiryDates = 0
4601
+				} else {
4602
+					if len(items["expiry_date"].(string)) == 0 {
4603
+						expiryDates = 0
4604
+
4605
+					} else {
4606
+						expiryDate, _ := items["expiry_date"].(string)
4607
+						expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
4608
+						expiryDates = expiry_date.Unix()
4609
+
4610
+					}
4611
+
4612
+				}
4613
+				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
4614
+					productDates = 0
4615
+				} else {
4616
+					if len(items["product_date"].(string)) == 0 {
4617
+						productDates = 0
4618
+
4619
+					} else {
4620
+						productDate, _ := items["product_date"].(string)
4621
+						product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
4622
+						productDates = product_date.Unix()
4623
+					}
4624
+
4625
+				}
4626
+
4627
+				number, _ := items["number"].(string)
4628
+
4629
+				batch_number, _ := items["batch_number"].(string)
4630
+
4631
+				if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
4632
+					utils.ErrorLog("max_unit")
4633
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4634
+					return
4635
+				}
4636
+				max_unit, _ := items["max_unit"].(string)
4637
+
4638
+				if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
4639
+					utils.ErrorLog("min_unit")
4640
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4641
+					return
4642
+				}
4643
+				min_unit, _ := items["min_unit"].(string)
4644
+
4645
+				var remark string
4646
+				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
4647
+					remark = ""
4648
+				} else {
4649
+					remark = items["remark"].(string)
4650
+				}
4651
+
4652
+				manufacturer := int64(items["manufacturer"].(float64))
4653
+
4654
+				dealer := int64(items["dealer"].(float64))
4655
+
4656
+				warehouseInfo := &models.XtSelfDrugWarehouseInfo{
4657
+					ID:               id,
4658
+					WarehousingOrder: warehousing_order,
4659
+					WarehousingId:    info.ID,
4660
+					DrugId:           drug_id,
4661
+					Number:           number,
4662
+					ProductDate:      productDates,
4663
+					ExpiryDate:       expiryDates,
4664
+					WarehousingCount: warehousing_count,
4665
+					Price:            0,
4666
+					TotalPrice:       0,
4667
+					Status:           1,
4668
+					Ctime:            time.Now().Unix(),
4669
+					Remark:           remark,
4670
+					OrgId:            adminUserInfo.CurrentOrgId,
4671
+					Type:             0,
4672
+					Manufacturer:     manufacturer,
4673
+					Dealer:           dealer,
4674
+					StockMaxNumber:   0,
4675
+					RetailTotalPrice: 0,
4676
+					BatchNumber:      batch_number,
4677
+					MaxUnit:          max_unit,
4678
+					MinUnit:          min_unit,
4679
+					RetailPrice:      0,
4680
+					StorehouseId:     0,
4681
+					IsCheck:          2,
4682
+					StockMinNumber:   0,
4683
+					PatientId:        patient_id,
4684
+					IsSys:            0,
4685
+					RecordDate:       warehousingDate.Unix(),
4686
+				}
4687
+				warehousingInfo = append(warehousingInfo, warehouseInfo)
4688
+			}
4689
+		}
4690
+	}
4691
+
4692
+	for _, item := range warehousingInfo {
4693
+		if item.ID == 0 {
4694
+			service.CreatedSlefWarehouseing(item, tx)
4695
+		}
4696
+		if item.ID > 0 {
4697
+			service.UpdateSelfWarehouseing(item, tx)
4698
+		}
4699
+	}
4700
+
4701
+	list, _ := service.FindSelfDrugWarehouseInfoListById(info.ID, adminUserInfo.CurrentOrgId, patient_id, tx)
4702
+	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
4703
+	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
4704
+	var drugType = "药品类型"
4705
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4706
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
4707
+
4708
+	c.ServeSuccessJSON(map[string]interface{}{
4709
+		"warehousingInfo":  warehousingInfo,
4710
+		"list":             list,
4711
+		"manufacturerList": manufacturerList,
4712
+		"dealerList":       dealerList,
4713
+		"drugTypeList":     drugTypeList,
4714
+		"info":             info,
4715
+	})
4716
+
4717
+}
4718
+
4719
+func (c *SelfDrugApiController) GetAllSelfDrugWarehouseInfoList() {
4720
+
4721
+	keyword := c.GetString("keyword")
4722
+	orgId := c.GetAdminUserInfo().CurrentOrgId
4723
+	patient_id, _ := c.GetInt64("patient_id")
4724
+	baseList, _ := service.GetAllBaseDrugListByKeyWord(keyword, orgId)
4725
+	var ids []int64
4726
+	for _, item := range baseList {
4727
+		ids = append(ids, item.ID)
4728
+	}
4729
+	infoList, _ := service.GetAllSelfDrugWarehouseInfoList(ids, orgId, patient_id)
4730
+
4731
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4732
+	dealerList, _ := service.GetAllDealerList(orgId)
4733
+	var drugType = "药品类型"
4734
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4735
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
4736
+
4737
+	c.ServeSuccessJSON(map[string]interface{}{
4738
+		"infoList":         infoList,
4739
+		"manufacturerList": manufacturerList,
4740
+		"dealerList":       dealerList,
4741
+		"drugTypeList":     drugTypeList,
4742
+	})
4743
+}
4744
+
4745
+func (c *SelfDrugApiController) GetSelfDrugWarehouseInfoByID() {
4746
+
4747
+	id, _ := c.GetInt64("id")
4748
+	info, _ := service.GetSelfDrugWarehouseInfoByID(id)
4749
+
4750
+	warehouseInfo, _ := service.GetSelfDrugWarehouseInfo(info.WarehousingId)
4751
+	orgId := c.GetAdminUserInfo().CurrentOrgId
4752
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4753
+	dealerList, _ := service.GetAllDealerList(orgId)
4754
+	var drugType = "药品类型"
4755
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4756
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
4757
+
4758
+	c.ServeSuccessJSON(map[string]interface{}{
4759
+		"info":             info,
4760
+		"manufacturerList": manufacturerList,
4761
+		"dealerList":       dealerList,
4762
+		"drugTypeList":     drugTypeList,
4763
+		"warehouseInfo":    warehouseInfo,
4764
+	})
4765
+}
4766
+
4767
+func (c *SelfDrugApiController) ModifySelfDrugWarehouse() {
4768
+
4769
+	patient_id, _ := c.GetInt64("patient_id")
4770
+	warehousing_time := c.GetString("warehousing_time")
4771
+	warehousing_id, _ := c.GetInt64("warehousing_id")
4772
+	adminUserInfo := c.GetAdminUserInfo()
4773
+
4774
+	warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
4775
+
4776
+	if parseDateErr != nil {
4777
+		c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
4778
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4779
+		return
4780
+	}
4781
+	// 开始主事务
4782
+	db := service.XTWriteDB()
4783
+	tx := db.Begin()
4784
+
4785
+	// 在函数结束时处理事务回滚
4786
+	defer func() {
4787
+		if r := recover(); r != nil {
4788
+			tx.Rollback()
4789
+		} else {
4790
+			tx.Commit()
4791
+		}
4792
+	}()
4793
+	timeStr := time.Now().Format("2006-01-02")
4794
+	timeArr := strings.Split(timeStr, "-")
4795
+	total, _ := service.FindSelfAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
4796
+	total = total + 1
4797
+
4798
+	operation_time := time.Now().Unix()
4799
+	creater := adminUserInfo.AdminUser.Id
4800
+
4801
+	warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
4802
+
4803
+	warehousing := models.XtSelfDrugWarehouse{
4804
+		ID:               warehousing_id,
4805
+		WarehousingOrder: warehousing_order,
4806
+		OperationTime:    operation_time,
4807
+		OrgId:            adminUserInfo.CurrentOrgId,
4808
+		Creater:          creater,
4809
+		Ctime:            time.Now().Unix(),
4810
+		Status:           1,
4811
+		WarehousingTime:  warehousingDate.Unix(),
4812
+		Type:             0,
4813
+		StorehouseId:     0,
4814
+		IsCheck:          2,
4815
+		PatientId:        patient_id,
4816
+	}
4817
+	if warehousing_id == 0 {
4818
+		service.AddSelfDrugWarehouse(&warehousing, tx)
4819
+	}
4820
+	if warehousing_id > 0 {
4821
+		service.UpdateSelfDrugWarehouse(&warehousing, tx)
4822
+	}
4823
+	info, _ := service.FindLastSelfWarehousing(adminUserInfo.CurrentOrgId, patient_id, tx)
4824
+	dataBody := make(map[string]interface{}, 0)
4825
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
4826
+	if err != nil {
4827
+		utils.ErrorLog(err.Error())
4828
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4829
+		return
4830
+	}
4831
+	var warehousingInfo []*models.XtSelfDrugWarehouseInfo
4832
+	if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
4833
+		thisStockIn, _ := dataBody["stockIn"].([]interface{})
4834
+		if len(thisStockIn) > 0 {
4835
+			for _, item := range thisStockIn {
4836
+				items := item.(map[string]interface{})
4837
+
4838
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
4839
+					utils.ErrorLog("id")
4840
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4841
+					return
4842
+				}
4843
+				id := int64(items["id"].(float64))
4844
+
4845
+				if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
4846
+					utils.ErrorLog("drug_id")
4847
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4848
+					return
4849
+				}
4850
+				drug_id := int64(items["drug_id"].(float64))
4851
+
4852
+				if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
4853
+					utils.ErrorLog("warehousing_count")
4854
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4855
+					return
4856
+				}
4857
+
4858
+				warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
4859
+
4860
+				var productDates int64
4861
+				var expiryDates int64
4862
+
4863
+				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
4864
+					expiryDates = 0
4865
+				} else {
4866
+					if len(items["expiry_date"].(string)) == 0 {
4867
+						expiryDates = 0
4868
+
4869
+					} else {
4870
+						expiryDate, _ := items["expiry_date"].(string)
4871
+						expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
4872
+						expiryDates = expiry_date.Unix()
4873
+
4874
+					}
4875
+
4876
+				}
4877
+				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
4878
+					productDates = 0
4879
+				} else {
4880
+					if len(items["product_date"].(string)) == 0 {
4881
+						productDates = 0
4882
+
4883
+					} else {
4884
+						productDate, _ := items["product_date"].(string)
4885
+						product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
4886
+						productDates = product_date.Unix()
4887
+					}
4888
+
4889
+				}
4890
+
4891
+				number, _ := items["number"].(string)
4892
+
4893
+				batch_number, _ := items["batch_number"].(string)
4894
+
4895
+				if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
4896
+					utils.ErrorLog("max_unit")
4897
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4898
+					return
4899
+				}
4900
+				max_unit, _ := items["max_unit"].(string)
4901
+
4902
+				if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
4903
+					utils.ErrorLog("min_unit")
4904
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4905
+					return
4906
+				}
4907
+				min_unit, _ := items["min_unit"].(string)
4908
+
4909
+				var remark string
4910
+				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
4911
+					remark = ""
4912
+				} else {
4913
+					remark = items["remark"].(string)
4914
+				}
4915
+
4916
+				manufacturer := int64(items["manufacturer"].(float64))
4917
+
4918
+				dealer := int64(items["dealer"].(float64))
4919
+
4920
+				warehouseInfo := &models.XtSelfDrugWarehouseInfo{
4921
+					ID:               id,
4922
+					WarehousingOrder: warehousing_order,
4923
+					WarehousingId:    info.ID,
4924
+					DrugId:           drug_id,
4925
+					Number:           number,
4926
+					ProductDate:      productDates,
4927
+					ExpiryDate:       expiryDates,
4928
+					WarehousingCount: warehousing_count,
4929
+					Price:            0,
4930
+					TotalPrice:       0,
4931
+					Status:           1,
4932
+					Ctime:            time.Now().Unix(),
4933
+					Remark:           remark,
4934
+					OrgId:            adminUserInfo.CurrentOrgId,
4935
+					Type:             0,
4936
+					Manufacturer:     manufacturer,
4937
+					Dealer:           dealer,
4938
+					StockMaxNumber:   0,
4939
+					RetailTotalPrice: 0,
4940
+					BatchNumber:      batch_number,
4941
+					MaxUnit:          max_unit,
4942
+					MinUnit:          min_unit,
4943
+					RetailPrice:      0,
4944
+					StorehouseId:     0,
4945
+					IsCheck:          2,
4946
+					StockMinNumber:   0,
4947
+					PatientId:        patient_id,
4948
+					IsSys:            0,
4949
+					RecordDate:       warehousingDate.Unix(),
4950
+				}
4951
+				warehousingInfo = append(warehousingInfo, warehouseInfo)
4952
+			}
4953
+		}
4954
+	}
4955
+
4956
+	for _, item := range warehousingInfo {
4957
+		if item.ID == 0 {
4958
+			service.CreatedSlefWarehouseing(item, tx)
4959
+		}
4960
+		if item.ID > 0 {
4961
+			service.UpdateSelfWarehouseing(item, tx)
4962
+		}
4963
+	}
4964
+
4965
+	list, _ := service.FindSelfDrugWarehouseInfoListById(info.ID, adminUserInfo.CurrentOrgId, patient_id, tx)
4966
+	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
4967
+	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
4968
+	var drugType = "药品类型"
4969
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4970
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUserInfo.CurrentOrgId)
4971
+
4972
+	c.ServeSuccessJSON(map[string]interface{}{
4973
+		"warehousingInfo":  warehousingInfo,
4974
+		"list":             list,
4975
+		"manufacturerList": manufacturerList,
4976
+		"dealerList":       dealerList,
4977
+		"drugTypeList":     drugTypeList,
4978
+		"info":             info,
4979
+	})
4980
+}
4981
+
4982
+func (c *SelfDrugApiController) DeleteSelfDrugWarehouse() {
4983
+
4984
+	id, _ := c.GetInt64("id")
4985
+	// 开始主事务
4986
+	db := service.XTWriteDB()
4987
+	tx := db.Begin()
4988
+	defer func() {
4989
+		if r := recover(); r != nil {
4990
+			tx.Rollback()
4991
+		} else {
4992
+			tx.Commit()
4993
+		}
4994
+	}()
4995
+	service.DeleteSelfDrugWarehouse(id, tx)
4996
+
4997
+	c.ServeSuccessJSON(map[string]interface{}{
4998
+		"msg": "删除成功",
4999
+	})
5000
+}
5001
+
5002
+func (c *SelfDrugApiController) TocheckSelfWarehouseingInfo() {
5003
+
5004
+	id, _ := c.GetInt64("id")
5005
+	patient_id, _ := c.GetInt64("patient_id")
5006
+	orgId := c.GetAdminUserInfo().CurrentOrgId
5007
+	info, _ := service.GetSelfWarehouseInfoByWarehouseInfo(id, patient_id, orgId)
5008
+
5009
+	db := service.XTWriteDB()
5010
+	tx := db.Begin()
5011
+	defer func() {
5012
+		if r := recover(); r != nil {
5013
+			tx.Rollback()
5014
+		} else {
5015
+			tx.Commit()
5016
+		}
5017
+	}()
5018
+	if len(info) > 0 {
5019
+		for _, item := range info {
5020
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
5021
+
5022
+			if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5023
+				//新增库存
5024
+				service.AddSelfDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
5025
+
5026
+			}
5027
+			if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
5028
+				//新增库存
5029
+				service.AddSelfDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
5030
+
5031
+			}
5032
+
5033
+			if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5034
+
5035
+				//新增库存
5036
+				service.AddSelfDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID, tx)
5037
+
5038
+			}
5039
+
5040
+			Creator := c.GetAdminUserInfo().AdminUser.Id
5041
+
5042
+			//查询默认仓库剩余多少库存
5043
+			list, _ := service.GetDrugSumCountByPatient(patient_id, item.OrgId, item.DrugId, tx)
5044
+			var sum_count int64
5045
+			var sum_in_count int64
5046
+			for _, it := range list {
5047
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
5048
+				if it.MaxUnit == baseDrug.MaxUnit {
5049
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
5050
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
5051
+				}
5052
+				sum_count += it.StockMaxNumber + it.StockMinNumber
5053
+				sum_in_count += it.WarehousingCount
5054
+			}
5055
+
5056
+			flow := &models.XtSelfDrugFlow{
5057
+				WarehousingId:           0,
5058
+				DrugId:                  item.DrugId,
5059
+				Number:                  item.Number,
5060
+				BatchNumber:             item.BatchNumber,
5061
+				Count:                   item.WarehousingCount,
5062
+				UserOrgId:               item.OrgId,
5063
+				PatientId:               item.PatientId,
5064
+				SystemTime:              time.Now().Unix(),
5065
+				ConsumableType:          1,
5066
+				IsSys:                   0,
5067
+				WarehousingOrder:        item.WarehousingOrder,
5068
+				WarehouseOutId:          0,
5069
+				WarehouseOutOrderNumber: "",
5070
+				IsEdit:                  0,
5071
+				CancelStockId:           0,
5072
+				CancelOrderNumber:       "",
5073
+				Manufacturer:            0,
5074
+				Dealer:                  0,
5075
+				Creator:                 Creator,
5076
+				UpdateCreator:           Creator,
5077
+				Status:                  1,
5078
+				Ctime:                   item.Ctime,
5079
+				Mtime:                   0,
5080
+				Price:                   item.Price,
5081
+				WarehousingDetailId:     item.ID,
5082
+				WarehouseOutDetailId:    0,
5083
+				CancelOutDetailId:       0,
5084
+				ExpireDate:              item.ExpiryDate,
5085
+				ProductDate:             item.ProductDate,
5086
+				MaxUnit:                 item.MaxUnit,
5087
+				MinUnit:                 item.MinUnit,
5088
+				StorehouseId:            item.StorehouseId,
5089
+				OverCount:               sum_count,
5090
+				OperateTime:             time.Now().Unix(),
5091
+			}
5092
+			service.CreateSelfDrugFlow(flow, tx)
5093
+
5094
+			drugInfolist, _ := service.GetSelfDrugSumCountByStorehouseId(item.PatientId, item.OrgId, item.DrugId, tx)
5095
+			var total_count int64 // 入库总数量
5096
+			var over_count int64  //剩余库存
5097
+			for _, it := range drugInfolist {
5098
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
5099
+				if it.MaxUnit == baseDrug.MaxUnit {
5100
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
5101
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
5102
+				}
5103
+			}
5104
+			for _, it := range drugInfolist {
5105
+				total_count += it.WarehousingCount
5106
+				over_count += it.StockMaxNumber + it.StockMinNumber
5107
+			}
5108
+			//查询该仓库是否有默认数据
5109
+			_, errcode := service.GetSelfDrugStockCount(item.PatientId, item.DrugId, item.OrgId, tx)
5110
+			if errcode == gorm.ErrRecordNotFound {
5111
+				drugStock := models.XtSelfDrugStockCount{
5112
+					UserOrgId:      item.OrgId,
5113
+					PatientId:      item.PatientId,
5114
+					SumInCount:     total_count,
5115
+					SumOutCount:    0,
5116
+					SumCancelCount: 0,
5117
+					DrugId:         item.DrugId,
5118
+					Ctime:          time.Now().Unix(),
5119
+					Mtime:          0,
5120
+					Status:         1,
5121
+					FlushCount:     over_count,
5122
+					SumActOutCount: 0,
5123
+				}
5124
+				service.CreateSelfDrugStockSum(drugStock, tx)
5125
+
5126
+			} else if errcode == nil {
5127
+				service.UpdateSelfDrugStockSum(item.PatientId, item.DrugId, item.OrgId, total_count, over_count, tx)
5128
+			}
5129
+
5130
+		}
5131
+
5132
+		c.ServeSuccessJSON(map[string]interface{}{
5133
+			"list": info,
5134
+		})
5135
+	}
5136
+}

+ 1 - 1
controllers/sign_api_controller.go ファイルの表示

1242
 	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1242
 	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1243
 	//}
1243
 	//}
1244
 
1244
 
1245
-	list, _ := service.GetAllDialysisOrder(14749)
1245
+	list, _ := service.GetAllDialysisOrder(31831)
1246
 	for _, item := range list {
1246
 	for _, item := range list {
1247
 		schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1247
 		schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1248
 		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
1248
 		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)

+ 8 - 266
controllers/stock_in_api_controller.go ファイルの表示

1314
 
1314
 
1315
 				register_number := items["register_number"].(string)
1315
 				register_number := items["register_number"].(string)
1316
 
1316
 
1317
+				class_type := items["class_type"].(string)
1318
+
1317
 				timeLayout := "2006-01-02"
1319
 				timeLayout := "2006-01-02"
1318
 				loc, _ := time.LoadLocation("Local")
1320
 				loc, _ := time.LoadLocation("Local")
1319
 				var expiryDate int64
1321
 				var expiryDate int64
1370
 					RegisterNumber:          register_number,
1372
 					RegisterNumber:          register_number,
1371
 					SysRecordTime:           warehouseOut.WarehouseOutTime,
1373
 					SysRecordTime:           warehouseOut.WarehouseOutTime,
1372
 					PatientId:               patient_id,
1374
 					PatientId:               patient_id,
1375
+					ClassType:               class_type,
1373
 				}
1376
 				}
1374
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1377
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1375
 
1378
 
1420
 			IsCheck:                 2,
1423
 			IsCheck:                 2,
1421
 			RegisterNumber:          it.RegisterNumber,
1424
 			RegisterNumber:          it.RegisterNumber,
1422
 			PatientId:               it.PatientId,
1425
 			PatientId:               it.PatientId,
1426
+			ClassType:               it.ClassType,
1423
 		}
1427
 		}
1424
 		if it.ID == 0 {
1428
 		if it.ID == 0 {
1425
 			service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1429
 			service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1730
 
1734
 
1731
 				patient_id := int64(items["patient_id"].(float64))
1735
 				patient_id := int64(items["patient_id"].(float64))
1732
 
1736
 
1737
+				class_type := items["class_type"].(string)
1738
+
1733
 				var productDate int64
1739
 				var productDate int64
1734
 				if len(product_date) > 0 {
1740
 				if len(product_date) > 0 {
1735
 					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1741
 					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1770
 						StockCount:              stock_count,
1776
 						StockCount:              stock_count,
1771
 						RegisterNumber:          register_number,
1777
 						RegisterNumber:          register_number,
1772
 						PatientId:               patient_id,
1778
 						PatientId:               patient_id,
1779
+						ClassType:               class_type,
1773
 					}
1780
 					}
1774
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1781
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1775
 
1782
 
1818
 						StockCount:              stock_count,
1825
 						StockCount:              stock_count,
1819
 						RegisterNumber:          register_number,
1826
 						RegisterNumber:          register_number,
1820
 						PatientId:               patient_id,
1827
 						PatientId:               patient_id,
1828
+						ClassType:               class_type,
1821
 					}
1829
 					}
1822
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1830
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1823
 				}
1831
 				}
1845
 	if len(upDateWarehouseOutInfos) > 0 {
1853
 	if len(upDateWarehouseOutInfos) > 0 {
1846
 		for _, item := range upDateWarehouseOutInfos {
1854
 		for _, item := range upDateWarehouseOutInfos {
1847
 			service.UpDateWarehouseOutInfo(item)
1855
 			service.UpDateWarehouseOutInfo(item)
1848
-			////1.查询该耗材该批次的最后一次出库记录
1849
-			//lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, item.OrgId)
1850
-			//
1851
-			////如果出库数量大于 最后一次批次的数量(那么要进行出库)
1852
-			//
1853
-			//if item.Count > lastGood.Count {
1854
-			//
1855
-			//	//查询该耗材是否还有库存
1856
-			//	warehouseinfo, _ := service.GetTotalCountByGoodId(item.GoodId, item.StorehouseId)
1857
-			//
1858
-			//	//无库存
1859
-			//	if warehouseinfo.StockCount <= 0 {
1860
-			//		c.ServeSuccessJSON(map[string]interface{}{
1861
-			//			"msg": "5",
1862
-			//		})
1863
-			//		return
1864
-			//	}
1865
-			//
1866
-			//	//有库存,进行出库,调用出库接口
1867
-			//	if warehouseinfo.StockCount > 0 {
1868
-			//		var total int64
1869
-			//		var stock_cout int64
1870
-			//		var total_count int64
1871
-			//		//计算和最后一次出库数据的差
1872
-			//		total = item.Count - lastGood.Count
1873
-			//
1874
-			//		if total > warehouseinfo.StockCount {
1875
-			//			c.ServeSuccessJSON(map[string]interface{}{
1876
-			//				"msg": "6",
1877
-			//			})
1878
-			//			return
1879
-			//		}
1880
-			//		//获取该耗材该批次的剩余库存量
1881
-			//		info, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
1882
-			//
1883
-			//		//判断该批次的剩余库存 和出库的库存进行比较
1884
-			//		//如果出库的库存大于该批次的剩余库存,那么需要出库下一批次的库存
1885
-			//
1886
-			//		if total > info.StockCount {
1887
-			//			//计算出库和该批次相差的库存
1888
-			//			total_count = item.Count - info.StockCount
1889
-			//			//清空本批次次库存
1890
-			//			service.DeleteWarehouseInfo(item.WarehouseInfotId)
1891
-			//			//调用出库逻辑
1892
-			//			parseDateErr := service.ConsumablesDeliveryTwo(item.OrgId, item, total_count)
1893
-			//			if parseDateErr != nil {
1894
-			//				utils.ErrorLog(errs.Error())
1895
-			//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1896
-			//				return
1897
-			//			}
1898
-			//		}
1899
-			//		//如果与上次比的库存小于或等于于该批次的剩余库存,那么需要该批次出库
1900
-			//		if total <= info.StockCount {
1901
-			//			stock_cout = lastGood.Count + total
1902
-			//			fmt.Println(stock_cout)
1903
-			//			//扣减库存
1904
-			//			warehouse := models.WarehousingInfo{
1905
-			//				StockCount: info.StockCount - total,
1906
-			//			}
1907
-			//			errs := service.UpdateWarehousingInfo(warehouse, info.ID)
1908
-			//
1909
-			//			warehouseOutInfo := &models.WarehouseOutInfo{
1910
-			//				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1911
-			//				WarehouseOutId:          id,
1912
-			//				WarehouseInfotId:        item.WarehouseInfotId,
1913
-			//				Status:                  1,
1914
-			//				Ctime:                   time.Now().Unix(),
1915
-			//				Remark:                  item.Remark,
1916
-			//				OrgId:                   item.OrgId,
1917
-			//				Type:                    1,
1918
-			//				Manufacturer:            item.Manufacturer,
1919
-			//				Dealer:                  item.Dealer,
1920
-			//				IsSys:                   0,
1921
-			//				SysRecordTime:           item.SysRecordTime,
1922
-			//				GoodTypeId:              item.GoodTypeId,
1923
-			//				GoodId:                  item.GoodId,
1924
-			//				ExpiryDate:              item.ExpiryDate,
1925
-			//				ProductDate:             item.ProductDate,
1926
-			//				Number:                  item.Number,
1927
-			//				Price:                   item.Price,
1928
-			//				LicenseNumber:           item.LicenseNumber,
1929
-			//				Count:                   item.Count,
1930
-			//				ConsumableType:          2,
1931
-			//				StorehouseId:            item.StorehouseId,
1932
-			//				AdminUserId:             item.AdminUserId,
1933
-			//				StockCount:              item.StockCount,
1934
-			//			}
1935
-			//
1936
-			//			//查询是否存在
1937
-			//			_, errcode := service.GetWarehouseOutInfoIsExist(item.ID)
1938
-			//			if errcode == gorm.ErrRecordNotFound {
1939
-			//
1940
-			//				errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1941
-			//				if errOne != nil {
1942
-			//					utils.ErrorLog(errs.Error())
1943
-			//					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1944
-			//					return
1945
-			//				}
1946
-			//			} else if errcode == nil {
1947
-			//				service.UpDateWarehouseOutInfo(item)
1948
-			//				//更新流水
1949
-			//				flow := models.VmStockFlow{
1950
-			//					Number:        item.Number,
1951
-			//					LicenseNumber: item.LicenseNumber,
1952
-			//					Count:         item.Count,
1953
-			//					Manufacturer:  item.Manufacturer,
1954
-			//					Dealer:        item.Dealer,
1955
-			//					ProductDate:   item.ProductDate,
1956
-			//					ExpireDate:    item.ExpiryDate,
1957
-			//					Price:         item.Price,
1958
-			//					StorehouseId:  item.StorehouseId,
1959
-			//					AdminUserId:   item.AdminUserId,
1960
-			//					StockCount:    item.StockCount,
1961
-			//				}
1962
-			//				service.UpdateStockFlowByDetailId(flow, item.ID)
1963
-			//
1964
-			//				goodInfo := models.GoodInfo{
1965
-			//					Manufacturer: item.Manufacturer,
1966
-			//					Dealer:       item.Dealer,
1967
-			//				}
1968
-			//				service.UpdatedGoodInfo(goodInfo, item.GoodId)
1969
-			//			}
1970
-			//		}
1971
-			//	}
1972
-			//}
1973
-			//
1974
-			//var last_count int64
1975
-			//var all_total int64
1976
-			//var stock_total int64
1977
-			////如果退库数量小于最后一次批次的数量(要么要进行退库)
1978
-			//if item.Count < lastGood.Count {
1979
-			//
1980
-			//	//退库数量和最后一次出库数据进行计算
1981
-			//	last_count = lastGood.Count - item.Count
1982
-			//
1983
-			//	//获取该耗材该批次的剩余库存量
1984
-			//	infoInfo, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
1985
-			//
1986
-			//	//退库数量和最后一次出库数据进行计算的差 加上 剩余库存的数量与 该批次的入库数量进行比较
1987
-			//	all_total = last_count + infoInfo.StockCount
1988
-			//
1989
-			//	//如果库存大于总数量,则退回到这个批次
1990
-			//
1991
-			//	if infoInfo.WarehousingCount > all_total {
1992
-			//		stock_total = last_count + infoInfo.StockCount
1993
-			//
1994
-			//		//退回该批次,计算数量
1995
-			//		warehousingInfoOne := models.WarehousingInfo{
1996
-			//			StockCount:   stock_total,
1997
-			//			ID:           item.WarehouseInfotId,
1998
-			//			OrgId:        item.OrgId,
1999
-			//			StorehouseId: item.StorehouseId,
2000
-			//		}
2001
-			//
2002
-			//		parseDateErr := service.UpdateWarehousingInfo(warehousingInfoOne, item.WarehouseInfotId)
2003
-			//
2004
-			//		fmt.Println("parseDateErr", parseDateErr)
2005
-			//		//插入一条新纪录
2006
-			//		warehouseOutInfoThree := &models.WarehouseOutInfo{
2007
-			//			WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
2008
-			//			WarehouseOutId:          id,
2009
-			//			WarehouseInfotId:        item.WarehouseInfotId,
2010
-			//			Status:                  1,
2011
-			//			Ctime:                   time.Now().Unix(),
2012
-			//			Remark:                  item.Remark,
2013
-			//			OrgId:                   item.OrgId,
2014
-			//			Type:                    1,
2015
-			//			Manufacturer:            item.Manufacturer,
2016
-			//			Dealer:                  item.Dealer,
2017
-			//			IsSys:                   0,
2018
-			//			GoodTypeId:              item.GoodTypeId,
2019
-			//			GoodId:                  item.GoodId,
2020
-			//			ExpiryDate:              item.ExpiryDate,
2021
-			//			ProductDate:             item.ProductDate,
2022
-			//			Number:                  item.Number,
2023
-			//			Price:                   item.Price,
2024
-			//			LicenseNumber:           item.LicenseNumber,
2025
-			//			ConsumableType:          2,
2026
-			//			Count:                   item.Count,
2027
-			//			StorehouseId:            item.StorehouseId,
2028
-			//			AdminUserId:             item.AdminUserId,
2029
-			//			StockCount:              item.StockCount,
2030
-			//		}
2031
-			//		//查询是否存在
2032
-			//		_, errcode := service.GetWarehouseOutInfoIsExist(item.ID)
2033
-			//		if errcode == gorm.ErrRecordNotFound {
2034
-			//			errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfoThree)
2035
-			//			if errOne != nil {
2036
-			//				utils.ErrorLog(errs.Error())
2037
-			//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
2038
-			//				return
2039
-			//			}
2040
-			//
2041
-			//		} else if errcode == nil {
2042
-			//			service.UpDateWarehouseOutInfo(item)
2043
-			//			flow := models.VmStockFlow{
2044
-			//				Number:        item.Number,
2045
-			//				LicenseNumber: item.LicenseNumber,
2046
-			//				Count:         item.Count,
2047
-			//				Manufacturer:  item.Manufacturer,
2048
-			//				Dealer:        item.Dealer,
2049
-			//				ProductDate:   item.ProductDate,
2050
-			//				ExpireDate:    item.ExpiryDate,
2051
-			//				Price:         item.Price,
2052
-			//				StorehouseId:  item.StorehouseId,
2053
-			//				AdminUserId:   item.AdminUserId,
2054
-			//				StockCount:    item.StockCount,
2055
-			//			}
2056
-			//			service.UpdateStockFlowByDetailId(flow, item.ID)
2057
-			//			goodInfo := models.GoodInfo{
2058
-			//				Manufacturer: item.Manufacturer,
2059
-			//				Dealer:       item.Dealer,
2060
-			//			}
2061
-			//			service.UpdatedGoodInfo(goodInfo, item.GoodId)
2062
-			//
2063
-			//		}
2064
-			//	}
2065
-			//
2066
-			//	//如果库存小于总数量,则报错提醒,该批次的退库数据大于入库数据了无法退库,则需要退库到另一个批次
2067
-			//	if infoInfo.WarehousingCount < all_total {
2068
-			//		c.ServeSuccessJSON(map[string]interface{}{
2069
-			//			"msg": "6",
2070
-			//		})
2071
-			//		return
2072
-			//	}
2073
-			//}
2074
-			//
2075
-			//if item.Count == lastGood.Count {
2076
-			//
2077
-			//	errs = service.UpDateWarehouseOutInfo(item)
2078
-			//	flow := models.VmStockFlow{
2079
-			//		Number:        item.Number,
2080
-			//		LicenseNumber: item.LicenseNumber,
2081
-			//		Count:         item.Count,
2082
-			//		Manufacturer:  item.Manufacturer,
2083
-			//		Dealer:        item.Dealer,
2084
-			//		ProductDate:   item.ProductDate,
2085
-			//		ExpireDate:    item.ExpiryDate,
2086
-			//		Price:         item.Price,
2087
-			//		StorehouseId:  item.StorehouseId,
2088
-			//		AdminUserId:   item.AdminUserId,
2089
-			//		BuyPrice:      item.BuyPrice,
2090
-			//		StockCount:    item.StockCount,
2091
-			//	}
2092
-			//	service.UpdateStockFlowByDetailId(flow, item.ID)
2093
-			//	goodInfo := models.GoodInfo{
2094
-			//		Manufacturer: item.Manufacturer,
2095
-			//		Dealer:       item.Dealer,
2096
-			//	}
2097
-			//	service.UpdatedGoodInfo(goodInfo, item.GoodId)
2098
-			//
2099
-			//}
2100
-			//
2101
-			////查询该机构默认仓库
2102
-			//storeConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
2103
-			////查询剩余库存
2104
-			//goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, adminUserInfo.CurrentOrgId)
2105
-			//var sum_count int64
2106
-			//var sum_in_count int64
2107
-			//for _, item := range goodList {
2108
-			//	sum_count += item.StockCount
2109
-			//	sum_in_count += item.WarehousingCount
2110
-			//}
2111
-			//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2112
-
2113
 		}
1856
 		}
2114
 	}
1857
 	}
2115
 
1858
 
5138
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4881
 	orgId := this.GetAdminUserInfo().CurrentOrgId
5139
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
4882
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
5140
 	list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
4883
 	list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
5141
-	fmt.Println("list000000000000000000000000", len(list))
5142
 	stockFlowListGroup, _ := service.GetOrderDetailStockFlowByStorehouseById(idsArray, orgId)
4884
 	stockFlowListGroup, _ := service.GetOrderDetailStockFlowByStorehouseById(idsArray, orgId)
5143
 	stockFlowList, _ := service.GetOrderDetailStockFlow(idsArray, orgId)
4885
 	stockFlowList, _ := service.GetOrderDetailStockFlow(idsArray, orgId)
5144
 	//获取耗材退库数据
4886
 	//获取耗材退库数据

+ 3 - 0
models/dialysis.go ファイルの表示

774
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
774
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
775
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
775
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
776
 	IsPressure                  string  `gorm:"column:is_pressure" json:"is_pressure" form:"is_pressure"`
776
 	IsPressure                  string  `gorm:"column:is_pressure" json:"is_pressure" form:"is_pressure"`
777
+	UltrafiltrationRateOne      string  `gorm:"column:ultrafiltration_rate_one" json:"ultrafiltration_rate_one" form:"ultrafiltration_rate_one"`
778
+	HeparinOne                  string  `gorm:"column:heparin_one" json:"heparin_one" form:"heparin_one"`
777
 }
779
 }
778
 
780
 
779
 func (MonitoringRecord) TableName() string {
781
 func (MonitoringRecord) TableName() string {
887
 	BloodFlowVolume            string        `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
889
 	BloodFlowVolume            string        `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
888
 	Condenser                  string        `gorm:"column:condenser" json:"condenser" form:"condenser"`
890
 	Condenser                  string        `gorm:"column:condenser" json:"condenser" form:"condenser"`
889
 	BloodDrawing               int64         `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
891
 	BloodDrawing               int64         `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
892
+	DialysisStrainer           string        `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
890
 }
893
 }
891
 
894
 
892
 func (DialysisOrder) TableName() string {
895
 func (DialysisOrder) TableName() string {

+ 182 - 0
models/drug.go ファイルの表示

106
 	IsPharmacy int64  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
106
 	IsPharmacy int64  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
107
 	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
107
 	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
108
 	IsProject  int64  `gorm:"column:is_project" json:"is_project" form:"is_project"`
108
 	IsProject  int64  `gorm:"column:is_project" json:"is_project" form:"is_project"`
109
+	DrugType   int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
110
+	IsSelfDrug int64  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
111
+	Dose       string `gorm:"column:dose" json:"dose" form:"dose"`
112
+	DoseUnit   string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
109
 }
113
 }
110
 
114
 
111
 func (BaseDrugLibSeven) TableName() string {
115
 func (BaseDrugLibSeven) TableName() string {
297
 func (BaseDrugLibTwenty) TableName() string {
301
 func (BaseDrugLibTwenty) TableName() string {
298
 	return "xt_base_drug"
302
 	return "xt_base_drug"
299
 }
303
 }
304
+
305
+type BaseDrugLibThrity struct {
306
+	ID                    int64                   `gorm:"column:id" json:"id" form:"id"`
307
+	DrugName              string                  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
308
+	Manufacturer          int64                   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
309
+	ManufacturerName      string                  `gorm:"column:manufacturer_name" json:"manufacturer_name"`
310
+	MaxUnit               string                  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
311
+	MinNumber             int64                   `gorm:"column:min_number" json:"min_number" form:"min_number"`
312
+	MinUnit               string                  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
313
+	Dose                  string                  `gorm:"column:dose" json:"dose" form:"dose"`
314
+	DoseUnit              string                  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
315
+	IsSelfDrug            int64                   `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
316
+	OrgId                 int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
317
+	Status                int64                   `gorm:"column:status" json:"status" form:"status"`
318
+	Dealer                int64                   `gorm:"column:dealer" json:"dealer" form:"dealer"`
319
+	DrugType              int64                   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
320
+	LastDrugWarehouseInfo XtSelfDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"first_drug_warehouse_info"`
321
+}
322
+
323
+func (BaseDrugLibThrity) TableName() string {
324
+	return "xt_base_drug"
325
+}
326
+
327
+type XtSelfDrugWarehouseInfo struct {
328
+	ID                        int64            `gorm:"column:id" json:"id" form:"id"`
329
+	WarehousingId             int64            `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
330
+	DrugId                    int64            `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
331
+	Number                    string           `gorm:"column:number" json:"number" form:"number"`
332
+	ProductDate               int64            `gorm:"column:product_date" json:"product_date" form:"product_date"`
333
+	ExpiryDate                int64            `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
334
+	WarehousingCount          int64            `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
335
+	WarehouseingUnit          string           `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
336
+	MaxUnit                   string           `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
337
+	MinUnit                   string           `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
338
+	StockMaxNumber            int64            `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
339
+	StockMinNumber            int64            `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
340
+	Price                     float64          `gorm:"column:price" json:"price" form:"price"`
341
+	TotalPrice                float64          `gorm:"column:total_price" json:"total_price" form:"total_price"`
342
+	Dealer                    int64            `gorm:"column:dealer" json:"dealer" form:"dealer"`
343
+	Manufacturer              int64            `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
344
+	Remark                    string           `gorm:"column:remark" json:"remark" form:"remark"`
345
+	Ctime                     int64            `gorm:"column:ctime" json:"ctime" form:"ctime"`
346
+	Mtime                     int64            `gorm:"column:mtime" json:"mtime" form:"mtime"`
347
+	Status                    int64            `gorm:"column:status" json:"status" form:"status"`
348
+	OrgId                     int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
349
+	IsReturn                  int64            `gorm:"column:is_return" json:"is_return" form:"is_return"`
350
+	WarehousingOrder          string           `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
351
+	Type                      int64            `gorm:"column:type" json:"type" form:"type"`
352
+	RetailPrice               float64          `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
353
+	RetailTotalPrice          float64          `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
354
+	BatchNumber               string           `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
355
+	WarehousingInfoId         int64            `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
356
+	SupplyWarehouseId         int64            `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
357
+	SupplyWarehouseDetailInfo int64            `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
358
+	StorehouseId              int64            `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
359
+	SecondWarehouseInfoId     int64            `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
360
+	PharmacyId                int64            `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
361
+	IsCheck                   int64            `gorm:"column:is_check" json:"is_check" form:"is_check"`
362
+	ManafacturerName          string           `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
363
+	DealerName                string           `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
364
+	PatientId                 int64            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
365
+	Creater                   int64            `gorm:"column:creater" json:"creater" form:"creater"`
366
+	IsSys                     int64            `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
367
+	RecordDate                int64            `gorm:"column:record_date" json:"record_date" form:"record_date"`
368
+	BaseDrugLib               BaseDrugLibSeven `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
369
+}
370
+
371
+func (XtSelfDrugWarehouseInfo) TableName() string {
372
+	return "xt_self_drug_warehouse_info"
373
+}
374
+
375
+type XtSelfDrugWarehouse struct {
376
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
377
+	WarehousingOrder  string `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
378
+	OperationTime     int64  `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
379
+	OrgId             int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
380
+	Creater           int64  `gorm:"column:creater" json:"creater" form:"creater"`
381
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
382
+	Modifier          int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
383
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
384
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
385
+	WarehousingTime   int64  `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
386
+	Dealer            int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
387
+	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
388
+	Type              int64  `gorm:"column:type" json:"type" form:"type"`
389
+	SupplyWarehouseId int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
390
+	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
391
+	SecondWarehouseId int64  `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
392
+	IsSys             int64  `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
393
+	IsCheck           int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
394
+	Checker           int64  `gorm:"column:checker" json:"checker" form:"checker"`
395
+	PatientId         int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
396
+}
397
+
398
+func (XtSelfDrugWarehouse) TableName() string {
399
+	return "xt_self_drug_warehouse"
400
+}
401
+
402
+type XtSelfDrugFlow struct {
403
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
404
+	WarehousingId             int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
405
+	DrugId                    int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
406
+	Number                    string  `gorm:"column:number" json:"number" form:"number"`
407
+	BatchNumber               string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
408
+	Count                     int64   `gorm:"column:count" json:"count" form:"count"`
409
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
410
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
411
+	SystemTime                int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
412
+	ConsumableType            int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
413
+	IsSys                     int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
414
+	WarehousingOrder          string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
415
+	WarehouseOutId            int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
416
+	WarehouseOutOrderNumber   string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
417
+	IsEdit                    int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
418
+	CancelStockId             int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
419
+	CancelOrderNumber         string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
420
+	Manufacturer              int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
421
+	Dealer                    int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
422
+	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
423
+	UpdateCreator             int64   `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
424
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
425
+	Ctime                     int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
426
+	Mtime                     int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
427
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
428
+	WarehousingDetailId       int64   `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
429
+	WarehouseOutDetailId      int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
430
+	CancelOutDetailId         int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
431
+	ExpireDate                int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
432
+	ProductDate               int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
433
+	MaxUnit                   string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
434
+	MinUnit                   string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
435
+	StockMaxNumber            int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
436
+	StockMinNumber            int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
437
+	LastStockMaxNumber        int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
438
+	LastStockMinNumber        int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
439
+	AdviceId                  int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
440
+	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
441
+	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
442
+	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
443
+	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
444
+	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
445
+	AdminUserId               int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
446
+	LastPrice                 float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
447
+	StockCount                string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
448
+	PharmacyId                int64   `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
449
+	IsRead                    int64   `gorm:"column:is_read" json:"is_read" form:"is_read"`
450
+	OverCount                 int64   `gorm:"column:over_count" json:"over_count" form:"over_count"`
451
+	IsCheck                   int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
452
+	RetailPrice               float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
453
+	OrderId                   int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
454
+	FlushOverCount            int64   `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
455
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
456
+	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
457
+}
458
+
459
+func (XtSelfDrugFlow) TableName() string {
460
+	return "xt_self_drug_flow"
461
+}
462
+
463
+type XtSelfDrugStockCount struct {
464
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
465
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
466
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
467
+	SumInCount     int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
468
+	SumOutCount    int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
469
+	SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
470
+	DrugId         int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
471
+	Ctime          int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
472
+	Mtime          int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
473
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
474
+	FlushCount     int64 `gorm:"column:flush_count" json:"flush_count" form:"flush_count"`
475
+	SumActOutCount int64 `gorm:"column:sum_act_out_count" json:"sum_act_out_count" form:"sum_act_out_count"`
476
+	SumOldCount    int64 `gorm:"column:sum_old_count" json:"sum_old_count" form:"sum_old_count"`
477
+}
478
+
479
+func (XtSelfDrugStockCount) TableName() string {
480
+	return "xt_self_drug_stock_count"
481
+}

+ 2 - 0
models/drug_stock.go ファイルの表示

195
 	OverCount               int64       `gorm:"column:over_count" json:"over_count" form:"over_count"`
195
 	OverCount               int64       `gorm:"column:over_count" json:"over_count" form:"over_count"`
196
 	OrderId                 int64       `gorm:"column:order_id" json:"order_id" form:"order_id"`
196
 	OrderId                 int64       `gorm:"column:order_id" json:"order_id" form:"order_id"`
197
 	ManafacturerName        string      `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
197
 	ManafacturerName        string      `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
198
+	ClassType               string      `gorm:"column:class_type" json:"class_type" form:"class_type"`
198
 }
199
 }
199
 
200
 
200
 func (DrugWarehouseOutInfo) TableName() string {
201
 func (DrugWarehouseOutInfo) TableName() string {
713
 	Drug                    BaseDrugLibSeven `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
714
 	Drug                    BaseDrugLibSeven `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
714
 	OverCount               int64            `gorm:"column:over_count" json:"over_count" form:"over_count"`
715
 	OverCount               int64            `gorm:"column:over_count" json:"over_count" form:"over_count"`
715
 	OrderId                 int64            `gorm:"column:order_id" json:"order_id" form:"order_id"`
716
 	OrderId                 int64            `gorm:"column:order_id" json:"order_id" form:"order_id"`
717
+	ClassType               string           `gorm:"column:class_type" json:"class_type" form:"class_type"`
716
 }
718
 }
717
 
719
 
718
 func (DrugWarehouseOutInfoNight) TableName() string {
720
 func (DrugWarehouseOutInfoNight) TableName() string {

+ 0 - 1
models/new_stock_models.go ファイルの表示

292
 	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`   //减少
292
 	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`   //减少
293
 	WareStartInStockFlow  []*VmStockFlowTwenty     `gorm:"json:"new_stock_in_flow"`        //盘盈
293
 	WareStartInStockFlow  []*VmStockFlowTwenty     `gorm:"json:"new_stock_in_flow"`        //盘盈
294
 	WareStartOutStockFlow []*VmStockFlowTwenty     `gorm:"json:"new_stock_out_flow"`       //盘亏
294
 	WareStartOutStockFlow []*VmStockFlowTwenty     `gorm:"json:"new_stock_out_flow"`       //盘亏
295
-
296
 	//期初结余
295
 	//期初结余
297
 	StartFlowInfo    []*VmStockFlowTwenty
296
 	StartFlowInfo    []*VmStockFlowTwenty
298
 	StartOutFlowInfo []*VmStockFlowTwenty
297
 	StartOutFlowInfo []*VmStockFlowTwenty

+ 14 - 0
models/patient_models.go ファイルの表示

2750
 	Count           int64
2750
 	Count           int64
2751
 	LastInspectData int64
2751
 	LastInspectData int64
2752
 }
2752
 }
2753
+
2754
+type XtTreatmentPlan struct {
2755
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2756
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2757
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2758
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2759
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2760
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2761
+}
2762
+
2763
+func (XtTreatmentPlan) TableName() string {
2764
+
2765
+	return "xt_treatment_plan"
2766
+}

+ 1 - 0
models/self_drug_models.go ファイルの表示

706
 	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
706
 	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
707
 	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
707
 	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
708
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
708
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
709
+	ClassType               string  `gorm:"column:class_type" json:"class_type" form:"class_type"`
709
 }
710
 }
710
 
711
 
711
 type XtDrugAdjustPrice struct {
712
 type XtDrugAdjustPrice struct {

+ 2 - 0
models/stock_models.go ファイルの表示

305
 	OrderId                 int64                `gorm:"column:order_id" json:"order_id" form:"order_id"`
305
 	OrderId                 int64                `gorm:"column:order_id" json:"order_id" form:"order_id"`
306
 	WarehousingInfoNight    WarehousingInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId"`
306
 	WarehousingInfoNight    WarehousingInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId"`
307
 	DealerName              string               `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
307
 	DealerName              string               `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
308
+	ClassType               string               `gorm:"column:class_type" json:"class_type" form:"class_type"`
308
 }
309
 }
309
 
310
 
310
 func (WarehouseOutInfo) TableName() string {
311
 func (WarehouseOutInfo) TableName() string {
574
 	StockCount                  string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
575
 	StockCount                  string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
575
 	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
576
 	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
576
 	WarehouseOutTime            int64   `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
577
 	WarehouseOutTime            int64   `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
578
+	ClassType                   string  `gorm:"column:class_type" json:"class_type" form:"class_type"`
577
 }
579
 }
578
 
580
 
579
 type WarehouseOutInfoTwo struct {
581
 type WarehouseOutInfoTwo struct {

+ 52 - 1
service/dialysis_service.go ファイルの表示

891
 	return admin, err
891
 	return admin, err
892
 }
892
 }
893
 
893
 
894
+func GetAdminUserEsTwo(orgid int64, aapid int64) (admin []*models.UserAdminRoles, err error) {
895
+	db := readUserDb.Table("sgj_user_admin_role as x")
896
+	table := readUserDb.Table("sgj_user_admin_electronic_signature as s")
897
+	fmt.Println("table", table)
898
+	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ? and x.app_id =?", orgid, aapid).Group("user_name").Scan(&admin).Error
899
+	return admin, err
900
+}
901
+
894
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
902
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
895
 	err = writeDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? ", orgId, patient, date).Updates(map[string]interface{}{"prescription_doctor": doctor_id}).Error
903
 	err = writeDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? ", orgId, patient, date).Updates(map[string]interface{}{"prescription_doctor": doctor_id}).Error
896
 	return
904
 	return
1508
 
1516
 
1509
 func GetGoodInfoMationSix(orgid int64, storehouse_id int64) (goodinfo []*models.GoodInfo, err error) {
1517
 func GetGoodInfoMationSix(orgid int64, storehouse_id int64) (goodinfo []*models.GoodInfo, err error) {
1510
 
1518
 
1511
-	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1 and storehouse_id = ?", storehouse_id).Find(&goodinfo).Error
1519
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1 and storehouse_id = ?", storehouse_id).Order("sort asc").Find(&goodinfo).Error
1512
 
1520
 
1513
 	return goodinfo, err
1521
 	return goodinfo, err
1514
 }
1522
 }
2512
 	}
2520
 	}
2513
 	return outInfo, err
2521
 	return outInfo, err
2514
 }
2522
 }
2523
+
2524
+func GetDialysisAutoGoodInfo(patient_id int64, record_time int64, org_id int64, tx *gorm.DB, good_id int64) (detail []*models.AutomaticReduceDetail, err error) {
2525
+
2526
+	err = tx.Where("patient_id = ? and record_time=? and org_id=? and status= 1 and good_id = ?", patient_id, record_time, org_id, good_id).Find(&detail).Error
2527
+	if err != gorm.ErrRecordNotFound {
2528
+		if err != nil {
2529
+			tx.Commit()
2530
+			return
2531
+		}
2532
+
2533
+	}
2534
+	return detail, err
2535
+}
2536
+
2537
+func CreateDialysisPrepare(prepare models.DialysisBeforePrepare, tx *gorm.DB) error {
2538
+
2539
+	err := tx.Create(&prepare).Error
2540
+	if err != nil {
2541
+		tx.Commit()
2542
+		return err
2543
+	}
2544
+	return err
2545
+}
2546
+
2547
+func ModfiyAddDialysisAuto(patient_id int64, record_date int64, count int64, good_id int64, tx *gorm.DB) error {
2548
+
2549
+	err = tx.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? and record_date  = ? and good_id = ? and status = 1", patient_id, record_date, good_id).UpdateColumn("count", gorm.Expr("count + ?", count)).Error
2550
+	if err != nil {
2551
+		tx.Rollback()
2552
+		return err
2553
+	}
2554
+	return err
2555
+}
2556
+
2557
+func ModfiyReduceDialysisAuto(patient_id int64, record_date int64, count int64, good_id int64, tx *gorm.DB) error {
2558
+
2559
+	err = tx.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? and record_date  = ? and good_id = ? and status = 1", patient_id, record_date, good_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
2560
+	if err != nil {
2561
+		tx.Rollback()
2562
+		return err
2563
+	}
2564
+	return err
2565
+}

+ 1 - 1
service/gobal_config_service.go ファイルの表示

941
 		db = db.Where("x.warehouse_out_id in(?)", id)
941
 		db = db.Where("x.warehouse_out_id in(?)", id)
942
 	}
942
 	}
943
 
943
 
944
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,x.storehouse_id,x.stock_count,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,x.admin_user_id,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
944
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,x.storehouse_id,x.stock_count,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,x.admin_user_id,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id,x.class_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
945
 	return info, err
945
 	return info, err
946
 }
946
 }
947
 
947
 

+ 1 - 1
service/his_project_service.go ファイルの表示

245
 
245
 
246
 func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
246
 func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
247
 
247
 
248
-	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1 and medical_status!=1", orgid).Find(&project).Error
248
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1 and medical_status!=1", orgid).Order("sort asc").Find(&project).Error
249
 	return project, err
249
 	return project, err
250
 }
250
 }
251
 
251
 

+ 35 - 4
service/his_service.go ファイルの表示

851
 }
851
 }
852
 
852
 
853
 func GetAllDrugLibListSix(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
853
 func GetAllDrugLibListSix(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
854
-	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
855
-		return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
856
-	}).Find(&list).Error
854
+	if org_id == 10598 {
855
+		err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
856
+			return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
857
+		}).Order("sort asc").Find(&list).Error
858
+
859
+		return
860
+	} else {
861
+		if org_id == 10489 {
862
+			err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0 AND sum_count >0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
863
+				return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
864
+			}).Order("sort asc").Find(&list).Error
865
+
866
+			return
867
+		} else {
868
+			err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
869
+				return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
870
+			}).Order("sort asc").Find(&list).Error
871
+
872
+			return
873
+		}
874
+
875
+	}
857
 
876
 
858
-	return
859
 }
877
 }
860
 
878
 
861
 func GetAllDrugLibListSeven(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
879
 func GetAllDrugLibListSeven(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
3399
 	return outInfo, err
3417
 	return outInfo, err
3400
 }
3418
 }
3401
 
3419
 
3420
+func GetGoodWarehouseOutInfoByProjectIdThree(patient_id int64, user_org_id int64, sys_record_date int64, drug_id int64, tx *gorm.DB) (models.WarehouseOutInfo, error) {
3421
+
3422
+	outInfo := models.WarehouseOutInfo{}
3423
+	err = tx.Where("patient_id = ? and org_id =? and sys_record_time = ? and good_id = ? and status=1", patient_id, user_org_id, sys_record_date, drug_id).Order("id desc").Last(&outInfo).Error
3424
+	if err != gorm.ErrRecordNotFound {
3425
+		if err != nil {
3426
+			tx.Rollback()
3427
+			return outInfo, err
3428
+		}
3429
+	}
3430
+	return outInfo, err
3431
+}
3432
+
3402
 func DeleteGoodWarehouseOutInfoByNumber(id int64, tx *gorm.DB) error {
3433
 func DeleteGoodWarehouseOutInfoByNumber(id int64, tx *gorm.DB) error {
3403
 
3434
 
3404
 	err := tx.Model(&models.WarehouseOutInfo{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"status": 0}).Error
3435
 	err := tx.Model(&models.WarehouseOutInfo{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"status": 0}).Error

+ 2 - 1
service/mobile_dialysis_service.go ファイルの表示

2251
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2251
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2252
 	tx := writeDb.Begin()
2252
 	tx := writeDb.Begin()
2253
 	updateTime := time.Now().Unix()
2253
 	updateTime := time.Now().Unix()
2254
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate, "schedule_remark": order.ScheduleRemark, "order_remark": order.OrderRemark, "catheter_operation": order.CatheterOperation, "blood_flow_volume": order.BloodFlowVolume, "blood_drawing": order.BloodDrawing}).Error
2254
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate, "schedule_remark": order.ScheduleRemark, "order_remark": order.OrderRemark, "catheter_operation": order.CatheterOperation, "blood_flow_volume": order.BloodFlowVolume, "blood_drawing": order.BloodDrawing, "dialysis_strainer": order.DialysisStrainer}).Error
2255
 	if err != nil {
2255
 	if err != nil {
2256
 		tx.Rollback()
2256
 		tx.Rollback()
2257
 		return err
2257
 		return err
2924
 	VMGoodInfo VMGoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
2924
 	VMGoodInfo VMGoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
2925
 	GoodsType  GoodsType  `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
2925
 	GoodsType  GoodsType  `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
2926
 	Count      int64      `gorm:"column:count" json:"count"`
2926
 	Count      int64      `gorm:"column:count" json:"count"`
2927
+	ProjectId  int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
2927
 }
2928
 }
2928
 
2929
 
2929
 func (AutomaticReduceDetail) TableName() string {
2930
 func (AutomaticReduceDetail) TableName() string {

+ 31 - 0
service/new_stock_service.go ファイルの表示

649
 
649
 
650
 	return drug, err
650
 	return drug, err
651
 }
651
 }
652
+
653
+func GetSelfDrugStockCount(patient_id int64, drug_id int64, org_id int64, tx *gorm.DB) (*models.XtSelfDrugStockCount, error) {
654
+
655
+	drugStockCount := models.XtSelfDrugStockCount{}
656
+	var err error
657
+	err = tx.Where("patient_id = ? and drug_id = ? and user_org_id  = ? and status = 1", patient_id, drug_id, org_id).Find(&drugStockCount).Error
658
+	if err == gorm.ErrRecordNotFound {
659
+		tx.Rollback()
660
+		return nil, err
661
+	}
662
+	if err != nil {
663
+		tx.Rollback()
664
+		return nil, err
665
+	}
666
+	return &drugStockCount, nil
667
+}
668
+
669
+func UpdateSelfDrugStockSum(patient_id int64, drug_id int64, user_org_id int64, waresing_count int64, over_count int64, tx *gorm.DB) error {
670
+
671
+	err = tx.Model(&models.XtSelfDrugStockCount{}).Where("user_org_id = ? and patient_id  = ? and drug_id  = ? and status = 1", user_org_id, patient_id, drug_id).Update(map[string]interface{}{"sum_in_count": waresing_count}).Error
672
+	if err != nil {
673
+		tx.Rollback()
674
+		return err
675
+	}
676
+	err = tx.Model(&models.XtSelfDrugStockCount{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and status = 1", user_org_id, patient_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
677
+	if err != nil {
678
+		tx.Rollback()
679
+		return err
680
+	}
681
+	return err
682
+}

+ 23 - 0
service/patient_service.go ファイルの表示

4074
 
4074
 
4075
 	return order, err
4075
 	return order, err
4076
 }
4076
 }
4077
+
4078
+func GetTreamentPland(user_org_id int64) (models.XtTreatmentPlan, error) {
4079
+
4080
+	treatmentPlan := models.XtTreatmentPlan{}
4081
+
4082
+	err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&treatmentPlan).Error
4083
+
4084
+	return treatmentPlan, err
4085
+}
4086
+
4087
+func CreateTreatqmentPland(plan models.XtTreatmentPlan) error {
4088
+
4089
+	err := XTWriteDB().Create(&plan).Error
4090
+
4091
+	return err
4092
+}
4093
+
4094
+func UpdateTheatmentPland(id int64, content string) error {
4095
+
4096
+	err := XTWriteDB().Model(&models.XtTreatmentPlan{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"content": content}).Error
4097
+
4098
+	return err
4099
+}

+ 3 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go ファイルの表示

111
 	PunctureWay        string          `gorm:"column:puncture_way" json:"puncture_way" form:"puncture_way"`
111
 	PunctureWay        string          `gorm:"column:puncture_way" json:"puncture_way" form:"puncture_way"`
112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
113
 	BloodDrawing       int64           `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
113
 	BloodDrawing       int64           `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
114
+	DialysisStrainer   string          `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
114
 }
115
 }
115
 
116
 
116
 func (DialysisOrderVM) TableName() string {
117
 func (DialysisOrderVM) TableName() string {
577
 	FilterPressure              string  `gorm:"column:filter_pressure" json:"filter_pressure" form:"filter_pressure"`
578
 	FilterPressure              string  `gorm:"column:filter_pressure" json:"filter_pressure" form:"filter_pressure"`
578
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
579
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
579
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
580
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
581
+	UltrafiltrationRateOne      string  `gorm:"column:ultrafiltration_rate_one" json:"ultrafiltration_rate_one" form:"ultrafiltration_rate_one"`
582
+	HeparinOne                  string  `gorm:"column:heparin_one" json:"heparin_one" form:"heparin_one"`
580
 }
583
 }
581
 
584
 
582
 func (MonitoringRecordVM) TableName() string {
585
 func (MonitoringRecordVM) TableName() string {

+ 293 - 0
service/self_drug_service.go ファイルの表示

3071
 
3071
 
3072
 }
3072
 }
3073
 
3073
 
3074
+func GetInitOutBanceTenty(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.VmStockFlowTwenty, err error) {
3075
+
3076
+	db := XTReadDB().Model(&list).Where("status=1 and (consumable_type=2 or consumable_type =3)")
3077
+	if good_id > 0 {
3078
+		db = db.Where("good_id = ?", good_id)
3079
+	}
3080
+	if user_org_id > 0 {
3081
+		db = db.Where("user_org_id = ?", user_org_id)
3082
+	}
3083
+
3084
+	if start_time > 0 {
3085
+		db = db.Where("ctime<?", start_time)
3086
+	}
3087
+
3088
+	if storehouse_id > 0 {
3089
+		db = db.Where("storehouse_id = ?", storehouse_id)
3090
+	}
3091
+
3092
+	err = db.Find(&list).Error
3093
+
3094
+	return list, err
3095
+}
3096
+
3074
 func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.WarehouseOutInfoTenty, err error) {
3097
 func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.WarehouseOutInfoTenty, err error) {
3075
 
3098
 
3076
 	db := XTReadDB().Model(&list).Where("status=1")
3099
 	db := XTReadDB().Model(&list).Where("status=1")
3445
 
3468
 
3446
 	return err
3469
 	return err
3447
 }
3470
 }
3471
+
3472
+func GetAllSelfDrugInfoList(org_id int64) (base []*models.BaseDrugLibThrity, err error) {
3473
+
3474
+	err = XTReadDB().Where("org_id = ? and status =1 and is_self_drug =1", org_id).Find(&base).Error
3475
+
3476
+	return base, err
3477
+}
3478
+
3479
+func GetAllPatientListByUserOrg(org_id int64) (patient []*models.XtPatients, err error) {
3480
+
3481
+	err = XTReadDB().Where("user_org_id =? and status=1", org_id).Find(&patient).Error
3482
+
3483
+	return patient, err
3484
+}
3485
+
3486
+func PostSearchSelfDrugList(keywords string, user_org_id int64) (drug []*models.BaseDrugLibThrity, err error) {
3487
+
3488
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1 and is_self_drug=1", user_org_id)
3489
+
3490
+	if len(keywords) > 0 {
3491
+		likekey := "%" + keywords + "%"
3492
+		err = db.Where("(drug_name LIKE ?)", likekey).Preload("LastDrugWarehouseInfo", "org_id=? and status = 1 and (stock_max_number > 0 or stock_min_number>0) and storehouse_id = ?", user_org_id).Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3493
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", user_org_id).Group("id")
3494
+		}).Find(&drug).Error
3495
+	} else {
3496
+		err = db.Preload("LastDrugWarehouseInfo", "org_id=? and status = 1 and (stock_max_number > 0 or stock_min_number>0)", user_org_id).Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3497
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0 ", user_org_id).Group("id")
3498
+		}).Find(&drug).Error
3499
+	}
3500
+	return
3501
+}
3502
+
3503
+func FindAllSelfDrugList(org_id int64, patient_id int64) (total int64, err error) {
3504
+	err = readDb.Model(&models.XtSelfDrugWarehouseInfo{}).Where("org_id = ? and patient_id", org_id, patient_id).Count(&total).Error
3505
+	return total, err
3506
+}
3507
+
3508
+func CreatedSlefWarehouseing(info *models.XtSelfDrugWarehouseInfo, tx *gorm.DB) {
3509
+
3510
+	err := tx.Create(&info).Error
3511
+	if err != nil {
3512
+		tx.Rollback()
3513
+		return
3514
+	}
3515
+	return
3516
+}
3517
+
3518
+func UpdateSelfWarehouseing(info *models.XtSelfDrugWarehouseInfo, tx *gorm.DB) error {
3519
+
3520
+	err := tx.Save(&info).Error
3521
+	if err != nil {
3522
+		tx.Rollback()
3523
+		return err
3524
+	}
3525
+	return err
3526
+}
3527
+
3528
+func FindSelfDrugWarehouseInfoListById(id int64, org_id int64, patient_id int64, tx *gorm.DB) (info []*models.XtSelfDrugWarehouseInfo, err error) {
3529
+
3530
+	err = tx.Where("warehousing_id = ? and org_id = ? and patient_id = ? and status=1", id, org_id, patient_id).Preload("BaseDrugLib", "status=1").Find(&info).Error
3531
+
3532
+	if err != gorm.ErrRecordNotFound {
3533
+		if err != nil {
3534
+			tx.Rollback()
3535
+			return info, err
3536
+
3537
+		}
3538
+	}
3539
+	return info, err
3540
+}
3541
+
3542
+func GetAllBaseDrugListByKeyWord(keyword string, org_id int64) (base []*models.BaseDrugLibSeven, err error) {
3543
+
3544
+	likeKey := "%" + keyword + "%"
3545
+
3546
+	db := XTReadDB().Model(&base).Where("status=1 and is_self_drug = 1")
3547
+	if len(keyword) > 0 {
3548
+		db = db.Where("drug_name like ?", likeKey)
3549
+	}
3550
+	if org_id > 0 {
3551
+		db = db.Where("org_id = ?", org_id)
3552
+	}
3553
+	err = db.Find(&base).Error
3554
+
3555
+	return base, err
3556
+
3557
+}
3558
+
3559
+func GetAllSelfDrugWarehouseInfoList(ids []int64, org_id int64, patient_id int64) (info []*models.XtSelfDrugWarehouseInfo, err error) {
3560
+
3561
+	db := XTReadDB().Model(&info).Where("status=1")
3562
+
3563
+	if len(ids) > 0 {
3564
+		db = db.Where("drug_id in(?)", ids)
3565
+	}
3566
+	if org_id > 0 {
3567
+		db = db.Where("org_id = ?", org_id)
3568
+	}
3569
+	if patient_id > 0 {
3570
+		db = db.Where("patient_id = ?", patient_id)
3571
+	}
3572
+
3573
+	err = db.Preload("BaseDrugLib", "status =1").Find(&info).Error
3574
+
3575
+	return info, err
3576
+}
3577
+
3578
+func AddSelfDrugWarehouse(warehouse *models.XtSelfDrugWarehouse, tx *gorm.DB) error {
3579
+
3580
+	err := tx.Create(&warehouse).Error
3581
+
3582
+	if err != nil {
3583
+		tx.Rollback()
3584
+		return err
3585
+	}
3586
+
3587
+	return err
3588
+}
3589
+
3590
+func UpdateSelfDrugWarehouse(warehouse *models.XtSelfDrugWarehouse, tx *gorm.DB) error {
3591
+
3592
+	err := tx.Save(&warehouse).Error
3593
+
3594
+	if err != nil {
3595
+		tx.Rollback()
3596
+		return err
3597
+	}
3598
+
3599
+	return err
3600
+
3601
+}
3602
+
3603
+func FindSelfAllWarehouseTotal(org_id int64, tx *gorm.DB) (total int64, err2 error) {
3604
+
3605
+	err = tx.Model(&models.XtSelfDrugWarehouse{}).Where("org_id = ?", org_id).Count(&total).Error
3606
+	if err != gorm.ErrRecordNotFound {
3607
+		if err != nil {
3608
+			tx.Rollback()
3609
+			return total, err
3610
+		}
3611
+	}
3612
+	return total, err
3613
+}
3614
+
3615
+func FindLastSelfWarehousing(user_org_id int64, patient_id int64, tx *gorm.DB) (models.XtSelfDrugWarehouse, error) {
3616
+
3617
+	selfDrugWarehouse := models.XtSelfDrugWarehouse{}
3618
+	err := tx.Where("org_id=? and patient_id =?", user_org_id, patient_id).Last(&selfDrugWarehouse).Error
3619
+
3620
+	if err != gorm.ErrRecordNotFound {
3621
+		if err != nil {
3622
+			tx.Rollback()
3623
+			return selfDrugWarehouse, err
3624
+		}
3625
+	}
3626
+	return selfDrugWarehouse, err
3627
+}
3628
+
3629
+func GetSelfDrugWarehouseInfoByID(id int64) (models.XtSelfDrugWarehouseInfo, error) {
3630
+
3631
+	selfDrugWarehouseInfo := models.XtSelfDrugWarehouseInfo{}
3632
+
3633
+	err := XTReadDB().Where("id = ? and status=1", id).Preload("BaseDrugLib", "status=1").Find(&selfDrugWarehouseInfo).Error
3634
+
3635
+	return selfDrugWarehouseInfo, err
3636
+}
3637
+
3638
+func GetSelfDrugWarehouseInfo(id int64) (models.XtSelfDrugWarehouse, error) {
3639
+
3640
+	warehouse := models.XtSelfDrugWarehouse{}
3641
+
3642
+	err := XTReadDB().Where("id = ? and status=1", id).Find(&warehouse).Error
3643
+
3644
+	return warehouse, err
3645
+}
3646
+
3647
+func DeleteSelfDrugWarehouse(id int64, tx *gorm.DB) error {
3648
+
3649
+	info := models.XtSelfDrugWarehouseInfo{}
3650
+
3651
+	err := tx.Model(&info).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
3652
+
3653
+	if err != nil {
3654
+		tx.Rollback()
3655
+		return err
3656
+	}
3657
+
3658
+	return err
3659
+}
3660
+
3661
+func GetSelfWarehouseInfoByWarehouseInfo(id int64, patient_id int64, org_id int64) (info []*models.XtSelfDrugWarehouseInfo, err error) {
3662
+
3663
+	err = XTReadDB().Where("id =? and patient_id =? and warehousing_id = ? and status=1 and org_id =?", id, patient_id, org_id).Find(&info).Error
3664
+	return info, err
3665
+}
3666
+
3667
+func AddSelfDrugWarehouseStockMaxNumber(count int64, id int64, tx *gorm.DB) error {
3668
+
3669
+	err := tx.Model(&models.XtSelfDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
3670
+	if err != nil {
3671
+		tx.Rollback()
3672
+		return err
3673
+	}
3674
+	err = tx.Model(&models.XtSelfDrugWarehouse{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
3675
+	if err != nil {
3676
+		tx.Rollback()
3677
+		return err
3678
+	}
3679
+
3680
+	return err
3681
+}
3682
+
3683
+func AddSelfDrugWarehouseStockMinNumber(count int64, id int64, tx *gorm.DB) error {
3684
+
3685
+	err := XTWriteDB().Model(&models.XtSelfDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
3686
+	if err != nil {
3687
+		tx.Rollback()
3688
+		return err
3689
+	}
3690
+	err = XTWriteDB().Model(&models.XtSelfDrugWarehouse{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
3691
+
3692
+	return err
3693
+}
3694
+
3695
+func GetDrugSumCountByPatient(patient_id int64, org_id int64, drug_id int64, tx *gorm.DB) (info []*models.XtSelfDrugWarehouseInfo, err error) {
3696
+
3697
+	err = tx.Where("patient_id = ? and org_id = ? and drug_id = ? and status =1", patient_id, org_id, drug_id).Find(&info).Error
3698
+
3699
+	if err != gorm.ErrRecordNotFound {
3700
+		if err != nil {
3701
+			tx.Rollback()
3702
+			return
3703
+		}
3704
+	}
3705
+
3706
+	return info, err
3707
+}
3708
+
3709
+func CreateSelfDrugFlow(flow *models.XtSelfDrugFlow, tx *gorm.DB) error {
3710
+
3711
+	err := tx.Create(&flow).Error
3712
+	if err != nil {
3713
+		tx.Rollback()
3714
+		return err
3715
+	}
3716
+	return err
3717
+}
3718
+
3719
+func GetSelfDrugSumCountByStorehouseId(patient_id int64, orgid int64, drug_id int64, tx *gorm.DB) (info []*models.XtSelfDrugWarehouseInfo, err error) {
3720
+
3721
+	err = tx.Where("patient_id = ? and org_id = ? and status = 1  and drug_id =? and is_check = 1", patient_id, orgid, drug_id).Find(&info).Error
3722
+
3723
+	if err != gorm.ErrRecordNotFound {
3724
+		if err != nil {
3725
+			tx.Rollback()
3726
+			return info, err
3727
+		}
3728
+	}
3729
+	return info, err
3730
+}
3731
+
3732
+func CreateSelfDrugStockSum(drug models.XtSelfDrugStockCount, tx *gorm.DB) error {
3733
+
3734
+	err := tx.Create(&drug).Error
3735
+	if err != nil {
3736
+		tx.Rollback()
3737
+		return err
3738
+	}
3739
+	return err
3740
+}

+ 1 - 1
service/sign_service.go ファイルの表示

2112
 
2112
 
2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2114
 
2114
 
2115
-	err = XTReadDB().Where("patient_id = ? and status =1", 26973).Find(&list).Error
2115
+	err = XTReadDB().Where("patient_id = ? and status =1", 31831).Find(&list).Error
2116
 
2116
 
2117
 	return list, err
2117
 	return list, err
2118
 }
2118
 }

+ 3 - 2
service/stock_service.go ファイルの表示

1871
 	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
1871
 	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
1872
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1872
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1873
 	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1873
 	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1874
+	ClassType               string  `gorm:"column:class_type" json:"class_type" form:"class_type"`
1874
 }
1875
 }
1875
 
1876
 
1876
 func (DrugWarehouseOutInfo) TableName() string {
1877
 func (DrugWarehouseOutInfo) TableName() string {
4588
 		db = db.Where("x.org_id = ?", orgid)
4589
 		db = db.Where("x.org_id = ?", orgid)
4589
 	}
4590
 	}
4590
 
4591
 
4591
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,x.remark,x.patient_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4592
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,x.remark,x.patient_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number,x.class_type").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4592
 
4593
 
4593
 	return out, err
4594
 	return out, err
4594
 }
4595
 }
8120
 
8121
 
8121
 func UpdatedDrugWarehouseInfo(info *models.DrugWarehouseOutInfo, id int64) error {
8122
 func UpdatedDrugWarehouseInfo(info *models.DrugWarehouseOutInfo, id int64) error {
8122
 
8123
 
8123
-	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount, "storehouse_id": info.StorehouseId, "patient_id": info.PatientId}).Error
8124
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount, "storehouse_id": info.StorehouseId, "patient_id": info.PatientId, "class_type": info.ClassType}).Error
8124
 	return err
8125
 	return err
8125
 }
8126
 }
8126
 
8127
 

+ 292 - 0
service/warhouse_service.go ファイルの表示

9442
 
9442
 
9443
 	return
9443
 	return
9444
 }
9444
 }
9445
+
9446
+func NewMobileHisGoodCancelInfo(orgID int64, creater int64, project *models.HisPrescriptionProject, cha_count int64, good models.GoodInformationThirty, tx *gorm.DB) (err error) {
9447
+
9448
+	storeConfig, _ := GetNewAllStoreHouseConfig(orgID, tx)
9449
+
9450
+	//查找患者最后一条的退库数据是否满足要求
9451
+	var out_count int64
9452
+	GoodOutInfo, _ := GetGoodWarehouseOutInfoByProjectIdThree(project.PatientId, project.UserOrgId, project.RecordDate, project.ProjectId, tx)
9453
+
9454
+	out_count = GoodOutInfo.Count
9455
+	//如果最后1条出库数量大于退库数量,则直接退库,满足退库要求
9456
+
9457
+	if out_count >= cha_count {
9458
+		//退库 退回 cha_count 的数量
9459
+		ModifyNewGoodWarehouseInfoStockMinNumber(cha_count, GoodOutInfo.GoodId, GoodOutInfo.OrgId, GoodOutInfo.WarehouseInfotId, tx)
9460
+
9461
+		if out_count == cha_count {
9462
+			//删除该出库单
9463
+			DeleteGoodWarehouseOutInfoByNumber(GoodOutInfo.ID, tx)
9464
+		} else {
9465
+			//减去出库单里面的数量
9466
+			ModifyGoodWarehouseOutInfoByNumber(GoodOutInfo.ID, cha_count, tx)
9467
+		}
9468
+
9469
+		//创建退库单
9470
+		goodList, _ := GetNewAllGoodSumCount(project.ProjectId, orgID, storeConfig.StorehouseOutInfo, tx)
9471
+		var sum_count int64
9472
+		for _, item := range goodList {
9473
+			sum_count += item.StockCount
9474
+		}
9475
+
9476
+		operation_time := time.Now().Unix()
9477
+
9478
+		//创建退库单
9479
+		timeStr := time.Now().Format("2006-01-02")
9480
+		timeArr := strings.Split(timeStr, "-")
9481
+		total, _ := FindNewAllCancelStockTotal(orgID, tx)
9482
+		total = total + 1
9483
+		orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
9484
+
9485
+		cancelStock := models.CancelStock{
9486
+			OrderNumber:  orderNumber,
9487
+			OperaTime:    operation_time,
9488
+			OrgId:        orgID,
9489
+			Creater:      creater,
9490
+			Ctime:        time.Now().Unix(),
9491
+			Status:       1,
9492
+			ReturnTime:   project.RecordDate,
9493
+			Type:         1,
9494
+			StorehouseId: storeConfig.StorehouseOutInfo,
9495
+			IsCheck:      1,
9496
+		}
9497
+		_, msgerrkonde := GetNewCancelStockDetailByOrderNumberOne(project.RecordDate, orgID, tx)
9498
+		if msgerrkonde == gorm.ErrRecordNotFound {
9499
+			AddNewSigleCancelStock(&cancelStock, tx)
9500
+		}
9501
+
9502
+		manufactureName, _ := GetNewManufactureById(GoodOutInfo.Manufacturer, tx)
9503
+		dealer, _ := GetNewDealerById(GoodOutInfo.Dealer, tx)
9504
+
9505
+		cancelInfo, _ := GetNewLastCancelStockById(orgID, tx)
9506
+
9507
+		cancelStockInfo := models.CancelStockInfo{
9508
+			GoodId:          project.ProjectId,
9509
+			CancelStockId:   cancelInfo.ID,
9510
+			GoodTypeId:      good.GoodTypeId,
9511
+			Count:           cha_count,
9512
+			Price:           project.Price,
9513
+			Total:           0,
9514
+			ProductDate:     GoodOutInfo.ProductDate,
9515
+			ExpiryDate:      GoodOutInfo.ExpiryDate,
9516
+			Ctime:           time.Now().Unix(),
9517
+			Status:          1,
9518
+			OrgId:           orgID,
9519
+			OrderNumber:     cancelInfo.OrderNumber,
9520
+			Type:            0,
9521
+			Dealer:          dealer.DealerName,
9522
+			Manufacturer:    manufactureName.ManufacturerName,
9523
+			Number:          GoodOutInfo.Number,
9524
+			RegisterAccount: "",
9525
+			Remark:          "",
9526
+			WarehouseInfoId: GoodOutInfo.WarehouseInfotId,
9527
+			PatientId:       project.ProjectId,
9528
+			RecordDate:      project.RecordDate,
9529
+			StorehouseId:    storeConfig.StorehouseOutInfo,
9530
+			IsCheck:         1,
9531
+		}
9532
+		CreateNewCancelStockInfoOne(&cancelStockInfo, tx)
9533
+
9534
+		flow := models.VmStockFlow{
9535
+			WarehousingId:           GoodOutInfo.WarehouseInfotId,
9536
+			GoodId:                  project.ProjectId,
9537
+			Number:                  GoodOutInfo.Number,
9538
+			LicenseNumber:           GoodOutInfo.LicenseNumber,
9539
+			Count:                   cha_count,
9540
+			UserOrgId:               orgID,
9541
+			PatientId:               project.PatientId,
9542
+			SystemTime:              project.RecordDate,
9543
+			ConsumableType:          7,
9544
+			IsSys:                   1,
9545
+			WarehousingOrder:        "",
9546
+			WarehouseOutId:          GoodOutInfo.WarehouseOutId,
9547
+			WarehouseOutOrderNumber: GoodOutInfo.WarehouseOutOrderNumber,
9548
+			IsEdit:                  0,
9549
+			CancelStockId:           cancelInfo.ID,
9550
+			CancelOrderNumber:       cancelInfo.OrderNumber,
9551
+			Manufacturer:            manufactureName.ID,
9552
+			Dealer:                  0,
9553
+			Creator:                 creater,
9554
+			UpdateCreator:           0,
9555
+			Status:                  1,
9556
+			Ctime:                   time.Now().Unix(),
9557
+			Mtime:                   0,
9558
+			Price:                   GoodOutInfo.Price,
9559
+			WarehousingDetailId:     GoodOutInfo.WarehouseInfotId,
9560
+			WarehouseOutDetailId:    GoodOutInfo.ID,
9561
+			CancelOutDetailId:       cancelInfo.ID,
9562
+			ProductDate:             GoodOutInfo.ProductDate,
9563
+			ExpireDate:              GoodOutInfo.ExpiryDate,
9564
+			StorehouseId:            storeConfig.StorehouseOutInfo,
9565
+			BuyPrice:                project.Price,
9566
+			ProjectId:               project.ID,
9567
+			OverCount:               sum_count,
9568
+			RegisterNumber:          GoodOutInfo.RegisterNumber,
9569
+			OperateTime:             time.Now().Unix(),
9570
+		}
9571
+		CreateNewStockFlowOne(flow, tx)
9572
+
9573
+		AddGoodNewCancelSumCountOne(storeConfig.StorehouseOutInfo, project.ProjectId, orgID, flow.Count, tx)
9574
+
9575
+		ReduceNewGoodCountTwo(project.ProjectId, orgID, storeConfig.StorehouseOutInfo, flow.Count, tx)
9576
+
9577
+	}
9578
+
9579
+	//如果出库的数据小于这个退库的数量差,则先该批次出库数量出完
9580
+	if out_count < cha_count {
9581
+
9582
+		//把该出库单的数量退完
9583
+		ModifyNewGoodWarehouseInfoStockMinNumber(out_count, GoodOutInfo.GoodId, GoodOutInfo.OrgId, GoodOutInfo.WarehouseInfotId, tx)
9584
+
9585
+		//删除该出库单
9586
+		DeleteGoodWarehouseOutInfoByNumber(GoodOutInfo.ID, tx)
9587
+
9588
+		//查询剩余库存
9589
+		goodList, _ := GetNewAllGoodSumCount(project.ProjectId, orgID, storeConfig.StorehouseOutInfo, tx)
9590
+		var sum_count int64
9591
+		for _, item := range goodList {
9592
+			sum_count += item.StockCount
9593
+		}
9594
+
9595
+		operation_time := time.Now().Unix()
9596
+		//创建退库单
9597
+		timeStr := time.Now().Format("2006-01-02")
9598
+		timeArr := strings.Split(timeStr, "-")
9599
+		total, _ := FindNewAllCancelStockTotal(orgID, tx)
9600
+		total = total + 1
9601
+		orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
9602
+
9603
+		cancelStock := models.CancelStock{
9604
+			OrderNumber:  orderNumber,
9605
+			OperaTime:    operation_time,
9606
+			OrgId:        orgID,
9607
+			Creater:      creater,
9608
+			Ctime:        time.Now().Unix(),
9609
+			Status:       1,
9610
+			ReturnTime:   project.RecordDate,
9611
+			Type:         1,
9612
+			StorehouseId: storeConfig.StorehouseOutInfo,
9613
+			IsCheck:      1,
9614
+		}
9615
+		_, msgerrkonde := GetNewCancelStockDetailByOrderNumberOne(project.RecordDate, orgID, tx)
9616
+		if msgerrkonde == gorm.ErrRecordNotFound {
9617
+			AddNewSigleCancelStock(&cancelStock, tx)
9618
+		}
9619
+
9620
+		manufactureName, _ := GetNewManufactureById(GoodOutInfo.Manufacturer, tx)
9621
+		dealer, _ := GetNewDealerById(GoodOutInfo.Dealer, tx)
9622
+
9623
+		cancelInfo, _ := GetNewLastCancelStockById(orgID, tx)
9624
+
9625
+		cancelStockInfo := models.CancelStockInfo{
9626
+			GoodId:          project.ProjectId,
9627
+			CancelStockId:   cancelInfo.ID,
9628
+			GoodTypeId:      good.GoodTypeId,
9629
+			Count:           out_count,
9630
+			Price:           project.Price,
9631
+			Total:           0,
9632
+			ProductDate:     GoodOutInfo.ProductDate,
9633
+			ExpiryDate:      GoodOutInfo.ExpiryDate,
9634
+			Ctime:           time.Now().Unix(),
9635
+			Status:          1,
9636
+			OrgId:           orgID,
9637
+			OrderNumber:     cancelInfo.OrderNumber,
9638
+			Type:            0,
9639
+			Dealer:          dealer.DealerName,
9640
+			Manufacturer:    manufactureName.ManufacturerName,
9641
+			Number:          GoodOutInfo.Number,
9642
+			RegisterAccount: "",
9643
+			Remark:          "",
9644
+			WarehouseInfoId: GoodOutInfo.WarehouseInfotId,
9645
+			PatientId:       project.ProjectId,
9646
+			RecordDate:      project.RecordDate,
9647
+			StorehouseId:    storeConfig.StorehouseOutInfo,
9648
+			IsCheck:         1,
9649
+		}
9650
+		CreateNewCancelStockInfoOne(&cancelStockInfo, tx)
9651
+
9652
+		flow := models.VmStockFlow{
9653
+			WarehousingId:           GoodOutInfo.WarehouseInfotId,
9654
+			GoodId:                  project.ProjectId,
9655
+			Number:                  GoodOutInfo.Number,
9656
+			LicenseNumber:           GoodOutInfo.LicenseNumber,
9657
+			Count:                   out_count,
9658
+			UserOrgId:               orgID,
9659
+			PatientId:               project.PatientId,
9660
+			SystemTime:              project.RecordDate,
9661
+			ConsumableType:          7,
9662
+			IsSys:                   1,
9663
+			WarehousingOrder:        "",
9664
+			WarehouseOutId:          GoodOutInfo.WarehouseOutId,
9665
+			WarehouseOutOrderNumber: GoodOutInfo.WarehouseOutOrderNumber,
9666
+			IsEdit:                  0,
9667
+			CancelStockId:           cancelInfo.ID,
9668
+			CancelOrderNumber:       cancelInfo.OrderNumber,
9669
+			Manufacturer:            manufactureName.ID,
9670
+			Dealer:                  0,
9671
+			Creator:                 creater,
9672
+			UpdateCreator:           0,
9673
+			Status:                  1,
9674
+			Ctime:                   time.Now().Unix(),
9675
+			Mtime:                   0,
9676
+			Price:                   GoodOutInfo.Price,
9677
+			WarehousingDetailId:     GoodOutInfo.WarehouseInfotId,
9678
+			WarehouseOutDetailId:    GoodOutInfo.ID,
9679
+			CancelOutDetailId:       cancelInfo.ID,
9680
+			ProductDate:             GoodOutInfo.ProductDate,
9681
+			ExpireDate:              GoodOutInfo.ExpiryDate,
9682
+			StorehouseId:            storeConfig.StorehouseOutInfo,
9683
+			BuyPrice:                project.Price,
9684
+			ProjectId:               project.ID,
9685
+			OverCount:               sum_count,
9686
+			RegisterNumber:          GoodOutInfo.RegisterNumber,
9687
+			OperateTime:             time.Now().Unix(),
9688
+		}
9689
+		CreateNewStockFlowOne(flow, tx)
9690
+
9691
+		AddGoodNewCancelSumCountOne(storeConfig.StorehouseOutInfo, project.ProjectId, orgID, flow.Count, tx)
9692
+
9693
+		ReduceNewGoodCountTwo(project.ProjectId, orgID, storeConfig.StorehouseOutInfo, flow.Count, tx)
9694
+
9695
+		//计算还有多少没有退库
9696
+		var over_count = cha_count - out_count
9697
+
9698
+		NewHisGoodCancelInfo(orgID, creater, project, over_count, good, tx)
9699
+	}
9700
+	return err
9701
+
9702
+}
9703
+
9704
+func NewMobileHisGoodAutoCancelInfo(orgID int64, creater int64, project *models.HisPrescriptionProject, cha_count int64, good models.GoodInformationThirty, tx *gorm.DB) error {
9705
+
9706
+	//查找患者最后一条的退库数据是否满足要求
9707
+	var out_count int64
9708
+	goodOutInfo, _ := GetGoodWarehouseOutInfoByProjectIdThree(project.PatientId, project.UserOrgId, project.RecordDate, project.ProjectId, tx)
9709
+
9710
+	out_count = goodOutInfo.Count
9711
+
9712
+	//如果最后1条出库数量大于退库数量,则直接退库,满足退库要求
9713
+	if out_count >= cha_count {
9714
+
9715
+		//减去出库单里面的数量
9716
+		ModifyGoodAuToWarehouseOut(goodOutInfo.ID, cha_count, tx)
9717
+
9718
+		if out_count == cha_count {
9719
+			//删除该出库单
9720
+			DeleteGoodWarehouseAutoByNumberTwo(goodOutInfo.ID, tx)
9721
+		}
9722
+	}
9723
+
9724
+	//如果出库的数据小于这个退库的数量差,则先该批次出库数量出完
9725
+	if out_count < cha_count {
9726
+
9727
+		//删除该出库单
9728
+		DeleteGoodWarehouseAutoByNumberTwo(goodOutInfo.ID, tx)
9729
+
9730
+		//计算还有多少没有退库
9731
+		var over_count = cha_count - out_count
9732
+
9733
+		NewHisGoodAutoCancelInfo(orgID, creater, project, over_count, good, tx)
9734
+	}
9735
+	return err
9736
+}