XMLWAN 4 лет назад
Родитель
Сommit
e421efa369

+ 19 - 4
controllers/mobile_api_controllers/dialysis_api_controller.go Просмотреть файл

@@ -3162,6 +3162,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3162 3162
 
3163 3163
 	if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3164 3164
 		goods, _ := dataBody["goods"].([]interface{})
3165
+
3165 3166
 		if len(goods) > 0 {
3166 3167
 			for _, item := range goods {
3167 3168
 				items := item.(map[string]interface{})
@@ -3188,7 +3189,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3188 3189
 
3189 3190
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3190 3191
 				commdity_code := items["commdity_code"].(string)
3191
-				fmt.Println("新建22222222222222", commdity_code)
3192
+
3192 3193
 				adminUser := c.GetMobileAdminUserInfo()
3193 3194
 				prepare := &models.DialysisBeforePrepare{
3194 3195
 					UserOrgId:    adminUser.Org.Id,
@@ -3203,7 +3204,9 @@ func (c *DialysisAPIController) CreateConsumables() {
3203 3204
 					Modifier:     0,
3204 3205
 					CommdityCode: commdity_code,
3205 3206
 				}
3207
+				//问题点
3206 3208
 				record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
3209
+
3207 3210
 				if record_count == 0 {
3208 3211
 					beforePrepares = append(beforePrepares, prepare)
3209 3212
 				}
@@ -3281,7 +3284,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3281 3284
 				ctime := int64(items["ctime"].(float64))
3282 3285
 
3283 3286
 				commdity_code := items["commdity_code"].(string)
3284
-				fmt.Println("commdityecode22222222222222222222", commdity_code)
3287
+
3285 3288
 				prepare := &models.DialysisBeforePrepare{
3286 3289
 					ID:           id,
3287 3290
 					UserOrgId:    adminUser.Org.Id,
@@ -3525,6 +3528,7 @@ func (c *DialysisAPIController) EditConsumables() {
3525 3528
 
3526 3529
 	var newBeforePrepares []*models.DialysisBeforePrepare
3527 3530
 
3531
+	//判断是否开启自动出库
3528 3532
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
3529 3533
 
3530 3534
 	if record.IsOpen == 1 {
@@ -3585,7 +3589,7 @@ func (c *DialysisAPIController) EditConsumables() {
3585 3589
 					}
3586 3590
 
3587 3591
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3588
-
3592
+					fmt.Println("count222222222222", count)
3589 3593
 					if items["ctime"] == nil || reflect.TypeOf(items["ctime"]).String() != "float64" {
3590 3594
 						utils.ErrorLog("ctime")
3591 3595
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -3593,7 +3597,7 @@ func (c *DialysisAPIController) EditConsumables() {
3593 3597
 					}
3594 3598
 					ctime := int64(items["ctime"].(float64))
3595 3599
 					commdity_code := items["commdity_code"].(string)
3596
-					fmt.Println("commdityecode22222222222222222222", commdity_code)
3600
+
3597 3601
 					adminUser := c.GetMobileAdminUserInfo()
3598 3602
 					prepare := &models.DialysisBeforePrepare{
3599 3603
 						ID:           id,
@@ -3616,7 +3620,9 @@ func (c *DialysisAPIController) EditConsumables() {
3616 3620
 			}
3617 3621
 		}
3618 3622
 
3623
+		//查询今日患者出库列表
3619 3624
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3625
+		fmt.Println("6666666666666", consumables_source)
3620 3626
 
3621 3627
 		if dataBody["new_goods"] != nil && reflect.TypeOf(dataBody["new_goods"]).String() == "[]interface {}" {
3622 3628
 			goods, _ := dataBody["new_goods"].([]interface{})
@@ -3645,6 +3651,7 @@ func (c *DialysisAPIController) EditConsumables() {
3645 3651
 					}
3646 3652
 
3647 3653
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3654
+
3648 3655
 					//commdity_code := items["commdity_code"].(string)
3649 3656
 					//fmt.Println("commdityecode22222222222222222222",commdity_code)
3650 3657
 					adminUser := c.GetMobileAdminUserInfo()
@@ -3666,9 +3673,12 @@ func (c *DialysisAPIController) EditConsumables() {
3666 3673
 				}
3667 3674
 				newBeforePrepares = RemoveRepeatedGood(newBeforePrepares)
3668 3675
 			}
3676
+
3677
+			//创建数据
3669 3678
 			service.CreateDialysisBeforePrepare(newBeforePrepares)
3670 3679
 		}
3671 3680
 
3681
+		//查询是否有出库单
3672 3682
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3673 3683
 		if err == gorm.ErrRecordNotFound {
3674 3684
 			//没有记录,则创建出库单
@@ -3694,7 +3704,9 @@ func (c *DialysisAPIController) EditConsumables() {
3694 3704
 				Type:                    1,
3695 3705
 				IsSys:                   1,
3696 3706
 			}
3707
+			//创建出库单
3697 3708
 			err := service.AddSigleWarehouseOut(&warehouseOut)
3709
+			fmt.Println("err22222222222222", err)
3698 3710
 			if err != nil {
3699 3711
 				utils.TraceLog("创建出库单失败 err = %v", err)
3700 3712
 			} else {
@@ -3719,6 +3731,7 @@ func (c *DialysisAPIController) EditConsumables() {
3719 3731
 						}
3720 3732
 						stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
3721 3733
 						warehouseOutInfo.Price = stockInInfo.Price
3734
+						//创建出库详情
3722 3735
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3723 3736
 						if err == nil {
3724 3737
 							details := &models.AutomaticReduceDetail{
@@ -3738,11 +3751,13 @@ func (c *DialysisAPIController) EditConsumables() {
3738 3751
 					}
3739 3752
 				}
3740 3753
 			}
3754
+			//没有出库单创建
3741 3755
 		} else if err == nil {
3742 3756
 
3743 3757
 			if len(newBeforePrepares) > 0 { //新增
3744 3758
 
3745 3759
 				for _, item := range newBeforePrepares {
3760
+
3746 3761
 					outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
3747 3762
 
3748 3763
 					if err == gorm.ErrRecordNotFound {

+ 1 - 1
models/user_models.go Просмотреть файл

@@ -523,7 +523,7 @@ func (XtPatientPasswayAssessment) TableName() string {
523 523
 type XtAerialDetection struct {
524 524
 	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
525 525
 	StartTime           int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
526
-	CreatedTime         int64  `gorm:"column:created_time" json:"created_ime" form:"created_time"`
526
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
527 527
 	Class               int64  `gorm:"column:class" json:"class" form:"class"`
528 528
 	DisinfectionMethods string `gorm:"column:disinfection_methods" json:"disinfection_methods" form:"disinfection_methods"`
529 529
 	DisinfectionFluid   string `gorm:"column:disinfection_fluid" json:"disinfection_fluid" form:"disinfection_fluid"`

+ 1 - 1
service/dialysis_service.go Просмотреть файл

@@ -1122,7 +1122,7 @@ func UpdateDrugUserInfoDetails(drug_id int64, time int64, org_id int64, patient_
1122 1122
 }
1123 1123
 
1124 1124
 func FindDialysisBeforePrepare(patient_id int64, good_id int64, good_type_id int64, user_org_id int64, record_time int64) (count int64) {
1125
-	readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ?  AND good_id = ? AND good_type_id = ? AND record_date = ? AND status = 1", user_org_id, patient_id, good_id, good_type_id, record_time).Count(&count)
1125
+	readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ?  AND good_id = ? AND good_type_id = ? AND record_date = ? AND status = 1 AND count<> 0", user_org_id, patient_id, good_id, good_type_id, record_time).Count(&count)
1126 1126
 	return
1127 1127
 
1128 1128
 }

+ 2 - 2
service/manage_service.go Просмотреть файл

@@ -1442,7 +1442,7 @@ func CreateAerialDetection(detection *models.XtAerialDetection) error {
1442 1442
 
1443 1443
 func GetAirList(limit int64, page int64, orgid int64) (airlist []*models.XtAerialDetection, total int64, err error) {
1444 1444
 	offset := (page - 1) * limit
1445
-	err = XTReadDB().Model(&airlist).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Find(&airlist).Error
1445
+	err = XTReadDB().Model(&airlist).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Order("created_time,ctime desc").Find(&airlist).Error
1446 1446
 	return airlist, total, err
1447 1447
 }
1448 1448
 
@@ -1474,7 +1474,7 @@ func SaveBodyDetection(detection *models.XtBodyDetection) error {
1474 1474
 func GetBodyList(limit int64, page int64, orgid int64) (body []*models.XtBodyDetection, total int64, err error) {
1475 1475
 
1476 1476
 	offset := (page - 1) * limit
1477
-	err = XTReadDB().Model(&body).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Find(&body).Error
1477
+	err = XTReadDB().Model(&body).Where("user_org_id = ? and status =1", orgid).Count(&total).Limit(limit).Offset(offset).Order("created_time,ctime desc").Find(&body).Error
1478 1478
 	return body, total, err
1479 1479
 
1480 1480
 }

+ 2 - 2
service/stock_service.go Просмотреть файл

@@ -2096,7 +2096,7 @@ func UpdateDrugStockOutInfoCount2(org_id int64, id int64, count int64) {
2096 2096
 
2097 2097
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
2098 2098
 
2099
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ?", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2099
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2100 2100
 	return
2101 2101
 
2102 2102
 }
@@ -2139,7 +2139,7 @@ func GetStockInGoodInfo(orgId int64) (stockIn []*VMWarehousingInfo, err error) {
2139 2139
 }
2140 2140
 
2141 2141
 func GetAllStockOutUserDetail(patient_id int64, orgId int64, record_time int64) (goodUser []*models.DialysisBeforePrepare, err error) {
2142
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND record_date = ? AND status = 1", patient_id, orgId, record_time).Find(&goodUser).Error
2142
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND record_date = ? AND status = 1 AND count <> 0 ", patient_id, orgId, record_time).Find(&goodUser).Error
2143 2143
 	return
2144 2144
 }
2145 2145