Przeglądaj źródła

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 3 lat temu
rodzic
commit
8552465560

+ 6 - 1
controllers/dialysis_api_controller.go Wyświetl plik

@@ -3208,6 +3208,11 @@ func (this *DialysisApiController) GetTodayMonitor() {
3208 3208
 				record.UltrafiltrationRate = ultrafiltration_rate
3209 3209
 			}
3210 3210
 
3211
+			if template.TemplateId == 43 { //adminInfo.CurrentOrgId == 9538
3212
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
3213
+				record.UltrafiltrationRate = ultrafiltration_rate
3214
+			}
3215
+
3211 3216
 			// 只针对方济医院
3212 3217
 			if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
3213 3218
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
@@ -3227,7 +3232,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3227 3232
 		}
3228 3233
 	}
3229 3234
 
3230
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 {
3235
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 || template.TemplateId == 43 {
3231 3236
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
3232 3237
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3233 3238
 

+ 13 - 2
controllers/dialysis_record_api_controller.go Wyświetl plik

@@ -570,6 +570,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
570 570
 // @param nurse:int 上机护士
571 571
 // @param bed:int 上机床位号
572 572
 func (this *DialysisRecordAPIController) StartDialysis() {
573
+
573 574
 	patientID, _ := this.GetInt64("patient_id")
574 575
 	recordDateStr := this.GetString("date")
575 576
 	nurseID, _ := this.GetInt64("nurse")
@@ -583,6 +584,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
583 584
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
584 585
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
585 586
 	bedID, _ := this.GetInt64("bed")
587
+
586 588
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
587 589
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
588 590
 		return
@@ -737,7 +739,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
737 739
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
738 740
 		return
739 741
 	}
740
-
742
+	fmt.Println("hhaaaaaaa888888888323232323232333232322333323232", adminUserInfo.CurrentOrgId)
741 743
 	dialysisRecord = &models.DialysisOrder{
742 744
 		DialysisDate:           recordDate.Unix(),
743 745
 		UserOrgId:              adminUserInfo.CurrentOrgId,
@@ -803,13 +805,22 @@ func (this *DialysisRecordAPIController) StartDialysis() {
803 805
 				}
804 806
 
805 807
 				//针对监利大垸医院
806
-				if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 9671 {
808
+				if adminUserInfo.CurrentOrgId == 10101 {
807 809
 
808 810
 					if evaluation.ID > 0 {
809 811
 						ultrafiltration_rate = math.Ceil(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
810 812
 						fmt.Println("ultrafiltration_rate", ultrafiltration_rate)
811 813
 					}
812 814
 				}
815
+				fmt.Println("hhh233223323223232332233233223323223323232322332322323", adminUserInfo.CurrentOrgId)
816
+				//针对肇庆三鹤血液透析中心
817
+				if adminUserInfo.CurrentOrgId == 10215 || template.TemplateId == 43 {
818
+
819
+					if evaluation.ID > 0 {
820
+						ultrafiltration_rate = math.Ceil(prescription.TargetUltrafiltration / float64(totalMin) * 60)
821
+						fmt.Println("hhhh2323323223322323323232", ultrafiltration_rate)
822
+					}
823
+				}
813 824
 			}
814 825
 		}
815 826
 		record := models.MonitoringRecord{

+ 3 - 2
controllers/drug_stock_api_contorller.go Wyświetl plik

@@ -2981,6 +2981,7 @@ func (c *StockDrugApiController) GetDrugWarehouseInfoPrint() {
2981 2981
 
2982 2982
 	start_time := c.GetString("start_time")
2983 2983
 	end_time := c.GetString("end_time")
2984
+	fmt.Println("开始实际23323233322323", start_time)
2984 2985
 	order_type, _ := c.GetInt64("order_type")
2985 2986
 	timeLayout := "2006-01-02"
2986 2987
 	loc, _ := time.LoadLocation("Local")
@@ -3049,8 +3050,8 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3049 3050
 	adminUserInfo := c.GetAdminUserInfo()
3050 3051
 	orgId := adminUserInfo.CurrentOrgId
3051 3052
 	if order_type == 2 {
3052
-		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3053
-		//list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3053
+		//list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId)
3054
+		list, err := service.GetDrugOutOrderPrintList(startTime, endTime, orgId)
3054 3055
 		if err == nil {
3055 3056
 			c.ServeSuccessJSON(map[string]interface{}{
3056 3057
 				"list": list,

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Wyświetl plik

@@ -335,7 +335,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
335 335
 
336 336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
337 337
 
338
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 {
338
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 {
339 339
 		dewater_amount = dewater_amount * 1000
340 340
 	}
341 341
 

+ 13 - 5
controllers/mobile_api_controllers/dialysis_api_controller.go Wyświetl plik

@@ -1493,7 +1493,7 @@ func (c *DialysisAPIController) Finish() {
1493 1493
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
1494 1494
 
1495 1495
 	}
1496
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 {
1496
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 9671 {
1497 1497
 		evaluation, _ := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, recordDate.Unix())
1498 1498
 		if evaluation.SystolicBloodPressure == 0 {
1499 1499
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
@@ -1916,6 +1916,12 @@ func (this *DialysisAPIController) StartDialysis() {
1916 1916
 			//针对监利大垸医院
1917 1917
 			if template.TemplateId == 41 {
1918 1918
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
1919
+			}
1920
+
1921
+			//针对肇庆三鹤血液透析中心
1922
+
1923
+			if template.TemplateId == 43 {
1924
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
1919 1925
 				fmt.Println("hhhh232332322323232332", ultrafiltration_rate)
1920 1926
 			}
1921 1927
 
@@ -2476,10 +2482,12 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2476 2482
 			}
2477 2483
 
2478 2484
 			if template.TemplateId == 41 {
2479
-				fmt.Println("hhhhhhhhhh", prescription.TargetUltrafiltration)
2480
-				fmt.Println("jj2332323322323", float64(totalMin))
2481 2485
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
2482
-				fmt.Println("ultrafiltration_rate000304293929329238328328328328238328328", ultrafiltration_rate)
2486
+				record.UltrafiltrationRate = ultrafiltration_rate
2487
+			}
2488
+
2489
+			if template.TemplateId == 43 {
2490
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2483 2491
 				record.UltrafiltrationRate = ultrafiltration_rate
2484 2492
 			}
2485 2493
 		}
@@ -2495,7 +2503,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2495 2503
 		}
2496 2504
 	}
2497 2505
 
2498
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 || template.TemplateId == 41 { //adminInfo.Org.Id == 9538
2506
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 || template.TemplateId == 41 || template.TemplateId == 43 { //adminInfo.Org.Id == 9538
2499 2507
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2500 2508
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2501 2509
 			record.UltrafiltrationVolume = ultrafiltration_volume

+ 8 - 6
controllers/mobile_api_controllers/patient_api_controller.go Wyświetl plik

@@ -972,12 +972,14 @@ func (c *PatientApiController) ExecDoctorAdvice() {
972 972
 					}
973 973
 				}
974 974
 			}
975
-
976
-			c.ServeSuccessJSON(map[string]interface{}{
977
-				"msg":    "ok",
978
-				"advice": advices,
979
-				"ids":    ids,
980
-			})
975
+			for _, item := range advices {
976
+				advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
977
+				c.ServeSuccessJSON(map[string]interface{}{
978
+					"msg":    "1",
979
+					"advice": advice,
980
+					"ids":    ids,
981
+				})
982
+			}
981 983
 
982 984
 		} else {
983 985
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 72 - 36
controllers/self_drug_api_congtroller.go Wyświetl plik

@@ -2016,18 +2016,25 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2016 2016
 	var minNumber int64
2017 2017
 	for _, item := range list {
2018 2018
 
2019
-		//查询库存信息
2019
+		//查询药品信息
2020 2020
 		drug, _ := service.GetDrugDetailByDrugId(item.DrugId)
2021 2021
 
2022 2022
 		//查询库存
2023
-		info, _ := service.GetDrugWareInfoById(item.WarehouseInfoId)
2023
+		info, _ := service.GetDrugWareInfoByIdTwo(item.WarehouseInfoId)
2024
+		var max_count int64
2025
+		var min_count int64
2026
+		for _, it := range info {
2027
+			max_count += it.StockMaxNumber
2028
+			min_count += it.StockMinNumber
2029
+		}
2024 2030
 
2025 2031
 		//获取最晚的库存数量
2026 2032
 		lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
2027 2033
 		firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
2028
-		stock_total = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2034
+		stock_total = max_count*drug.MinNumber + min_count
2029 2035
 		proof_count = item.Count*drug.MinNumber + item.MinCount
2030
-
2036
+		fmt.Println("stock_total", stock_total)
2037
+		fmt.Println("proof_count", proof_count)
2031 2038
 		//判断 如果库存数量 大于盘点库存,则出库
2032 2039
 		if stock_total > proof_count {
2033 2040
 			minNumber = (stock_total - proof_count) % drug.MinNumber
@@ -2057,11 +2064,12 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2057 2064
 				WarehouseOutTime:        ctime,
2058 2065
 				Type:                    1,
2059 2066
 			}
2060
-
2067
+			service.AddSigleDrugWarehouseOut(&warehouseOut)
2068
+			warehouse, _ := service.GetLastDrugWarehouseOut(adminUserInfo.CurrentOrgId)
2061 2069
 			warehouseOutInfo := models.DrugWarehouseOutInfo{
2062 2070
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
2063
-				WarehouseOutId:          warehouseOut.ID,
2064
-				DrugId:                  firstInfo.DrugId,
2071
+				WarehouseOutId:          warehouse.ID,
2072
+				DrugId:                  item.DrugId,
2065 2073
 				Count:                   maxNumber,
2066 2074
 				Price:                   firstInfo.Price,
2067 2075
 				TotalPrice:              firstInfo.TotalPrice,
@@ -2086,7 +2094,7 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2086 2094
 			drugflow := models.DrugFlow{
2087 2095
 				WarehouseOutId:          warehouseOut.ID,
2088 2096
 				WarehouseOutOrderNumber: warehousing_out_order,
2089
-				DrugId:                  firstInfo.DrugId,
2097
+				DrugId:                  item.DrugId,
2090 2098
 				Number:                  firstInfo.Number,
2091 2099
 				ProductDate:             firstInfo.ProductDate,
2092 2100
 				ExpireDate:              firstInfo.ExpiryDate,
@@ -2104,18 +2112,43 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2104 2112
 				Creator:                 adminUserInfo.AdminUser.Id,
2105 2113
 				IsSys:                   0,
2106 2114
 			}
2107
-
2108
-			service.AddSigleDrugWarehouseOut(&warehouseOut)
2109 2115
 			service.CreateDrugWarehouseOutInfo(warehouseOutInfo)
2110 2116
 			service.CreateDrugFlowOne(drugflow)
2111 2117
 
2118
+			//扣减当前批次号的库存
2119
+			var total_count int64
2120
+
2121
+			//查询当前批次库存的数量
2122
+			warehosueInfoList, _ := service.GetCurrentWarehosueInfo(item.WarehouseInfoId)
2123
+			fmt.Println(warehosueInfoList)
2124
+			for _, item := range warehosueInfoList {
2125
+				total_count += item.StockMaxNumber*drug.MinNumber + item.StockMinNumber
2126
+			}
2127
+			//判断当前批次库存 和 需要出库的数据
2128
+			//出库
2129
+			if proof_count <= total_count {
2130
+
2131
+				//var total_count_one int64
2132
+				//获取当前批次号的库存
2133
+				//warehouseinfoOne, _ := service.GetCurrentWarehosueInfoOne(item.WarehouseInfoId)
2134
+				//total_count_one = warehouseinfoOne.StockMaxNumber * drug.MinNumber + warehouseinfoOne.StockMinNumber
2135
+
2136
+			}
2137
+			//报错提示
2138
+			if proof_count > total_count {
2139
+				this.ServeSuccessJSON(map[string]interface{}{
2140
+					"msg": "1",
2141
+				})
2142
+			}
2112 2143
 		}
2113 2144
 
2114 2145
 		//判断 如果库存数量 小于于盘点库存,则入库
2146
+		fmt.Println("stock_total2332322323223", stock_total, proof_count)
2115 2147
 		if stock_total < proof_count {
2116 2148
 
2117 2149
 			maxNumber = (proof_count - stock_total) / drug.MinNumber
2118 2150
 			minNumber = (proof_count - stock_total) % drug.MinNumber
2151
+			fmt.Println("min_number23233232323223322323", minNumber)
2119 2152
 			ctime := time.Now().Unix()
2120 2153
 
2121 2154
 			timeStr := time.Now().Format("2006-01-02")
@@ -2137,36 +2170,38 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2137 2170
 				WarehousingTime:  ctime,
2138 2171
 				Type:             1,
2139 2172
 			}
2140
-
2173
+			service.AddSigleDrugWarehouse(&warehousing)
2174
+			warehouse, _ := service.GetLastDrugWarehouse(adminUserInfo.CurrentOrgId)
2141 2175
 			warehouseInfo := models.DrugWarehouseInfo{
2142
-				WarehousingOrder: warehousing.WarehousingOrder,
2143
-				WarehousingId:    warehousing.ID,
2144
-				DrugId:           lastInfo.DrugId,
2145
-				Number:           lastInfo.Number,
2146
-				ProductDate:      lastInfo.ProductDate,
2147
-				ExpiryDate:       lastInfo.ExpiryDate,
2148
-				WarehousingCount: lastInfo.WarehousingCount,
2149
-				Price:            lastInfo.Price,
2150
-				TotalPrice:       lastInfo.TotalPrice,
2151
-				Status:           1,
2152
-				Ctime:            ctime,
2153
-				Remark:           item.Remark,
2154
-				OrgId:            adminUserInfo.CurrentOrgId,
2155
-				Type:             1,
2156
-				Manufacturer:     lastInfo.Manufacturer,
2157
-				Dealer:           lastInfo.Dealer,
2158
-				StockMaxNumber:   maxNumber,
2159
-				StockMinNumber:   minNumber,
2160
-				RetailTotalPrice: lastInfo.RetailTotalPrice,
2161
-				BatchNumber:      lastInfo.BatchNumber,
2162
-				MaxUnit:          drug.MaxUnit,
2163
-				MinUnit:          drug.MinUnit,
2176
+				WarehousingOrder:  warehousing.WarehousingOrder,
2177
+				WarehousingId:     warehouse.ID,
2178
+				DrugId:            item.DrugId,
2179
+				Number:            lastInfo.Number,
2180
+				ProductDate:       lastInfo.ProductDate,
2181
+				ExpiryDate:        lastInfo.ExpiryDate,
2182
+				WarehousingCount:  maxNumber,
2183
+				Price:             lastInfo.Price,
2184
+				TotalPrice:        lastInfo.TotalPrice,
2185
+				Status:            1,
2186
+				Ctime:             ctime,
2187
+				Remark:            item.Remark,
2188
+				OrgId:             adminUserInfo.CurrentOrgId,
2189
+				Type:              1,
2190
+				Manufacturer:      lastInfo.Manufacturer,
2191
+				Dealer:            lastInfo.Dealer,
2192
+				StockMaxNumber:    maxNumber,
2193
+				StockMinNumber:    minNumber,
2194
+				RetailTotalPrice:  lastInfo.RetailTotalPrice,
2195
+				BatchNumber:       lastInfo.BatchNumber,
2196
+				MaxUnit:           drug.MaxUnit,
2197
+				MinUnit:           drug.MinUnit,
2198
+				WarehousingInfoId: item.WarehouseInfoId,
2164 2199
 			}
2165 2200
 
2166 2201
 			drugflow := models.DrugFlow{
2167 2202
 				WarehousingOrder: warehousing.WarehousingOrder,
2168
-				WarehousingId:    warehousing.ID,
2169
-				DrugId:           lastInfo.DrugId,
2203
+				WarehousingId:    warehouse.ID,
2204
+				DrugId:           item.DrugId,
2170 2205
 				Number:           lastInfo.Number,
2171 2206
 				ProductDate:      lastInfo.ProductDate,
2172 2207
 				ExpireDate:       lastInfo.ExpiryDate,
@@ -2185,9 +2220,10 @@ func (this *SelfDrugApiController) SaveDrugCheckInventory() {
2185 2220
 				Creator:          adminUserInfo.AdminUser.Id,
2186 2221
 				IsSys:            0,
2187 2222
 			}
2188
-			service.AddSigleDrugWarehouse(&warehousing)
2223
+
2189 2224
 			service.CreateDrugWarehouseInfo(warehouseInfo)
2190 2225
 			service.CreateDrugFlowOne(drugflow)
2226
+
2191 2227
 		}
2192 2228
 	}
2193 2229
 	returnData := make(map[string]interface{}, 0)

+ 10 - 3
controllers/stock_in_api_controller.go Wyświetl plik

@@ -1173,6 +1173,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1173 1173
 
1174 1174
 				expiry_date := items["expiry_date"].(string)
1175 1175
 
1176
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1176 1177
 				timeLayout := "2006-01-02"
1177 1178
 				loc, _ := time.LoadLocation("Local")
1178 1179
 				var expiryDate int64
@@ -1216,6 +1217,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1216 1217
 					ProductDate:             productDate,
1217 1218
 					Dealer:                  dealer,
1218 1219
 					LicenseNumber:           license_number,
1220
+					WarehouseInfotId:        warehouse_info_id,
1219 1221
 				}
1220 1222
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1221 1223
 
@@ -1240,9 +1242,13 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1240 1242
 	//出库逻辑
1241 1243
 	for _, item := range warehousingOutInfo {
1242 1244
 		//查询库存
1243
-		warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1244
-		fmt.Println("库存数量组吗", warehouse.Count)
1245
-		if item.Count > warehouse.Count {
1245
+		//warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
1246
+		//查询该批次的库存
1247
+
1248
+		warehouseOne, _ := service.FindWarehousingInfoByIdSeven(item.WarehouseInfotId)
1249
+		fmt.Println("数据232323232323232323323232", warehouseOne)
1250
+		fmt.Println("库存查询23322332233232233232322323232323", warehouseOne.StockCount)
1251
+		if item.Count > warehouseOne.StockCount {
1246 1252
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
1247 1253
 			c.ServeSuccessJSON(map[string]interface{}{
1248 1254
 				"msg":                "1",
@@ -1250,6 +1256,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1250 1256
 				"specification_name": goodObj.SpecificationName,
1251 1257
 			})
1252 1258
 			return
1259
+
1253 1260
 		} else {
1254 1261
 
1255 1262
 			_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)

+ 2 - 0
main.go Wyświetl plik

@@ -16,6 +16,8 @@ func main() {
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()
18 18
 	//service.BeginAutoCreateStaffScheduleJob()
19
+	//service.BeginAutoCreateDrugJob()
20
+	service.BeginAutoCreateStockJob()
19 21
 	beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60
20 22
 	beego.Run()
21 23
 }

+ 27 - 26
models/drug_stock.go Wyświetl plik

@@ -51,32 +51,33 @@ type DrugWarehouseInfoSix struct {
51 51
 }
52 52
 
53 53
 type DrugWarehouseInfo struct {
54
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
55
-	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
56
-	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
57
-	Number           string  `gorm:"column:number" json:"number" form:"number"`
58
-	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
59
-	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
60
-	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
61
-	Price            float64 `gorm:"column:price" json:"price" form:"price"`
62
-	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
63
-	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
64
-	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
65
-	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
66
-	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
67
-	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
68
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
69
-	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
70
-	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
71
-	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
72
-	Type             int64   `gorm:"column:type" json:"type" form:"type"`
73
-	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
74
-	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
75
-	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
76
-	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
77
-	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
78
-	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
79
-	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
54
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
55
+	WarehousingId     int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
56
+	DrugId            int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
57
+	Number            string  `gorm:"column:number" json:"number" form:"number"`
58
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
59
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
60
+	WarehousingCount  int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
61
+	Price             float64 `gorm:"column:price" json:"price" form:"price"`
62
+	TotalPrice        float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
63
+	Dealer            int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
64
+	Manufacturer      int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
65
+	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
66
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
67
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
68
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
69
+	OrgId             int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
70
+	IsReturn          int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
71
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
72
+	Type              int64   `gorm:"column:type" json:"type" form:"type"`
73
+	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
74
+	RetailTotalPrice  float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
75
+	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
76
+	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
77
+	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
78
+	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
79
+	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
80
+	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
80 81
 }
81 82
 
82 83
 func (DrugWarehouseInfo) TableName() string {

+ 27 - 26
models/self_drug_models.go Wyświetl plik

@@ -381,32 +381,33 @@ func (XtDrugAutomaticReduceDetail) TableName() string {
381 381
 }
382 382
 
383 383
 type XtDrugWarehouseInfo struct {
384
-	ID               int64      `gorm:"column:id" json:"id" form:"id"`
385
-	WarehousingId    int64      `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
386
-	DrugId           int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
387
-	Number           string     `gorm:"column:number" json:"number" form:"number"`
388
-	ProductDate      int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
389
-	ExpiryDate       int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
390
-	WarehousingCount int64      `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
391
-	Price            float64    `gorm:"column:price" json:"price" form:"price"`
392
-	TotalPrice       float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
393
-	Dealer           int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
394
-	Manufacturer     int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
395
-	Remark           string     `gorm:"column:remark" json:"remark" form:"remark"`
396
-	Ctime            int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
397
-	Mtime            int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
398
-	Status           int64      `gorm:"column:status" json:"status" form:"status"`
399
-	OrgId            int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
400
-	IsReturn         int64      `gorm:"column:is_return" json:"is_return" form:"is_return"`
401
-	WarehousingOrder string     `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
402
-	Type             int64      `gorm:"column:type" json:"type" form:"type"`
403
-	RetailPrice      float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
404
-	RetailTotalPrice float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
405
-	StockMaxNumber   int64      `gorm:"column:stock_max_number" json:"stock_max_number"`
406
-	StockMinNumber   int64      `gorm:"column:stock_min_number" json:"stock_min_number"`
407
-	BatchNumber      string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
408
-	MaxUnit          string     `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
409
-	XtBaseDrug       XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
384
+	ID                int64      `gorm:"column:id" json:"id" form:"id"`
385
+	WarehousingId     int64      `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
386
+	DrugId            int64      `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
387
+	Number            string     `gorm:"column:number" json:"number" form:"number"`
388
+	ProductDate       int64      `gorm:"column:product_date" json:"product_date" form:"product_date"`
389
+	ExpiryDate        int64      `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
390
+	WarehousingCount  int64      `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
391
+	Price             float64    `gorm:"column:price" json:"price" form:"price"`
392
+	TotalPrice        float64    `gorm:"column:total_price" json:"total_price" form:"total_price"`
393
+	Dealer            int64      `gorm:"column:dealer" json:"dealer" form:"dealer"`
394
+	Manufacturer      int64      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
395
+	Remark            string     `gorm:"column:remark" json:"remark" form:"remark"`
396
+	Ctime             int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
397
+	Mtime             int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
398
+	Status            int64      `gorm:"column:status" json:"status" form:"status"`
399
+	OrgId             int64      `gorm:"column:org_id" json:"org_id" form:"org_id"`
400
+	IsReturn          int64      `gorm:"column:is_return" json:"is_return" form:"is_return"`
401
+	WarehousingOrder  string     `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
402
+	Type              int64      `gorm:"column:type" json:"type" form:"type"`
403
+	RetailPrice       float64    `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
404
+	RetailTotalPrice  float64    `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
405
+	StockMaxNumber    int64      `gorm:"column:stock_max_number" json:"stock_max_number"`
406
+	StockMinNumber    int64      `gorm:"column:stock_min_number" json:"stock_min_number"`
407
+	BatchNumber       string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
408
+	MaxUnit           string     `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
409
+	WarehousingInfoId int64      `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
410
+	XtBaseDrug        XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
410 411
 }
411 412
 
412 413
 func (XtDrugWarehouseInfo) TableName() string {

+ 62 - 10
service/auto_create_stock.go Wyświetl plik

@@ -44,17 +44,36 @@ func AutoCreateStockJob() {
44 44
 
45 45
 		information, _ := FindAlLGoodInformation(item.UserOrgId)
46 46
 		for _, ite := range information {
47
-			countList, _ := FindAllGoodInformationTotalCount(ite.ID)
48
-			for _, it := range countList {
49
-				if ite.ID == it.GoodId {
50
-					formatInt := strconv.FormatInt(it.StockCount, 10)
51
-					total, _ := strconv.ParseFloat(formatInt, 64)
52
-					info := models.GoodInfo{
53
-						Total: total,
54
-					}
55
-					UpdateStockTotal(it.GoodId, info)
56
-				}
47
+			//countList, _ := FindAllGoodInformationTotalCount(ite.ID)
48
+			//查询入库数量
49
+			warehouseInfo, _ := FindAllGoodWarehouseInfoCount(ite.ID)
50
+
51
+			//查询自动出库数量
52
+			autoWarehouseOut, _ := FindAutoGoodWarehouseInfoCount(ite.ID)
53
+
54
+			//查询手动出库
55
+			warehouseOut, _ := FindGoodWarehouseOutCount(ite.ID)
56
+
57
+			var total int64
58
+
59
+			total = warehouseInfo.WarehousingCount - autoWarehouseOut.Count - warehouseOut.Count
60
+			formatInt := strconv.FormatInt(total, 10)
61
+			totalfloat, _ := strconv.ParseFloat(formatInt, 64)
62
+			info := models.GoodInfo{
63
+				Total: totalfloat,
57 64
 			}
65
+			UpdateStockTotal(ite.ID, info)
66
+
67
+			//for _, it := range countList {
68
+			//	if ite.ID == it.GoodId {
69
+			//		formatInt := strconv.FormatInt(it.StockCount, 10)
70
+			//		total, _ := strconv.ParseFloat(formatInt, 64)
71
+			//		info := models.GoodInfo{
72
+			//			Total: total,
73
+			//		}
74
+			//		UpdateStockTotal(it.GoodId, info)
75
+			//	}
76
+			//}
58 77
 		}
59 78
 
60 79
 	}
@@ -85,3 +104,36 @@ func UpdateStockTotal(id int64, lib models.GoodInfo) error {
85 104
 	err := XTWriteDB().Model(&lib).Where("id=? and status = 1", id).Updates(map[string]interface{}{"total": lib.Total}).Error
86 105
 	return err
87 106
 }
107
+
108
+func FindAllGoodWarehouseInfoCount(good_id int64) (models.WarehousingInfo, error) {
109
+
110
+	info := models.WarehousingInfo{}
111
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
112
+	if good_id > 0 {
113
+		db = db.Where("x.good_id = ? and x.warehousing_count <> 0", good_id)
114
+	}
115
+	err = db.Select("x.good_id,sum(x.warehousing_count) as warehousing_count").Find(&info).Error
116
+	return info, err
117
+}
118
+
119
+func FindAutoGoodWarehouseInfoCount(good_id int64) (models.AutomaticReduceDetail, error) {
120
+
121
+	detail := models.AutomaticReduceDetail{}
122
+	db := XTReadDB().Table("xt_automatic_reduce_detail as x").Where("x.status = 1")
123
+	if good_id > 0 {
124
+		db = db.Where("x.good_id = ? and x.count<> 0", good_id)
125
+	}
126
+	err := db.Select("x.good_id,sum(x.count) as count").Find(&detail).Error
127
+	return detail, err
128
+}
129
+
130
+func FindGoodWarehouseOutCount(good_id int64) (models.WarehouseOutInfo, error) {
131
+
132
+	out := models.WarehouseOutInfo{}
133
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
134
+	if good_id > 0 {
135
+		db = db.Where("x.good_id = ? and x.is_sys = 0 and x.count<> 0", good_id)
136
+	}
137
+	err := db.Select("x.good_id,sum(x.count) as count").Find(&out).Error
138
+	return out, err
139
+}

+ 1 - 1
service/auto_create_week_disinfection.go Wyświetl plik

@@ -94,7 +94,7 @@ func AutoCreateWeekDisinfectionJob() {
94 94
 				fmt.Println("错误是什么", errplan)
95 95
 				if errplan == gorm.ErrRecordNotFound {
96 96
 					fmt.Println("该设备无消毒计划")
97
-					return
97
+					continue
98 98
 				} else if errplan == nil {
99 99
 					//fmt.Println("消毒时长", plan.DisinfecTime)
100 100
 					//fmt.Println("基表消毒方式", plan.Way)

+ 1 - 1
service/auto_create_week_plan.go Wyświetl plik

@@ -89,7 +89,7 @@ func AutoCreateWeekPlanJob() {
89 89
 				fmt.Println("错误", errplan)
90 90
 				if errplan == gorm.ErrRecordNotFound {
91 91
 					fmt.Println("该设备无消毒计划")
92
-					return
92
+					continue
93 93
 				} else if errplan == nil {
94 94
 					//查询该病人是否有记录,无记录的则添加
95 95
 					information, errcode := GetInfor(it.PatientId, timenow, it.UserOrgId, it.SchedualType)

+ 5 - 5
service/drug_stock_service.go Wyświetl plik

@@ -196,17 +196,17 @@ func GetDrugCancelExportList(orderid []string, orgid int64) (info []*models.Drug
196 196
 
197 197
 func GetDrugWarehouseInfoPrint(startime int64, endtime int64, orgid int64) (info []*models.XtDrugWarehouseInfo, err error) {
198 198
 
199
-	db := XTReadDB().Table("xt_drug_warehouse_info").Where("status = 1")
199
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
200 200
 	if startime > 0 {
201
-		db = db.Where("ctime >=?", startime)
201
+		db = db.Where("x.ctime >=?", startime)
202 202
 	}
203 203
 	if endtime > 0 {
204
-		db = db.Where("ctime<=?", endtime)
204
+		db = db.Where("x.ctime<=?", endtime)
205 205
 	}
206 206
 	if orgid > 0 {
207
-		db = db.Where("org_id = ?", orgid)
207
+		db = db.Where("x.org_id = ?", orgid)
208 208
 	}
209
-	err = db.Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("drug_id").Find(&info).Error
209
+	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number").Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("x.drug_id").Find(&info).Error
210 210
 
211 211
 	//err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number").Group("x.drug_id").Find(&DrugWarehouseInfo{}).Error
212 212
 	return info, err

+ 1 - 1
service/his_service.go Wyświetl plik

@@ -387,7 +387,7 @@ func SaveHisPatientCaseHistory(caseHistory *models.HisPatientCaseHistory) error
387 387
 
388 388
 func UpdatePatientCaseHistory(id int64, his *models.HisPatientCaseHistory) error {
389 389
 
390
-	err := XTWriteDB().Model(&his).Where("id = ? and status  =1", id).Updates(map[string]interface{}{"temperature": his.Temperature, "blood_sugar": his.BloodSugar, "pulse": his.BloodSugar, "allergic_history": his.AllergicHistory, "diagnose": his.AllergicHistory, "sick": his.Sick, "remark": his.Remark, "doctor_advice": his.DoctorAdvice, "breathing": his.Breathing, "delivery_way": his.DeliveryWay, "diagnostic": his.Diagnostic, "family_history": his.FamilyHistory, "personal_history": his.PersonalHistory, "chief_conplaint": his.ChiefConplaint, "doctor": his.Doctor, "past_history": his.PastHistory, "history_of_present_illness": his.HistoryOfPresentIllness, "is_infect": his.IsInfect, "sick_date": his.SickDate, "symptom": his.Symptom, "sick_type": his.SickType, "blood_fat": his.BloodFat}).Error
390
+	err := XTWriteDB().Model(&his).Where("id = ? and status  =1", id).Updates(map[string]interface{}{"temperature": his.Temperature, "blood_sugar": his.BloodSugar, "pulse": his.Pulse, "allergic_history": his.AllergicHistory, "diagnose": his.AllergicHistory, "sick": his.Sick, "remark": his.Remark, "doctor_advice": his.DoctorAdvice, "breathing": his.Breathing, "delivery_way": his.DeliveryWay, "diagnostic": his.Diagnostic, "family_history": his.FamilyHistory, "personal_history": his.PersonalHistory, "chief_conplaint": his.ChiefConplaint, "doctor": his.Doctor, "past_history": his.PastHistory, "history_of_present_illness": his.HistoryOfPresentIllness, "is_infect": his.IsInfect, "sick_date": his.SickDate, "symptom": his.Symptom, "sick_type": his.SickType, "blood_fat": his.BloodFat, "sbp": his.Sbp, "dbp": his.Dbp}).Error
391 391
 	return err
392 392
 }
393 393
 

+ 1 - 1
service/manage_service.go Wyświetl plik

@@ -730,7 +730,7 @@ func UpdatedZoneID(bedid int64, orgid int64, number *models.DeviceNumber) error
730 730
 
731 731
 func UpadateForm(id int64, orgid int64, infor *models.DeviceInformation) error {
732 732
 
733
-	err := UserWriteDB().Model(&infor).Where("id = ? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"date": infor.Date, "class": infor.Class, "zone": infor.Zone, "bed_number": infor.BedNumber, "contagion": infor.Contagion, "dialysis_mode": infor.DialysisMode, "start_time": infor.StartTime, "end_time": infor.EndTime, "dialysis_hour": infor.DialysisHour, "hyperfiltratio": infor.Hyperfiltratio, "weight_loss": infor.WeightLoss, "warning_value": infor.WarningValue, "user_total": infor.UserTotal, "move": infor.Move, "failure_stage": infor.FailureStage, "fault_description": infor.FaultDescription, "code_information": infor.CodeInformation, "disinfect_type": infor.DisinfectType, "disinfectant_type": infor.DisinfectType, "disinfection": infor.Disinfection, "machine_run": infor.MachineRun, "fluid_path": infor.FluidPath, "disinfectant": infor.Disinfectant, "disinfection_status": infor.DisinfectionStatus, "disinfection_residue": infor.DisinfectionResidue, "long_time": infor.LongTime, "disinfec_startime": infor.DisinfecStartime, "disinfec_endtime": infor.DisinfecEndtime, "dialysis_checked": infor.DialysisChecked, "dialysis_name": infor.DialysisName, "norms": infor.Norms, "dialysis_concentration": infor.DialysisConcentration,
733
+	err := UserWriteDB().Model(&infor).Where("id = ? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"date": infor.Date, "class": infor.Class, "zone": infor.Zone, "bed_number": infor.BedNumber, "contagion": infor.Contagion, "dialysis_mode": infor.DialysisMode, "start_time": infor.StartTime, "end_time": infor.EndTime, "dialysis_hour": infor.DialysisHour, "hyperfiltratio": infor.Hyperfiltratio, "weight_loss": infor.WeightLoss, "warning_value": infor.WarningValue, "user_total": infor.UserTotal, "move": infor.Move, "failure_stage": infor.FailureStage, "fault_description": infor.FaultDescription, "code_information": infor.CodeInformation, "disinfect_type": infor.DisinfectType, "disinfectant_type": infor.DisinfectantType, "disinfection": infor.Disinfection, "machine_run": infor.MachineRun, "fluid_path": infor.FluidPath, "disinfectant": infor.Disinfectant, "disinfection_status": infor.DisinfectionStatus, "disinfection_residue": infor.DisinfectionResidue, "long_time": infor.LongTime, "disinfec_startime": infor.DisinfecStartime, "disinfec_endtime": infor.DisinfecEndtime, "dialysis_checked": infor.DialysisChecked, "dialysis_name": infor.DialysisName, "norms": infor.Norms, "dialysis_concentration": infor.DialysisConcentration,
734 734
 		"germ_checked": infor.GermChecked, "germ_name": infor.GermName, "germ_number": infor.GermNumber, "clean": infor.Clean, "sign_name": infor.SignName, "bed": infor.Bed, "patient_id": infor.PatientId, "mtime": time.Now().Unix()}).Error
735 735
 	return err
736 736
 }

+ 2 - 2
service/patientmanage_service.go Wyświetl plik

@@ -1626,8 +1626,8 @@ func GetInspectionMajorItem(startime int64, lasttime int64, orgid int64, patient
1626 1626
 
1627 1627
 	db := XTReadDB().Table("xt_inspection")
1628 1628
 
1629
-	err = db.Raw("select * from xt_inspection where id in(select max(id) from xt_inspection where org_id = ? and status = 1 and patient_id = ? and inspect_date>=? and inspect_date<=? group by project_id)", orgid, patientid, lasttime, startime).Scan(&inspection).Error
1630
-
1629
+	//err = db.Raw("select * from xt_inspection where id in(select max(id) from xt_inspection where org_id = ? and status = 1 and patient_id = ? and inspect_date>=? and inspect_date<=? group by project_id)", orgid, patientid, lasttime, startime).Scan(&inspection).Error
1630
+	err = db.Raw("select * from xt_inspection  where org_id = ? and status = 1 and patient_id = ? and inspect_date>=? and inspect_date<=? group by project_id", orgid, patientid, lasttime, startime).Scan(&inspection).Error
1631 1631
 	return inspection, err
1632 1632
 }
1633 1633
 

+ 24 - 5
service/self_drug_service.go Wyświetl plik

@@ -980,7 +980,7 @@ func GetDrugInventoryList(keyword string, page int64, limit int64, orgid int64,
980 980
 	if endtime > 0 {
981 981
 		db = db.Where("x.start_time<=?", endtime)
982 982
 	}
983
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
983
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
984 984
 	return list, total, err
985 985
 }
986 986
 
@@ -1009,6 +1009,26 @@ func GetDrugWareInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
1009 1009
 	return info, err
1010 1010
 }
1011 1011
 
1012
+func GetDrugWareInfoByIdTwo(id int64) (info []*models.XtDrugWarehouseInfo, err error) {
1013
+
1014
+	err = XTReadDB().Model(&info).Where("(id = ? or warehousing_info_id = ?) and status = 1", id, id).Find(&info).Error
1015
+	return info, err
1016
+}
1017
+
1018
+func GetLastDrugWarehouse(orgid int64) (models.DrugWarehouse, error) {
1019
+
1020
+	info := models.DrugWarehouse{}
1021
+	err := XTReadDB().Model(&info).Where("org_id=? and status = 1", orgid).Last(&info).Error
1022
+	return info, err
1023
+}
1024
+
1025
+func GetLastDrugWarehouseOut(orgid int64) (models.DrugWarehouseOut, error) {
1026
+
1027
+	info := models.DrugWarehouseOut{}
1028
+	err := XTReadDB().Model(&info).Where("org_id=? and status = 1", orgid).Last(&info).Error
1029
+	return info, err
1030
+}
1031
+
1012 1032
 func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1013 1033
 
1014 1034
 	info := models.XtDrugWarehouseInfo{}
@@ -1078,11 +1098,10 @@ func UpdateDrugWarehouseInfoById(id int64, inventory *models.XtDrugWarehouseInfo
1078 1098
 	return err
1079 1099
 }
1080 1100
 
1081
-func GetDrugWarehouseInfoTotal(id int64) (models.XtDrugWarehouseInfo, error) {
1101
+func GetDrugWarehouseInfoTotal(id int64) (list []*models.XtDrugWarehouseInfo, err error) {
1082 1102
 
1083
-	info := models.XtDrugWarehouseInfo{}
1084
-	err := XTReadDB().Where("id = ? and status = 1", id).Preload("XtBaseDrug", "status = 1").Find(&info).Error
1085
-	return info, err
1103
+	err = XTReadDB().Where("id = ? or warehousing_info_id = ? and status = 1", id, id).Preload("XtBaseDrug", "status = 1").Find(&list).Error
1104
+	return list, err
1086 1105
 }
1087 1106
 
1088 1107
 func CreateDrugWarehouseInfo(info models.DrugWarehouseInfo) error {

+ 19 - 12
service/stock_service.go Wyświetl plik

@@ -623,6 +623,12 @@ func FindFirstWarehousingInfoByStockTwo(good_id int64, good_type_id int64) (info
623 623
 	return info, err
624 624
 }
625 625
 
626
+func FindWarehousingInfoByIdSeven(id int64) (models.WarehousingInfo, error) {
627
+	info := models.WarehousingInfo{}
628
+	err := XTReadDB().Model(&info).Where("id= ? and status = 1", id).Find(&info).Error
629
+	return info, err
630
+}
631
+
626 632
 //药品先进先出,找出最先入库的批次
627 633
 
628 634
 func FindLastDrugWarehousingInfoByID(drug_id int64) (info models.XtDrugWarehouseInfo, err error) {
@@ -3398,18 +3404,6 @@ func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (auto
3398 3404
 		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count,x.record_time FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
3399 3405
 	}
3400 3406
 
3401
-	//db := XTReadDB().Table("xt_automatic_reduce_detail as x").Where("x.status = 1")
3402
-	//
3403
-	//if startime > 0 {
3404
-	//  db = db.Where("x.ctime >=?", startime)
3405
-	//}
3406
-	//if endtime > 0{
3407
-	//  db = db.Where("x.ctime<=?", endtime)
3408
-	//}
3409
-	//if orgid > 0 {
3410
-	//  db = db.Where("x.org_id = ?", orgid)
3411
-	//}
3412
-	//err = db.Group("x.good_id").Select("x.good_id,sum(x.count) as count").Scan(&autoMatic).Error
3413 3407
 	return autoMatic, err
3414 3408
 
3415 3409
 }
@@ -4753,3 +4747,16 @@ func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4753 4747
 	err := db.Select("sum(x.stock_count) as stock_count").Scan(&info).Error
4754 4748
 	return info, err
4755 4749
 }
4750
+
4751
+func GetCurrentWarehosueInfo(id int64) (info []*models.DrugWarehouseInfo, err error) {
4752
+
4753
+	err = XTReadDB().Model(&info).Where("id=? or warehousing_info_id = ? ", id, id).Find(&info).Error
4754
+	return info, err
4755
+}
4756
+
4757
+func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
4758
+
4759
+	info := models.DrugWarehouseInfo{}
4760
+	err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
4761
+	return info, err
4762
+}