Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
eced77bbec

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 33 - 29
controllers/drug_stock_api_contorller.go View File

@@ -1225,7 +1225,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1225 1225
 
1226 1226
 	var warehousingOutInfo []*models.DrugWarehouseOutInfo
1227 1227
 
1228
-	var drugFlow []*models.DrugFlow
1228
+	//var drugFlow []*models.DrugFlow
1229 1229
 
1230 1230
 	if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
1231 1231
 		thisStockIn, _ := dataBody["stockOut"].([]interface{})
@@ -1326,28 +1326,28 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1326 1326
 				}
1327 1327
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1328 1328
 
1329
-				drugflow := &models.DrugFlow{
1330
-					WarehouseOutId:          warehouseOut.ID,
1331
-					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1332
-					DrugId:                  drug_id,
1333
-					Number:                  number,
1334
-					ProductDate:             productDates,
1335
-					ExpireDate:              expiryDates,
1336
-					Count:                   count,
1337
-					Price:                   price,
1338
-					Status:                  1,
1339
-					Ctime:                   ctime,
1340
-					UserOrgId:               adminUserInfo.CurrentOrgId,
1341
-					Manufacturer:            manufacturer,
1342
-					Dealer:                  dealer,
1343
-					BatchNumber:             batch_number,
1344
-					MaxUnit:                 max_unit,
1345
-					ConsumableType:          2,
1346
-					IsEdit:                  1,
1347
-					Creator:                 adminUserInfo.AdminUser.Id,
1348
-					IsSys:                   0,
1349
-				}
1350
-				drugFlow = append(drugFlow, drugflow)
1329
+				//drugflow := &models.DrugFlow{
1330
+				//	WarehouseOutId:          warehouseOut.ID,
1331
+				//	WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1332
+				//	DrugId:                  drug_id,
1333
+				//	Number:                  number,
1334
+				//	ProductDate:             productDates,
1335
+				//	ExpireDate:              expiryDates,
1336
+				//	Count:                   count,
1337
+				//	Price:                   price,
1338
+				//	Status:                  1,
1339
+				//	Ctime:                   ctime,
1340
+				//	UserOrgId:               adminUserInfo.CurrentOrgId,
1341
+				//	Manufacturer:            manufacturer,
1342
+				//	Dealer:                  dealer,
1343
+				//	BatchNumber:             batch_number,
1344
+				//	MaxUnit:                 max_unit,
1345
+				//	ConsumableType:          2,
1346
+				//	IsEdit:                  1,
1347
+				//	Creator:                 adminUserInfo.AdminUser.Id,
1348
+				//	IsSys:                   0,
1349
+				//}
1350
+				//drugFlow = append(drugFlow, drugflow)
1351 1351
 			}
1352 1352
 		}
1353 1353
 	}
@@ -1374,8 +1374,10 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1374 1374
 			prescribing_number_total = item.Count
1375 1375
 		}
1376 1376
 
1377
+		fmt.Println("药品ID", item.DrugId)
1377 1378
 		fmt.Println("数量一", prescribing_number_total)
1378 1379
 		fmt.Println("数量二", total_count)
1380
+
1379 1381
 		//判断单位
1380 1382
 		if total_count == 0 {
1381 1383
 			goodObj, _ := service.GetDrugByGoodId(item.DrugId)
@@ -1405,11 +1407,11 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1405 1407
 			return
1406 1408
 		} else {
1407 1409
 			service.AddSigleDrugWarehouseOut(&warehouseOut)
1408
-			list, _ := service.GetLastWarehouseOut(adminUserInfo.CurrentOrgId)
1409
-			for _, item := range drugFlow {
1410
-				item.WarehouseOutId = list.ID
1411
-			}
1412
-			service.CreateDrugFlow(drugFlow)
1410
+			//list, _ := service.GetLastWarehouseOut(adminUserInfo.CurrentOrgId)
1411
+			//for _, item := range drugFlow {
1412
+			//	item.WarehouseOutId = list.ID
1413
+			//}
1414
+			//service.CreateDrugFlow(drugFlow)
1413 1415
 			// 出库流程
1414 1416
 			// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
1415 1417
 			drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
@@ -1417,6 +1419,8 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1417 1419
 				prescribingNumber := item.Count
1418 1420
 				service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
1419 1421
 			}
1422
+			prescribing_number_total = 0
1423
+			total_count = 0
1420 1424
 		}
1421 1425
 
1422 1426
 	}
@@ -1430,7 +1434,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1430 1434
 		"min_unit":   "",
1431 1435
 		"max_unit":   "",
1432 1436
 	})
1433
-
1437
+	return
1434 1438
 }
1435 1439
 func (c *StockDrugApiController) GetDrugWarehouseOutList() {
1436 1440
 	page, _ := c.GetInt64("page", -1)

+ 23 - 10
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -268,22 +268,35 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
268 268
 		}
269 269
 		startTime = theTime.Unix()
270 270
 	}
271
-	fmt.Println("时间搓", startTime)
272 271
 	zoneid, _ := this.GetInt64("zoneid")
273 272
 	fmt.Println(zoneid)
274 273
 	classtype, _ := this.GetInt64("classtype")
275
-	fmt.Println("classtype", classtype)
276 274
 
277
-	//获取当天排班的病人情况
278
-	schedule, err := service.GetPatientSchedule(startTime, zoneid, classtype, orgid)
275
+	is_open, _ := this.GetInt64("is_open")
279 276
 
280
-	if err != nil {
281
-		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
282
-		return
277
+	if is_open == 0 {
278
+		//获取当天排班的病人情况
279
+		schedule, err := service.GetPatientSchedule(startTime, zoneid, classtype, orgid)
280
+
281
+		if err != nil {
282
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
283
+			return
284
+		}
285
+		this.ServeSuccessJSON(map[string]interface{}{
286
+			"schedule": schedule,
287
+		})
288
+	}
289
+	if is_open == 1 {
290
+		//获取空床位的排班数据
291
+		list, err := service.GetPatientScheduleByBed(startTime, zoneid, classtype, orgid)
292
+		if err != nil {
293
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
294
+			return
295
+		}
296
+		this.ServeSuccessJSON(map[string]interface{}{
297
+			"schedule": list,
298
+		})
283 299
 	}
284
-	this.ServeSuccessJSON(map[string]interface{}{
285
-		"schedule": schedule,
286
-	})
287 300
 }
288 301
 
289 302
 func (this *StaffScheduleApiController) DeleteSchedule() {

+ 59 - 24
controllers/patient_api_controller.go View File

@@ -2450,36 +2450,71 @@ func (c *PatientApiController) GetDoctorAdvices() {
2450 2450
 		theEndtTIme = theTime.Unix()
2451 2451
 	}
2452 2452
 
2453
-	advices, total, _ := service.GetDoctorAdviceListOne(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit)
2454
-	advicestwo, _, _ := service.GetDoctorAdviceListTwo(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page)
2453
+	hisconfig, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2455 2454
 
2456
-	if len(advices) > 0 {
2457
-		for _, item := range advices {
2458
-			if item.AdviceDoctor > 0 {
2459
-				operatorIDs = append(operatorIDs, item.AdviceDoctor)
2460
-			}
2461
-			if item.ExecutionStaff > 0 {
2462
-				operatorIDs = append(operatorIDs, item.ExecutionStaff)
2463
-			}
2464
-			if item.Checker > 0 {
2465
-				operatorIDs = append(operatorIDs, item.Checker)
2455
+	if hisconfig.IsOpen == 1 {
2456
+		advices, total, _ := service.GetDoctorAdviceListThree(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit)
2457
+		advicestwo, _, _ := service.GetDoctorAdviceListFour(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page)
2458
+
2459
+		if len(advices) > 0 {
2460
+			for _, item := range advices {
2461
+				if item.AdviceDoctor > 0 {
2462
+					operatorIDs = append(operatorIDs, item.AdviceDoctor)
2463
+				}
2464
+				if item.ExecutionStaff > 0 {
2465
+					operatorIDs = append(operatorIDs, item.ExecutionStaff)
2466
+				}
2467
+				if item.Checker > 0 {
2468
+					operatorIDs = append(operatorIDs, item.Checker)
2469
+				}
2470
+				if item.StopDoctor > 0 {
2471
+					operatorIDs = append(operatorIDs, item.StopDoctor)
2472
+				}
2466 2473
 			}
2467
-			if item.StopDoctor > 0 {
2468
-				operatorIDs = append(operatorIDs, item.StopDoctor)
2474
+		}
2475
+
2476
+		//相关操作对应的操作人
2477
+		operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
2478
+
2479
+		c.ServeSuccessJSON(map[string]interface{}{
2480
+			"advices":   advices,
2481
+			"operators": operators,
2482
+			"total":     total,
2483
+			"advicetwo": advicestwo,
2484
+		})
2485
+		return
2486
+	} else {
2487
+		advices, total, _ := service.GetDoctorAdviceListOne(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit)
2488
+		advicestwo, _, _ := service.GetDoctorAdviceListTwo(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page)
2489
+
2490
+		if len(advices) > 0 {
2491
+			for _, item := range advices {
2492
+				if item.AdviceDoctor > 0 {
2493
+					operatorIDs = append(operatorIDs, item.AdviceDoctor)
2494
+				}
2495
+				if item.ExecutionStaff > 0 {
2496
+					operatorIDs = append(operatorIDs, item.ExecutionStaff)
2497
+				}
2498
+				if item.Checker > 0 {
2499
+					operatorIDs = append(operatorIDs, item.Checker)
2500
+				}
2501
+				if item.StopDoctor > 0 {
2502
+					operatorIDs = append(operatorIDs, item.StopDoctor)
2503
+				}
2469 2504
 			}
2470 2505
 		}
2471
-	}
2472 2506
 
2473
-	//相关操作对应的操作人
2474
-	operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
2507
+		//相关操作对应的操作人
2508
+		operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
2475 2509
 
2476
-	c.ServeSuccessJSON(map[string]interface{}{
2477
-		"advices":   advices,
2478
-		"operators": operators,
2479
-		"total":     total,
2480
-		"advicetwo": advicestwo,
2481
-	})
2482
-	return
2510
+		c.ServeSuccessJSON(map[string]interface{}{
2511
+			"advices":   advices,
2512
+			"operators": operators,
2513
+			"total":     total,
2514
+			"advicetwo": advicestwo,
2515
+		})
2516
+		return
2517
+	}
2483 2518
 
2484 2519
 }
2485 2520
 

+ 1 - 1
controllers/self_drug_api_congtroller.go View File

@@ -2574,7 +2574,7 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2574 2574
 				CancelOutDetailId:       0,
2575 2575
 				ExpireDate:              expiry_date,
2576 2576
 				ProductDate:             0,
2577
-				MaxUnit:                 max_unit,
2577
+				MaxUnit:                 min_unit,
2578 2578
 				MinUnit:                 min_unit,
2579 2579
 			}
2580 2580
 			if ord_total != new_total {

+ 28 - 21
controllers/stock_in_api_controller.go View File

@@ -680,9 +680,6 @@ func (c *StockManagerApiController) EditWarehouse() {
680 680
 			//获取该批次该型号的库存
681 681
 			info, _ := service.GetLastWarehousingByIdOne(item.ID, item.GoodId)
682 682
 
683
-			//判断 该批次的库存数量 和 编辑库存数量
684
-			fmt.Println("库存11111111111111", item.WarehousingCount)
685
-			fmt.Println("库存22222222222222", info.WarehousingCount)
686 683
 			//增加库存
687 684
 			if item.WarehousingCount > info.WarehousingCount {
688 685
 
@@ -728,6 +725,13 @@ func (c *StockManagerApiController) EditWarehouse() {
728 725
 					WarehousingCount: item.WarehousingCount,
729 726
 					StockCount:       info.StockCount,
730 727
 					Price:            item.Price,
728
+					Manufacturer:     item.Manufacturer,
729
+					Number:           item.Number,
730
+					ProductDate:      item.ProductDate,
731
+					ExpiryDate:       item.ExpiryDate,
732
+					LicenseNumber:    item.LicenseNumber,
733
+					Dealer:           item.Dealer,
734
+					Remark:           item.Remark,
731 735
 				}
732 736
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
733 737
 				break
@@ -1304,8 +1308,10 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1304 1308
 
1305 1309
 		// 查询该耗材是否有库存
1306 1310
 		warehouseOne, _ := service.FindWarehousingInfoTen(item.GoodId)
1311
+		fmt.Println("hhh2333223223", item.GoodId, item.Count, warehouseOne.StockCount)
1307 1312
 		// 如果出库数量大于该批次剩余库存数量
1308 1313
 		if item.Count > warehouseOne.StockCount {
1314
+
1309 1315
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1310 1316
 			c.ServeSuccessJSON(map[string]interface{}{
1311 1317
 				"msg":                "1",
@@ -1314,27 +1320,28 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1314 1320
 			})
1315 1321
 			return
1316 1322
 
1317
-		} else {
1318
-			//查询是否生成出库单
1319
-			_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1320
-			if errcodes == gorm.ErrRecordNotFound {
1321
-				service.AddSigleWarehouseOut(&warehouseOut)
1322
-			}
1323
-			//出库逻辑
1324
-			parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count, creater)
1325
-			if parseDateErr != nil {
1326
-				utils.ErrorLog(parseDateErr.Error())
1327
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1328
-				return
1329
-			}
1323
+		}
1324
+	}
1330 1325
 
1331
-			c.ServeSuccessJSON(map[string]interface{}{
1332
-				"msg":                "2",
1333
-				"good_name":          "",
1334
-				"specification_name": "",
1335
-			})
1326
+	for _, it := range warehousingOutInfo {
1327
+		//查询是否生成出库单
1328
+		_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
1329
+		if errcodes == gorm.ErrRecordNotFound {
1330
+			service.AddSigleWarehouseOut(&warehouseOut)
1331
+		}
1332
+		//出库逻辑
1333
+		parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), it, &warehouseOut, it.Count, creater)
1334
+		if parseDateErr != nil {
1335
+			utils.ErrorLog(parseDateErr.Error())
1336
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1337
+			return
1336 1338
 		}
1337 1339
 
1340
+		c.ServeSuccessJSON(map[string]interface{}{
1341
+			"msg":                "2",
1342
+			"good_name":          "",
1343
+			"specification_name": "",
1344
+		})
1338 1345
 	}
1339 1346
 }
1340 1347
 func (c *StockManagerApiController) GetWarehouseOutList() {

+ 25 - 0
models/device_models.go View File

@@ -1054,3 +1054,28 @@ type VmXtSchedule struct {
1054 1054
 	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1055 1055
 	Count        int64
1056 1056
 }
1057
+
1058
+type PatientDeviceNumber struct {
1059
+	ID            int64         `gorm:"column:id" json:"id"`
1060
+	OrgID         int64         `gorm:"column:org_id" json:"-"`
1061
+	Number        string        `gorm:"column:number" json:"number"`
1062
+	GroupID       int64         `gorm:"column:group_id" json:"group_id"`
1063
+	ZoneID        int64         `gorm:"column:zone_id" json:"zone_id"`
1064
+	CreateTime    int64         `gorm:"column:ctime" json:"-"`
1065
+	ModifyTime    int64         `gorm:"column:mtime" json:"-"`
1066
+	Sort          int64         `gorm:"column:sort" json:"sort" form:"sort"`
1067
+	PartitionId   int64         `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1068
+	BedId         int64         `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1069
+	PatientId     int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1070
+	ScheduleDate  int64         `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1071
+	ScheduleType  int64         `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1072
+	ScheduleWeek  int64         `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1073
+	ModeId        int64         `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1074
+	Name          string        `gorm:"column:name" json:"name"`
1075
+	Patient       Patients      `json:"patient"  gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
1076
+	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
1077
+	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
1078
+	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
1079
+	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
1080
+	Schedule      Schedule      `json:"schedule"  gorm:"foreignkey:BedId;AssociationForeignKey:ID;"`
1081
+}

+ 56 - 0
models/dialysis.go View File

@@ -1093,3 +1093,59 @@ type BloodDoctorAdvice struct {
1093 1093
 	DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1094 1094
 	Total       int64
1095 1095
 }
1096
+
1097
+type HisDoctorAdvice struct {
1098
+	ID                    int64              `gorm:"column:id" json:"id" form:"id"`
1099
+	GroupNo               int64              `gorm:"column:groupno" json:"groupno" form:"groupno"`
1100
+	UserOrgId             int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1101
+	PatientId             int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1102
+	AdviceType            int64              `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1103
+	AdviceDate            int64              `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1104
+	StartTime             int64              `gorm:"column:start_time" json:"start_time" form:"start_time"`
1105
+	AdviceName            string             `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1106
+	AdviceDesc            string             `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1107
+	ReminderDate          int64              `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1108
+	SingleDose            float64            `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1109
+	SingleDoseUnit        string             `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1110
+	DrugSpec              float64            `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1111
+	DrugSpecUnit          string             `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1112
+	PrescribingNumber     float64            `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1113
+	PrescribingNumberUnit string             `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1114
+	DeliveryWay           string             `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1115
+	ExecutionFrequency    string             `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1116
+	AdviceDoctor          int64              `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1117
+	Status                int64              `gorm:"column:status" json:"status" form:"status"`
1118
+	CreatedTime           int64              `gorm:"column:created_time" json:"created_time" form:"created_time"`
1119
+	UpdatedTime           int64              `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1120
+	AdviceAffirm          string             `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1121
+	Remark                string             `gorm:"column:remark" json:"remark" form:"remark"`
1122
+	StopTime              int64              `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1123
+	StopReason            string             `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1124
+	StopDoctor            int64              `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1125
+	StopState             int64              `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1126
+	ParentId              int64              `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1127
+	ExecutionTime         int64              `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1128
+	ExecutionStaff        int64              `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1129
+	ExecutionState        int64              `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1130
+	Checker               int64              `gorm:"column:checker" json:"checker" form:"checker"`
1131
+	RecordDate            int64              `gorm:"column:record_date" json:"record_date"`
1132
+	DialysisOrderId       int64              `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
1133
+	CheckTime             int64              `gorm:"column:check_time" json:"check_time" form:"check_time"`
1134
+	CheckState            int64              `gorm:"column:check_state" json:"check_state" form:"check_state"`
1135
+	AdviceId              int64              `gorm:"-"`
1136
+	RemindType            int64              `gorm:"column:remind_type" json:"remind_type"`
1137
+	FrequencyType         int64              `gorm:"column:frequency_type" json:"frequency_type"`
1138
+	DayCount              int64              `gorm:"column:day_count" json:"day_count"`
1139
+	WeekDay               string             `gorm:"column:week_day" json:"week_day"`
1140
+	ChildDoctorAdvice     []*HisDoctorAdvice `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
1141
+	TemplateId            string             `gorm:"column:template_id" json:"template_id"`
1142
+	Modifier              int64              `gorm:"column:modifier" json:"modifier" form:"modifier"`
1143
+	IsCheck               int64              `gorm:"-" json:"is_check" form:"is_check"`
1144
+	Way                   int64              `gorm:"column:way" json:"way" form:"way"`
1145
+	DrugId                int64              `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1146
+	DrugNameId            int64              `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1147
+}
1148
+
1149
+func (HisDoctorAdvice) TableName() string {
1150
+	return "his_doctor_advice_info"
1151
+}

+ 20 - 0
service/doctor_schedule_service.go View File

@@ -598,6 +598,26 @@ func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int
598 598
 	return schedule, err
599 599
 }
600 600
 
601
+func GetPatientScheduleByBed(startime int64, zoneid int64, classtype int64, orgid int64) (list []*models.PatientDeviceNumber, err error) {
602
+
603
+	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
604
+	table := XTReadDB().Table("xt_schedule as s").Where("s.status = 1")
605
+	p := XTReadDB().Table("xt_patients as p").Where("p.status = 1")
606
+	fmt.Println(table, p)
607
+	if zoneid > 0 {
608
+		db = db.Where("s.zone_id = ?", zoneid)
609
+	}
610
+	if orgid > 0 {
611
+		db = db.Where("x.org_id = ?", orgid)
612
+	}
613
+	if classtype > 0 {
614
+		db = db.Where("s.schedule_type = ?", classtype)
615
+	}
616
+
617
+	err = db.Select("x.id,x.number,x.group_id,x.zone_id,x.sort,s.partition_id,s.bed_id,s.patient_id,s.schedule_date,s.schedule_type,s.schedule_week,s.mode_id").Joins("left join xt_schedule as s on s.bed_id = x.id").Where("s.schedule_date = ?", startime).Scan(&list).Error
618
+	return list, err
619
+}
620
+
601 621
 func DeleteSchedule(id int64) error {
602 622
 
603 623
 	schedule := models.XtSchedule{}

+ 88 - 2
service/patient_service.go View File

@@ -788,7 +788,7 @@ func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int6
788 788
 		db = db.Where("x.start_time>=?", start)
789 789
 	}
790 790
 	if end != 0 {
791
-		db = db.Where("start_time<=?", end)
791
+		db = db.Where("x.start_time<=?", end)
792 792
 	}
793 793
 	if len(keywords) > 0 {
794 794
 		likeKey := "%" + keywords + "%"
@@ -831,7 +831,7 @@ func GetDoctorAdviceListTwo(orgID int64, patientID int64, advice_type int64, sto
831 831
 		db = db.Where("x.start_time>=?", start)
832 832
 	}
833 833
 	if end != 0 {
834
-		db = db.Where("start_time<=?", end)
834
+		db = db.Where("x.start_time<=?", end)
835 835
 	}
836 836
 	if len(keywords) > 0 {
837 837
 		likeKey := "%" + keywords + "%"
@@ -1515,3 +1515,89 @@ func UpdateScheduleItemByPatientId(id int64) error {
1515 1515
 	err := XTWriteDB().Model(models.PatientScheduleTemplateItem{}).Where("patient_id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1516 1516
 	return err
1517 1517
 }
1518
+
1519
+func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end int64, keywords string, page int64, limit int64) (advices []*models.HisDoctorAdvice, total int64, err error) {
1520
+
1521
+	db := readDb.Table("his_doctor_advice_info as x").Where("x.status = 1")
1522
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1523
+	fmt.Print("table", table)
1524
+	if orgID > 0 {
1525
+		db = db.Where("x.user_org_id=?", orgID)
1526
+	}
1527
+	if patientID > 0 {
1528
+		db = db.Where("x.patient_id = ?", patientID)
1529
+	}
1530
+	if advice_type == 1 && advice_type > 0 {
1531
+		db = db.Where("x.advice_type = ?", advice_type)
1532
+	}
1533
+	if advice_type == 3 && advice_type > 0 {
1534
+		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
1535
+	}
1536
+	if advice_type == 4 && advice_type > 0 {
1537
+		db = db.Where("x.advice_type = 4")
1538
+	}
1539
+	if stop == 1 {
1540
+		db = db.Where("(x.stop_state=? or x.execution_state=?)", stop, stop)
1541
+	} else if stop == 2 {
1542
+		db = db.Where("x.stop_state=? and x.execution_state=?", stop, stop)
1543
+	}
1544
+
1545
+	if start != 0 {
1546
+		db = db.Where("x.start_time>=?", start)
1547
+	}
1548
+	if end != 0 {
1549
+		db = db.Where("x.start_time<=?", end)
1550
+	}
1551
+	if len(keywords) > 0 {
1552
+		likeKey := "%" + keywords + "%"
1553
+		db = db.Where("x.advice_name LIKE ?", likeKey)
1554
+	}
1555
+	offset := (page - 1) * limit
1556
+	err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&advices).Error
1557
+	fmt.Print("err", err)
1558
+	return
1559
+}
1560
+
1561
+func GetDoctorAdviceListFour(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64) (advices []*models.HisDoctorAdvice, total int64, err error) {
1562
+
1563
+	db := readDb.Table("his_doctor_advice_info as x").Where("x.status = 1")
1564
+	table := UserReadDB().Table("sgj_user_admin_role as r")
1565
+	fmt.Println(table)
1566
+	if orgID > 0 {
1567
+		db = db.Where("x.user_org_id=?", orgID)
1568
+	}
1569
+	if patientID > 0 {
1570
+		db = db.Where("x.patient_id = ?", patientID)
1571
+	}
1572
+	if advice_type == 1 {
1573
+		db = db.Where("x.advice_type = ?", advice_type)
1574
+	}
1575
+	if advice_type == 3 && advice_type > 0 {
1576
+		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
1577
+	}
1578
+	if advice_type == 4 && advice_type > 0 {
1579
+		db = db.Where("x.advice_type = 4")
1580
+	}
1581
+
1582
+	if stop == 1 {
1583
+		db = db.Where("(x.stop_state=? or x.execution_state=?)", stop, stop)
1584
+	} else if stop == 2 {
1585
+		db = db.Where("x.stop_state=? and x.execution_state=?", stop, stop)
1586
+	}
1587
+
1588
+	if start != 0 {
1589
+		db = db.Where("x.start_time>=?", start)
1590
+	}
1591
+	if end != 0 {
1592
+		db = db.Where("x.start_time<=?", end)
1593
+	}
1594
+	if len(keywords) > 0 {
1595
+		likeKey := "%" + keywords + "%"
1596
+		db = db.Where("x.advice_name LIKE ?", likeKey)
1597
+	}
1598
+	offset := (page - 1) * limit
1599
+	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&advices).Error
1600
+	fmt.Print("错误是什么", err)
1601
+	return
1602
+
1603
+}

+ 1 - 1
service/stock_service.go View File

@@ -4937,6 +4937,6 @@ func UpdateWarehouseInfoByGoodId(info models.WarehousingInfo, id int64) error {
4937 4937
 
4938 4938
 func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
4939 4939
 
4940
-	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}).Error
4940
+	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 4941
 	return err
4942 4942
 }

+ 60 - 12
service/warhouse_service.go View File

@@ -809,32 +809,56 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
809 809
 			WarehouseOutId:          warehouseout.ID,
810 810
 			Status:                  1,
811 811
 			Ctime:                   time.Now().Unix(),
812
-			Remark:                  advice.Remark,
812
+			Remark:                  warehouse.Remark,
813 813
 			OrgId:                   orgID,
814 814
 			Type:                    1,
815 815
 			Manufacturer:            advice.Manufacturer,
816
-			Dealer:                  advice.Dealer,
816
+			Dealer:                  warehouse.Dealer,
817 817
 			IsSys:                   0,
818 818
 			SysRecordTime:           advice.Ctime,
819 819
 			DrugId:                  advice.DrugId,
820 820
 			ExpiryDate:              advice.ExpiryDate,
821 821
 			ProductDate:             advice.ProductDate,
822 822
 			Number:                  advice.Number,
823
-			BatchNumber:             advice.BatchNumber,
824
-			Count:                   advice.Count,
823
+			BatchNumber:             warehouse.BatchNumber,
824
+			Count:                   deliver_number,
825 825
 			RetailPrice:             advice.RetailPrice,
826 826
 			Price:                   advice.Price,
827 827
 			WarehouseInfoId:         warehouse.ID,
828
+			CountUnit:               drup.MinUnit,
828 829
 		}
829 830
 
830 831
 		warehouseOutInfo.Count = prescribingNumber
831 832
 		warehouseOutInfo.CountUnit = advice.CountUnit
832 833
 
833 834
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
834
-
835 835
 		if errOne != nil {
836 836
 			return errOne
837 837
 		}
838
+		list, _ := GetLastWarehouseOut(drup.OrgId)
839
+		drugflow := models.DrugFlow{
840
+			WarehouseOutId:          list.ID,
841
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
842
+			DrugId:                  advice.DrugId,
843
+			Number:                  warehouse.Number,
844
+			ProductDate:             warehouse.ProductDate,
845
+			ExpireDate:              warehouse.ExpiryDate,
846
+			Count:                   deliver_number,
847
+			Price:                   advice.Price,
848
+			Status:                  1,
849
+			Ctime:                   time.Now().Unix(),
850
+			UserOrgId:               advice.OrgId,
851
+			Manufacturer:            advice.Manufacturer,
852
+			Dealer:                  advice.Dealer,
853
+			BatchNumber:             warehouse.BatchNumber,
854
+			MaxUnit:                 drup.MinUnit,
855
+			ConsumableType:          2,
856
+			IsEdit:                  1,
857
+			Creator:                 0,
858
+			IsSys:                   0,
859
+		}
860
+
861
+		CreateDrugFlowOne(drugflow)
838 862
 		// 出库完成后,要减去对应批次的库存数量
839 863
 		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
840 864
 		var maxNumber int64 = 0
@@ -878,22 +902,23 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
878 902
 			WarehouseOutId:          warehouseout.ID,
879 903
 			Status:                  1,
880 904
 			Ctime:                   time.Now().Unix(),
881
-			Remark:                  advice.Remark,
905
+			Remark:                  warehouse.Remark,
882 906
 			OrgId:                   orgID,
883 907
 			Type:                    1,
884 908
 			Manufacturer:            advice.Manufacturer,
885
-			Dealer:                  advice.Dealer,
909
+			Dealer:                  warehouse.Dealer,
886 910
 			IsSys:                   0,
887 911
 			SysRecordTime:           advice.Ctime,
888 912
 			DrugId:                  advice.DrugId,
889
-			ExpiryDate:              advice.ExpiryDate,
890
-			ProductDate:             advice.ProductDate,
891
-			Number:                  advice.Number,
892
-			BatchNumber:             advice.BatchNumber,
893
-			Count:                   advice.Count,
913
+			ExpiryDate:              warehouse.ExpiryDate,
914
+			ProductDate:             warehouse.ProductDate,
915
+			Number:                  warehouse.Number,
916
+			BatchNumber:             warehouse.BatchNumber,
917
+			Count:                   deliver_number,
894 918
 			RetailPrice:             advice.RetailPrice,
895 919
 			Price:                   advice.Price,
896 920
 			WarehouseInfoId:         warehouse.ID,
921
+			CountUnit:               drup.MinUnit,
897 922
 		}
898 923
 		warehouseOutInfo.Count = prescribingNumber
899 924
 
@@ -903,6 +928,29 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
903 928
 		if errOne != nil {
904 929
 			return errOne
905 930
 		}
931
+		list, _ := GetLastWarehouseOut(drup.OrgId)
932
+		drugflow := models.DrugFlow{
933
+			WarehouseOutId:          list.ID,
934
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
935
+			DrugId:                  advice.DrugId,
936
+			Number:                  warehouse.Number,
937
+			ProductDate:             warehouse.ProductDate,
938
+			ExpireDate:              warehouse.ExpiryDate,
939
+			Count:                   deliver_number,
940
+			Price:                   advice.Price,
941
+			Status:                  1,
942
+			Ctime:                   time.Now().Unix(),
943
+			UserOrgId:               advice.OrgId,
944
+			Manufacturer:            advice.Manufacturer,
945
+			Dealer:                  advice.Dealer,
946
+			BatchNumber:             warehouse.BatchNumber,
947
+			MaxUnit:                 drup.MinUnit,
948
+			ConsumableType:          2,
949
+			IsEdit:                  1,
950
+			Creator:                 0,
951
+			IsSys:                   0,
952
+		}
953
+		CreateDrugFlowOne(drugflow)
906 954
 		// 出库完成后,要将该批次库存清零
907 955
 		warehouse.StockMaxNumber = 0
908 956
 		warehouse.StockMinNumber = 0