Pārlūkot izejas kodu

11月8日库存管理

XMLWAN 3 gadus atpakaļ
vecāks
revīzija
7c52dd006c

+ 11 - 2
controllers/drug_stock_api_contorller.go Parādīt failu

@@ -654,7 +654,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
654 654
 					IsSys:            0,
655 655
 				}
656 656
 				_, existerrcodes := service.GetDrugFlowIsExist(info.ID, info.DrugId)
657
-				fmt.Println("23323232232323我的时间232332332232332322323232", existerrcodes)
657
+
658 658
 				if existerrcodes == gorm.ErrRecordNotFound {
659 659
 					service.CreateDrugFlowOne(flows)
660 660
 				}
@@ -718,7 +718,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
718 718
 			if item.WarehousingCount > warehouseInfo.WarehousingCount {
719 719
 				total = item.WarehousingCount - warehouseInfo.WarehousingCount
720 720
 				item.StockMaxNumber = warehouseInfo.StockMaxNumber + total
721
-				fmt.Println("我的世界hhh23323232333232323", item.StockMaxNumber)
721
+
722 722
 				errs = service.UpDateDrugWarehousingInfo(item)
723 723
 				if len(drugFlow) > 0 {
724 724
 					for _, it := range drugFlow {
@@ -728,14 +728,17 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
728 728
 						}
729 729
 						parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, warehouseInfo.WarehousingId)
730 730
 						fmt.Println(parseDateErr)
731
+
731 732
 					}
732 733
 				}
734
+				break
733 735
 			}
734 736
 
735 737
 			// 如果当前的入库数量 小于 历史入库数量
736 738
 			if item.WarehousingCount < warehouseInfo.WarehousingCount {
737 739
 				total = warehouseInfo.WarehousingCount - item.WarehousingCount
738 740
 				item.StockMaxNumber = warehouseInfo.StockMaxNumber - total
741
+
739 742
 				errs = service.UpDateDrugWarehousingInfo(item)
740 743
 				if len(drugFlow) > 0 {
741 744
 					for _, it := range drugFlow {
@@ -747,6 +750,12 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
747 750
 						fmt.Println(parseDateErr)
748 751
 					}
749 752
 				}
753
+				break
754
+			}
755
+
756
+			if item.WarehousingCount == warehouseInfo.WarehousingCount {
757
+				errs = service.UpDateDrugWarehousingInfo(item)
758
+				break
750 759
 			}
751 760
 		}
752 761
 	}

+ 108 - 109
controllers/his_api_controller.go Parādīt failu

@@ -633,115 +633,114 @@ func (c *HisApiController) CreateHisPrescription() {
633 633
 
634 634
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
635 635
 
636
-	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
637
-
638
-	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
639
-
640
-	if drugStockConfig.IsOpen == 1 {
641
-		//校验库存总量
642
-		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
643
-			prescriptions, _ := dataBody["prescriptions"].([]interface{})
644
-			if len(prescriptions) > 0 {
645
-				for _, item := range prescriptions {
646
-					items := item.(map[string]interface{})
647
-					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
648
-						advices := items["advices"].([]interface{})
649
-						if len(advices) > 0 {
650
-							for _, advice := range advices {
651
-								var drug_id int64
652
-								var prescribing_number float64
653
-								var prescribingNumberUnit string
654
-
655
-								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
656
-									drug_id = int64(advice.(map[string]interface{})["id"].(float64))
657
-								}
658
-								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
659
-									//prescribing_number = advice.(map[string]interface{})["prescribing_number"].(string)
660
-									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
661
-									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
662
-
663
-								}
664
-
665
-								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
666
-									prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
667
-								}
668
-
669
-								drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
670
-								if drug.ID == 0 {
671
-									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
672
-									return
673
-								}
674
-
675
-								if prescribingNumberUnit == drug.MinUnit {
676
-									if prescribing_number > drug.Total {
677
-										c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
678
-										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
679
-										return
680
-									}
681
-								} else {
682
-									if prescribingNumberUnit == drug.MaxUnit {
683
-										num := prescribing_number * float64(drug.MinNumber)
684
-										if num > drug.Total {
685
-											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
686
-											//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
687
-											return
688
-										}
689
-									}
690
-								}
691
-							}
692
-						}
693
-					}
694
-				}
695
-			}
696
-		}
697
-	}
698
-
699
-	if stockConfig.IsOpen == 1 {
700
-		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
701
-			prescriptions, _ := dataBody["prescriptions"].([]interface{})
702
-			if len(prescriptions) > 0 {
703
-				for _, item := range prescriptions {
704
-					items := item.(map[string]interface{})
705
-					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
706
-						projects := items["project"].([]interface{})
707
-						if len(projects) > 0 {
708
-							for _, project := range projects {
709
-								var project_id int64
710
-								var project_type int64
711
-								var totals float64
712
-								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
713
-									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
714
-								}
715
-								if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
716
-									project_type = int64(project.(map[string]interface{})["type"].(float64))
717
-								}
718
-								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
719
-									total, _ := project.(map[string]interface{})["total"].(string)
720
-
721
-									totals, _ = strconv.ParseFloat(total, 64)
722
-								}
723
-								if project_type == 3 {
724
-									good, _ := service.FindGoodInfoByIdTwo(project_id)
725
-									if good.ID == 0 {
726
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
727
-										return
728
-									}
729
-									if totals > good.Total {
730
-										c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
731
-										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
732
-										return
733
-									}
734
-
735
-								}
736
-
737
-							}
738
-						}
739
-					}
740
-				}
741
-			}
742
-		}
743
-
744
-	}
636
+	//_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
637
+	//
638
+	//_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
639
+	//
640
+	//if drugStockConfig.IsOpen == 1 {
641
+	//	//校验库存总量
642
+	//	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
643
+	//		prescriptions, _ := dataBody["prescriptions"].([]interface{})
644
+	//		if len(prescriptions) > 0 {
645
+	//			for _, item := range prescriptions {
646
+	//				items := item.(map[string]interface{})
647
+	//				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
648
+	//					advices := items["advices"].([]interface{})
649
+	//					if len(advices) > 0 {
650
+	//						for _, advice := range advices {
651
+	//							var drug_id int64
652
+	//							var prescribing_number float64
653
+	//							var prescribingNumberUnit string
654
+	//
655
+	//							if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
656
+	//								drug_id = int64(advice.(map[string]interface{})["id"].(float64))
657
+	//							}
658
+	//							if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
659
+	//								//prescribing_number = advice.(map[string]interface{})["prescribing_number"].(string)
660
+	//								prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
661
+	//								prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
662
+	//
663
+	//							}
664
+	//
665
+	//							if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
666
+	//								prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
667
+	//							}
668
+	//
669
+	//							drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
670
+	//							if drug.ID == 0 {
671
+	//								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
672
+	//								return
673
+	//							}
674
+	//
675
+	//							if prescribingNumberUnit == drug.MinUnit {
676
+	//								if prescribing_number > drug.Total {
677
+	//									c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
678
+	//									//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
679
+	//									return
680
+	//								}
681
+	//							} else {
682
+	//								if prescribingNumberUnit == drug.MaxUnit {
683
+	//									num := prescribing_number * float64(drug.MinNumber)
684
+	//									if num > drug.Total {
685
+	//										c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
686
+	//										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
687
+	//										return
688
+	//									}
689
+	//								}
690
+	//							}
691
+	//						}
692
+	//					}
693
+	//				}
694
+	//			}
695
+	//		}
696
+	//	}
697
+	//}
698
+	//
699
+	//if stockConfig.IsOpen == 1 {
700
+	//	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
701
+	//		prescriptions, _ := dataBody["prescriptions"].([]interface{})
702
+	//		if len(prescriptions) > 0 {
703
+	//			for _, item := range prescriptions {
704
+	//				items := item.(map[string]interface{})
705
+	//				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
706
+	//					projects := items["project"].([]interface{})
707
+	//					if len(projects) > 0 {
708
+	//						for _, project := range projects {
709
+	//							var project_id int64
710
+	//							var project_type int64
711
+	//							var totals float64
712
+	//							if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
713
+	//								project_id = int64(project.(map[string]interface{})["project_id"].(float64))
714
+	//							}
715
+	//							if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
716
+	//								project_type = int64(project.(map[string]interface{})["type"].(float64))
717
+	//							}
718
+	//							if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
719
+	//								total, _ := project.(map[string]interface{})["total"].(string)
720
+	//
721
+	//								totals, _ = strconv.ParseFloat(total, 64)
722
+	//							}
723
+	//							if project_type == 3 {
724
+	//								good, _ := service.FindGoodInfoByIdTwo(project_id)
725
+	//								if good.ID == 0 {
726
+	//									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
727
+	//									return
728
+	//								}
729
+	//								if totals > good.Total {
730
+	//									c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
731
+	//									//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
732
+	//									return
733
+	//								}
734
+	//
735
+	//							}
736
+	//
737
+	//						}
738
+	//					}
739
+	//				}
740
+	//			}
741
+	//		}
742
+	//	}
743
+	//}
745 744
 
746 745
 	info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
747 746
 	var hpInfo models.HisPrescriptionInfo

+ 13 - 2
controllers/stock_in_api_controller.go Parādīt failu

@@ -634,7 +634,6 @@ func (c *StockManagerApiController) EditWarehouse() {
634 634
 		for _, its := range warehousingInfo {
635 635
 			//查询
636 636
 			info, _ := service.GetLastGoodWarehouseInfo(its.GoodId)
637
-			fmt.Println("hh23323232323233232323322323", info)
638 637
 			flows := models.VmStockFlow{
639 638
 				WarehousingOrder:    info.WarehousingOrder,
640 639
 				WarehousingId:       info.ID,
@@ -657,7 +656,7 @@ func (c *StockManagerApiController) EditWarehouse() {
657 656
 				WarehousingDetailId: info.ID,
658 657
 			}
659 658
 			_, errcodescode := service.GetGoodStockFlowInfo(info.ID, info.GoodId)
660
-			fmt.Println("wodeshijehh23322333223233223323232", errcodescode)
659
+
661 660
 			if errcodescode == gorm.ErrRecordNotFound {
662 661
 				service.CreateStockFlowOne(flows)
663 662
 			}
@@ -721,7 +720,19 @@ func (c *StockManagerApiController) EditWarehouse() {
721 720
 					Total: good.Total - all_total,
722 721
 				}
723 722
 				service.UpdateGoodInfoMation(info.GoodId, goodInfo)
723
+
724 724
 			}
725
+
726
+			if item.WarehousingCount == info.WarehousingCount {
727
+				goodinfo := models.WarehousingInfo{
728
+					WarehousingCount: item.WarehousingCount,
729
+					StockCount:       info.StockCount,
730
+					Price:            item.Price,
731
+				}
732
+				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
733
+				break
734
+			}
735
+
725 736
 		}
726 737
 	}
727 738
 

+ 1 - 1
service/dialysis_service.go Parādīt failu

@@ -1179,7 +1179,7 @@ func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1179 1179
 
1180 1180
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1181 1181
 
1182
-	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count >0").Find(&goodinfo).Error
1182
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count >0 and status = 1").Find(&goodinfo).Error
1183 1183
 	return goodinfo, err
1184 1184
 }
1185 1185
 

+ 6 - 0
service/stock_service.go Parādīt failu

@@ -4934,3 +4934,9 @@ func UpdateWarehouseInfoByGoodId(info models.WarehousingInfo, id int64) error {
4934 4934
 	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount}).Error
4935 4935
 	return err
4936 4936
 }
4937
+
4938
+func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
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
4941
+	return err
4942
+}

+ 1 - 1
service/warhouse_service.go Parādīt failu

@@ -615,7 +615,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
615 615
 		fmt.Println("库存数量2332232323", stock_number)
616 616
 		fmt.Println("c出库数量", maxNumber)
617 617
 		fmt.Println("c出库数量", minNumber)
618
-
618
+		return
619 619
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
620 620
 
621 621
 		fmt.Println("剩余库存", warehouse.StockMaxNumber)