Explorar el Código

11月8日库存管理

XMLWAN hace 2 años
padre
commit
b396f83d46

+ 66 - 66
controllers/dialysis_record_api_controller.go Ver fichero

@@ -1349,72 +1349,72 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1349 1349
 
1350 1350
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10215 || adminUserInfo.CurrentOrgId == 10233 || adminUserInfo.CurrentOrgId == 10223 || adminUserInfo.CurrentOrgId == 10243 || adminUserInfo.CurrentOrgId == 10340 {
1351 1351
 
1352
-		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1353
-		if evaluation.SystolicBloodPressure == 0 {
1354
-			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1355
-
1356
-			pre := models.PredialysisEvaluation{
1357
-				SystolicBloodPressure: evaluation.SystolicBloodPressure,
1358
-			}
1359
-			fmt.Println("prew", pre)
1360
-			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1361
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1362
-			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1363
-
1364
-			redis := service.RedisClient()
1365
-			redis.Set(key, "", time.Second)
1366
-			redis.Set(keyOne, "", time.Second)
1367
-			defer redis.Close()
1368
-			fmt.Println(getNurseErr)
1369
-		}
1370
-		if evaluation.DiastolicBloodPressure == 0 {
1371
-			evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1372
-			pres := models.PredialysisEvaluation{
1373
-				DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1374
-			}
1375
-			getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1376
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1377
-
1378
-			redis := service.RedisClient()
1379
-			redis.Set(key, "", time.Second)
1380
-
1381
-			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1382
-			redis.Set(keyOne, "", time.Second)
1383
-			defer redis.Close()
1384
-			fmt.Println(getNurseErr)
1385
-		}
1386
-		if evaluation.PulseFrequency == 0 {
1387
-			evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1388
-			press := models.PredialysisEvaluation{
1389
-				PulseFrequency: evaluation.PulseFrequency,
1390
-			}
1391
-			getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1392
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1393
-
1394
-			redis := service.RedisClient()
1395
-			redis.Set(key, "", time.Second)
1396
-			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1397
-			redis.Set(keyOne, "", time.Second)
1398
-			defer redis.Close()
1399
-			fmt.Println(getNurseErr)
1400
-		}
1401
-
1402
-		if evaluation.Temperature == 0 {
1403
-			evaluation.Temperature = fmonitorRecords.Temperature
1404
-			press := models.PredialysisEvaluation{
1405
-				Temperature: evaluation.Temperature,
1406
-			}
1407
-			getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1408
-			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1409
-
1410
-			redis := service.RedisClient()
1411
-			redis.Set(key, "", time.Second)
1412
-			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1413
-			redis.Set(keyOne, "", time.Second)
1414
-			defer redis.Close()
1415
-			fmt.Println(getNurseErr)
1416
-		}
1417
-
1352
+		//evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1353
+		//if evaluation.SystolicBloodPressure == 0 {
1354
+		//	evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1355
+		//
1356
+		//	pre := models.PredialysisEvaluation{
1357
+		//		SystolicBloodPressure: evaluation.SystolicBloodPressure,
1358
+		//	}
1359
+		//	fmt.Println("prew", pre)
1360
+		//	getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1361
+		//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1362
+		//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1363
+		//
1364
+		//	redis := service.RedisClient()
1365
+		//	redis.Set(key, "", time.Second)
1366
+		//	redis.Set(keyOne, "", time.Second)
1367
+		//	defer redis.Close()
1368
+		//	fmt.Println(getNurseErr)
1369
+		//}
1370
+		//if evaluation.DiastolicBloodPressure == 0 {
1371
+		//	evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1372
+		//	pres := models.PredialysisEvaluation{
1373
+		//		DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1374
+		//	}
1375
+		//	getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1376
+		//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1377
+		//
1378
+		//	redis := service.RedisClient()
1379
+		//	redis.Set(key, "", time.Second)
1380
+		//
1381
+		//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1382
+		//	redis.Set(keyOne, "", time.Second)
1383
+		//	defer redis.Close()
1384
+		//	fmt.Println(getNurseErr)
1385
+		//}
1386
+		//if evaluation.PulseFrequency == 0 {
1387
+		//	evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1388
+		//	press := models.PredialysisEvaluation{
1389
+		//		PulseFrequency: evaluation.PulseFrequency,
1390
+		//	}
1391
+		//	getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1392
+		//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1393
+		//
1394
+		//	redis := service.RedisClient()
1395
+		//	redis.Set(key, "", time.Second)
1396
+		//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1397
+		//	redis.Set(keyOne, "", time.Second)
1398
+		//	defer redis.Close()
1399
+		//	fmt.Println(getNurseErr)
1400
+		//}
1401
+		//
1402
+		//if evaluation.Temperature == 0 {
1403
+		//	evaluation.Temperature = fmonitorRecords.Temperature
1404
+		//	press := models.PredialysisEvaluation{
1405
+		//		Temperature: evaluation.Temperature,
1406
+		//	}
1407
+		//	getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1408
+		//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1409
+		//
1410
+		//	redis := service.RedisClient()
1411
+		//	redis.Set(key, "", time.Second)
1412
+		//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1413
+		//	redis.Set(keyOne, "", time.Second)
1414
+		//	defer redis.Close()
1415
+		//	fmt.Println(getNurseErr)
1416
+		//}
1417
+		//
1418 1418
 		if err != nil {
1419 1419
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1420 1420
 			return

+ 1 - 2
controllers/drug_stock_api_contorller.go Ver fichero

@@ -3875,8 +3875,7 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3875 3875
 	adminUserInfo := c.GetAdminUserInfo()
3876 3876
 	orgId := adminUserInfo.CurrentOrgId
3877 3877
 	if order_type == 2 {
3878
-		//list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3879
-		list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3878
+		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3880 3879
 		if err == nil {
3881 3880
 			c.ServeSuccessJSON(map[string]interface{}{
3882 3881
 				"list": list,

+ 30 - 1
controllers/gobal_config_api_controller.go Ver fichero

@@ -118,6 +118,8 @@ func GobalConfigRegistRouters() {
118 118
 	beego.Router("/api/changeadviceconfig", &GobalConfigApiController{}, "Get:ChangeAdviceConfig")
119 119
 
120 120
 	beego.Router("/api/changeprescriptionconfig", &GobalConfigApiController{}, "Get:ChangePrescriptionConfig")
121
+
122
+	beego.Router("/api/changedrugopenconfig", &GobalConfigApiController{}, "Get:ChangeDrugOpenConfig")
121 123
 }
122 124
 
123 125
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1567,12 +1569,15 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1567 1569
 	adviceSetting, _ := service.FindAdviceSettingById(adminUserInfo.CurrentOrgId)
1568 1570
 
1569 1571
 	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminUserInfo.CurrentOrgId)
1572
+
1573
+	drugOutConfig, _ := service.FindDrugOutConfigById(adminUserInfo.CurrentOrgId)
1570 1574
 	c.ServeSuccessJSON(map[string]interface{}{
1571 1575
 		"is_open_xt_his":         config.IsOpen,
1572 1576
 		"is_open_xt_his_project": project_config.IsOpen,
1573 1577
 		"is_open_stock":          stockSetting.IsType,
1574 1578
 		"is_open_advice":         adviceSetting.IsAdviceOpen,
1575 1579
 		"is_prescription_advice": prescriptionConfig.IsOpen,
1580
+		"is_open":                drugOutConfig.IsOpen,
1576 1581
 	})
1577 1582
 
1578 1583
 }
@@ -2239,7 +2244,7 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2239 2244
 
2240 2245
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2241 2246
 
2242
-	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids)
2247
+	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2243 2248
 
2244 2249
 	c.ServeSuccessJSON(map[string]interface{}{
2245 2250
 		"info":              info,
@@ -2437,3 +2442,27 @@ func (c *GobalConfigApiController) ChangePrescriptionConfig() {
2437 2442
 	}
2438 2443
 
2439 2444
 }
2445
+
2446
+func (c *GobalConfigApiController) ChangeDrugOpenConfig() {
2447
+
2448
+	drug_out_open, _ := c.GetInt64("drug_out_open")
2449
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2450
+	_, errcode := service.GetDrugOpenConfig(orgId)
2451
+	if errcode == gorm.ErrRecordNotFound {
2452
+		config := models.DrugOutConfig{
2453
+			UserOrgId: orgId,
2454
+			IsOpen:    drug_out_open,
2455
+			Status:    1,
2456
+			Ctime:     time.Now().Unix(),
2457
+		}
2458
+		service.CreateDrugOutConfig(config)
2459
+		c.ServeSuccessJSON(map[string]interface{}{
2460
+			"msg": 1,
2461
+		})
2462
+	} else if errcode == nil {
2463
+		service.UpdateDrugOutConfig(orgId, drug_out_open)
2464
+		c.ServeSuccessJSON(map[string]interface{}{
2465
+			"msg": 1,
2466
+		})
2467
+	}
2468
+}

+ 27 - 0
models/drug_stock.go Ver fichero

@@ -467,3 +467,30 @@ type DrugWarehouseOutInfoTenty struct {
467 467
 func (DrugWarehouseOutInfoTenty) TableName() string {
468 468
 	return "xt_drug_warehouse_out_info"
469 469
 }
470
+
471
+type DrugWarehouseOutTwenty struct {
472
+	ID                        int64                     `gorm:"column:id" json:"id" form:"id"`
473
+	WarehouseOutOrderNumber   string                    `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
474
+	OperationTime             int64                     `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
475
+	Creater                   int64                     `gorm:"column:creater" json:"creater" form:"creater"`
476
+	OrgId                     int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
477
+	Modifier                  int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
478
+	Remark                    string                    `gorm:"column:remark" json:"remark" form:"remark"`
479
+	Ctime                     int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
480
+	Mtime                     int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
481
+	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
482
+	WarehouseOutTime          int64                     `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
483
+	Dealer                    int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
484
+	Manufacturer              int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
485
+	Type                      int64                     `gorm:"column:type" json:"type" form:"type"`
486
+	IsSys                     int64                     `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
487
+	SupplyCancelOutId         int64                     `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
488
+	SupplyWarehouseId         int64                     `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
489
+	StorehouseId              int64                     `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
490
+	SecondWarehouseId         int64                     `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
491
+	DrugWarehouseOutInfoTenty DrugWarehouseOutInfoTenty `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutId"json:"xt_drug_warehouse_out_info" `
492
+}
493
+
494
+func (DrugWarehouseOutTwenty) TableName() string {
495
+	return "xt_drug_warehouse_out"
496
+}

+ 13 - 0
models/stock_models.go Ver fichero

@@ -1378,3 +1378,16 @@ type XtPrescriptionConfig struct {
1378 1378
 func (XtPrescriptionConfig) TableName() string {
1379 1379
 	return "xt_prescription_config"
1380 1380
 }
1381
+
1382
+type DrugOutConfig struct {
1383
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1384
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1385
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1386
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1387
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1388
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1389
+}
1390
+
1391
+func (DrugOutConfig) TableName() string {
1392
+	return "xt_drug_out_config"
1393
+}

+ 38 - 2
service/stock_service.go Ver fichero

@@ -4688,9 +4688,13 @@ func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehou
4688 4688
 	return out, err
4689 4689
 }
4690 4690
 
4691
-func GetDrugWarehouseOutTenty(warehouse_out_id []string) (out []*models.DrugWarehouseOutInfoTenty, err error) {
4691
+func GetDrugWarehouseOutTenty(warehouse_out_id []string, orgid int64) (out []*models.DrugWarehouseOutTwenty, err error) {
4692
+
4693
+	err = XTReadDB().Where("id in(?)", warehouse_out_id).
4694
+		Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
4695
+			return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid)
4696
+		}).Find(&out).Error
4692 4697
 
4693
-	err = XTReadDB().Where("warehouse_out_id in(?)", warehouse_out_id).Preload("BaseDrugLib", "status = 1").Find(&out).Error
4694 4698
 	return out, err
4695 4699
 }
4696 4700
 
@@ -6794,3 +6798,35 @@ func UpdateWarehouseInfoTentyThree(count int64, id int64) error {
6794 6798
 
6795 6799
 	return err
6796 6800
 }
6801
+
6802
+func GetDrugOpenConfig(orgid int64) (*models.DrugOutConfig, error) {
6803
+
6804
+	config := models.DrugOutConfig{}
6805
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6806
+	if err == gorm.ErrRecordNotFound {
6807
+		return nil, err
6808
+	}
6809
+	if err != nil {
6810
+		return nil, err
6811
+	}
6812
+	return &config, nil
6813
+}
6814
+
6815
+func CreateDrugOutConfig(config models.DrugOutConfig) error {
6816
+
6817
+	err := XTWriteDB().Create(&config).Error
6818
+	return err
6819
+}
6820
+
6821
+func UpdateDrugOutConfig(orgid int64, drug_out_open int64) error {
6822
+
6823
+	err := XTWriteDB().Model(&models.DrugOutConfig{}).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": drug_out_open}).Error
6824
+	return err
6825
+}
6826
+
6827
+func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
6828
+
6829
+	config := models.DrugOutConfig{}
6830
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6831
+	return config, err
6832
+}