Explorar el Código

11月8日库存管理

XMLWAN hace 3 años
padre
commit
fe1adacc99

+ 4 - 0
controllers/dialysis_api_controller.go Ver fichero

@@ -2810,6 +2810,10 @@ func (c *DialysisApiController) GetDialysisOrder() {
2810 2810
 		dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2811 2811
 		patientInfo.TotalDialysis = dialysis_count
2812 2812
 	}
2813
+	if adminUserInfo.CurrentOrgId == 10101 {
2814
+		dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2815
+		patientInfo.TotalDialysis = dialysis_count
2816
+	}
2813 2817
 
2814 2818
 	//相关操作对应的操作人
2815 2819
 	//operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)

+ 1 - 1
controllers/qiniiu_api_controller.go Ver fichero

@@ -22,7 +22,7 @@ func (c *QiNiuApiController) GetQNUpToken() {
22 22
 	defer redisClient.Close()
23 23
 
24 24
 	token, err := redisClient.Get("qn_token").Result()
25
-	fmt.Print("token------------------------------------", token)
25
+
26 26
 	if err != nil {
27 27
 		defer fmt.Println(err)
28 28
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)

+ 81 - 0
controllers/schedule_api_controller.go Ver fichero

@@ -67,6 +67,7 @@ func ScheduleApiRegistRouters() {
67 67
 	beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
68 68
 	beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
69 69
 	beego.Router("/api/schedule/getnextweekpanels", &ScheduleApiController{}, "Get:GetNextWeekPanels")
70
+	beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
70 71
 }
71 72
 
72 73
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -367,7 +368,9 @@ func (c *ScheduleApiController) CreateSchedule() {
367 368
 	}
368 369
 
369 370
 	redis := service.RedisClient()
371
+
370 372
 	err = service.CreateSchedule(&schedule)
373
+
371 374
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
372 375
 
373 376
 	redis.Set(key, "", time.Second)
@@ -1400,6 +1403,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1400 1403
 			//err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1401 1404
 			if err == nil {
1402 1405
 				for _, item := range schedules {
1406
+					//删除当天的日期排班
1407
+					service.DeleteScheduleExist(item.ScheduleDate, item.UserOrgId)
1403 1408
 					//查找当天日期是否存在
1404 1409
 					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId, item.ModeId, item.ScheduleType)
1405 1410
 					if errcode == gorm.ErrRecordNotFound {
@@ -2731,3 +2736,79 @@ func (c *ScheduleApiController) GetNextWeekPanels() {
2731 2736
 		"schedule": schedule,
2732 2737
 	})
2733 2738
 }
2739
+
2740
+func (c *ScheduleApiController) SynchroSchedule() {
2741
+
2742
+	template_id, _ := c.GetInt64("template_id")
2743
+	copy_startime, _ := c.GetInt64("copy_startime")
2744
+	copy_endtime, _ := c.GetInt64("copy_endtime")
2745
+
2746
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2747
+	//根据模板ID获取模板数据
2748
+	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
2749
+	//清空该时间段的所有排班数据
2750
+	service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
2751
+
2752
+	var tuesday int64
2753
+	var wednesday int64
2754
+	var thursday int64
2755
+	var friday int64
2756
+	var saturday int64
2757
+
2758
+	tuesday = copy_startime + 86400
2759
+	wednesday = copy_startime + 172800
2760
+	thursday = copy_startime + 259200
2761
+	friday = copy_startime + 345600
2762
+	saturday = copy_startime + 432000
2763
+
2764
+	for _, item := range list {
2765
+		if item.Weekday == 1 {
2766
+			item.ScheduleDate = copy_startime
2767
+		}
2768
+		if item.Weekday == 2 {
2769
+			item.ScheduleDate = tuesday
2770
+		}
2771
+		if item.Weekday == 3 {
2772
+			item.ScheduleDate = wednesday
2773
+		}
2774
+		if item.Weekday == 4 {
2775
+			item.ScheduleDate = thursday
2776
+		}
2777
+		if item.Weekday == 5 {
2778
+			item.ScheduleDate = friday
2779
+		}
2780
+		if item.Weekday == 6 {
2781
+			item.ScheduleDate = saturday
2782
+		}
2783
+		if item.Weekday == 7 {
2784
+			item.ScheduleDate = copy_endtime
2785
+		}
2786
+
2787
+		//根据床位号获取区号
2788
+		number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
2789
+		item.ZoneId = number.ZoneID
2790
+	}
2791
+
2792
+	for _, item := range list {
2793
+		schedule := models.XtSchedule{
2794
+			UserOrgId:    orgId,
2795
+			PartitionId:  item.ZoneId,
2796
+			BedId:        item.DeviceNumberID,
2797
+			PatientId:    item.PatientID,
2798
+			ScheduleDate: item.ScheduleDate,
2799
+			ScheduleType: item.TimeType,
2800
+			ScheduleWeek: item.Weekday,
2801
+			ModeId:       item.TreatMode,
2802
+			Status:       1,
2803
+			CreatedTime:  time.Now().Unix(),
2804
+			UpdatedTime:  0,
2805
+		}
2806
+
2807
+		service.CreatePatientSchedule(&schedule)
2808
+	}
2809
+
2810
+	returnData := make(map[string]interface{}, 0)
2811
+	returnData["list"] = list
2812
+	c.ServeSuccessJSON(returnData)
2813
+	return
2814
+}

+ 3 - 0
controllers/schedule_template_api_controller.go Ver fichero

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9
+	"fmt"
9 10
 	"time"
10 11
 
11 12
 	"github.com/astaxie/beego"
@@ -76,6 +77,8 @@ func (this *PatientScheduleTemplateAPIController) InitData() {
76 77
 	}
77 78
 
78 79
 	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId)
80
+
81
+	fmt.Println("deviceNumbers233323232332232323223233223323232323", deviceNumbers)
79 82
 	if getDeviceNumbersErr != nil {
80 83
 		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
81 84
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 1 - 1
main.go Ver fichero

@@ -11,7 +11,7 @@ func init() {
11 11
 }
12 12
 
13 13
 func main() {
14
-	//service.BeginAutoCreateWeekSchedulesJob()
14
+	service.BeginAutoCreateWeekSchedulesJob()
15 15
 	//service.BeginAutoCreateWeekDisinfectionJob()
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()

+ 21 - 0
models/patient_schedule_template_models.go Ver fichero

@@ -44,3 +44,24 @@ type PatientScheduleTemplateItem struct {
44 44
 func (PatientScheduleTemplateItem) TableName() string {
45 45
 	return "xt_patient_schedule_template_item"
46 46
 }
47
+
48
+type VmPatientScheduleTemplateItem struct {
49
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
50
+	OrgID          int64 `gorm:"column:org_id" json:"-" form:"org_id"`
51
+	TemplateID     int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
52
+	DeviceNumberID int64 `gorm:"column:device_number_id" json:"device_number_id" form:"device_number_id"`
53
+	PatientID      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
54
+	TreatMode      int64 `gorm:"column:treat_mode" json:"treat_mode" form:"treat_mode"` // 治疗模式
55
+	Weekday        int64 `gorm:"column:weekday" json:"weekday" form:"weekday"`          // 周一-周日 1-7
56
+	TimeType       int64 `gorm:"column:time_type" json:"time_type" form:"time_type"`    // 上下晚 123
57
+	Status         int64 `gorm:"column:status" json:"-" form:"status"`
58
+	CreateTime     int64 `gorm:"column:ctime" json:"-" form:"ctime"`
59
+	ModifyTime     int64 `gorm:"column:mtime" json:"-" form:"mtime"`
60
+	IsExport       int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
61
+	ScheduleDate   int64
62
+	ZoneId         int64
63
+}
64
+
65
+func (VmPatientScheduleTemplateItem) TableName() string {
66
+	return "xt_patient_schedule_template_item"
67
+}

+ 1 - 0
service/auto_create_week_schedules_service.go Ver fichero

@@ -147,6 +147,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
147 147
 
148 148
 	// 批量插入排班
149 149
 	if len(templateItems) > 0 {
150
+
150 151
 		valueStrs := make([]string, 0, len(templateItems))
151 152
 		values := make([]interface{}, 0, len(templateItems)*11)
152 153
 		for _, item := range templateItems {

+ 5 - 0
service/mobile_dialysis_service.go Ver fichero

@@ -2534,6 +2534,11 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
2534 2534
 	return
2535 2535
 }
2536 2536
 
2537
+func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2538
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1640966400 and  dialysis_date <= 1672416000 AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", orgID, patient_id).Count(&count).Error
2539
+	return
2540
+}
2541
+
2537 2542
 func GetFirstDateOfMonth(d time.Time) time.Time {
2538 2543
 	d = d.AddDate(0, 0, -d.Day()+1)
2539 2544
 	return GetZeroTime(d)

+ 11 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

@@ -57,9 +57,13 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
57 57
 		return nil, err
58 58
 	}
59 59
 	for _, item := range schedules {
60
-		dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
61
-		fmt.Println(dialysis_count)
60
+
62 61
 		if orgID != 10101 {
62
+			dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
63
+			item.Patient.TotalDialysis = dialysis_count
64
+		}
65
+		if orgID == 10101 {
66
+			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
63 67
 			item.Patient.TotalDialysis = dialysis_count
64 68
 		}
65 69
 
@@ -203,6 +207,11 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
203 207
 	return
204 208
 }
205 209
 
210
+func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
211
+	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= 1672416000 AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", orgID, patient_id).Count(&count).Error
212
+	return
213
+}
214
+
206 215
 func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
207 216
 
208 217
 	err = p_service.XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error

+ 43 - 2
service/schedule_service.go Ver fichero

@@ -161,7 +161,16 @@ func GetPointSchedule(orgID, scheduleDate, scheduleWeek, scheduleType, bedId int
161 161
 }
162 162
 
163 163
 func CreateSchedule(m *models.Schedule) error {
164
-	return writeDb.Model(&models.Schedule{}).Create(&m).Error
164
+	utx := XTWriteDB().Begin()
165
+	err := utx.Create(&m).Error
166
+	utx.Commit()
167
+	return err
168
+}
169
+
170
+func DeleteScheduleExist(scheduleData int64, user_org_id int64) (models.XtSchedule, error) {
171
+	schedule := models.XtSchedule{}
172
+	err := XTWriteDB().Where("schedule_date= ? and user_org_id = ? and status = 1", scheduleData, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
173
+	return schedule, err
165 174
 }
166 175
 
167 176
 func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64, mode_id int64, schedule_type int64) (*models.XtSchedule, error) {
@@ -193,7 +202,10 @@ func GetSchedule(orgID, id int64) (*models.Schedule, error) {
193 202
 }
194 203
 
195 204
 func UpdateSchedule(m *models.Schedule) error {
196
-	return writeDb.Model(&models.Schedule{}).Save(&m).Error
205
+	utx := XTWriteDB().Begin()
206
+	err := utx.Save(&m).Error
207
+	utx.Commit()
208
+	return err
197 209
 }
198 210
 
199 211
 func GetPatientScheduleFormToday(orgId, id, start int64) (schedules []*models.PatientSchedule, err error) {
@@ -996,3 +1008,32 @@ func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*
996 1008
 	}).Find(&schedule).Error
997 1009
 	return schedule, err
998 1010
 }
1011
+
1012
+func GetTemplateListByTemplateId(id int64, orgid int64) (list []*models.VmPatientScheduleTemplateItem, err error) {
1013
+
1014
+	err = XTReadDB().Where("template_id =? and org_id = ? and status = 1", id, orgid).Find(&list).Error
1015
+	return list, err
1016
+}
1017
+
1018
+func DeletePatientSchedule(startime int64, endtime int64, org_id int64) (models.XtSchedule, error) {
1019
+
1020
+	schedule := models.XtSchedule{}
1021
+	err := XTWriteDB().Model(&schedule).Where("schedule_date>=? and schedule_date<=? and user_org_id = ? and status = 1", startime, endtime, org_id).Updates(map[string]interface{}{"status": 0}).Error
1022
+	return schedule, err
1023
+}
1024
+
1025
+func GetBedNumberById(id int64, org_id int64) (models.DeviceNumber, error) {
1026
+
1027
+	number := models.DeviceNumber{}
1028
+
1029
+	err := XTReadDB().Where("id = ? and status = 1 and org_id =?", id, org_id).Find(&number).Error
1030
+	return number, err
1031
+}
1032
+
1033
+func CreatePatientSchedule(schedule *models.XtSchedule) error {
1034
+
1035
+	utx := XTWriteDB().Begin()
1036
+	err := utx.Create(&schedule).Error
1037
+	utx.Commit()
1038
+	return err
1039
+}

+ 12 - 2
service/stock_service.go Ver fichero

@@ -1380,7 +1380,12 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
1380 1380
 	}
1381 1381
 	db = db.Count(&total)
1382 1382
 	offset := (page - 1) * limit
1383
-	err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.ctime desc").Find(&list).Error
1383
+	if orgId == 10191 {
1384
+		err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.warehouse_out_time desc").Find(&list).Error
1385
+	} else {
1386
+		err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.ctime desc").Find(&list).Error
1387
+	}
1388
+
1384 1389
 	return list, total, err
1385 1390
 
1386 1391
 }
@@ -1429,7 +1434,12 @@ func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startT
1429 1434
 	}
1430 1435
 	db = db.Count(&total)
1431 1436
 	offset := (page - 1) * limit
1432
-	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1437
+	if orgId == 10191 {
1438
+		err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.warehouse_out_time desc").Find(&list).Error
1439
+	} else {
1440
+		err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1441
+	}
1442
+
1433 1443
 	return list, total, err
1434 1444
 
1435 1445
 }