Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 7 months ago
parent
commit
17b0f352ce
34 changed files with 1977 additions and 719 deletions
  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 View File

@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10489 //机构id
86
+		subscibe.OrgId = 10666 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,8 +93,8 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 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 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
100 100
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10489 //机构id小英9675或4
332
+		subscibe.OrgId = 10666 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,8 +339,8 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 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 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes
346 346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 55 - 6
controllers/dialysis_api_controller.go View File

@@ -4421,6 +4421,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4421 4421
 	//获取上次的透后体重
4422 4422
 	//	assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4423 4423
 	assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4424
+
4424 4425
 	//获取透析次数
4425 4426
 	_, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
4426 4427
 
@@ -4470,9 +4471,9 @@ func (c *DialysisApiController) GetDialysisOrder() {
4470 4471
 
4471 4472
 	//相关操作对应的操作人
4472 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 4477
 	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
4477 4478
 
4478 4479
 	//获取当前日期月份的第一天
@@ -4481,14 +4482,62 @@ func (c *DialysisApiController) GetDialysisOrder() {
4481 4482
 	//获取当前月份的病人透析次数
4482 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 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 4509
 	//hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
4488 4510
 	config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
4489 4511
 
4490 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 4543
 	prescriptionInfo, _ := service.GetPrescriptionInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
@@ -4525,7 +4574,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4525 4574
 			"PredialysisEvaluation":     PredialysisEvaluation,
4526 4575
 			"AssessmentAfterDislysis":   AssessmentAfterDislysis,
4527 4576
 			"dialysisPrescription":      dialysisPrescription,
4528
-			"advices":                   hisAdvice,
4577
+			"advices":                   his_advices_one,
4529 4578
 			"monitors":                  Record,
4530 4579
 			"summary":                   TreatmentSummary,
4531 4580
 			"receiverTreatmentAccess":   receiverTreatmentAccess,
@@ -4550,7 +4599,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
4550 4599
 			"dialysiscount":             dialysiscount,
4551 4600
 			"last_order":                lastOrder,
4552 4601
 			"project_config":            project_config,
4553
-			"projects":                  projects,
4602
+			"projects":                  projectsOne,
4554 4603
 			"prescriptionInfo":          prescriptionInfo,
4555 4604
 			"patientDiagnose":           patientDiagnose,
4556 4605
 			"lastSchedule":              lastSchedule,

+ 10 - 1
controllers/dialysis_record_api_controller.go View File

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

+ 7 - 0
controllers/drug_stock_api_contorller.go View File

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

+ 7 - 5
controllers/gobal_config_api_controller.go View File

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

+ 13 - 4
controllers/his_api_controller.go View File

@@ -2998,7 +2998,7 @@ func (c *HisApiController) CreateHisPrescription() {
2998 2998
 
2999 2999
 											}
3000 3000
 
3001
-											//service.DeleteAutoWarehouse(patient_id, recordDateTime)
3001
+											service.DeleteAutoWarehouse(patient_id, recordDateTime)
3002 3002
 
3003 3003
 										}
3004 3004
 
@@ -3051,7 +3051,7 @@ func (c *HisApiController) CreateHisPrescription() {
3051 3051
 													service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, item.OrgId)
3052 3052
 												}
3053 3053
 
3054
-												//service.DeleteAutoWarehouse(patient_id, recordDateTime)
3054
+												service.DeleteAutoWarehouse(patient_id, recordDateTime)
3055 3055
 
3056 3056
 											}
3057 3057
 
@@ -3181,7 +3181,7 @@ func (c *HisApiController) CreateHisPrescription() {
3181 3181
 	var adviceList []models.HisDoctorAdviceInfo
3182 3182
 	var projectList []models.HisPrescriptionProject
3183 3183
 
3184
-	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 {
3184
+	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 {
3185 3185
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3186 3186
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3187 3187
 
@@ -4442,7 +4442,11 @@ func (c *HisApiController) CreateHisPrescription() {
4442 4442
 										s.Price = lastWarehouse.RetailPrice
4443 4443
 									}
4444 4444
 									if s.Price == 0 {
4445
-										s.Price = lastWarehouse.RetailPrice
4445
+										if lastWarehouse.ID == 0 {
4446
+											lastWarehouseTwo, _ := service.FindLastDrugWarehousingInfoByIDTwo(s.DrugId, storeConfig.DrugStorehouseOut)
4447
+											s.Price = lastWarehouseTwo.RetailPrice
4448
+										}
4449
+
4446 4450
 									}
4447 4451
 								}
4448 4452
 
@@ -4529,6 +4533,11 @@ func (c *HisApiController) CreateHisPrescription() {
4529 4533
 										if p.Price != lastWarehouse.PackingPrice {
4530 4534
 											p.Price = lastWarehouse.PackingPrice
4531 4535
 										}
4536
+										if p.Price == 0 {
4537
+											lastWarehouseTwo, _ := service.FindFirstWarehousingInfoByStockFour(p.ProjectId, storeConfig.DrugStorehouseOut)
4538
+											p.Price = lastWarehouseTwo.PackingPrice
4539
+										}
4540
+
4532 4541
 										if p.Unit == "" {
4533 4542
 											goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4534 4543
 											p.Unit = goodInfoOne.PackingUnit

+ 8 - 7
controllers/manage_api_controller.go View File

@@ -1,17 +1,18 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+	"unsafe"
9
+
4 10
 	"XT_New/enums"
5 11
 	"XT_New/models"
6 12
 	"XT_New/service"
7 13
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10 14
 	"github.com/astaxie/beego"
11 15
 	"github.com/jinzhu/gorm"
12
-	"strconv"
13
-	"time"
14
-	"unsafe"
15 16
 )
16 17
 
17 18
 type MachineApiController struct {
@@ -5400,9 +5401,9 @@ func (this *MachineApiController) GetObjectDisInfectionLongTime() {
5400 5401
 
5401 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 5408
 	for _, dialysisOrder := range list {
5408 5409
 

+ 145 - 403
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -505,6 +505,7 @@ func (this *DialysisAPIController) DialysisRecord() {
505 505
 	go func() {
506 506
 		// 先走redis,没有走数据库
507 507
 		projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
508
+
508 509
 		ch <- struct{}{}
509 510
 	}()
510 511
 
@@ -561,6 +562,23 @@ func (this *DialysisAPIController) DialysisRecord() {
561 562
 
562 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 583
 	if adminInfo.Org.Id == 10666 || adminInfo.Org.Id == 10644 {
566 584
 		if len(projects) > 0 {
@@ -584,25 +602,6 @@ func (this *DialysisAPIController) DialysisRecord() {
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 605
 	team_projects = RemoveRepeatedCheckRecod(team_projects)
607 606
 
608 607
 	stockType, _ = service.GetStockType(adminInfo.Org.Id)
@@ -3169,6 +3168,7 @@ func (this *DialysisAPIController) StartDialysis() {
3169 3168
 	order_remark := this.GetString("order_remark")
3170 3169
 	catheter_operation := this.GetString("catheter_operation")
3171 3170
 	blood_flow_volume := this.GetString("blood_flow_volume")
3171
+	dialysis_strainer := this.GetString("dialysis_strainer")
3172 3172
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
3173 3173
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3174 3174
 		return
@@ -3390,6 +3390,7 @@ func (this *DialysisAPIController) StartDialysis() {
3390 3390
 		CatheterOperation:      catheter_operation,
3391 3391
 		BloodFlowVolume:        blood_flow_volume,
3392 3392
 		BloodDrawing:           blood_drawing,
3393
+		DialysisStrainer:       dialysis_strainer,
3393 3394
 	}
3394 3395
 	//查询该床位是否有人用了
3395 3396
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
@@ -3461,6 +3462,8 @@ func (this *DialysisAPIController) StartDialysis() {
3461 3462
 	//}
3462 3463
 
3463 3464
 	var ultrafiltration_rate float64
3465
+
3466
+	var ultrafiltration_rate_one string
3464 3467
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3465 3468
 	//后期预增脱水量
3466 3469
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
@@ -3558,10 +3561,12 @@ func (this *DialysisAPIController) StartDialysis() {
3558 3561
 			if adminUserInfo.Org.Id == 10693 {
3559 3562
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3560 3563
 				ultrafiltration_rate = ultrafiltration_rate
3564
+				ultrafiltration_rate_one = strconv.FormatFloat(ultrafiltration_rate, 'f', -1, 64)
3565
+
3561 3566
 			}
3562 3567
 
3563 3568
 			if adminUserInfo.Org.Id == 10694 || adminUserInfo.Org.Id == 10697 {
3564
-				fmt.Println("hahahahhahahahahah")
3569
+
3565 3570
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3566 3571
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3567 3572
 			}
@@ -3576,13 +3581,14 @@ func (this *DialysisAPIController) StartDialysis() {
3576 3581
 		MonitoringDate:  schedulestartTime,
3577 3582
 		OperateTime:     startDate.Unix(),
3578 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,6 +4743,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4737 4743
 	catheter_operation := this.GetString("catheter_operation")
4738 4744
 	blood_flow_volume := this.GetString("blood_flow_volume")
4739 4745
 	blood_drawing, _ := this.GetInt64("blood_drawing")
4746
+	dialysis_strainer := this.GetString("dialysis_strainer")
4740 4747
 	if record_id == 0 {
4741 4748
 		this.ErrorLog("id:%v", record_id)
4742 4749
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -4904,6 +4911,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4904 4911
 		CatheterOperation:      catheter_operation,
4905 4912
 		BloodFlowVolume:        blood_flow_volume,
4906 4913
 		BloodDrawing:           blood_drawing,
4914
+		DialysisStrainer:       dialysis_strainer,
4907 4915
 	}
4908 4916
 
4909 4917
 	//修改床位号需要重新消毒
@@ -6242,6 +6250,7 @@ func (c *DialysisAPIController) CreateConsumables() {
6242 6250
 						service.CreateGoodErrcode(goodErrcode)
6243 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 6256
 				if item.Count < his_count {
@@ -6259,11 +6268,14 @@ func (c *DialysisAPIController) CreateConsumables() {
6259 6268
 						Mtime:      time.Now().Unix(),
6260 6269
 						PatientId:  item.PatientId,
6261 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 6281
 				if item.Count == his_count {
@@ -6290,6 +6302,7 @@ func (c *DialysisAPIController) CreateConsumables() {
6290 6302
 						}
6291 6303
 						//出库
6292 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,6 +6437,7 @@ func (c *DialysisAPIController) CreateConsumables() {
6424 6437
 						service.CreateGoodErrcode(goodErrcode)
6425 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 6443
 				if item.Count < his_count {
@@ -6441,11 +6455,14 @@ func (c *DialysisAPIController) CreateConsumables() {
6441 6455
 						Mtime:      time.Now().Unix(),
6442 6456
 						PatientId:  item.PatientId,
6443 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 6468
 				if item.Count == his_count {
@@ -6472,6 +6489,8 @@ func (c *DialysisAPIController) CreateConsumables() {
6472 6489
 						}
6473 6490
 						//出库
6474 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,6 +6630,13 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6611 6630
 				}
6612 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 6640
 				prepare := &models.DialysisBeforePrepare{
6615 6641
 					GoodTypeId:   good_type_id,
6616 6642
 					GoodId:       good_id,
@@ -6622,6 +6648,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6622 6648
 					Ctime:        time.Now().Unix(),
6623 6649
 					Creater:      adminInfo.AdminUser.Id,
6624 6650
 					StorehouseId: houseConfig.StorehouseOutInfo,
6651
+					ProjectId:    project_id,
6625 6652
 				}
6626 6653
 
6627 6654
 				consumables = append(consumables, prepare)
@@ -6636,8 +6663,8 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6636 6663
 		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6637 6664
 		//查询是否有库存
6638 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 6669
 			if item.Count > warehouse.Count {
6643 6670
 				goodErrcode := models.XtGoodErrcode{
@@ -6655,7 +6682,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6655 6682
 				}
6656 6683
 				service.CreateGoodErrcode(goodErrcode)
6657 6684
 
6658
-				goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
6685
+				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
6659 6686
 				c.ServeSuccessJSON(map[string]interface{}{
6660 6687
 					"message":            "1",
6661 6688
 					"good_name":          goodObj.GoodName,
@@ -6668,7 +6695,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6668 6695
 		//查询是否有出库单
6669 6696
 		_, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
6670 6697
 
6671
-		fmt.Println("err000000000000000000000000000000000000000000", err)
6672 6698
 		if err == gorm.ErrRecordNotFound {
6673 6699
 			//没有记录,则创建出库单
6674 6700
 			timeStr := time.Now().Format("2006-01-02")
@@ -6727,7 +6753,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6727 6753
 					}
6728 6754
 				}()
6729 6755
 				for _, item := range consumables {
6730
-
6731 6756
 					//出库
6732 6757
 					if item.Count > 0 {
6733 6758
 						timeStr := time.Now().Format("2006-01-02")
@@ -6769,13 +6794,13 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6769 6794
 
6770 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 6798
 						houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
6774 6799
 
6775 6800
 						dialyPrepareOne := models.DialysisBeforePrepare{
6776 6801
 							GoodTypeId:   goodObj.GoodTypeId,
6777
-							GoodId:       item.ProjectId,
6778
-							PatientId:    item.PatientId,
6802
+							GoodId:       item.GoodId,
6803
+							PatientId:    patient_id,
6779 6804
 							RecordDate:   record_time,
6780 6805
 							UserOrgId:    adminInfo.Org.Id,
6781 6806
 							Count:        item.Count,
@@ -6805,180 +6830,50 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6805 6830
 							service.CreateGoodErrcode(goodErrcode)
6806 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 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 6844
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
6814 6845
 
6815 6846
 						newPrescriptionProject := &models.HisPrescriptionProject{
6816 6847
 							ID:         item.ProjectId,
6817
-							ProjectId:  item.ProjectId,
6848
+							ProjectId:  item.GoodId,
6818 6849
 							UserOrgId:  adminInfo.Org.Id,
6819 6850
 							Status:     1,
6820 6851
 							Ctime:      time.Now().Unix(),
6821 6852
 							Mtime:      time.Now().Unix(),
6822
-							PatientId:  item.PatientId,
6853
+							PatientId:  patient_id,
6823 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 6867
 					var sum_count int64
6973 6868
 					for _, item := range goodList {
6974 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,144 +6894,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
6999 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 6899
 				if item.Count > 0 {
@@ -7179,13 +6936,13 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
7179 6936
 
7180 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 6940
 					houseConfig, _ := service.GetNewAllStoreHouseConfig(adminInfo.Org.Id, tx)
7184 6941
 
7185 6942
 					dialyPrepareOne := models.DialysisBeforePrepare{
7186 6943
 						GoodTypeId:   goodObj.GoodTypeId,
7187
-						GoodId:       item.ProjectId,
7188
-						PatientId:    item.PatientId,
6944
+						GoodId:       item.GoodId,
6945
+						PatientId:    patient_id,
7189 6946
 						RecordDate:   record_time,
7190 6947
 						UserOrgId:    adminInfo.Org.Id,
7191 6948
 						Count:        item.Count,
@@ -7215,41 +6972,50 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
7215 6972
 						service.CreateGoodErrcode(goodErrcode)
7216 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 6980
 				if item.Count < 0 {
7222
-					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
6981
+					goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
7223 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 6987
 					newPrescriptionProject := &models.HisPrescriptionProject{
7226 6988
 						ID:         item.ProjectId,
7227
-						ProjectId:  item.ProjectId,
6989
+						ProjectId:  item.GoodId,
7228 6990
 						UserOrgId:  adminInfo.Org.Id,
7229 6991
 						Status:     1,
7230 6992
 						Ctime:      time.Now().Unix(),
7231 6993
 						Mtime:      time.Now().Unix(),
7232 6994
 						PatientId:  item.PatientId,
7233 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 7009
 				var sum_count int64
7244 7010
 				for _, item := range goodList {
7245 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 7021
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -7321,6 +7087,7 @@ func (c *DialysisAPIController) EditConsumables() {
7321 7087
 	//判断是否开启自动出库
7322 7088
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
7323 7089
 
7090
+	fmt.Println("record.IsOpen====================================", record)
7324 7091
 	if record.IsOpen == 1 {
7325 7092
 
7326 7093
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
@@ -7395,7 +7162,7 @@ func (c *DialysisAPIController) EditConsumables() {
7395 7162
 					var his_count int64
7396 7163
 					//查询该耗材今日出库了多少
7397 7164
 					outInfo, _ := service.GetHistoryWarehouseOutInfo(item.PatientId, adminInfo.Org.Id, record_time, item.GoodId, tx)
7398
-
7165
+					fmt.Println("outInfo---------------------------------------", outInfo)
7399 7166
 					for _, it := range outInfo {
7400 7167
 						his_count += it.Count
7401 7168
 					}
@@ -7480,12 +7247,13 @@ func (c *DialysisAPIController) EditConsumables() {
7480 7247
 							service.CreateGoodErrcode(goodErrcode)
7481 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 7253
 					if item.Count < his_count {
7486 7254
 						var cha_count int64
7487 7255
 						cha_count = his_count - item.Count
7488
-						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
7256
+						goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.GoodId, tx)
7489 7257
 						creater := c.GetMobileAdminUserInfo().AdminUser.Id
7490 7258
 
7491 7259
 						newPrescriptionProject := &models.HisPrescriptionProject{
@@ -7499,9 +7267,11 @@ func (c *DialysisAPIController) EditConsumables() {
7499 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 7277
 					if item.Count == his_count {
@@ -7528,6 +7298,8 @@ func (c *DialysisAPIController) EditConsumables() {
7528 7298
 							}
7529 7299
 							//出库
7530 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,11 +7782,12 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
8010 7782
 				Mtime:      time.Now().Unix(),
8011 7783
 				PatientId:  item.PatientId,
8012 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,6 +7833,36 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
8060 7833
 		//耗材
8061 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 7868
 	finish := models.XtDialysisFinish{
@@ -8079,67 +7882,6 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
8079 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 7886
 	var errs error
8145 7887
 	if errs == nil {

+ 13 - 4
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -1,15 +1,16 @@
1 1
 package mobile_api_controllers
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+
4 9
 	"XT_New/enums"
5 10
 	"XT_New/models"
6 11
 	"XT_New/service"
7 12
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10 13
 	"github.com/jinzhu/gorm"
11
-	"strconv"
12
-	"time"
13 14
 )
14 15
 
15 16
 // /m/api/monitor/add [post]
@@ -110,6 +111,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
110 111
 	replacement_speed, _ := this.GetFloat("replacement_speed")
111 112
 	dicarbonate, _ := this.GetFloat("dicarbonate")
112 113
 	is_pressure := this.GetString("is_pressure")
114
+	heparin_one := this.GetString("heparin_one")
115
+	ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
113 116
 	adminInfo := this.GetMobileAdminUserInfo()
114 117
 	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
115 118
 	if getPatientErr != nil {
@@ -203,6 +206,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
203 206
 		Dicarbonate:                 dicarbonate,
204 207
 		ReplacementSpeed:            replacement_speed,
205 208
 		IsPressure:                  is_pressure,
209
+		HeparinOne:                  heparin_one,
210
+		UltrafiltrationRateOne:      ultrafiltration_rate_one,
206 211
 	}
207 212
 
208 213
 	err := service.CreateMonitor(&record)
@@ -353,6 +358,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
353 358
 	replacement_speed, _ := this.GetFloat("replacement_speed")
354 359
 	dicarbonate, _ := this.GetFloat("dicarbonate")
355 360
 	is_pressure := this.GetString("is_pressure")
361
+	ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
362
+	heparin_one := this.GetString("heparin_one")
356 363
 	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
357 364
 	if err != nil {
358 365
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -413,6 +420,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
413 420
 	monitor.Dehydration = dehydration
414 421
 	monitor.FilterPressure = filter_pressure
415 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 View File

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

+ 48 - 0
controllers/patient_api_controller.go View File

@@ -130,6 +130,8 @@ func PatientApiRegistRouters() {
130 130
 
131 131
 	beego.Router("/api/patient/savetheapyinformed", &PatientApiController{}, "Post:SaveTheapyInformed")
132 132
 
133
+	beego.Router("/api/patient/savetreamentplan", &PatientApiController{}, "Post:SaveTreatmentPlan")
134
+
133 135
 	beego.Router("api/patient/gettherapyinformed", &PatientApiController{}, "Get:GetTherapyInformed")
134 136
 
135 137
 	beego.Router("/api/patient/savemedicalhistory", &PatientApiController{}, "Post:SaveMedicalHistory")
@@ -144,6 +146,8 @@ func PatientApiRegistRouters() {
144 146
 
145 147
 	beego.Router("/api/patient/deletesolution", &PatientApiController{}, "Get:DeleteSolution")
146 148
 
149
+	beego.Router("/api/patient/gettreamentplan", &PatientApiController{}, "Get:GetTreatMentPlanList")
150
+
147 151
 }
148 152
 func (c *PatientApiController) GetExportList() {
149 153
 	startTime := c.GetString("start_time")
@@ -7040,3 +7044,47 @@ func (c *PatientApiController) DeleteSolution() {
7040 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 View File

@@ -1,13 +1,14 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"XT_New/enums"
5
-	service "XT_New/service/print_data_service/schedule_dialysis"
6
-	"XT_New/utils"
7 4
 	"fmt"
8 5
 	"strings"
9 6
 	"time"
10 7
 
8
+	"XT_New/enums"
9
+	service "XT_New/service/print_data_service/schedule_dialysis"
10
+	"XT_New/utils"
11
+
11 12
 	"github.com/astaxie/beego"
12 13
 )
13 14
 
@@ -195,6 +196,9 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
195 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 204
 		if getScheduleErr != nil {

+ 707 - 0
controllers/self_drug_api_congtroller.go View File

@@ -129,6 +129,25 @@ func SelfDrugRouters() {
129 129
 	beego.Router("/api/good/getcheckgoodbatchlist", &SelfDrugApiController{}, "Get:GetCheckGoodBatchList")
130 130
 
131 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 153
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -3838,6 +3857,7 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3838 3857
 			//期间减少
3839 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 3861
 			for _, it := range banceOutList {
3842 3862
 				item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
3843 3863
 			}
@@ -4427,3 +4447,690 @@ func (this *SelfDrugApiController) GetDrugPatientName() {
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 View File

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

+ 8 - 266
controllers/stock_in_api_controller.go View File

@@ -1314,6 +1314,8 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1314 1314
 
1315 1315
 				register_number := items["register_number"].(string)
1316 1316
 
1317
+				class_type := items["class_type"].(string)
1318
+
1317 1319
 				timeLayout := "2006-01-02"
1318 1320
 				loc, _ := time.LoadLocation("Local")
1319 1321
 				var expiryDate int64
@@ -1370,6 +1372,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1370 1372
 					RegisterNumber:          register_number,
1371 1373
 					SysRecordTime:           warehouseOut.WarehouseOutTime,
1372 1374
 					PatientId:               patient_id,
1375
+					ClassType:               class_type,
1373 1376
 				}
1374 1377
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1375 1378
 
@@ -1420,6 +1423,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1420 1423
 			IsCheck:                 2,
1421 1424
 			RegisterNumber:          it.RegisterNumber,
1422 1425
 			PatientId:               it.PatientId,
1426
+			ClassType:               it.ClassType,
1423 1427
 		}
1424 1428
 		if it.ID == 0 {
1425 1429
 			service.AddSigleWarehouseOutInfo(warehouseOutInfo)
@@ -1730,6 +1734,8 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1730 1734
 
1731 1735
 				patient_id := int64(items["patient_id"].(float64))
1732 1736
 
1737
+				class_type := items["class_type"].(string)
1738
+
1733 1739
 				var productDate int64
1734 1740
 				if len(product_date) > 0 {
1735 1741
 					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
@@ -1770,6 +1776,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1770 1776
 						StockCount:              stock_count,
1771 1777
 						RegisterNumber:          register_number,
1772 1778
 						PatientId:               patient_id,
1779
+						ClassType:               class_type,
1773 1780
 					}
1774 1781
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1775 1782
 
@@ -1818,6 +1825,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1818 1825
 						StockCount:              stock_count,
1819 1826
 						RegisterNumber:          register_number,
1820 1827
 						PatientId:               patient_id,
1828
+						ClassType:               class_type,
1821 1829
 					}
1822 1830
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1823 1831
 				}
@@ -1845,271 +1853,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1845 1853
 	if len(upDateWarehouseOutInfos) > 0 {
1846 1854
 		for _, item := range upDateWarehouseOutInfos {
1847 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,7 +4881,6 @@ func (this *StockManagerApiController) GetOrderDetialByOrderId() {
5138 4881
 	orgId := this.GetAdminUserInfo().CurrentOrgId
5139 4882
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
5140 4883
 	list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
5141
-	fmt.Println("list000000000000000000000000", len(list))
5142 4884
 	stockFlowListGroup, _ := service.GetOrderDetailStockFlowByStorehouseById(idsArray, orgId)
5143 4885
 	stockFlowList, _ := service.GetOrderDetailStockFlow(idsArray, orgId)
5144 4886
 	//获取耗材退库数据

+ 3 - 0
models/dialysis.go View File

@@ -774,6 +774,8 @@ type MonitoringRecord struct {
774 774
 	ReplacementSpeed            float64 `gorm:"column:replacement_speed" json:"replacement_speed" form:"replacement_speed"`
775 775
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
776 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 781
 func (MonitoringRecord) TableName() string {
@@ -887,6 +889,7 @@ type DialysisOrder struct {
887 889
 	BloodFlowVolume            string        `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
888 890
 	Condenser                  string        `gorm:"column:condenser" json:"condenser" form:"condenser"`
889 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 895
 func (DialysisOrder) TableName() string {

+ 182 - 0
models/drug.go View File

@@ -106,6 +106,10 @@ type BaseDrugLibSeven struct {
106 106
 	IsPharmacy int64  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
107 107
 	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
108 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 115
 func (BaseDrugLibSeven) TableName() string {
@@ -297,3 +301,181 @@ type BaseDrugLibTwenty struct {
297 301
 func (BaseDrugLibTwenty) TableName() string {
298 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 View File

@@ -195,6 +195,7 @@ type DrugWarehouseOutInfo struct {
195 195
 	OverCount               int64       `gorm:"column:over_count" json:"over_count" form:"over_count"`
196 196
 	OrderId                 int64       `gorm:"column:order_id" json:"order_id" form:"order_id"`
197 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 201
 func (DrugWarehouseOutInfo) TableName() string {
@@ -713,6 +714,7 @@ type DrugWarehouseOutInfoNight struct {
713 714
 	Drug                    BaseDrugLibSeven `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
714 715
 	OverCount               int64            `gorm:"column:over_count" json:"over_count" form:"over_count"`
715 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 720
 func (DrugWarehouseOutInfoNight) TableName() string {

+ 0 - 1
models/new_stock_models.go View File

@@ -292,7 +292,6 @@ type GoodInfoTwenty struct {
292 292
 	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`   //减少
293 293
 	WareStartInStockFlow  []*VmStockFlowTwenty     `gorm:"json:"new_stock_in_flow"`        //盘盈
294 294
 	WareStartOutStockFlow []*VmStockFlowTwenty     `gorm:"json:"new_stock_out_flow"`       //盘亏
295
-
296 295
 	//期初结余
297 296
 	StartFlowInfo    []*VmStockFlowTwenty
298 297
 	StartOutFlowInfo []*VmStockFlowTwenty

+ 14 - 0
models/patient_models.go View File

@@ -2750,3 +2750,17 @@ type NewInspection struct {
2750 2750
 	Count           int64
2751 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 View File

@@ -706,6 +706,7 @@ type VmDrugWarehouseOutInfo struct {
706 706
 	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
707 707
 	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
708 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 712
 type XtDrugAdjustPrice struct {

+ 2 - 0
models/stock_models.go View File

@@ -305,6 +305,7 @@ type WarehouseOutInfo struct {
305 305
 	OrderId                 int64                `gorm:"column:order_id" json:"order_id" form:"order_id"`
306 306
 	WarehousingInfoNight    WarehousingInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId"`
307 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 311
 func (WarehouseOutInfo) TableName() string {
@@ -574,6 +575,7 @@ type WarehouseOutInfoOne struct {
574 575
 	StockCount                  string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
575 576
 	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
576 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 581
 type WarehouseOutInfoTwo struct {

+ 52 - 1
service/dialysis_service.go View File

@@ -891,6 +891,14 @@ func GetAdminUserEsOne(orgid int64) (admin []*models.UserAdminRoles, err error)
891 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 902
 func UpDateDialysisPrescriptionDoctorSign(patient int64, date int64, orgId int64, doctor_id int64) (err error) {
895 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 904
 	return
@@ -1508,7 +1516,7 @@ func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1508 1516
 
1509 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 1521
 	return goodinfo, err
1514 1522
 }
@@ -2512,3 +2520,46 @@ func GetHistoryWarehouseOutInfo(patient_id int64, user_org_id int64, record_time
2512 2520
 	}
2513 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 View File

@@ -941,7 +941,7 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
941 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 945
 	return info, err
946 946
 }
947 947
 

+ 1 - 1
service/his_project_service.go View File

@@ -245,7 +245,7 @@ func DeleteProjectList(id int64) error {
245 245
 
246 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 249
 	return project, err
250 250
 }
251 251
 

+ 35 - 4
service/his_service.go View File

@@ -876,11 +876,29 @@ func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
876 876
 }
877 877
 
878 878
 func GetAllDrugLibListSix(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
879
-	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 {
880
-		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)
881
-	}).Find(&list).Error
879
+	if org_id == 10598 {
880
+		err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
881
+			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)
882
+		}).Order("sort asc").Find(&list).Error
883
+
884
+		return
885
+	} else {
886
+		if org_id == 10489 {
887
+			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 {
888
+				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)
889
+			}).Order("sort asc").Find(&list).Error
890
+
891
+			return
892
+		} else {
893
+			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 {
894
+				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)
895
+			}).Order("sort asc").Find(&list).Error
896
+
897
+			return
898
+		}
899
+
900
+	}
882 901
 
883
-	return
884 902
 }
885 903
 
886 904
 func GetAllDrugLibListSeven(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
@@ -3424,6 +3442,19 @@ func GetGoodWarehouseOutInfoByProjectIdTwo(patient_id int64, user_org_id int64,
3424 3442
 	return outInfo, err
3425 3443
 }
3426 3444
 
3445
+func GetGoodWarehouseOutInfoByProjectIdThree(patient_id int64, user_org_id int64, sys_record_date int64, drug_id int64, tx *gorm.DB) (models.WarehouseOutInfo, error) {
3446
+
3447
+	outInfo := models.WarehouseOutInfo{}
3448
+	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
3449
+	if err != gorm.ErrRecordNotFound {
3450
+		if err != nil {
3451
+			tx.Rollback()
3452
+			return outInfo, err
3453
+		}
3454
+	}
3455
+	return outInfo, err
3456
+}
3457
+
3427 3458
 func DeleteGoodWarehouseOutInfoByNumber(id int64, tx *gorm.DB) error {
3428 3459
 
3429 3460
 	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 View File

@@ -2251,7 +2251,7 @@ func BatchUpdateMonitors(monitors []*models.MonitoringRecord) error {
2251 2251
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2252 2252
 	tx := writeDb.Begin()
2253 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 2255
 	if err != nil {
2256 2256
 		tx.Rollback()
2257 2257
 		return err
@@ -2924,6 +2924,7 @@ type AutomaticReduceDetail struct {
2924 2924
 	VMGoodInfo VMGoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
2925 2925
 	GoodsType  GoodsType  `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
2926 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 2930
 func (AutomaticReduceDetail) TableName() string {

+ 31 - 0
service/new_stock_service.go View File

@@ -649,3 +649,34 @@ func GetDrugNewInventoryList(org_id int64, keyword string) (drug []*models.BaseD
649 649
 
650 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 View File

@@ -4074,3 +4074,26 @@ func GetDialysisTotalCountByTime(user_org_id int64, start_time int64, end_time i
4074 4074
 
4075 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 View File

@@ -111,6 +111,7 @@ type DialysisOrderVM struct {
111 111
 	PunctureWay        string          `gorm:"column:puncture_way" json:"puncture_way" form:"puncture_way"`
112 112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
113 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 117
 func (DialysisOrderVM) TableName() string {
@@ -577,6 +578,8 @@ type MonitoringRecordVM struct {
577 578
 	FilterPressure              string  `gorm:"column:filter_pressure" json:"filter_pressure" form:"filter_pressure"`
578 579
 	Dicarbonate                 float64 `gorm:"column:dicarbonate" json:"dicarbonate" form:"dicarbonate"`
579 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 585
 func (MonitoringRecordVM) TableName() string {

+ 293 - 0
service/self_drug_service.go View File

@@ -3071,6 +3071,29 @@ func GetInitBalanceList(good_id int64, user_org_id int64, start_time int64, end_
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 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 3099
 	db := XTReadDB().Model(&list).Where("status=1")
@@ -3445,3 +3468,273 @@ func UpdateGoodInfoByIdOne(id int64, total_count_one int64) error {
3445 3468
 
3446 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 View File

@@ -2112,7 +2112,7 @@ func UpdateAllPatient(id int64, diagose string, orgid int64) error {
2112 2112
 
2113 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 2117
 	return list, err
2118 2118
 }

+ 3 - 2
service/stock_service.go View File

@@ -1871,6 +1871,7 @@ type DrugWarehouseOutInfo struct {
1871 1871
 	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
1872 1872
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1873 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 1877
 func (DrugWarehouseOutInfo) TableName() string {
@@ -4588,7 +4589,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4588 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 4594
 	return out, err
4594 4595
 }
@@ -8120,7 +8121,7 @@ func UpdateDrugWarehouseInfoTwenty(id int64, info *models.DrugWarehouseInfo) err
8120 8121
 
8121 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 8125
 	return err
8125 8126
 }
8126 8127
 

+ 292 - 0
service/warhouse_service.go View File

@@ -9442,3 +9442,295 @@ func HisFaDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvi
9442 9442
 
9443 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
+}