Browse Source

2024/6/17

28169 4 days ago
parent
commit
b94fce09b3

BIN
XT_New.exe View File


+ 4 - 4
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 = 10164 //机构id
86
+		subscibe.OrgId = 10028 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,7 +93,7 @@ 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 = 10164 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10028 //机构id小英9675或4
97 97
 		adminUserInfo.CurrentAppId = 12123 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
@@ -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 = 10164 //机构id小英9675或4
332
+		subscibe.OrgId = 10028 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ 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 = 10164 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10028 //机构id小英9675或4
343 343
 		adminUserInfo.CurrentAppId = 12123 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 8 - 8
controllers/drug_stock_api_contorller.go View File

@@ -13,7 +13,6 @@ import (
13 13
 	"XT_New/service"
14 14
 	"XT_New/utils"
15 15
 	"github.com/astaxie/beego"
16
-	"github.com/jinzhu/gorm"
17 16
 )
18 17
 
19 18
 type StockDrugApiController struct {
@@ -3280,10 +3279,6 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3280 3279
 
3281 3280
 	warehousing_id, _ := c.GetInt64("warehousing_id")
3282 3281
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3283
-	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3284
-
3285
-	checker := c.GetAdminUserInfo().AdminUser.Id
3286
-
3287 3282
 	// 开始外部循环的事务
3288 3283
 	db := service.XTWriteDB()
3289 3284
 	tx := db.Begin()
@@ -3294,6 +3289,9 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3294 3289
 			tx.Rollback()
3295 3290
 		}
3296 3291
 	}()
3292
+	houseConfig, _ := service.GetNewAllStoreHouseConfig(orgId, tx)
3293
+
3294
+	checker := c.GetAdminUserInfo().AdminUser.Id
3297 3295
 
3298 3296
 	//更改核对状态
3299 3297
 	service.CheckNewWarehousingInfo(warehousing_id, orgId, checker, tx)
@@ -3392,8 +3390,9 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3392 3390
 			over_count += it.StockMaxNumber + it.StockMinNumber
3393 3391
 		}
3394 3392
 		//查询该仓库是否有默认数据
3395
-		_, errcode := service.GetNewDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId, tx)
3396
-		if errcode == gorm.ErrRecordNotFound {
3393
+		drugStockCount, _ := service.GetNewDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId, tx)
3394
+		fmt.Println("errcode======================", drugStockCount.ID)
3395
+		if drugStockCount.ID == 0 {
3397 3396
 			drugStock := models.XtDrugStockCount{
3398 3397
 				UserOrgId:      item.OrgId,
3399 3398
 				StorehouseId:   item.StorehouseId,
@@ -3409,7 +3408,8 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3409 3408
 			}
3410 3409
 			service.CreateNewDrugStockSum(drugStock, tx)
3411 3410
 
3412
-		} else if errcode == nil {
3411
+		}
3412
+		if drugStockCount.ID > 0 {
3413 3413
 			service.UpdateNewDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count, tx)
3414 3414
 		}
3415 3415
 	}

+ 144 - 36
controllers/his_api_controller.go View File

@@ -3619,7 +3619,6 @@ func (c *HisApiController) CreateHisPrescription() {
3619 3619
 
3620 3620
 					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
3621 3621
 						advices := items["advices"].([]interface{})
3622
-						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
3623 3622
 						groupNo := int64(0)
3624 3623
 						if len(advices) > 0 {
3625 3624
 							for _, advice := range advices {
@@ -3695,6 +3694,7 @@ func (c *HisApiController) CreateHisPrescription() {
3695 3694
 									if drugOutConfig.IsOpen == 1 {
3696 3695
 
3697 3696
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
3697
+
3698 3698
 										// 查询该药品最后一次出库记录
3699 3699
 										druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3700 3700
 
@@ -3741,6 +3741,110 @@ func (c *HisApiController) CreateHisPrescription() {
3741 3741
 
3742 3742
 										}
3743 3743
 
3744
+										//库存不足
3745
+										if s.UserOrgId != 10206 {
3746
+											if s.ID == 0 {
3747
+												//查询改药品是否已经停用
3748
+												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
3749
+
3750
+												if base.ID > 0 {
3751
+													tx.Rollback()
3752
+													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3753
+													return
3754
+
3755
+												}
3756
+
3757
+												drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
3758
+
3759
+												if drugMedical.SumCount == 0 {
3760
+													tx.Rollback()
3761
+													c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3762
+													return
3763
+
3764
+												}
3765
+
3766
+												//针对康德
3767
+												if s.UserOrgId == 10402 || s.UserOrgId == 10164 {
3768
+													//获取该药品的总入库数量
3769
+													drugWarehouseinfo, _ := service.GetAllDrugInfoList(s.DrugId, s.UserOrgId)
3770
+
3771
+													//获取该药品总共开了多少支医嘱
3772
+													hisDocInfoList, _ := service.GetHisDocInfoList(s.DrugId, s.UserOrgId)
3773
+													var in_count int64
3774
+													var in_prescription_number_total int64
3775
+													if len(drugWarehouseinfo) > 0 {
3776
+														for _, item := range drugWarehouseinfo {
3777
+															if item.MaxUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3778
+
3779
+																in_count += item.WarehousingCount * drugMedical.MinNumber
3780
+															}
3781
+
3782
+															if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3783
+
3784
+																in_count += item.WarehousingCount
3785
+															}
3786
+
3787
+															if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3788
+
3789
+																in_count += item.WarehousingCount
3790
+															}
3791
+
3792
+														}
3793
+													}
3794
+
3795
+													if len(hisDocInfoList) > 0 {
3796
+
3797
+														for _, item := range hisDocInfoList {
3798
+															if item.PrescribingNumberUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3799
+																prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3800
+																prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3801
+
3802
+																in_prescription_number_total += prescribingNumberSevenTy * drug.MinNumber
3803
+															}
3804
+
3805
+															if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3806
+																prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3807
+																prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3808
+																in_prescription_number_total += prescribingNumberSevenTy
3809
+															}
3810
+
3811
+															if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3812
+																prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3813
+																prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3814
+																in_prescription_number_total += prescribingNumberSevenTy
3815
+															}
3816
+														}
3817
+													}
3818
+													//
3819
+													//fmt.Println("no_user_total------------------------------", no_user_total)
3820
+													//fmt.Println("in_prescription_number_total---------------------------", in_prescription_number_total)
3821
+													//fmt.Println("in_count----------------------------------", in_count)
3822
+
3823
+													//如果已经开过的医嘱 加上未开的医嘱数量 大于 入库总数量则提示库存不足
3824
+													if no_user_total+in_prescription_number_total > in_count {
3825
+														tx.Rollback()
3826
+														c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3827
+														return
3828
+													}
3829
+
3830
+												}
3831
+
3832
+												//查询该药品所有入库数量
3833
+
3834
+											}
3835
+											if s.ID > 0 {
3836
+												//查询改药品是否已经停用
3837
+												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
3838
+
3839
+												if base.ID > 0 {
3840
+													tx.Rollback()
3841
+													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3842
+													return
3843
+
3844
+												}
3845
+											}
3846
+										}
3847
+
3744 3848
 										//fmt.Println("药品名称----------------------", drug.DrugName)
3745 3849
 										//fmt.Println("药品名称----------------------", drug.IsUse)
3746 3850
 										//fmt.Println("is_user_total-------------------------", is_user_total)
@@ -4127,40 +4231,6 @@ func (c *HisApiController) CreateHisPrescription() {
4127 4231
 								timeFormat := tempTime.Format("20060102150405")
4128 4232
 								s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
4129 4233
 
4130
-								if s.UserOrgId != 10206 {
4131
-									if s.ID == 0 {
4132
-										//查询改药品是否已经停用
4133
-										base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
4134
-
4135
-										if base.ID > 0 {
4136
-											tx.Rollback()
4137
-											c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
4138
-											return
4139
-
4140
-										}
4141
-
4142
-										drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
4143
-
4144
-										if drugMedical.SumCount == 0 {
4145
-											tx.Rollback()
4146
-											c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
4147
-											return
4148
-
4149
-										}
4150
-									}
4151
-									if s.ID > 0 {
4152
-										//查询改药品是否已经停用
4153
-										base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
4154
-
4155
-										if base.ID > 0 {
4156
-											tx.Rollback()
4157
-											c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
4158
-											return
4159
-
4160
-										}
4161
-									}
4162
-								}
4163
-
4164 4234
 								//赤峰
4165 4235
 								if adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10489 {
4166 4236
 
@@ -4313,7 +4383,7 @@ func (c *HisApiController) CreateHisPrescription() {
4313 4383
 								if p.PatientId != 30038 {
4314 4384
 
4315 4385
 									//用机构ID区分
4316
-									if adminInfo.CurrentOrgId != 9671 && adminInfo.CurrentOrgId != 10164 {
4386
+									if adminInfo.CurrentOrgId != 9671 {
4317 4387
 										if goodOutConfig.IsOpen == 1 {
4318 4388
 											//耗材出库
4319 4389
 											if p.Type == 3 {
@@ -4326,6 +4396,44 @@ func (c *HisApiController) CreateHisPrescription() {
4326 4396
 
4327 4397
 												nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
4328 4398
 
4399
+												//针对康德
4400
+												if p.UserOrgId == 10164 || p.UserOrgId == 10402 {
4401
+
4402
+													//查询耗材的总入库数量
4403
+													warehouseInfo, _ := service.GetAllWarehouseInfo(p.ProjectId, adminInfo.CurrentOrgId)
4404
+
4405
+													//查询该耗材的总出库数量
4406
+													prescriptionGood, _ := service.GetHisPrescriptionByGoodId(p.ProjectId, adminInfo.CurrentOrgId)
4407
+
4408
+													var all_good_count int64
4409
+
4410
+													var prescription_count int64
4411
+													if len(warehouseInfo) > 0 {
4412
+
4413
+														for _, item := range warehouseInfo {
4414
+															all_good_count += item.WarehousingCount
4415
+														}
4416
+													}
4417
+													if len(prescriptionGood) > 0 {
4418
+														for _, item := range prescriptionGood {
4419
+
4420
+															hisCount, _ := strconv.ParseInt(item.Count, 10, 64)
4421
+															prescription_count += hisCount
4422
+														}
4423
+													}
4424
+
4425
+													fmt.Println("prescription_count-------------------------", prescription_count)
4426
+													fmt.Println("nowCount-------------------------", nowCount)
4427
+													fmt.Println("all_good_count-------------------------", all_good_count)
4428
+
4429
+													if prescription_count+nowCount > all_good_count {
4430
+														goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4431
+														tx.Rollback()
4432
+														c.ServeDynamicFailJsonSend(goodInfoOne.GoodName + "耗材无库存,保存失败!")
4433
+														return
4434
+													}
4435
+												}
4436
+
4329 4437
 												//如果当前处方数量大于历史数据,则需要出库
4330 4438
 												if nowCount > historyCount {
4331 4439
 

+ 225 - 0
controllers/patient_api_controller.go View File

@@ -210,6 +210,20 @@ func PatientApiRegistRouters() {
210 210
 
211 211
 	beego.Router("/api/patient/getpatientrescuerecordlist", &PatientApiController{}, "Get:GetPatientRescureRecordList")
212 212
 
213
+	beego.Router("/api/patient/getmonitorsearchlist", &PatientApiController{}, "Get:GetMonitorSearchList")
214
+
215
+	beego.Router("/api/patient/getsummarysearchlist", &PatientApiController{}, "Get:GetSummarySearchList")
216
+
217
+	beego.Router("/api/patient/getpatientdryweightlist", &PatientApiController{}, "Get:GetPatientDryWeightList")
218
+
219
+	beego.Router("/api/patient/getdialysissystemlist", &PatientApiController{}, "Get:GetDialysisSystemList")
220
+
221
+	beego.Router("/api/patient/getpatientadvicelist", &PatientApiController{}, "Get:GetPatientAdviceList")
222
+
223
+	beego.Router("/api/patient/getpatientinspectionlist", &PatientApiController{}, "Get:GetPatientInspectionList")
224
+
225
+	beego.Router("/api/patient/getinspectionbyprojectid", &PatientApiController{}, "Get:GetInspectionByProjectId")
226
+
213 227
 }
214 228
 func (c *PatientApiController) GetExportList() {
215 229
 	startTime := c.GetString("start_time")
@@ -8723,3 +8737,214 @@ func (this *PatientApiController) GetPatientRescureRecordList() {
8723 8737
 		"operators":        operators,
8724 8738
 	})
8725 8739
 }
8740
+
8741
+func (this *PatientApiController) GetMonitorSearchList() {
8742
+
8743
+	timeLayout := "2006-01-02"
8744
+	loc, _ := time.LoadLocation("Local")
8745
+	start_time := this.GetString("start_time")
8746
+	end_time := this.GetString("end_time")
8747
+	patient_id, _ := this.GetInt64("patient_id")
8748
+
8749
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8750
+	var startTime int64
8751
+	if len(start_time) > 0 {
8752
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8753
+		if err != nil {
8754
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8755
+			return
8756
+		}
8757
+		startTime = theTime.Unix()
8758
+	}
8759
+
8760
+	var endTime int64
8761
+	if len(end_time) > 0 {
8762
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8763
+		if err != nil {
8764
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8765
+			return
8766
+		}
8767
+		endTime = theTime.Unix()
8768
+	}
8769
+
8770
+	monitorList, _ := service.GetMonitorSearchList(patient_id, orgId, startTime, endTime)
8771
+
8772
+	this.ServeSuccessJSON(map[string]interface{}{
8773
+		"monitorList": monitorList,
8774
+	})
8775
+
8776
+}
8777
+
8778
+func (this *PatientApiController) GetSummarySearchList() {
8779
+
8780
+	timeLayout := "2006-01-02"
8781
+	loc, _ := time.LoadLocation("Local")
8782
+	start_time := this.GetString("start_time")
8783
+	end_time := this.GetString("end_time")
8784
+	patient_id, _ := this.GetInt64("patient_id")
8785
+
8786
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8787
+	var startTime int64
8788
+	if len(start_time) > 0 {
8789
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8790
+		if err != nil {
8791
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8792
+			return
8793
+		}
8794
+		startTime = theTime.Unix()
8795
+	}
8796
+
8797
+	var endTime int64
8798
+	if len(end_time) > 0 {
8799
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8800
+		if err != nil {
8801
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8802
+			return
8803
+		}
8804
+		endTime = theTime.Unix()
8805
+	}
8806
+
8807
+	summaryList, _ := service.GetSummarySearchList(patient_id, orgId, startTime, endTime)
8808
+
8809
+	this.ServeSuccessJSON(map[string]interface{}{
8810
+		"summaryList": summaryList,
8811
+	})
8812
+}
8813
+
8814
+func (this *PatientApiController) GetPatientDryWeightList() {
8815
+
8816
+	timeLayout := "2006-01-02"
8817
+	loc, _ := time.LoadLocation("Local")
8818
+	start_time := this.GetString("start_time")
8819
+	end_time := this.GetString("end_time")
8820
+	patient_id, _ := this.GetInt64("patient_id")
8821
+
8822
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8823
+	var startTime int64
8824
+	if len(start_time) > 0 {
8825
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8826
+		if err != nil {
8827
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8828
+			return
8829
+		}
8830
+		startTime = theTime.Unix()
8831
+	}
8832
+
8833
+	var endTime int64
8834
+	if len(end_time) > 0 {
8835
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8836
+		if err != nil {
8837
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8838
+			return
8839
+		}
8840
+		endTime = theTime.Unix()
8841
+	}
8842
+
8843
+	dryWeightList, _ := service.GetPatientDryWeightList(patient_id, orgId, startTime, endTime)
8844
+
8845
+	this.ServeSuccessJSON(map[string]interface{}{
8846
+		"dryWeightList": dryWeightList,
8847
+	})
8848
+}
8849
+
8850
+func (this *PatientApiController) GetDialysisSystemList() {
8851
+
8852
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8853
+
8854
+	prescription, _ := service.GetDialysisSystemList(orgId)
8855
+
8856
+	this.ServeSuccessJSON(map[string]interface{}{
8857
+		"prescription": prescription,
8858
+	})
8859
+}
8860
+
8861
+func (this *PatientApiController) GetPatientAdviceList() {
8862
+
8863
+	timeLayout := "2006-01-02"
8864
+	loc, _ := time.LoadLocation("Local")
8865
+	start_time := this.GetString("start_time")
8866
+	end_time := this.GetString("end_time")
8867
+	patient_id, _ := this.GetInt64("patient_id")
8868
+	advice_type, _ := this.GetInt64("advice_type")
8869
+
8870
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8871
+	var startTime int64
8872
+	if len(start_time) > 0 {
8873
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8874
+		if err != nil {
8875
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8876
+			return
8877
+		}
8878
+		startTime = theTime.Unix()
8879
+	}
8880
+
8881
+	var endTime int64
8882
+	if len(end_time) > 0 {
8883
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8884
+		if err != nil {
8885
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8886
+			return
8887
+		}
8888
+		endTime = theTime.Unix()
8889
+	}
8890
+
8891
+	advicelist, _ := service.GetPatientAdviceList(patient_id, orgId, startTime, endTime, advice_type)
8892
+
8893
+	this.ServeSuccessJSON(map[string]interface{}{
8894
+		"advicelist": advicelist,
8895
+	})
8896
+}
8897
+
8898
+func (this *PatientApiController) GetPatientInspectionList() {
8899
+
8900
+	timeLayout := "2006-01-02"
8901
+	loc, _ := time.LoadLocation("Local")
8902
+	start_time := this.GetString("start_time")
8903
+	end_time := this.GetString("end_time")
8904
+	patient_id, _ := this.GetInt64("patient_id")
8905
+
8906
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8907
+	var startTime int64
8908
+	if len(start_time) > 0 {
8909
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8910
+		if err != nil {
8911
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8912
+			return
8913
+		}
8914
+		startTime = theTime.Unix()
8915
+	}
8916
+
8917
+	var endTime int64
8918
+	if len(end_time) > 0 {
8919
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8920
+		if err != nil {
8921
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8922
+			return
8923
+		}
8924
+		endTime = theTime.Unix()
8925
+	}
8926
+
8927
+	groupList, _ := service.GetNewPatientGroupInspectionList(patient_id, orgId, startTime, endTime)
8928
+
8929
+	inspection, _ := service.GetNewPatientInspectionList(patient_id, orgId, startTime, endTime)
8930
+
8931
+	this.ServeSuccessJSON(map[string]interface{}{
8932
+		"groupList":  groupList,
8933
+		"inspection": inspection,
8934
+	})
8935
+}
8936
+
8937
+func (this *PatientApiController) GetInspectionByProjectId() {
8938
+
8939
+	patient_id, _ := this.GetInt64("patient_id")
8940
+	project_id, _ := this.GetInt64("project_id")
8941
+	inspect_date, _ := this.GetInt64("inspect_date")
8942
+
8943
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8944
+
8945
+	inspection, _ := service.GetNewInspectionByProjectId(patient_id, project_id, inspect_date, orgId)
8946
+
8947
+	this.ServeSuccessJSON(map[string]interface{}{
8948
+		"inspection": inspection,
8949
+	})
8950
+}

+ 4 - 5
controllers/stock_in_api_controller.go View File

@@ -7466,9 +7466,6 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7466 7466
 			//基础库插入数据
7467 7467
 			service.UpdateNewGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count, tx)
7468 7468
 
7469
-			//查询该仓库是否有数据
7470
-			_, errcode := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7471
-
7472 7469
 			goodList, _ := service.GetNewSumGoodList(orgId, item.StorehouseId, item.GoodId, tx)
7473 7470
 			var flush_count int64
7474 7471
 			for _, it := range goodList {
@@ -7518,7 +7515,9 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7518 7515
 			//创建出库流水
7519 7516
 			service.CreateNewStockFlowOne(stockFlow, tx)
7520 7517
 
7521
-			if errcode == gorm.ErrRecordNotFound {
7518
+			//查询该仓库是否有数据
7519
+			stockCount, _ := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7520
+			if stockCount.ID == 0 {
7522 7521
 
7523 7522
 				goodCount := models.XtGoodStockCount{
7524 7523
 					UserOrgId:        orgId,
@@ -7535,7 +7534,7 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7535 7534
 				}
7536 7535
 				service.CreateNewGoodCount(goodCount, tx)
7537 7536
 			}
7538
-			if errcode == nil {
7537
+			if stockCount.ID > 0 {
7539 7538
 				service.UpdateNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, item.WarehousingCount, flush_count, tx)
7540 7539
 			}
7541 7540
 		}

+ 87 - 0
models/dialysis.go View File

@@ -1815,3 +1815,90 @@ type XtDoctorAdviceOne struct {
1815 1815
 func (XtDoctorAdviceOne) TableName() string {
1816 1816
 	return "xt_doctor_advice"
1817 1817
 }
1818
+
1819
+type PatientNewSchedule struct {
1820
+	ID                              int64                           `gorm:"column:id" json:"id" form:"id"`
1821
+	UserOrgId                       int64                           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1822
+	PatientId                       int64                           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1823
+	ModeId                          int64                           `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1824
+	Status                          int64                           `gorm:"column:status" json:"status" form:"status"`
1825
+	ScheduleDate                    int64                           `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1826
+	PatientMonitoringRecord         []*PatientMonitoringRecord      `gorm:"ForeignKey:PatientId,MonitoringDate;AssociationForeignKey:PatientId,ScheduleDate" json:"monitor"`
1827
+	PatientAssessmentAfterDislysis  PatientAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"after"`
1828
+	PatientAssessmentBeforeDislysis PatientAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"befor"`
1829
+}
1830
+
1831
+func (PatientNewSchedule) TableName() string {
1832
+	return "xt_schedule"
1833
+}
1834
+
1835
+type PatientNewScheduleOne struct {
1836
+	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
1837
+	UserOrgId               int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1838
+	PatientId               int64                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1839
+	ModeId                  int64                   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1840
+	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
1841
+	ScheduleDate            int64                   `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1842
+	PatientTreatmentSummary PatientTreatmentSummary `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"summary"`
1843
+}
1844
+
1845
+func (PatientNewScheduleOne) TableName() string {
1846
+	return "xt_schedule"
1847
+}
1848
+
1849
+type PatientMonitoringRecord struct {
1850
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1851
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1852
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1853
+	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1854
+	MonitoringDate         int64   `gorm:"column:monitoring_date" json:"monitoring_date" form:"monitoring_date"`
1855
+	MonitoringTime         string  `gorm:"column:monitoring_time" json:"monitoring_time" form:"monitoring_time"`
1856
+	BreathingRate          string  `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
1857
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1858
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1859
+}
1860
+
1861
+func (PatientMonitoringRecord) TableName() string {
1862
+	return "xt_monitoring_record"
1863
+}
1864
+
1865
+type PatientAssessmentAfterDislysis struct {
1866
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1867
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1868
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1869
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1870
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1871
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1872
+}
1873
+
1874
+func (PatientAssessmentAfterDislysis) TableName() string {
1875
+	return "xt_assessment_after_dislysis"
1876
+}
1877
+
1878
+type PatientAssessmentBeforeDislysis struct {
1879
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1880
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1881
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1882
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1883
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1884
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1885
+}
1886
+
1887
+func (PatientAssessmentBeforeDislysis) TableName() string {
1888
+	return "xt_assessment_before_dislysis"
1889
+}
1890
+
1891
+type PatientTreatmentSummary struct {
1892
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
1893
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1894
+	PatientId       int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1895
+	AssessmentDate  int64  `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1896
+	DialysisOrderId int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1897
+	Mission         string `gorm:"column:mission" json:"mission" form:"mission"`
1898
+	DialysisSummary string `gorm:"column:dialysis_summary" json:"dialysis_summary" form:"dialysis_summary"`
1899
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
1900
+}
1901
+
1902
+func (PatientTreatmentSummary) TableName() string {
1903
+	return "xt_treatment_summary"
1904
+}

+ 21 - 0
models/patient_models.go View File

@@ -3082,3 +3082,24 @@ func (BtAssessmentBeforeDislysis) TableName() string {
3082 3082
 
3083 3083
 	return "xt_assessment_before_dislysis"
3084 3084
 }
3085
+
3086
+type BtInspection struct {
3087
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
3088
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3089
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3090
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
3091
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
3092
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
3093
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
3094
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
3095
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
3096
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
3097
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
3098
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
3099
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
3100
+}
3101
+
3102
+func (BtInspection) TableName() string {
3103
+
3104
+	return "xt_inspection"
3105
+}

+ 1 - 4
service/new_stock_service.go View File

@@ -348,16 +348,13 @@ func GetNewDrugStockCount(storehouse_id int64, drug_id int64, org_id int64, tx *
348 348
 	drugStockCount := models.XtDrugStockCount{}
349 349
 	var err error
350 350
 	err = tx.Where("storehouse_id = ? and drug_id = ? and user_org_id  = ? and status = 1", storehouse_id, drug_id, org_id).Find(&drugStockCount).Error
351
-	if err == gorm.ErrRecordNotFound {
351
+	if err != gorm.ErrRecordNotFound {
352 352
 		if err != nil {
353 353
 			tx.Rollback()
354 354
 			return nil, err
355 355
 		}
356 356
 		return nil, err
357 357
 	}
358
-	if err != nil {
359
-		return nil, err
360
-	}
361 358
 	return &drugStockCount, nil
362 359
 }
363 360
 

+ 151 - 0
service/patient_service.go View File

@@ -4860,3 +4860,154 @@ func GetPatientLastBefor(patient_id int64, start_time int64, end_time int64, org
4860 4860
 
4861 4861
 	return beforeDislysis, err
4862 4862
 }
4863
+
4864
+func GetMonitorSearchList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (schedule []*models.PatientNewSchedule, err error) {
4865
+
4866
+	db := XTReadDB().Model(&schedule).Where("status= 1")
4867
+
4868
+	if patient_id > 0 {
4869
+		db = db.Where("patient_id = ?", patient_id)
4870
+	}
4871
+	if user_org_id > 0 {
4872
+		db = db.Where("user_org_id = ?", user_org_id)
4873
+	}
4874
+	if start_time > 0 {
4875
+		db = db.Where("schedule_date>=?", start_time)
4876
+	}
4877
+	if end_time > 0 {
4878
+		db = db.Where("schedule_date<=?", end_time)
4879
+	}
4880
+
4881
+	err = db.Preload("PatientMonitoringRecord", "user_org_id = ? and status=1", user_org_id).Preload("PatientAssessmentAfterDislysis", "user_org_id = ? and status=1", user_org_id).Preload("PatientAssessmentBeforeDislysis", "user_org_id = ? and status=1", user_org_id).Find(&schedule).Error
4882
+
4883
+	return schedule, err
4884
+
4885
+}
4886
+
4887
+func GetSummarySearchList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (schedule []*models.PatientNewScheduleOne, err error) {
4888
+
4889
+	db := XTReadDB().Model(&schedule).Where("status= 1")
4890
+
4891
+	if patient_id > 0 {
4892
+		db = db.Where("patient_id = ?", patient_id)
4893
+	}
4894
+	if user_org_id > 0 {
4895
+		db = db.Where("user_org_id = ?", user_org_id)
4896
+	}
4897
+	if start_time > 0 {
4898
+		db = db.Where("schedule_date>=?", start_time)
4899
+	}
4900
+	if end_time > 0 {
4901
+		db = db.Where("schedule_date<=?", end_time)
4902
+	}
4903
+
4904
+	err = db.Preload("PatientTreatmentSummary", "user_org_id = ? and status=1", user_org_id).Find(&schedule).Error
4905
+
4906
+	return schedule, err
4907
+}
4908
+
4909
+func GetPatientDryWeightList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (dry []*models.SgjPatientDryweight, err error) {
4910
+
4911
+	db := XTReadDB().Model(&dry).Where("status=1")
4912
+
4913
+	if patient_id > 0 {
4914
+		db = db.Where("patient_id = ?", patient_id)
4915
+	}
4916
+	if user_org_id > 0 {
4917
+		db = db.Where("user_org_id = ?", user_org_id)
4918
+	}
4919
+	if start_time > 0 {
4920
+		db = db.Where("ctime>=?", start_time)
4921
+	}
4922
+	if end_time > 0 {
4923
+		db = db.Where("ctime<=?", start_time)
4924
+	}
4925
+	err = db.Find(&dry).Error
4926
+
4927
+	return dry, err
4928
+}
4929
+
4930
+func GetDialysisSystemList(user_org_id int64) (prescription []*models.SystemPrescription, err error) {
4931
+
4932
+	err = XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&prescription).Error
4933
+
4934
+	return prescription, err
4935
+}
4936
+
4937
+func GetPatientAdviceList(patient_id int64, user_org_id int64, start_time int64, end_time int64, advice_type int64) (list []*models.XtDoctorAdvice, err error) {
4938
+
4939
+	db := XTReadDB().Model(&list).Where("status= 1")
4940
+
4941
+	if patient_id > 0 {
4942
+		db = db.Where("patient_id = ?", patient_id)
4943
+	}
4944
+	if user_org_id > 0 {
4945
+		db = db.Where("user_org_id = ?", user_org_id)
4946
+	}
4947
+	if start_time > 0 {
4948
+		db = db.Where("advice_date>=?", start_time)
4949
+	}
4950
+	if end_time > 0 {
4951
+		db = db.Where("advice_date<=?", end_time)
4952
+	}
4953
+	if advice_type > 0 {
4954
+		db = db.Where("advice_type = ?", advice_type)
4955
+	}
4956
+
4957
+	err = db.Find(&list).Error
4958
+
4959
+	return list, err
4960
+
4961
+}
4962
+
4963
+func GetNewPatientGroupInspectionList(patient_id int64, org_id int64, start_time int64, end_time int64) (inspection []*models.BtInspection, err error) {
4964
+
4965
+	db := XTReadDB().Model(&inspection).Where("status= 1")
4966
+
4967
+	if patient_id > 0 {
4968
+		db = db.Where("patient_id = ?", patient_id)
4969
+	}
4970
+
4971
+	if org_id > 0 {
4972
+		db = db.Where("org_id = ?", org_id)
4973
+	}
4974
+	if start_time > 0 {
4975
+		db = db.Where("inspect_date>=?", start_time)
4976
+	}
4977
+	if end_time > 0 {
4978
+		db = db.Where("inspect_date<=?", end_time)
4979
+	}
4980
+	err = db.Group("project_id,inspect_date").Order("project_id").Find(&inspection).Error
4981
+
4982
+	return inspection, err
4983
+}
4984
+
4985
+func GetNewPatientInspectionList(patient_id int64, org_id int64, start_time int64, end_time int64) (inspection []*models.XtInspection, err error) {
4986
+
4987
+	db := XTReadDB().Model(&inspection).Where("status= 1")
4988
+
4989
+	if patient_id > 0 {
4990
+		db = db.Where("patient_id = ?", patient_id)
4991
+	}
4992
+
4993
+	if org_id > 0 {
4994
+		db = db.Where("org_id = ?", org_id)
4995
+	}
4996
+	if start_time > 0 {
4997
+		db = db.Where("inspect_date>=?", start_time)
4998
+	}
4999
+	if end_time > 0 {
5000
+		db = db.Where("inspect_date<=?", end_time)
5001
+	}
5002
+	err = db.Find(&inspection).Error
5003
+
5004
+	return inspection, err
5005
+
5006
+}
5007
+
5008
+func GetNewInspectionByProjectId(patient_id int64, project_id int64, inspect_date int64, org_id int64) (inspection []*models.XtInspection, err error) {
5009
+
5010
+	err = XTReadDB().Where("patient_id = ? and project_id = ? and inspect_date = ? and status=1 and org_id = ?", patient_id, project_id, inspect_date, org_id).Find(&inspection).Error
5011
+
5012
+	return inspection, err
5013
+}

+ 14 - 0
service/self_drug_service.go View File

@@ -5397,3 +5397,17 @@ func ModifyDrugCodeWarehosueInfo(id int64, drug_code string) (models.XtDrugWareh
5397 5397
 
5398 5398
 	return drugWarehouseInfo, err
5399 5399
 }
5400
+
5401
+func GetAllDrugInfoList(drug_id int64, user_org_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
5402
+
5403
+	err = XTReadDB().Where("drug_id = ? and org_id = ? and status =1 and is_check =1", drug_id, user_org_id).Find(&info).Find(&info).Error
5404
+
5405
+	return info, err
5406
+}
5407
+
5408
+func GetHisDocInfoList(drug_id int64, user_org_id int64) (info []*models.HisDoctorAdviceInfo, err error) {
5409
+
5410
+	err = XTReadDB().Where("drug_id = ? and user_org_id = ? and status=1", drug_id, user_org_id).Find(&info).Error
5411
+
5412
+	return info, err
5413
+}

+ 18 - 6
service/smart_sch.go View File

@@ -8,12 +8,24 @@ import (
8 8
 )
9 9
 
10 10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
11
-	db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
12
-	if len(keywords) > 0 {
13
-		likekey := "%" + keywords + "%"
14
-		err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
15
-	} else {
16
-		err = db.Find(&patient).Error
11
+	if orgID != 10517 {
12
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
13
+		if len(keywords) > 0 {
14
+			likekey := "%" + keywords + "%"
15
+			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
16
+		} else {
17
+			err = db.Find(&patient).Error
18
+		}
19
+	}
20
+
21
+	if orgID == 10517 {
22
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1", orgID)
23
+		if len(keywords) > 0 {
24
+			likekey := "%" + keywords + "%"
25
+			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
26
+		} else {
27
+			err = db.Find(&patient).Error
28
+		}
17 29
 	}
18 30
 
19 31
 	//for _, item := range patient {

+ 20 - 6
service/stock_service.go View File

@@ -3527,7 +3527,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3527 3527
 		return
3528 3528
 	} else {
3529 3529
 		db := readDb.Model(&models.WarehouseOutInfo{})
3530
-		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
3530
+		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.count <> 0 ", orgId)
3531 3531
 
3532 3532
 		if len(keywords) > 0 {
3533 3533
 			likeKey := "%" + keywords + "%"
@@ -3537,7 +3537,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3537 3537
 
3538 3538
 			db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_warehouse_out_info.warehouse_out_order_number LIKE ?  OR xt_good_information.specification_name LIKE ?  OR xt_good_information.good_name LIKE ?", likeKey, likeKey, likeKey, likeKey).Group("xt_warehouse_out_info.id")
3539 3539
 		} else {
3540
-			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3540
+			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3541 3541
 		}
3542 3542
 
3543 3543
 		if manufacturer > 0 {
@@ -3552,8 +3552,8 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3552 3552
 			db = db.Where("xt_warehouse_out_info.storehouse_id = ?", storehouse_id)
3553 3553
 		}
3554 3554
 
3555
-		db = db.Preload("WarehouseOut", "status = 1 AND org_id = ?", orgId)
3556
-		db = db.Preload("WarehousingInfoNight", "status=1 and org_id = ?", orgId)
3555
+		db = db.Preload("WarehouseOut", "status = 1 AND org_id = ? and is_check =1", orgId)
3556
+		db = db.Preload("WarehousingInfoNight", "status=1 and org_id = ? and is_check =1", orgId)
3557 3557
 		db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
3558 3558
 		db = db.Count(&total)
3559 3559
 		offset := (page - 1) * limit
@@ -3565,7 +3565,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3565 3565
 
3566 3566
 func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (err error, totalPrice float64) {
3567 3567
 	db := readDb.Model(&models.WarehouseOutInfo{})
3568
-	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0", orgId)
3568
+	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.count > 0", orgId)
3569 3569
 
3570 3570
 	if len(keywords) > 0 {
3571 3571
 		likeKey := "%" + keywords + "%"
@@ -3575,7 +3575,7 @@ func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keyword
3575 3575
 
3576 3576
 		db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_warehouse_out_info.warehouse_out_order_number LIKE ?", likeKey, likeKey).Group("xt_warehouse_out_info.id")
3577 3577
 	} else {
3578
-		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3578
+		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and   xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3579 3579
 	}
3580 3580
 
3581 3581
 	if manufacturer > 0 {
@@ -9905,6 +9905,20 @@ func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty,
9905 9905
 	return info, err
9906 9906
 }
9907 9907
 
9908
+func GetAllWarehouseInfo(good_id int64, user_org_id int64) (info []*models.WarehousingInfo, err error) {
9909
+
9910
+	err = XTReadDB().Where("good_id = ? and user_org_id =? and status=1 and is_check =1", good_id, user_org_id).Find(&info).Error
9911
+
9912
+	return info, err
9913
+}
9914
+
9915
+func GetHisPrescriptionByGoodId(good_id int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
9916
+
9917
+	err = XTReadDB().Where("project_id  = ? and user_org_id =? and status=1 and type =3", good_id, user_org_id).Find(&project).Error
9918
+
9919
+	return project, err
9920
+}
9921
+
9908 9922
 func GetHisDocById(id int64, orgid int64) (models.HisDoctorAdvice, error) {
9909 9923
 
9910 9924
 	advice := models.HisDoctorAdvice{}

+ 2 - 0
service/warhouse_service.go View File

@@ -11195,6 +11195,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11195 11195
 			SystemTime:              advice.SysRecordTime,
11196 11196
 			PatientId:               advice.PatientId,
11197 11197
 			Remark:                  advice.Remark,
11198
+			OperateTime:             time.Now().Unix(),
11198 11199
 		}
11199 11200
 		if warehouse.RetailPrice == 0 {
11200 11201
 			drugflow.Price = advice.Price
@@ -11266,6 +11267,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11266 11267
 			SystemTime:              advice.SysRecordTime,
11267 11268
 			PatientId:               advice.PatientId,
11268 11269
 			Remark:                  advice.Remark,
11270
+			OperateTime:             time.Now().Unix(),
11269 11271
 		}
11270 11272
 
11271 11273
 		CreateNewDrugFlowOne(drugflow, tx)