csx před 3 roky
rodič
revize
295a3b4d34

+ 60 - 59
controllers/base_api_controller.go Zobrazit soubor

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"fmt"
7 8
 	"strconv"
@@ -69,36 +70,36 @@ type BaseAuthAPIController struct {
69 70
 func (this *BaseAuthAPIController) Prepare() {
70 71
 	this.BaseAPIController.Prepare()
71 72
 	if this.GetAdminUserInfo() == nil {
72
-		//var userAdmin models.AdminUser
73
-		//userAdmin.Id = 1448
74
-		//userAdmin.Mobile = "13318599895"
75
-		//
76
-		//userAdmin.Id = 597
77
-		//userAdmin.Mobile = "19874122664"
78
-		//userAdmin.IsSuperAdmin = false
79
-		//userAdmin.Status = 1
80
-		//userAdmin.CreateTime = 1530786071
81
-		//userAdmin.ModifyTime = 1530786071
82
-		//var subscibe models.ServeSubscibe
83
-		//subscibe.ID = 1
84
-		//subscibe.OrgId = 9675
85
-		//subscibe.PeriodStart = 1538035409
86
-		//subscibe.PeriodEnd = 1569571409
87
-		//subscibe.State = 1
88
-		//subscibe.Status = 1
89
-		//subscibe.CreatedTime = 1538035409
90
-		//subscibe.UpdatedTime = 1538035409
91
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
-		//subscibes[4] = &subscibe
93
-		//var adminUserInfo service.AdminUserInfo
94
-		//adminUserInfo.CurrentOrgId = 9675
95
-		//adminUserInfo.CurrentAppId = 4
96
-		//adminUserInfo.AdminUser = &userAdmin
97
-		//adminUserInfo.Subscibes = subscibes
98
-		//this.SetSession("admin_user_info", &adminUserInfo)
99
-
100
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		this.StopRun()
73
+		var userAdmin models.AdminUser
74
+		userAdmin.Id = 1448
75
+		userAdmin.Mobile = "13318599895"
76
+
77
+		userAdmin.Id = 597
78
+		userAdmin.Mobile = "19874122664"
79
+		userAdmin.IsSuperAdmin = false
80
+		userAdmin.Status = 1
81
+		userAdmin.CreateTime = 1530786071
82
+		userAdmin.ModifyTime = 1530786071
83
+		var subscibe models.ServeSubscibe
84
+		subscibe.ID = 1
85
+		subscibe.OrgId = 3877
86
+		subscibe.PeriodStart = 1538035409
87
+		subscibe.PeriodEnd = 1569571409
88
+		subscibe.State = 1
89
+		subscibe.Status = 1
90
+		subscibe.CreatedTime = 1538035409
91
+		subscibe.UpdatedTime = 1538035409
92
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
+		subscibes[4] = &subscibe
94
+		var adminUserInfo service.AdminUserInfo
95
+		adminUserInfo.CurrentOrgId = 3877
96
+		adminUserInfo.CurrentAppId = 4
97
+		adminUserInfo.AdminUser = &userAdmin
98
+		adminUserInfo.Subscibes = subscibes
99
+		this.SetSession("admin_user_info", &adminUserInfo)
100
+
101
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
102
+		//this.StopRun()
102 103
 
103 104
 	}
104 105
 
@@ -315,35 +316,35 @@ type BaseServeAPIController struct {
315 316
 func (this *BaseServeAPIController) Prepare() {
316 317
 	this.BaseAPIController.Prepare()
317 318
 	if this.GetAdminUserInfo() == nil {
318
-		//var userAdmin models.AdminUser
319
-		//userAdmin.Id = 1448
320
-		//userAdmin.Mobile = "13318599895"
321
-		//
322
-		//userAdmin.Id = 597
323
-		//userAdmin.Mobile = "19874122664"
324
-		//userAdmin.IsSuperAdmin = false
325
-		//userAdmin.Status = 1
326
-		//userAdmin.CreateTime = 1530786071
327
-		//userAdmin.ModifyTime = 1530786071
328
-		//var subscibe models.ServeSubscibe
329
-		//subscibe.ID = 1
330
-		//subscibe.OrgId = 9675
331
-		//subscibe.PeriodStart = 1538035409
332
-		//subscibe.PeriodEnd = 1569571409
333
-		//subscibe.State = 1
334
-		//subscibe.Status = 1
335
-		//subscibe.CreatedTime = 1538035409
336
-		//subscibe.UpdatedTime = 1538035409
337
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
-		//subscibes[4] = &subscibe
339
-		//var adminUserInfo service.AdminUserInfo
340
-		//adminUserInfo.CurrentOrgId = 9675
341
-		//adminUserInfo.CurrentAppId = 4
342
-		//adminUserInfo.AdminUser = &userAdmin
343
-		//adminUserInfo.Subscibes = subscibes
344
-		//this.SetSession("admin_user_info", &adminUserInfo)
345
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
-		this.StopRun()
319
+		var userAdmin models.AdminUser
320
+		userAdmin.Id = 1448
321
+		userAdmin.Mobile = "13318599895"
322
+
323
+		userAdmin.Id = 597
324
+		userAdmin.Mobile = "19874122664"
325
+		userAdmin.IsSuperAdmin = false
326
+		userAdmin.Status = 1
327
+		userAdmin.CreateTime = 1530786071
328
+		userAdmin.ModifyTime = 1530786071
329
+		var subscibe models.ServeSubscibe
330
+		subscibe.ID = 1
331
+		subscibe.OrgId = 3877
332
+		subscibe.PeriodStart = 1538035409
333
+		subscibe.PeriodEnd = 1569571409
334
+		subscibe.State = 1
335
+		subscibe.Status = 1
336
+		subscibe.CreatedTime = 1538035409
337
+		subscibe.UpdatedTime = 1538035409
338
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
+		subscibes[4] = &subscibe
340
+		var adminUserInfo service.AdminUserInfo
341
+		adminUserInfo.CurrentOrgId = 3877
342
+		adminUserInfo.CurrentAppId = 4
343
+		adminUserInfo.AdminUser = &userAdmin
344
+		adminUserInfo.Subscibes = subscibes
345
+		this.SetSession("admin_user_info", &adminUserInfo)
346
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
+		//this.StopRun()
347 348
 	}
348 349
 
349 350
 	//if adminUserInfo.AppRole != nil {

+ 5 - 3
controllers/dialysis_api_controller.go Zobrazit soubor

@@ -1348,7 +1348,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1348 1348
 	remark := c.GetString("remark")
1349 1349
 	puncture_method := c.GetString("puncture_method")
1350 1350
 
1351
-	dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1351
+	//dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1352
+	dialysis_count := c.GetString("dialysis_count")
1352 1353
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1353 1354
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1354 1355
 	ductus_arantii := c.GetString("ductus_arantii")
@@ -1365,14 +1366,15 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1365 1366
 
1366 1367
 	is_infect, _ := c.GetInt64("is_infect", 0)
1367 1368
 	exposed, _ := c.GetFloat("exposed", 0)
1368
-	//skin, _ := c.GetInt64("skin", 0)
1369 1369
 	skin := c.GetString("skin")
1370 1370
 	skin_other := c.GetString("skin_other")
1371 1371
 	infect_other := c.GetString("infect_other")
1372 1372
 	ductus_arantii_other := c.GetString("ductus_arantii_other")
1373 1373
 	machine_type := c.GetString("machine_type")
1374 1374
 	puncture_needle := c.GetString("puncture_needle")
1375
-	humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1375
+	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1376
+
1377
+	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1376 1378
 	phinholing := c.GetString("pinholing")
1377 1379
 
1378 1380
 	catheter_suture := c.GetString("catheter_suture")

+ 4 - 3
controllers/doctors_api_controller.go Zobrazit soubor

@@ -62,6 +62,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
62 62
 	delivery_way := c.GetString("delivery_way")
63 63
 	schedule_type, _ := c.GetInt64("schedule_type")
64 64
 	partition_type, _ := c.GetInt64("partition_type")
65
+	patient_id, _ := c.GetInt64("patient_id")
65 66
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
66 67
 		adviceType = 0
67 68
 	}
@@ -80,10 +81,10 @@ func (c *DoctorsApiController) ScheduleAdvices() {
80 81
 	adminUserInfo := c.GetAdminUserInfo()
81 82
 	orgID := adminUserInfo.CurrentOrgId
82 83
 
83
-	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
84
-	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
84
+	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id)
85
+	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
85 86
 
86
-	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
87
+	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
87 88
 
88 89
 	index := 0
89 90
 	for _, item := range project {

+ 0 - 1
controllers/drug_stock_api_contorller.go Zobrazit soubor

@@ -755,7 +755,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
755 755
 
756 756
 			if item.WarehousingCount == warehouseInfo.WarehousingCount {
757 757
 				errs = service.UpDateDrugWarehousingInfo(item)
758
-				break
759 758
 			}
760 759
 		}
761 760
 	}

+ 2 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -1019,7 +1019,9 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1019 1019
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1020 1020
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1021 1021
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1022
+
1022 1023
 		if err == nil {
1024
+			fmt.Println("hhhhhhhhhhh0000000000", err)
1023 1025
 			c.ServeSuccessJSON(map[string]interface{}{
1024 1026
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1025 1027
 			})

+ 5 - 11
controllers/mobile_api_controllers/patient_api_controller.go Zobrazit soubor

@@ -1936,10 +1936,7 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1936 1936
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
1937 1937
 		evaluation.BloodAccessPartId = blood_access_part_id
1938 1938
 	}
1939
-	//if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "float64" {
1940
-	//	blood_access_part_id := int64(dataBody["blood_access_part_id"].(float64))
1941
-	//	evaluation.BloodAccessPartId = blood_access_part_id
1942
-	//}
1939
+
1943 1940
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
1944 1941
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
1945 1942
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
@@ -1958,9 +1955,6 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1958 1955
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
1959 1956
 		evaluation.IsHemorrhage = is_hemorrhage
1960 1957
 
1961
-		//if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "float64" {
1962
-		//	is_hemorrhage := int64(dataBody["is_hemorrhage"].(float64))
1963
-		//	fmt.Println("is_hemorrhage2222222222222222",is_hemorrhage)
1964 1958
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
1965 1959
 			is_hemorrhage = 0
1966 1960
 		}
@@ -2031,8 +2025,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2031 2025
 
2032 2026
 	if dataBody["dialysis_count"] != nil && reflect.TypeOf(dataBody["dialysis_count"]).String() == "string" {
2033 2027
 		dialysis_count, _ := dataBody["dialysis_count"].(string)
2034
-		count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2035
-		evaluation.DialysisCount = count
2028
+		//count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2029
+		evaluation.DialysisCount = dialysis_count
2036 2030
 	}
2037 2031
 
2038 2032
 	if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
@@ -2072,8 +2066,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2072 2066
 		evaluation.PunctureNeedle = punctureNeedle
2073 2067
 	}
2074 2068
 
2075
-	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "float64" {
2076
-		humor_excessive_symptom := int64(dataBody["humor_excessive_symptom"].(float64))
2069
+	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
2070
+		humor_excessive_symptom := dataBody["humor_excessive_symptom"].(string)
2077 2071
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2078 2072
 	}
2079 2073
 

+ 223 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Zobrazit soubor

@@ -5,8 +5,12 @@ import (
5 5
 	"XT_New/enums"
6 6
 	"XT_New/models"
7 7
 	"XT_New/service"
8
+	"XT_New/utils"
9
+	"encoding/json"
8 10
 	"fmt"
9 11
 	"github.com/jinzhu/gorm"
12
+	"reflect"
13
+	"strconv"
10 14
 	"strings"
11 15
 	"time"
12 16
 )
@@ -417,3 +421,222 @@ func (this *StaffScheduleApiController) UpdateBloodSchedule() {
417 421
 		service.UpdateDialysisPrescriptionOne(prescription, patient_id, startTime)
418 422
 	}
419 423
 }
424
+
425
+func (this *StaffScheduleApiController) GetSchedulePatient() {
426
+
427
+	schedule, _ := this.GetInt64("schedule", 0) //1已2未
428
+	contagion, _ := this.GetInt64("contagion", 0)
429
+	keywords := this.GetString("keywords", "")
430
+	adminInfo := this.GetAdminUserInfo()
431
+
432
+	thisTime := time.Now()
433
+	weekDay := int(thisTime.Weekday())
434
+	if weekDay == 0 {
435
+		weekDay = 7
436
+	}
437
+	thisWeekEnd := 7 - weekDay
438
+	weekStartPoint := thisWeekEnd - 6
439
+	weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
440
+	weekEndPoint := thisWeekEnd + 7
441
+	weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
442
+	fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
443
+
444
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
445
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
446
+	fmt.Println(weekStartTime, weekEndTime)
447
+
448
+	timeLayout := "2006-01-02 15:04:05"
449
+	loc, _ := time.LoadLocation("Local")
450
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
451
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
452
+	weekStart := theStarTime.Unix()
453
+	weekEnd := theEndTime.Unix()
454
+
455
+	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
456
+
457
+	this.ServeSuccessJSON(map[string]interface{}{
458
+		"patients": patients,
459
+	})
460
+	return
461
+}
462
+
463
+func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
464
+
465
+	patientID, _ := c.GetInt64("patient_id", 0)
466
+	if patientID <= 0 {
467
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
468
+		return
469
+	}
470
+
471
+	adminUserInfo := c.GetAdminUserInfo()
472
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
473
+	if patientInfo.ID == 0 {
474
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
475
+		return
476
+	}
477
+
478
+	var schedule models.Schedule
479
+	dataBody := make(map[string]interface{}, 0)
480
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
481
+	if err != nil {
482
+		utils.ErrorLog(err.Error())
483
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
484
+		return
485
+	}
486
+
487
+	if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
488
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+		return
490
+	}
491
+	scheduleDate, _ := dataBody["schedule_date"].(string)
492
+	if len(scheduleDate) == 0 {
493
+		utils.ErrorLog("len(schedule_date) == 0")
494
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
+		return
496
+	}
497
+	timeLayout := "2006-01-02"
498
+	loc, _ := time.LoadLocation("Local")
499
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
500
+	if err != nil {
501
+		utils.ErrorLog(err.Error())
502
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
503
+		return
504
+	}
505
+	schedule.ScheduleDate = theTime.Unix()
506
+
507
+	timeNow := time.Now().Format("2006-01-02")
508
+	if timeNow > scheduleDate {
509
+		utils.ErrorLog(timeNow)
510
+		utils.ErrorLog(scheduleDate)
511
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
512
+		return
513
+	}
514
+
515
+	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
516
+		utils.ErrorLog("schedule_type")
517
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
+		return
519
+	}
520
+	scheduleType := int64(dataBody["schedule_type"].(float64))
521
+	if scheduleType < 1 || scheduleType > 3 {
522
+		utils.ErrorLog("scheduleType < 3")
523
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
524
+		return
525
+	}
526
+	schedule.ScheduleType = scheduleType
527
+
528
+	if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
529
+		utils.ErrorLog("bed_id")
530
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
531
+		return
532
+	}
533
+	bedId := int64(dataBody["bed_id"].(float64))
534
+	if bedId < 1 {
535
+		utils.ErrorLog("bedId < 1")
536
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
537
+		return
538
+	}
539
+	schedule.BedId = bedId
540
+
541
+	if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
542
+		utils.ErrorLog("partition_id")
543
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
544
+		return
545
+	}
546
+	partitionId := int64(dataBody["partition_id"].(float64))
547
+	if partitionId < 1 {
548
+		utils.ErrorLog("partitionId < 1")
549
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
550
+		return
551
+	}
552
+	schedule.PartitionId = partitionId
553
+
554
+	if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
555
+		utils.ErrorLog("schedule_week")
556
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
557
+		return
558
+	}
559
+	scheduleWeek := int64(dataBody["schedule_week"].(float64))
560
+	if scheduleWeek < 1 || scheduleWeek > 7 {
561
+		utils.ErrorLog("scheduleWeek < 1")
562
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
563
+		return
564
+	}
565
+	schedule.ScheduleWeek = scheduleWeek
566
+
567
+	if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
568
+		utils.ErrorLog("mode_id")
569
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
570
+		return
571
+	}
572
+	modeId := int64(dataBody["mode_id"].(float64))
573
+	if modeId < 1 && modeId > 14 {
574
+		utils.ErrorLog("modeId < 1")
575
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
576
+		return
577
+	}
578
+	schedule.ModeId = modeId
579
+
580
+	schedule.PatientId = patientID
581
+	schedule.CreatedTime = time.Now().Unix()
582
+	schedule.UpdatedTime = time.Now().Unix()
583
+	schedule.Status = 1
584
+	schedule.UserOrgId = adminUserInfo.CurrentOrgId
585
+
586
+	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
587
+	if bed == nil {
588
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
589
+		return
590
+	}
591
+	if bed.ZoneID != schedule.PartitionId {
592
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
593
+		return
594
+	}
595
+
596
+	scheduleDateStart := scheduleDate + " 00:00:00"
597
+	scheduleDateEnd := scheduleDate + " 23:59:59"
598
+	timeLayout = "2006-01-02 15:04:05"
599
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
600
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
601
+	startTime := theStartTime.Unix()
602
+	endTime := theEndTime.Unix()
603
+
604
+	//一天只有排班一次
605
+	daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
606
+	if daySchedule.ID > 0 {
607
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
608
+		return
609
+	}
610
+
611
+	//同天同位置只能排一个
612
+	pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
613
+	if err != nil {
614
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
615
+		return
616
+	}
617
+	if pointSchedule.ID > 0 {
618
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
619
+		return
620
+	}
621
+
622
+	redis := service.RedisClient()
623
+	defer redis.Close()
624
+	err = service.CreateSchedule(&schedule)
625
+
626
+	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
627
+	redis.Set(key, "", time.Second)
628
+
629
+	fmt.Println(err)
630
+	if err != nil {
631
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
632
+		return
633
+	}
634
+	schedule.Patient = patientInfo.Name
635
+
636
+	c.ServeSuccessJSON(map[string]interface{}{
637
+		"msg":      "ok",
638
+		"schedule": schedule,
639
+	})
640
+	return
641
+
642
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Zobrazit soubor

@@ -21,4 +21,6 @@ func StaffScheduleApiControllersRegisterRouters() {
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22 22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23 23
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
24
+	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
25
+	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
24 26
 }

+ 10 - 4
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -690,6 +690,10 @@ func (c *StockManagerApiController) EditWarehouse() {
690 690
 				}
691 691
 
692 692
 				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
693
+				flowStock := models.VmStockFlow{
694
+					Count: item.WarehousingCount,
695
+				}
696
+				service.UpdatedStockFlowByGoodId(item.WarehousingId, item.GoodId, flowStock)
693 697
 				//改变库存
694 698
 				good, _ := service.GetLastInfoMationById(info.GoodId)
695 699
 				warhouseCount := strconv.FormatInt(total, 10)
@@ -734,7 +738,6 @@ func (c *StockManagerApiController) EditWarehouse() {
734 738
 					Remark:           item.Remark,
735 739
 				}
736 740
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
737
-				break
738 741
 			}
739 742
 
740 743
 		}
@@ -5339,7 +5342,7 @@ func (this *StockManagerApiController) GetReportStockList() {
5339 5342
 	fmt.Println("startTime", startTime, "endTime", endTime)
5340 5343
 	//list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
5341 5344
 
5342
-	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit)
5345
+	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit, startTime, endTime)
5343 5346
 	damageList, _ := service.GetStockDamagedCount(orgId)
5344 5347
 	doctorlist, _ := service.GetAllDoctorThree(orgId)
5345 5348
 
@@ -6482,9 +6485,12 @@ func (this *StockManagerApiController) SaveStockInventoryList() {
6482 6485
 func (this *StockManagerApiController) GetDamageDetailByGoodId() {
6483 6486
 
6484 6487
 	good_id, _ := this.GetInt64("good_id")
6485
-	list, _ := service.GetDamageDetailByGoodId(good_id)
6488
+	warehousing_order := this.GetString("warehousing_order")
6489
+	inventory_type, _ := this.GetInt64("type")
6490
+	fmt.Println("inventory_type23232323223322332", inventory_type)
6491
+	list, _ := service.GetDamageDetailByGoodId(good_id, warehousing_order, inventory_type)
6486 6492
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6487
-	damageList, _ := service.GetStockDamagedCount(orgId)
6493
+	damageList, _ := service.GetStockDamagedCountOne(orgId, warehousing_order, inventory_type)
6488 6494
 	this.ServeSuccessJSON(map[string]interface{}{
6489 6495
 		"list":       list,
6490 6496
 		"damageList": damageList,

+ 3 - 3
models/dialysis.go Zobrazit soubor

@@ -287,7 +287,7 @@ type PredialysisEvaluation struct {
287 287
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
288 288
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
289 289
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
290
-	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
290
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count"`
291 291
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
292 292
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
293 293
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
@@ -301,7 +301,7 @@ type PredialysisEvaluation struct {
301 301
 	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other"`
302 302
 	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other"`
303 303
 	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other"`
304
-	HumorExcessiveSymptom          int64   `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
304
+	HumorExcessiveSymptom          string  `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
305 305
 	Phinholing                     string  `gorm:"column:pinholing" json:"pinholing" form:"pinholing"`
306 306
 	CatheterSuture                 string  `gorm:"column:catheter_suture" json:"catheter_suture" form:"catheter_suture"`
307 307
 	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`
@@ -862,7 +862,7 @@ type XtDialysisOrders struct {
862 862
 	FinishCreator  int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
863 863
 	FinishModifier int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
864 864
 	SchedualType   int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
865
-	Number         int64  `gorm:"column:number" json:"number" form:"number"`
865
+	Number         string `gorm:"column:number" json:"number" form:"number"`
866 866
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
867 867
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
868 868
 	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`

+ 236 - 121
service/mobile_dialysis_service.go Zobrazit soubor

@@ -1220,52 +1220,6 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
1220 1220
 	return vms, err
1221 1221
 }
1222 1222
 
1223
-//func GetMobileHisPrescriptionTeamProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
1224
-//	var vms []*HisMScheduleProjectVM
1225
-//	if patientType == 0 {
1226
-//		db := readDb.
1227
-//			Table("xt_schedule").
1228
-//			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1229
-//			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1230
-//				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1231
-//			}).
1232
-//			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1233
-//			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1234
-//			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1235
-//			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1236
-//				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Group("team_id").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
1237
-//			}).
1238
-//			Where("status = 1 AND user_org_id = ?", orgID)
1239
-//		if scheduleDate != 0 {
1240
-//			db = db.Where("schedule_date = ?", scheduleDate)
1241
-//		}
1242
-//		err = db.Find(&vms).Error
1243
-//	}
1244
-//
1245
-//	if patientType > 0 {
1246
-//		db := readDb.
1247
-//			Table("xt_schedule").
1248
-//			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1249
-//			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1250
-//				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1251
-//			}).
1252
-//			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1253
-//			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1254
-//			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1255
-//			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1256
-//			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1257
-//				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
1258
-//			}).
1259
-//			Where("status = 1 AND user_org_id = ?", orgID)
1260
-//		if scheduleDate != 0 {
1261
-//			db = db.Where("schedule_date = ?", scheduleDate)
1262
-//		}
1263
-//		err = db.Find(&vms).Error
1264
-//	}
1265
-//
1266
-//	return vms, err
1267
-//}
1268
-
1269 1223
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
1270 1224
 	now := time.Now()
1271 1225
 	tx := writeDb.Begin()
@@ -2203,76 +2157,157 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
2203 2157
 	return advice, err
2204 2158
 }
2205 2159
 
2206
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
2160
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64) ([]*MScheduleDoctorAdviceVM, error) {
2207 2161
 	var vms []*MScheduleDoctorAdviceVM
2208 2162
 	adviceWhere := ""
2209 2163
 	adviceCondition := []interface{}{}
2210 2164
 	if adviceType == 0 {
2211 2165
 		if patientType == 0 {
2212
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2213
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2166
+			if patient_id > 0 {
2167
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
2168
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2169
+			} else {
2170
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2171
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2172
+			}
2214 2173
 
2215 2174
 		} else if patientType == 1 {
2216
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2217
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2175
+			if patient_id > 0 {
2176
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
2177
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2178
+			} else {
2179
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2180
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2181
+			}
2218 2182
 
2219 2183
 		} else if patientType == 2 {
2220
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2221
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2184
+			if patient_id > 0 {
2185
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
2186
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2187
+			} else {
2188
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2189
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2190
+			}
2191
+
2222 2192
 		}
2223 2193
 
2224 2194
 	} else if adviceType == 1 {
2225 2195
 		if patientType == 0 {
2226
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2227
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2196
+			if patient_id > 0 {
2197
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
2198
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2199
+			} else {
2200
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2201
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2202
+			}
2228 2203
 
2229 2204
 		} else if patientType == 1 {
2230
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2231
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2205
+			if patient_id > 0 {
2206
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
2207
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2208
+			} else {
2209
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2210
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2211
+			}
2232 2212
 
2233 2213
 		} else if patientType == 2 {
2234
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2235
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2214
+			if patient_id > 0 {
2215
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
2216
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2217
+			} else {
2218
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2219
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2220
+			}
2236 2221
 
2237 2222
 		}
2238 2223
 
2239 2224
 	} else if adviceType == 3 {
2240 2225
 		if patientType == 0 {
2241
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2242
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2226
+			if patient_id > 0 {
2227
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ?  "
2228
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2229
+			} else {
2230
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2231
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2232
+			}
2243 2233
 
2244 2234
 		} else if patientType == 1 {
2245
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2246
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2235
+			if patient_id > 0 {
2236
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
2237
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2238
+			} else {
2239
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2240
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2241
+			}
2242
+
2247 2243
 		} else if patientType == 2 {
2248
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2249
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2244
+			if patient_id > 0 {
2245
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and patient_id = ?"
2246
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2247
+			} else {
2248
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2249
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2250
+			}
2251
+
2250 2252
 		}
2251 2253
 
2252 2254
 	} else if adviceType == 2 && len(deliverWay) > 0 {
2253 2255
 		if patientType == 0 {
2254
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2255
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2256
+			if patient_id > 0 {
2257
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
2258
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
2259
+			} else {
2260
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2261
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2262
+			}
2256 2263
 
2257 2264
 		} else if patientType == 1 {
2258
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2259
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2265
+			if patient_id > 0 {
2266
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and patient_id = ?"
2267
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
2268
+			} else {
2269
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2270
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2271
+			}
2272
+
2260 2273
 		} else if patientType == 2 {
2261
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2262
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2274
+			if patient_id > 0 {
2275
+
2276
+			} else {
2277
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2278
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2279
+			}
2280
+
2263 2281
 		}
2264 2282
 
2265 2283
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
2266 2284
 		if patientType == 0 {
2267
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2268
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2285
+			if patient_id > 0 {
2286
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
2287
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2288
+			} else {
2289
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2290
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2291
+			}
2269 2292
 
2270 2293
 		} else if patientType == 1 {
2271
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2272
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2294
+			if patient_id > 0 {
2295
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
2296
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2297
+			} else {
2298
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2299
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2300
+			}
2301
+
2273 2302
 		} else if patientType == 2 {
2274
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2275
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2303
+			if patient_id > 0 {
2304
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and patient_id = ?"
2305
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2306
+			} else {
2307
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2308
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2309
+			}
2310
+
2276 2311
 		}
2277 2312
 
2278 2313
 	}
@@ -2302,7 +2337,7 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
2302 2337
 	return vms, err
2303 2338
 }
2304 2339
 
2305
-func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2340
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64, patient_id int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2306 2341
 
2307 2342
 	var vms []*HisMScheduleDoctorAdviceVM
2308 2343
 	if len(deliverWay) > 0 {
@@ -2313,19 +2348,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2313 2348
 		if partitionType > 0 {
2314 2349
 			db = db.Where("partition_id = ?", partitionType)
2315 2350
 		}
2316
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2317
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2318
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2319
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2320
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2321
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2322
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2323
-			}).
2324
-			Where("status = 1 AND user_org_id = ?", orgID)
2325
-		if scheduleDate != 0 {
2326
-			db = db.Where("schedule_date = ?", scheduleDate)
2351
+		if patient_id > 0 {
2352
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id =?", orgID, patient_id).
2353
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2354
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2355
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2356
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
2357
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2358
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2359
+				}).
2360
+				Where("status = 1 AND user_org_id = ?", orgID)
2361
+			if scheduleDate != 0 {
2362
+				db = db.Where("schedule_date = ?", scheduleDate)
2363
+			}
2364
+			err = db.Find(&vms).Error
2365
+		} else {
2366
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2367
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2368
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2369
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2370
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2371
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2372
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2373
+				}).
2374
+				Where("status = 1 AND user_org_id = ?", orgID)
2375
+			if scheduleDate != 0 {
2376
+				db = db.Where("schedule_date = ?", scheduleDate)
2377
+			}
2378
+			err = db.Find(&vms).Error
2327 2379
 		}
2328
-		err = db.Find(&vms).Error
2380
+
2329 2381
 	} else {
2330 2382
 		db := readDb.Table("xt_schedule")
2331 2383
 		if scheduleType > 0 {
@@ -2334,19 +2386,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2334 2386
 		if partitionType > 0 {
2335 2387
 			db = db.Where("partition_id = ?", partitionType)
2336 2388
 		}
2337
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2338
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2339
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2340
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2341
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2342
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2343
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2344
-			}).
2345
-			Where("status = 1 AND user_org_id = ?", orgID)
2346
-		if scheduleDate != 0 {
2347
-			db = db.Where("schedule_date = ?", scheduleDate)
2389
+		if patient_id > 0 {
2390
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
2391
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2392
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2393
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2394
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2395
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2396
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2397
+				}).
2398
+				Where("status = 1 AND user_org_id = ?", orgID)
2399
+			if scheduleDate != 0 {
2400
+				db = db.Where("schedule_date = ?", scheduleDate)
2401
+			}
2402
+			err = db.Find(&vms).Error
2403
+		} else {
2404
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2405
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2406
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2407
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2408
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2409
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2410
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2411
+				}).
2412
+				Where("status = 1 AND user_org_id = ?", orgID)
2413
+			if scheduleDate != 0 {
2414
+				db = db.Where("schedule_date = ?", scheduleDate)
2415
+			}
2416
+			err = db.Find(&vms).Error
2348 2417
 		}
2349
-		err = db.Find(&vms).Error
2418
+
2350 2419
 	}
2351 2420
 
2352 2421
 	return vms, err
@@ -2476,28 +2545,74 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
2476 2545
 	return
2477 2546
 }
2478 2547
 
2479
-func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
2548
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64, patient_id int64) ([]*HisMScheduleProjectVM, error) {
2480 2549
 	var vms []*HisMScheduleProjectVM
2481 2550
 	if patientType == 0 {
2482
-		db := readDb.
2483
-			Table("xt_schedule").
2484
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2485
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2486
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2487
-			}).
2488
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2489
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2490
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2491
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2492
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2493
-			}).
2494
-			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2495
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2496
-			}).Where("status = 1 AND user_org_id = ?", orgID)
2497
-		if scheduleDate != 0 {
2498
-			db = db.Where("schedule_date = ?", scheduleDate)
2551
+
2552
+		if patient_id > 0 {
2553
+			db := readDb.
2554
+				Table("xt_schedule").
2555
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2556
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2557
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2558
+				}).
2559
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2560
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2561
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2562
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2563
+					return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2564
+				}).
2565
+				Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2566
+					return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2567
+				}).Where("status = 1 AND user_org_id = ?", orgID)
2568
+			if scheduleDate != 0 {
2569
+				db = db.Where("schedule_date = ?", scheduleDate)
2570
+			}
2571
+			err = db.Find(&vms).Error
2572
+		} else {
2573
+			if patient_id > 0 {
2574
+				db := readDb.
2575
+					Table("xt_schedule").
2576
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id= ?", orgID, patient_id).
2577
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2578
+						return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2579
+					}).
2580
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2581
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2582
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2583
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2584
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2585
+					}).
2586
+					Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2587
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2588
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2589
+				if scheduleDate != 0 {
2590
+					db = db.Where("schedule_date = ?", scheduleDate)
2591
+				}
2592
+				err = db.Find(&vms).Error
2593
+			} else {
2594
+				db := readDb.
2595
+					Table("xt_schedule").
2596
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2597
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2598
+						return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2599
+					}).
2600
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2601
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2602
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2603
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2604
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2605
+					}).
2606
+					Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2607
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2608
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2609
+				if scheduleDate != 0 {
2610
+					db = db.Where("schedule_date = ?", scheduleDate)
2611
+				}
2612
+				err = db.Find(&vms).Error
2613
+			}
2499 2614
 		}
2500
-		err = db.Find(&vms).Error
2615
+
2501 2616
 	}
2502 2617
 
2503 2618
 	if patientType > 0 {

+ 2 - 1
service/patient_service.go Zobrazit soubor

@@ -947,7 +947,7 @@ func GetPatientDialysisRecord(orgID, patientID int64, page, limit, start, end, m
947 947
 		}).
948 948
 		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
949 949
 		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
950
-		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
950
+		Where("do.patient_id=? and do.user_org_id=?  and do.status=1", patientID, orgID).Group("s.schedule_date")
951 951
 
952 952
 	if start != 0 {
953 953
 		db = db.Where("do.dialysis_date>=?", start)
@@ -1105,6 +1105,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1105 1105
 
1106 1106
 func GetPatientByKeyWord(orgID int64, keywords string) (patient []*models.Patients, err error) {
1107 1107
 	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID)
1108
+	fmt.Println("keywords22222223322332322332322323323", keywords)
1108 1109
 	if len(keywords) > 0 {
1109 1110
 		likekey := "%" + keywords + "%"
1110 1111
 		err = db.Where("name LIKE ? OR dialysis_no LIKE ? ", likekey, likekey).Find(&patient).Error

+ 3 - 3
service/self_drug_service.go Zobrazit soubor

@@ -879,7 +879,7 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
879 879
 func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
880 880
 	likeKey := "%" + keyword + "%"
881 881
 	offset := (page - 1) * limit
882
-	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and inventory_type = 11")
882
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
883 883
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
884 884
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
885 885
 	fmt.Println(table, tab)
@@ -903,7 +903,7 @@ func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword strin
903 903
 }
904 904
 
905 905
 func GetDrugDamageByOrgId(orgid int64) (list []*models.XtDrugInventory, err error) {
906
-	err = XTReadDB().Model(&list).Where("user_org_id = ? and inventory_type = 11 and status = 1", orgid).Find(&list).Error
906
+	err = XTReadDB().Model(&list).Where("user_org_id = ? and type = 4 and status = 1", orgid).Find(&list).Error
907 907
 	return list, err
908 908
 }
909 909
 
@@ -1126,7 +1126,7 @@ func CreateDrugWarehouseOutInfo(info models.DrugWarehouseOutInfo) error {
1126 1126
 
1127 1127
 func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (drug []*models.VmXtDrugInventory, err error) {
1128 1128
 
1129
-	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and inventory_type = 11 ")
1129
+	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and type = 4 ")
1130 1130
 
1131 1131
 	if drugid > 0 {
1132 1132
 		db = db.Where("drug_id = ?", drugid)

+ 61 - 8
service/stock_service.go Zobrazit soubor

@@ -3835,7 +3835,7 @@ func GetCancelStockOrderPrintOne(idstr []string, orgid int64) (info []*models.Ca
3835 3835
 
3836 3836
 func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3837 3837
 
3838
-	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3838
+	db := readDb2.Table("xt_cancel_stock_info as x").Where("x.status = 1")
3839 3839
 
3840 3840
 	if startime > 0 {
3841 3841
 		db = db.Where("x.ctime >=?", startime)
@@ -3888,7 +3888,7 @@ func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3888 3888
 
3889 3889
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3890 3890
 
3891
-	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> '' and stock_count<> 0", id, orgid).Find(&info).Error
3891
+	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Find(&info).Error
3892 3892
 	return info, err
3893 3893
 }
3894 3894
 
@@ -4133,6 +4133,13 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4133 4133
 		if consumable_type == 4 {
4134 4134
 			db = db.Where(" consumable_type = ?", consumable_type)
4135 4135
 		}
4136
+
4137
+		if consumable_type == 10 {
4138
+			db = db.Where(" consumable_type = ?", consumable_type)
4139
+		}
4140
+		if consumable_type == 11 {
4141
+			db = db.Where(" consumable_type = ?", consumable_type)
4142
+		}
4136 4143
 	}
4137 4144
 	if orgId > 0 {
4138 4145
 		db = db.Where("user_org_id = ?", orgId)
@@ -4592,7 +4599,7 @@ func GetReportStockList(startime int64, endtime int64, orgid int64, keyword stri
4592 4599
 	return adjust, total, err
4593 4600
 }
4594 4601
 
4595
-func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (adjust []*models.VmStockInventory, total int64, err error) {
4602
+func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64, startime int64, endtime int64) (adjust []*models.VmStockInventory, total int64, err error) {
4596 4603
 	likeKey := "%" + keyword + "%"
4597 4604
 	offset := (page - 1) * limit
4598 4605
 	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
@@ -4607,15 +4614,41 @@ func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (
4607 4614
 	if orgid > 0 {
4608 4615
 		db = db.Where("x.user_org_id = ?", orgid)
4609 4616
 	}
4617
+	if startime > 0 {
4618
+		db = db.Where("x.ctime >=?", startime)
4619
+	}
4620
+	if endtime > 0 {
4621
+		db = db.Where("x.ctime <=?", endtime)
4622
+	}
4610 4623
 
4611
-	err = db.Group("x.id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4624
+	err = db.Group("x.id").Select("x.ctime,x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4612 4625
 	return adjust, total, err
4613 4626
 
4614 4627
 }
4615 4628
 
4629
+func GetStockDamagedCountOne(orgid int64, keyword string, inventory_type int64) (adjust []*models.VmStockInventory, err error) {
4630
+
4631
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1")
4632
+	if inventory_type == 0 {
4633
+		db = db.Where("x.inventory_type = 4")
4634
+	}
4635
+	if inventory_type > 0 {
4636
+		db = db.Where("x.inventory_type = ?", inventory_type)
4637
+	}
4638
+	if len(keyword) > 0 {
4639
+		likeKey := "%" + keyword + "%"
4640
+		db = db.Where("x.warehousing_order like ?", likeKey)
4641
+	}
4642
+	if orgid > 0 {
4643
+		db = db.Where("x.user_org_id = ?", orgid)
4644
+	}
4645
+	err = db.Group("x.good_id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,sum(x.count) as count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number").Scan(&adjust).Error
4646
+	return adjust, err
4647
+}
4648
+
4616 4649
 func GetStockDamagedCount(orgid int64) (adjust []*models.VmStockInventory, err error) {
4617 4650
 
4618
-	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
4651
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and inventory_type = 4 ")
4619 4652
 	if orgid > 0 {
4620 4653
 		db = db.Where("x.user_org_id = ?", orgid)
4621 4654
 	}
@@ -4766,7 +4799,7 @@ func GetInventoryDetailList(keyword string, limit int64, page int64, orgid int64
4766 4799
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4767 4800
 	fmt.Println(table, tab)
4768 4801
 	if len(keyword) > 0 {
4769
-		db = db.Where("x.good_name = ?", likeKey)
4802
+		db = db.Where("x.good_name like ?", likeKey)
4770 4803
 	}
4771 4804
 	if orgid > 0 {
4772 4805
 		db = db.Where("x.user_org_id = ?", orgid)
@@ -4866,9 +4899,23 @@ func UpdatedWarehousingInfo(info models.WarehousingInfo, id int64) error {
4866 4899
 	return err
4867 4900
 }
4868 4901
 
4869
-func GetDamageDetailByGoodId(good_id int64) (list []*models.XtStockInventory, err error) {
4902
+func GetDamageDetailByGoodId(good_id int64, keyword string, inventory_type int64) (list []*models.XtStockInventory, err error) {
4870 4903
 
4871
-	err = XTReadDB().Model(&list).Where("good_id = ? and status = 1", good_id).Find(&list).Error
4904
+	db := XTReadDB().Model(&list).Where(" status = 1")
4905
+	if good_id > 0 {
4906
+		db = db.Where("good_id = ?", good_id)
4907
+	}
4908
+	if len(keyword) > 0 {
4909
+		likeKey := "%" + keyword + "%"
4910
+		db = db.Where("warehousing_order like ?", likeKey)
4911
+	}
4912
+	if inventory_type > 0 {
4913
+		db = db.Where("inventory_type = ?", inventory_type)
4914
+	}
4915
+	if inventory_type == 0 {
4916
+		db = db.Where("inventory_type = 4")
4917
+	}
4918
+	err = db.Find(&list).Error
4872 4919
 
4873 4920
 	return list, err
4874 4921
 }
@@ -4940,3 +4987,9 @@ func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error
4940 4987
 	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark}).Error
4941 4988
 	return err
4942 4989
 }
4990
+
4991
+func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
4992
+
4993
+	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4994
+	return err
4995
+}