Browse Source

历史排班

28169 1 year ago
parent
commit
89dde95fed

+ 21 - 25
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -694,9 +694,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
694 694
 					var total int64
695 695
 					var prescribing_number_total int64
696 696
 
697
-					//判断库存
697
+					//出库
698 698
 					for _, item := range advices {
699 699
 						if item.Way == 1 {
700
+
700 701
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
701 702
 							//查询该药品的剩余库存
702 703
 							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
@@ -719,7 +720,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
719 720
 							}
720 721
 
721 722
 							if medical.IsUse == 1 {
722
-								service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
723
+
723 724
 								c.ServeSuccessJSON(map[string]interface{}{
724 725
 									"msg":    "1",
725 726
 									"advice": advice,
@@ -731,6 +732,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
731 732
 							if medical.IsUse != 1 {
732 733
 								if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
733 734
 									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
735
+									advice.ExecutionTime = 0
736
+									advice.ExecutionState = 2
737
+									advice.ExecutionStaff = 0
734 738
 									c.ServeSuccessJSON(map[string]interface{}{
735 739
 										"msg":    "3",
736 740
 										"advice": advice,
@@ -741,6 +745,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
741 745
 								}
742 746
 								if prescribing_number_total > total {
743 747
 									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
748
+									advice.ExecutionTime = 0
749
+									advice.ExecutionState = 2
750
+									advice.ExecutionStaff = 0
744 751
 									c.ServeSuccessJSON(map[string]interface{}{
745 752
 										"msg":    "2",
746 753
 										"advice": advice,
@@ -749,17 +756,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
749 756
 									return
750 757
 								}
751 758
 							}
752
-
753
-						}
754
-					}
755
-
756
-					//出库
757
-					for _, item := range advices {
758
-						if item.Way == 1 {
759 759
 							//查询是否出库按钮开启
760 760
 							adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
761
-							//查询改药品信息
762
-							medical, _ := service.GetBaseDrugMedical(item.DrugId)
763 761
 							if adviceSetting.IsAdviceOpen == 1 {
764 762
 								//查询是否出库按钮开启
765 763
 								prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
@@ -861,16 +859,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
861 859
 				if len(advices) > 0 {
862 860
 					var total int64
863 861
 					var prescribing_number_total int64
864
-					for _, item := range advices {
865 862
 
863
+					for _, item := range advices {
866 864
 						if item.Way == 1 {
865
+							//查询改药品信息
866
+							medical, _ := service.GetBaseDrugMedical(item.DrugId)
867
+							pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
868
+
867 869
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
868 870
 							//查询该药品的剩余库存
869 871
 							list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
870 872
 
871
-							//查询改药品信息
872
-							medical, _ := service.GetBaseDrugMedical(item.DrugId)
873
-
874 873
 							//判断单位是否相等
875 874
 							if medical.MaxUnit == item.PrescribingNumberUnit {
876 875
 								prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
@@ -889,7 +888,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
889 888
 							}
890 889
 
891 890
 							if medical.IsUse == 1 {
892
-								service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
891
+
893 892
 								c.ServeSuccessJSON(map[string]interface{}{
894 893
 									"msg":    "1",
895 894
 									"advice": advice,
@@ -900,6 +899,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
900 899
 							if medical.IsUse != 1 {
901 900
 								if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
902 901
 									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
902
+									advice.ExecutionTime = 0
903
+									advice.ExecutionState = 2
904
+									advice.ExecutionStaff = 0
903 905
 									c.ServeSuccessJSON(map[string]interface{}{
904 906
 										"msg":    "3",
905 907
 										"advice": advice,
@@ -909,6 +911,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
909 911
 								}
910 912
 								if prescribing_number_total > total {
911 913
 									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
914
+									advice.ExecutionTime = 0
915
+									advice.ExecutionState = 2
916
+									advice.ExecutionStaff = 0
912 917
 									c.ServeSuccessJSON(map[string]interface{}{
913 918
 										"msg":    "2",
914 919
 										"advice": advice,
@@ -917,15 +922,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
917 922
 									return
918 923
 								}
919 924
 							}
920
-
921
-						}
922
-					}
923
-
924
-					for _, item := range advices {
925
-						if item.Way == 1 {
926
-							//查询改药品信息
927
-							medical, _ := service.GetBaseDrugMedical(item.DrugId)
928
-							pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
929 925
 							if medical.IsUse == 2 {
930 926
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
931 927
 									//查询今日是否出库

+ 43 - 6
controllers/patient_api_controller.go View File

@@ -1831,10 +1831,17 @@ func (c *PatientApiController) ExecGroupAdvice() {
1831 1831
 				pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
1832 1832
 				if medical.IsUse == 2 {
1833 1833
 					if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1834
-						service.DrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
1834
+						drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1835
+						if drugOutInfo.ID == 0 {
1836
+							service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1837
+						}
1838
+
1835 1839
 					}
1836 1840
 					if pharmacyConfig.IsOpen != 1 {
1837
-						service.DrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
1841
+						drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1842
+						if drugOutInfo.ID == 0 {
1843
+							service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1844
+						}
1838 1845
 					}
1839 1846
 
1840 1847
 					//查询默认仓库
@@ -2029,7 +2036,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2029 2036
 				}
2030 2037
 
2031 2038
 				if medical.IsUse != 1 {
2039
+
2032 2040
 					if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
2041
+						service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
2042
+						advice.ExecutionState = 2
2043
+						advice.ExecutionStaff = 0
2044
+						advice.ExecutionTime = 0
2033 2045
 						c.ServeSuccessJSON(map[string]interface{}{
2034 2046
 							"msg":    "3",
2035 2047
 							"advice": advice,
@@ -2037,6 +2049,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2037 2049
 						return
2038 2050
 					}
2039 2051
 					if prescribing_number_total > total {
2052
+						service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
2053
+						advice.ExecutionState = 2
2054
+						advice.ExecutionStaff = 0
2055
+						advice.ExecutionTime = 0
2040 2056
 						c.ServeSuccessJSON(map[string]interface{}{
2041 2057
 							"msg":    "2",
2042 2058
 							"advice": advice,
@@ -2069,12 +2085,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2069 2085
 								//是通过药房发药
2070 2086
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2071 2087
 									//执行出库
2072
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2088
+
2089
+									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2090
+									if drugOutInfo.ID == 0 {
2091
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2092
+									}
2073 2093
 								}
2074 2094
 								//不通过药房发药
2075 2095
 								if pharmacyConfig.IsOpen != 1 {
2076 2096
 									//执行出库
2077
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2097
+
2098
+									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2099
+									if drugOutInfo.ID == 0 {
2100
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2101
+									}
2078 2102
 								}
2079 2103
 
2080 2104
 								//查询默认仓库
@@ -2091,6 +2115,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2091 2115
 								}
2092 2116
 
2093 2117
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2118
+
2119
+								//剩余库存
2120
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
2094 2121
 								break
2095 2122
 								c.ServeSuccessJSON(map[string]interface{}{
2096 2123
 									"msg":    "1",
@@ -2120,11 +2147,19 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2120 2147
 						if medical.IsUse == 2 {
2121 2148
 							//是通过药房发药
2122 2149
 							if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2123
-								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2150
+
2151
+								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2152
+								if drugOutInfo.ID == 0 {
2153
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2154
+								}
2124 2155
 							}
2125 2156
 							//不通过药房发药
2126 2157
 							if pharmacyConfig.IsOpen != 1 {
2127
-								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2158
+
2159
+								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2160
+								if drugOutInfo.ID == 0 {
2161
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2162
+								}
2128 2163
 							}
2129 2164
 							//更新字典里面的库存
2130 2165
 							var sum_count int64
@@ -2136,6 +2171,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2136 2171
 								sum_count += its.StockMaxNumber + its.StockMinNumber
2137 2172
 							}
2138 2173
 							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2174
+							//剩余库存
2175
+							service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
2139 2176
 							break
2140 2177
 							c.ServeSuccessJSON(map[string]interface{}{
2141 2178
 								"msg":    "1",

+ 2 - 2
controllers/secondary_order_api_contorller.go View File

@@ -1321,12 +1321,12 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1321 1321
 					}
1322 1322
 					//查询该调拨单是否有生成入库单
1323 1323
 					_, errcodess := service.GetWarehouseBySecondWarehouseId(12, item.WarehouseId, orgId, record_date)
1324
-					fmt.Println("ERRCODESSS-------------------", errcodess)
1324
+
1325 1325
 					if errcodess == gorm.ErrRecordNotFound {
1326 1326
 						service.AddSigleWarehouse(&warehousing)
1327 1327
 					}
1328 1328
 					infoObj, _ := service.GetLastWarehouseById(12, item.WarehouseId, orgId, record_date)
1329
-					fmt.Println("INFOR----------------------", infoObj.ID)
1329
+
1330 1330
 					warehouseInfo := &models.WarehousingInfo{
1331 1331
 						WarehousingOrder:      infoObj.WarehousingOrder,
1332 1332
 						WarehousingId:         infoObj.ID,

+ 6 - 2
service/his_project_service.go View File

@@ -93,11 +93,15 @@ func CreatedProjectTeam(team *models.XtHisProjectTeam) error {
93 93
 func GetProjectTeamList(limit int64, page int64, orgid int64, keyword string) (projectTeam []*models.XtHisProjectTeam, total int64, err error) {
94 94
 	offset := (page - 1) * limit
95 95
 	likeKey := "%" + keyword + "%"
96
-	db := XTReadDB().Model(&projectTeam)
96
+	db := XTReadDB().Model(&projectTeam).Where("status=1")
97 97
 	if len(keyword) > 0 {
98 98
 		db = db.Where("project_team like ?", likeKey)
99 99
 	}
100
-	err = db.Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Order("sort asc").Find(&projectTeam).Error
100
+	if orgid > 0 {
101
+		db = db.Where("user_org_id = ?", orgid)
102
+	}
103
+
104
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("sort asc").Find(&projectTeam).Error
101 105
 	return projectTeam, total, err
102 106
 }
103 107
 

+ 1 - 1
service/manage_service.go View File

@@ -1732,7 +1732,7 @@ func DeleteObjectTableDisinfect(id int64) error {
1732 1732
 
1733 1733
 func GetAirDisInfectionLongTime(user_org_id int64) (list []*models.XtNewAriDisinfect, err error) {
1734 1734
 
1735
-	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&list).Error
1735
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Order("id desc").First(&list).Error
1736 1736
 	return
1737 1737
 }
1738 1738
 

+ 1 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -227,6 +227,7 @@ type PrescriptionVM struct {
227 227
 	SodiumBicarbonateFlow      string  `gorm:"column:sodium_bicarbonate_flow" json:"sodium_bicarbonate_flow" form:"sodium_bicarbonate_flow"`
228 228
 	DisplaceSpeed              string  `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
229 229
 	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
230
+	PrescriptionWater          float64 `gorm:"column:prescription_water" json:"prescription_water" form:"prescription_water"`
230 231
 }
231 232
 
232 233
 func (PrescriptionVM) TableName() string {

+ 37 - 4
service/warhouse_service.go View File

@@ -4026,6 +4026,12 @@ func ConsumablesDeliveryTwelve(orgID int64, record_time int64, goods *models.War
4026 4026
 
4027 4027
 		AddWarehosingInfo(warehouseInfo)
4028 4028
 
4029
+		//查询剩余库存
4030
+		goodListOne, _ := GetAllGoodSumCount(goods.GoodId, orgID, warehouseInfo.StorehouseId)
4031
+		var sum_count_one int64
4032
+		for _, item := range goodListOne {
4033
+			sum_count_one += item.StockCount
4034
+		}
4029 4035
 		stockInfoFlow := models.VmStockFlow{
4030 4036
 			WarehousingId:           warehouseInfo.WarehousingId,
4031 4037
 			GoodId:                  goods.GoodId,
@@ -4059,6 +4065,7 @@ func ConsumablesDeliveryTwelve(orgID int64, record_time int64, goods *models.War
4059 4065
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
4060 4066
 			StorehouseId:            warehouseInfo.StorehouseId,
4061 4067
 			SecondWarehouseInfoId:   warehouseInfo.SecondWarehouseInfoId,
4068
+			OverCount:               sum_count_one,
4062 4069
 		}
4063 4070
 
4064 4071
 		//创建入库流水
@@ -4199,6 +4206,12 @@ func ConsumablesDeliveryTwelve(orgID int64, record_time int64, goods *models.War
4199 4206
 
4200 4207
 		AddWarehosingInfo(warehouseInfo)
4201 4208
 
4209
+		//查询剩余库存
4210
+		goodListOne, _ := GetAllGoodSumCount(goods.GoodId, orgID, warehouseInfo.StorehouseId)
4211
+		var sum_count_one int64
4212
+		for _, item := range goodListOne {
4213
+			sum_count_one += item.StockCount
4214
+		}
4202 4215
 		stockInfoFlow := models.VmStockFlow{
4203 4216
 			WarehousingId:           warehouseInfo.WarehousingId,
4204 4217
 			GoodId:                  goods.GoodId,
@@ -4232,6 +4245,7 @@ func ConsumablesDeliveryTwelve(orgID int64, record_time int64, goods *models.War
4232 4245
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
4233 4246
 			StorehouseId:            warehouseInfo.StorehouseId,
4234 4247
 			SecondWarehouseInfoId:   warehouseInfo.SecondWarehouseInfoId,
4248
+			OverCount:               sum_count_one,
4235 4249
 		}
4236 4250
 
4237 4251
 		//创建出库流水
@@ -4267,8 +4281,8 @@ func AutoDrugDeliverInfoTwelve(orgID int64, prescribingNumber int64, warehouseou
4267 4281
 	//开启事物
4268 4282
 	//storeConfig, _ := GetAllStoreHouseConfig(orgID)
4269 4283
 	lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, warehouseout.StorehouseId)
4270
-	fmt.Println("lastWarehouse.StockMinNumber", lastWarehouse.StockMinNumber)
4271
-	fmt.Println("drup.MinNumber", drup.MinNumber)
4284
+	//fmt.Println("lastWarehouse.StockMinNumber", lastWarehouse.StockMinNumber)
4285
+	//fmt.Println("drup.MinNumber", drup.MinNumber)
4272 4286
 	if lastWarehouse.StockMinNumber >= drup.MinNumber {
4273 4287
 		var stockMax int64
4274 4288
 		var stockMin int64
@@ -4289,8 +4303,8 @@ func AutoDrugDeliverInfoTwelve(orgID int64, prescribingNumber int64, warehouseou
4289 4303
 
4290 4304
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
4291 4305
 
4292
-	fmt.Println("stock23233233232", stock_number)
4293
-	fmt.Println("deliver_number", deliver_number)
4306
+	//fmt.Println("stock23233233232", stock_number)
4307
+	//fmt.Println("deliver_number", deliver_number)
4294 4308
 
4295 4309
 	// 出库完成后,要减去对应批次的库存数量
4296 4310
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
@@ -4455,6 +4469,15 @@ func AutoDrugDeliverInfoTwelve(orgID int64, prescribingNumber int64, warehouseou
4455 4469
 
4456 4470
 		CreateDrugWarehouseInfo(drugInfo)
4457 4471
 
4472
+		//查询剩余库存
4473
+		stockInfoOne, _ := GetDrugAllStockInfo(drugWarehouse.StorehouseId, orgID, advice.DrugId)
4474
+		var sum_count_one int64
4475
+		for _, its := range stockInfoOne {
4476
+			if its.MaxUnit == drup.MaxUnit {
4477
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
4478
+			}
4479
+			sum_count_one += its.StockMaxNumber + its.StockMinNumber
4480
+		}
4458 4481
 		flow := models.DrugFlow{
4459 4482
 			WarehousingId:           drugWarehouse.WarehousingId,
4460 4483
 			DrugId:                  warehouse.DrugId,
@@ -4491,6 +4514,7 @@ func AutoDrugDeliverInfoTwelve(orgID int64, prescribingNumber int64, warehouseou
4491 4514
 			StockMinNumber:          deliver_number,
4492 4515
 			StorehouseId:            drugWarehouse.StorehouseId,
4493 4516
 			SecondWarehouseInfoId:   drugWarehouse.SecondWarehouseInfoId,
4517
+			OverCount:               sum_count_one,
4494 4518
 		}
4495 4519
 
4496 4520
 		CreateDrugFlowOne(flow)
@@ -4623,6 +4647,15 @@ func AutoDrugDeliverInfoTwelve(orgID int64, prescribingNumber int64, warehouseou
4623 4647
 
4624 4648
 		CreateDrugWarehouseInfo(drugInfo)
4625 4649
 
4650
+		//查询剩余库存
4651
+		stockInfoTwo, _ := GetDrugAllStockInfo(drugWarehouse.StorehouseId, orgID, advice.DrugId)
4652
+		var sum_count_one int64
4653
+		for _, its := range stockInfoTwo {
4654
+			if its.MaxUnit == drup.MaxUnit {
4655
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
4656
+			}
4657
+			sum_count_one += its.StockMaxNumber + its.StockMinNumber
4658
+		}
4626 4659
 		flow := models.DrugFlow{
4627 4660
 			WarehousingId:           drugWarehouse.WarehousingId,
4628 4661
 			DrugId:                  warehouse.DrugId,