瀏覽代碼

耗材参数

XMLWAN 4 年之前
父節點
當前提交
e421efa369

+ 19 - 4
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

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

+ 1 - 1
models/user_models.go 查看文件

523
 type XtAerialDetection struct {
523
 type XtAerialDetection struct {
524
 	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
524
 	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
525
 	StartTime           int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
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
 	Class               int64  `gorm:"column:class" json:"class" form:"class"`
527
 	Class               int64  `gorm:"column:class" json:"class" form:"class"`
528
 	DisinfectionMethods string `gorm:"column:disinfection_methods" json:"disinfection_methods" form:"disinfection_methods"`
528
 	DisinfectionMethods string `gorm:"column:disinfection_methods" json:"disinfection_methods" form:"disinfection_methods"`
529
 	DisinfectionFluid   string `gorm:"column:disinfection_fluid" json:"disinfection_fluid" form:"disinfection_fluid"`
529
 	DisinfectionFluid   string `gorm:"column:disinfection_fluid" json:"disinfection_fluid" form:"disinfection_fluid"`

+ 1 - 1
service/dialysis_service.go 查看文件

1122
 }
1122
 }
1123
 
1123
 
1124
 func FindDialysisBeforePrepare(patient_id int64, good_id int64, good_type_id int64, user_org_id int64, record_time int64) (count int64) {
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
 	return
1126
 	return
1127
 
1127
 
1128
 }
1128
 }

+ 2 - 2
service/manage_service.go 查看文件

1442
 
1442
 
1443
 func GetAirList(limit int64, page int64, orgid int64) (airlist []*models.XtAerialDetection, total int64, err error) {
1443
 func GetAirList(limit int64, page int64, orgid int64) (airlist []*models.XtAerialDetection, total int64, err error) {
1444
 	offset := (page - 1) * limit
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
 	return airlist, total, err
1446
 	return airlist, total, err
1447
 }
1447
 }
1448
 
1448
 
1474
 func GetBodyList(limit int64, page int64, orgid int64) (body []*models.XtBodyDetection, total int64, err error) {
1474
 func GetBodyList(limit int64, page int64, orgid int64) (body []*models.XtBodyDetection, total int64, err error) {
1475
 
1475
 
1476
 	offset := (page - 1) * limit
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
 	return body, total, err
1478
 	return body, total, err
1479
 
1479
 
1480
 }
1480
 }

+ 2 - 2
service/stock_service.go 查看文件

2096
 
2096
 
2097
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
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
 	return
2100
 	return
2101
 
2101
 
2102
 }
2102
 }
2139
 }
2139
 }
2140
 
2140
 
2141
 func GetAllStockOutUserDetail(patient_id int64, orgId int64, record_time int64) (goodUser []*models.DialysisBeforePrepare, err error) {
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
 	return
2143
 	return
2144
 }
2144
 }
2145
 
2145