Browse Source

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

陈少旭 6 months ago
parent
commit
affada0bbc

BIN
XT_New.exe View File


+ 1 - 1
conf/app.conf View File

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

+ 6 - 6
controllers/base_api_controller.go View File

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

+ 8 - 0
controllers/drug_stock_api_contorller.go View File

@@ -240,6 +240,8 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
240 240
 				}
241 241
 				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
242 242
 
243
+				drug_code := items["drug_code"].(string)
244
+
243 245
 				warehouseInfo := &models.DrugWarehouseInfo{
244 246
 					ID:               id,
245 247
 					WarehousingOrder: info.WarehousingOrder,
@@ -267,6 +269,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
267 269
 					StorehouseId:     storehouse_id,
268 270
 					IsCheck:          2,
269 271
 					StockMinNumber:   0,
272
+					DrugCode:         drug_code,
270 273
 				}
271 274
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
272 275
 			}
@@ -545,6 +548,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
545 548
 
546 549
 				dealer := int64(items["dealer"].(float64))
547 550
 
551
+				drug_code, _ := items["drug_code"].(string)
548 552
 				medical, _ := service.GetBaseDrugMedical(drug_id)
549 553
 				if id == 0 {
550 554
 					warehouseInfo := &models.DrugWarehouseInfo{
@@ -572,6 +576,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
572 576
 						StockMaxNumber:   0,
573 577
 						StorehouseId:     storehouse_id,
574 578
 						StockMinNumber:   0,
579
+						DrugCode:         drug_code,
575 580
 					}
576 581
 
577 582
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
@@ -602,6 +607,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
602 607
 						MinUnit:          min_unit,
603 608
 						BatchNumber:      batch_number,
604 609
 						StorehouseId:     storehouse_id,
610
+						DrugCode:         drug_code,
605 611
 					}
606 612
 					if medical.MaxUnit == medical.MinUnit {
607 613
 						warehouseInfo.StockMaxNumber = warehousing_count
@@ -651,6 +657,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
651 657
 						IsSys:               0,
652 658
 						WarehousingDetailId: id,
653 659
 						StorehouseId:        storehouse_id,
660
+						DrugCode:            drug_code,
654 661
 					}
655 662
 
656 663
 					if max_unit == min_unit {
@@ -3651,6 +3658,7 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3651 3658
 			StorehouseId:            item.StorehouseId,
3652 3659
 			OverCount:               sum_count,
3653 3660
 			OperateTime:             time.Now().Unix(),
3661
+			DrugCode:                item.DrugCode,
3654 3662
 		}
3655 3663
 		service.CreateDrugFlowTwo(flow)
3656 3664
 		//更新基础库剩余库存

+ 190 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -11317,3 +11317,193 @@ func (c *DialysisAPIController) UpdateEditDrugOrder() {
11317 11317
 		"advice": advice,
11318 11318
 	})
11319 11319
 }
11320
+
11321
+func (c *DialysisAPIController) SaveLongAdviceTemplate() {
11322
+
11323
+	dataBody := make(map[string]interface{}, 0)
11324
+	timeLayout := "2006-01-02"
11325
+	loc, _ := time.LoadLocation("Local")
11326
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
11327
+	if err != nil {
11328
+		utils.ErrorLog(err.Error())
11329
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11330
+		return
11331
+	}
11332
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11333
+		utils.ErrorLog("start_time")
11334
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11335
+		return
11336
+	}
11337
+
11338
+	startTime2, _ := dataBody["start_time"].(string)
11339
+	time_arr := strings.Split(startTime2, " ")
11340
+	if len(time_arr) > 0 {
11341
+		startTime2 = time_arr[0]
11342
+	}
11343
+	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
11344
+		utils.ErrorLog("advice_date")
11345
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11346
+		return
11347
+	}
11348
+	advice_date, _ := dataBody["advice_date"].(string)
11349
+
11350
+	var advicedateunix int64
11351
+	if len(advice_date) > 0 {
11352
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
11353
+		if err != nil {
11354
+			fmt.Println(err)
11355
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11356
+			return
11357
+		}
11358
+		advicedateunix = theTime.Unix()
11359
+	}
11360
+
11361
+	adviceDate := startTime2
11362
+	if len(adviceDate) == 0 {
11363
+		utils.ErrorLog("len(adviceDate) == 0")
11364
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11365
+		return
11366
+	}
11367
+	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
11368
+	if err != nil {
11369
+		utils.ErrorLog(err.Error())
11370
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11371
+		return
11372
+	}
11373
+	RecordDate := advicedateunix
11374
+
11375
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11376
+		utils.ErrorLog("start_time")
11377
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11378
+		return
11379
+	}
11380
+	startTime, _ := dataBody["start_time"].(string)
11381
+
11382
+	if len(startTime) == 0 {
11383
+		utils.ErrorLog("len(start_time) == 0")
11384
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11385
+		return
11386
+	}
11387
+	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
11388
+
11389
+	if err != nil {
11390
+		utils.ErrorLog(err.Error())
11391
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11392
+		return
11393
+	}
11394
+	StartTime := theTime.Unix()
11395
+
11396
+	patient_id := int64(dataBody["patient_id"].(float64))
11397
+
11398
+	group_no := int64(dataBody["group_no"].(float64))
11399
+
11400
+	org_id := c.GetMobileAdminUserInfo().Org.Id
11401
+
11402
+	advice_doctor := c.GetMobileAdminUserInfo().AdminUser.Id
11403
+
11404
+	if dataBody["advices"] == nil || reflect.TypeOf(dataBody["advices"]).String() != "[]interface {}" {
11405
+		utils.ErrorLog("advices")
11406
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11407
+		return
11408
+	}
11409
+	adviceNames := dataBody["advices"].([]interface{})
11410
+
11411
+	var advices []*models.GroupAdvice
11412
+	for _, adviceNameMap := range adviceNames {
11413
+		var advice models.GroupAdvice
11414
+		adviceNameM := adviceNameMap.(map[string]interface{})
11415
+		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
11416
+			utils.ErrorLog("advice_name")
11417
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11418
+			return
11419
+		}
11420
+		adviceName, _ := adviceNameM["advice_name"].(string)
11421
+
11422
+		if len(adviceName) == 0 {
11423
+			utils.ErrorLog("len(advice_name) == 0")
11424
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11425
+			return
11426
+		}
11427
+		advice.AdviceName = adviceName
11428
+
11429
+		if adviceNameM["drug_spec"] != nil && reflect.TypeOf(adviceNameM["drug_spec"]).String() == "string" {
11430
+			drugSpec, _ := strconv.ParseFloat(adviceNameM["drug_spec"].(string), 64)
11431
+			advice.DrugSpec = drugSpec
11432
+		}
11433
+
11434
+		if adviceNameM["advice_desc"] != nil && reflect.TypeOf(adviceNameM["advice_desc"]).String() == "string" {
11435
+			adviceDesc, _ := adviceNameM["advice_desc"].(string)
11436
+			advice.AdviceDesc = adviceDesc
11437
+		}
11438
+
11439
+		if adviceNameM["drug_spec_unit"] != nil && reflect.TypeOf(adviceNameM["drug_spec_unit"]).String() == "string" {
11440
+			drugSpecUnit, _ := adviceNameM["drug_spec_unit"].(string)
11441
+			advice.DrugSpecUnit = drugSpecUnit
11442
+		}
11443
+
11444
+		if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "string" {
11445
+			singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
11446
+			advice.SingleDose = singleDose
11447
+		}
11448
+		if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
11449
+			singleDose := adviceNameM["single_dose"].(float64)
11450
+			advice.SingleDose = singleDose
11451
+		}
11452
+
11453
+		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
11454
+			singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
11455
+			advice.SingleDoseUnit = singleDoseUnit
11456
+		}
11457
+		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "float64" {
11458
+			tmp := adviceNameM["single_dose_unit"].(float64)
11459
+			singleDoseUnit := service.TypeConversion(tmp)
11460
+			advice.SingleDoseUnit = singleDoseUnit
11461
+		}
11462
+
11463
+		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
11464
+			prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
11465
+			advice.PrescribingNumber = prescribingNumber
11466
+		}
11467
+		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
11468
+			prescribingNumber := adviceNameM["prescribing_number"].(float64)
11469
+			advice.PrescribingNumber = prescribingNumber
11470
+		}
11471
+
11472
+		if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
11473
+			prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
11474
+			advice.PrescribingNumberUnit = prescribingNumberUnit
11475
+		}
11476
+		if adviceNameM["delivery_way"] != nil && reflect.TypeOf(adviceNameM["delivery_way"]).String() == "string" {
11477
+			deliveryWay, _ := adviceNameM["delivery_way"].(string)
11478
+			advice.DeliveryWay = deliveryWay
11479
+		}
11480
+
11481
+		if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
11482
+			executionFrequency, _ := adviceNameM["execution_frequency"].(string)
11483
+			advice.ExecutionFrequency = executionFrequency
11484
+		}
11485
+
11486
+		remark, _ := adviceNameM["remark"].(string)
11487
+
11488
+		advice.Remark = remark
11489
+
11490
+		advice.AdviceType = 1
11491
+
11492
+		advice.StartTime = StartTime
11493
+		advice.RecordDate = RecordDate
11494
+
11495
+		advice.PatientId = patient_id
11496
+
11497
+		advice.UserOrgId = org_id
11498
+
11499
+		advice.AdviceDoctor = advice_doctor
11500
+
11501
+		advices = append(advices, &advice)
11502
+	}
11503
+
11504
+	newAdvices, _ := service.CreateMobileMGroupAdvice(org_id, advices, group_no)
11505
+
11506
+	c.ServeSuccessJSON(map[string]interface{}{
11507
+		"advice": newAdvices,
11508
+	})
11509
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -229,4 +229,6 @@ func MobileAPIControllersRegisterRouters() {
229 229
 	beego.Router("/m/api/updatelongmobileadvice", &DialysisAPIController{}, "Post:UpdateLongMobileAdvice")
230 230
 
231 231
 	beego.Router("/m/api/updateeditdrugorder", &DialysisAPIController{}, "Post:UpdateEditDrugOrder")
232
+
233
+	beego.Router("/m/api/savelongadvicetemplate", &DialysisAPIController{}, "Post:SaveLongAdviceTemplate")
232 234
 }

+ 0 - 1
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -5625,7 +5625,6 @@ func (c *PatientApiController) CreateGroupAdvice() {
5625 5625
 		Startdate := int64(dataBody["record_date"].(float64))
5626 5626
 
5627 5627
 		var advices []*models.GroupAdvice
5628
-		// utils.TraceLog("%+v", dataBody["adviceNames"])
5629 5628
 		if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
5630 5629
 			utils.ErrorLog("adviceNames")
5631 5630
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 2 - 2
controllers/self_drug_api_congtroller.go View File

@@ -6059,7 +6059,7 @@ func (c *SelfDrugApiController) GetAllSelfDrugWarehouse() {
6059 6059
 
6060 6060
 	list, total, _ := service.GetAllSelfDrugWarehouse(keyword, startTime, endTime, check_type, orgId, page, limit, patient_id)
6061 6061
 
6062
-	doctorList, _ := service.GetAllDoctorList(orgId, appId)
6062
+	doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
6063 6063
 
6064 6064
 	c.ServeSuccessJSON(map[string]interface{}{
6065 6065
 		"list":       list,
@@ -6114,7 +6114,7 @@ func (c *SelfDrugApiController) GetAllSelfDrugWarehouseOut() {
6114 6114
 	}
6115 6115
 
6116 6116
 	list, total, _ := service.GetAllSelfDrugWarehouseOut(startTime, endTime, orgId, page, limit, patient_id, keyword, check_type)
6117
-	doctorList, _ := service.GetAllDoctorList(orgId, appId)
6117
+	doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
6118 6118
 	c.ServeSuccessJSON(map[string]interface{}{
6119 6119
 		"list":       list,
6120 6120
 		"total":      total,

+ 5 - 1
models/drug_stock.go View File

@@ -91,6 +91,7 @@ type DrugWarehouseInfo struct {
91 91
 	IsCheck                   int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
92 92
 	ManafacturerName          string  `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
93 93
 	DealerName                string  `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
94
+	DrugCode                  string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
94 95
 }
95 96
 
96 97
 func (DrugWarehouseInfo) TableName() string {
@@ -463,6 +464,7 @@ type DrugFlow struct {
463 464
 	Remark                    string                 `gorm:"column:remark" json:"remark" form:"remark"`
464 465
 	OperateTime               int64                  `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
465 466
 	SaleDate                  string                 `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
467
+	DrugCode                  string                 `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
466 468
 }
467 469
 
468 470
 func (DrugFlow) TableName() string {
@@ -577,8 +579,10 @@ type DrugWarehouseInfoTwenty struct {
577 579
 	StorehouseId              int64                        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
578 580
 	SecondWarehouseInfoId     int64                        `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
579 581
 	IsCheck                   int64                        `gorm:"column:is_check" json:"is_check" form:"is_check"`
582
+	DrugCode                  string                       `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
580 583
 	BaseDrugLib               BaseDrugLib                  `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
581
-	DrugWarehouseOutInfoTenty []*DrugWarehouseOutInfoTenty `gorm:"ForeignKey:WarehouseOutId;AssociationForeignKey:ID"json:"xt_drug_warehouse_out_info" `
584
+	DrugWarehouseOutInfoTenty []*DrugWarehouseOutInfoTenty `gorm:"ForeignKey:WarehouseOutId;AssociationForeignKey:ID"json:"xt_drug_warehouse_out_info" 
585
+    `
582 586
 }
583 587
 
584 588
 func (DrugWarehouseInfoTwenty) TableName() string {

+ 1 - 0
models/self_drug_models.go View File

@@ -426,6 +426,7 @@ type XtDrugWarehouseInfo struct {
426 426
 	IsCheck                   int64      `gorm:"column:is_check" json:"is_check" form:"is_check"`
427 427
 	ManafacturerName          string     `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
428 428
 	DealerName                string     `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
429
+	DrugCode                  string     `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
429 430
 }
430 431
 
431 432
 func (XtDrugWarehouseInfo) TableName() string {

+ 42 - 2
service/dialysis_service.go View File

@@ -2619,12 +2619,52 @@ func DeleteSelfAdviceSubAdvice(id int64) (models.XtDoctorAdviceOne, error) {
2619 2619
 
2620 2620
 func UpdateMobileDoctorAdviceById(id int64, advice models.XtDoctorAdviceOne) error {
2621 2621
 
2622
-	err := XTWriteDB().Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark}).Error
2622
+	err := XTWriteDB().Model(&models.XtDoctorAdviceOne{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark}).Error
2623 2623
 	return err
2624 2624
 }
2625 2625
 
2626 2626
 func UpdateMobileDoctorAdviceByIdOne(id int64, advice models.XtDoctorAdviceOne) error {
2627 2627
 
2628
-	err := XTWriteDB().Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark, "frequency_type": advice.FrequencyType, "week_day": advice.WeekDay, "day_count": advice.DayCount}).Error
2628
+	err := XTWriteDB().Model(&models.XtDoctorAdviceOne{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark, "frequency_type": advice.FrequencyType, "week_day": advice.WeekDay, "day_count": advice.DayCount}).Error
2629 2629
 	return err
2630 2630
 }
2631
+
2632
+func CreateMobileMGroupAdvice(orgId int64, advices []*models.GroupAdvice, groupNo int64) (list []*models.GroupAdvice, err error) {
2633
+	if groupNo <= 0 {
2634
+		group := GetMaxAdviceGroupID(orgId)
2635
+		groupNo = group + 1
2636
+	}
2637
+
2638
+	tx := writeDb.Begin()
2639
+	defer func() {
2640
+		if r := recover(); r != nil {
2641
+			tx.Rollback()
2642
+		}
2643
+	}()
2644
+	for _, advice := range advices {
2645
+		advice.GroupNo = groupNo
2646
+		advice.Status = 1
2647
+		template_id := strconv.FormatInt(groupNo, 10)
2648
+		advice.TemplateId = "M" + template_id
2649
+		if err = tx.Create(advice).Error; err != nil {
2650
+			tx.Rollback()
2651
+			return
2652
+		}
2653
+		list = append(list, advice)
2654
+		if len(advice.Children) > 0 {
2655
+			for _, child := range advice.Children {
2656
+				child.GroupNo = groupNo
2657
+				child.ParentId = advice.ID
2658
+				fmt.Println(child)
2659
+				if err = tx.Create(&child).Error; err != nil {
2660
+					tx.Rollback()
2661
+					return
2662
+				}
2663
+				list = append(list, child)
2664
+			}
2665
+		}
2666
+
2667
+	}
2668
+	tx.Commit()
2669
+	return
2670
+}

+ 2 - 1
service/stock_service.go View File

@@ -1098,6 +1098,7 @@ type VMDrugWarehouseInfo struct {
1098 1098
 	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
1099 1099
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
1100 1100
 	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1101
+	DrugCode                  string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
1101 1102
 }
1102 1103
 
1103 1104
 func (VMDrugWarehouseInfo) TableName() string {
@@ -8197,7 +8198,7 @@ func AddDrugReturnWarehouseStockMinNumber(count int64, id int64) error {
8197 8198
 
8198 8199
 func UpdateDrugWarehouseInfoTwenty(id int64, info *models.DrugWarehouseInfo) error {
8199 8200
 
8200
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "retail_price": info.RetailPrice, "max_unit": info.MaxUnit, "min_unit": info.MinUnit}).Error
8201
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "retail_price": info.RetailPrice, "max_unit": info.MaxUnit, "min_unit": info.MinUnit, "drug_code": info.DrugCode}).Error
8201 8202
 	return err
8202 8203
 }
8203 8204