28169 1 år sedan
förälder
incheckning
953fd65f03

+ 9 - 8
controllers/doctor_schedule_api_controller.go Visa fil

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"fmt"
5
+	"time"
6
+
4
 	"XT_New/enums"
7
 	"XT_New/enums"
5
 	"XT_New/models"
8
 	"XT_New/models"
6
 	"XT_New/service"
9
 	"XT_New/service"
7
-	"fmt"
8
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego"
9
 	"github.com/jinzhu/gorm"
11
 	"github.com/jinzhu/gorm"
10
-	"time"
11
 )
12
 )
12
 
13
 
13
 type DoctorScheduleApiController struct {
14
 type DoctorScheduleApiController struct {
282
 
283
 
283
 	orgId := this.GetAdminUserInfo().CurrentOrgId
284
 	orgId := this.GetAdminUserInfo().CurrentOrgId
284
 	doctor_id, _ := this.GetInt64("doctor_id")
285
 	doctor_id, _ := this.GetInt64("doctor_id")
285
-	fmt.Println("doctor_id", doctor_id)
286
+
286
 	doctor_type, _ := this.GetInt64("doctor_type")
287
 	doctor_type, _ := this.GetInt64("doctor_type")
287
-	fmt.Println("doctor_type", doctor_type)
288
+
288
 	start_time, _ := this.GetInt64("start_time")
289
 	start_time, _ := this.GetInt64("start_time")
289
-	fmt.Println("start_time", start_time)
290
+
290
 	end_time, _ := this.GetInt64("end_time")
291
 	end_time, _ := this.GetInt64("end_time")
291
-	fmt.Println("end_time", end_time)
292
+
292
 	schedule_type, _ := this.GetInt64("schedule_type")
293
 	schedule_type, _ := this.GetInt64("schedule_type")
293
-	fmt.Println("schedule_type", schedule_type)
294
+
294
 	schedule_week, _ := this.GetInt64("schedule_week")
295
 	schedule_week, _ := this.GetInt64("schedule_week")
295
-	fmt.Println("schedule_week", schedule_week)
296
+
296
 	schedule_date, _ := this.GetInt64("schedule_date")
297
 	schedule_date, _ := this.GetInt64("schedule_date")
297
 	schedule := models.StaffSchedule{
298
 	schedule := models.StaffSchedule{
298
 		DoctorId:     doctor_id,
299
 		DoctorId:     doctor_id,

+ 118 - 264
controllers/his_api_controller.go Visa fil

1866
 
1866
 
1867
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
1867
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
1868
 
1868
 
1869
-	//保存处方出库
1869
+	//自动出库的开关开启
1870
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1870
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1871
 
1871
 
1872
 	//自动出库
1872
 	//自动出库
1927
 		}
1927
 		}
1928
 	}
1928
 	}
1929
 	if isMidicine == true {
1929
 	if isMidicine == true {
1930
+
1930
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
1931
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
1931
 		return
1932
 		return
1932
 	}
1933
 	}
1982
 
1983
 
1983
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
1984
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
1984
 								if drug.ID == 0 {
1985
 								if drug.ID == 0 {
1986
+
1987
+									tx.Rollback()
1985
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1988
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1986
 									return
1989
 									return
1987
 								}
1990
 								}
1997
 								//查询该药品是否存在开药记录
2000
 								//查询该药品是否存在开药记录
1998
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
2001
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1999
 
2002
 
2000
-								//新增处方
2003
+								//新增处方盘点库存是否充足
2001
 								if advicelist.ID == 0 {
2004
 								if advicelist.ID == 0 {
2002
 									all_count, _ := strconv.ParseFloat(totals, 64)
2005
 									all_count, _ := strconv.ParseFloat(totals, 64)
2003
 									if prescribingNumberUnit == drug.MinUnit {
2006
 									if prescribingNumberUnit == drug.MinUnit {
2004
 										if drug.IsUse != 1 {
2007
 										if drug.IsUse != 1 {
2005
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2008
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2006
 												if all_count == 0 {
2009
 												if all_count == 0 {
2010
+													tx.Rollback()
2007
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2011
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2008
 													return
2012
 													return
2009
 												}
2013
 												}
2010
 
2014
 
2011
 												if prescribing_number > all_count {
2015
 												if prescribing_number > all_count {
2016
+													tx.Rollback()
2012
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2017
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2013
 													return
2018
 													return
2014
 												}
2019
 												}
2022
 										if drug.IsUse != 1 {
2027
 										if drug.IsUse != 1 {
2023
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2028
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2024
 												if all_count == 0 {
2029
 												if all_count == 0 {
2030
+													tx.Rollback()
2025
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2031
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2026
 													return
2032
 													return
2027
 												}
2033
 												}
2028
 												if num > all_count {
2034
 												if num > all_count {
2035
+													tx.Rollback()
2029
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2036
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2030
 													return
2037
 													return
2031
 												}
2038
 												}
2036
 								}
2043
 								}
2037
 
2044
 
2038
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
2045
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
2046
+								//不使用保存处方出库
2039
 								if drugOutConfig.IsOpen != 1 {
2047
 								if drugOutConfig.IsOpen != 1 {
2040
 									//修改处方
2048
 									//修改处方
2041
 									for _, advice := range advices {
2049
 									for _, advice := range advices {
2064
 
2072
 
2065
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2073
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2066
 										if drug.ID == 0 {
2074
 										if drug.ID == 0 {
2075
+											tx.Rollback()
2067
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2076
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2068
 											return
2077
 											return
2069
 										}
2078
 										}
2085
 												if drug.IsUse != 1 {
2094
 												if drug.IsUse != 1 {
2086
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2095
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2087
 														if all_count == 0 {
2096
 														if all_count == 0 {
2097
+															tx.Rollback()
2088
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2098
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2089
 															return
2099
 															return
2090
 														}
2100
 														}
2091
 														if prescribing_number > all_count {
2101
 														if prescribing_number > all_count {
2102
+															tx.Rollback()
2092
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2103
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2093
 															return
2104
 															return
2094
 														}
2105
 														}
2101
 													if drug.IsUse != 1 {
2112
 													if drug.IsUse != 1 {
2102
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2113
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2103
 															if all_count == 0 {
2114
 															if all_count == 0 {
2115
+																tx.Rollback()
2104
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2116
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2105
 																return
2117
 																return
2106
 															}
2118
 															}
2107
 															if num > all_count {
2119
 															if num > all_count {
2120
+																tx.Rollback()
2108
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2121
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2109
 																return
2122
 																return
2110
 															}
2123
 															}
2146
 												//如果修改的差数量 大于库存数量
2159
 												//如果修改的差数量 大于库存数量
2147
 												if drug.IsUse != 1 {
2160
 												if drug.IsUse != 1 {
2148
 													if (number_count - device_number) > total_count {
2161
 													if (number_count - device_number) > total_count {
2162
+														tx.Rollback()
2149
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2163
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2150
 														return
2164
 														return
2151
 													}
2165
 													}
2197
 
2211
 
2198
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2212
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2199
 								if drug.ID == 0 {
2213
 								if drug.ID == 0 {
2214
+									tx.Rollback()
2200
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2215
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2201
 									return
2216
 									return
2202
 								}
2217
 								}
2221
 								//新增处方
2236
 								//新增处方
2222
 								if advicelist.ID == 0 {
2237
 								if advicelist.ID == 0 {
2223
 									all_count, _ := strconv.ParseFloat(totals, 64)
2238
 									all_count, _ := strconv.ParseFloat(totals, 64)
2239
+
2224
 									batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
2240
 									batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
2225
 
2241
 
2226
 									if prescribingNumberUnit == drug.MinUnit {
2242
 									if prescribingNumberUnit == drug.MinUnit {
2229
 
2245
 
2230
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2246
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2231
 												if all_count == 0 {
2247
 												if all_count == 0 {
2248
+													tx.Rollback()
2232
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2249
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2233
 													return
2250
 													return
2234
 												}
2251
 												}
2235
 												if prescribing_number > all_count {
2252
 												if prescribing_number > all_count {
2253
+													tx.Rollback()
2236
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2254
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2237
 													return
2255
 													return
2238
 												}
2256
 												}
2240
 
2258
 
2241
 											if adminInfo.CurrentOrgId == 10215 {
2259
 											if adminInfo.CurrentOrgId == 10215 {
2242
 												if prescribing_number > batch_number_all_count {
2260
 												if prescribing_number > batch_number_all_count {
2261
+													tx.Rollback()
2243
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2262
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2244
 													return
2263
 													return
2245
 												}
2264
 												}
2253
 										if drug.IsUse != 1 {
2272
 										if drug.IsUse != 1 {
2254
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2273
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2255
 												if all_count == 0 {
2274
 												if all_count == 0 {
2275
+													tx.Rollback()
2256
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2276
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2257
 													return
2277
 													return
2258
 												}
2278
 												}
2259
 												if num > all_count {
2279
 												if num > all_count {
2280
+													tx.Rollback()
2260
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2281
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2261
 													return
2282
 													return
2262
 												}
2283
 												}
2264
 
2285
 
2265
 											if adminInfo.CurrentOrgId == 10215 {
2286
 											if adminInfo.CurrentOrgId == 10215 {
2266
 												if num > batch_number_all_count {
2287
 												if num > batch_number_all_count {
2288
+													tx.Rollback()
2267
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2289
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2268
 													return
2290
 													return
2269
 												}
2291
 												}
2302
 
2324
 
2303
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2325
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2304
 										if drug.ID == 0 {
2326
 										if drug.ID == 0 {
2327
+											tx.Rollback()
2305
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2328
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2306
 											return
2329
 											return
2307
 										}
2330
 										}
2329
 												if drug.IsUse != 1 {
2352
 												if drug.IsUse != 1 {
2330
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2353
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2331
 														if all_count == 0 {
2354
 														if all_count == 0 {
2355
+															tx.Rollback()
2332
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2356
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2333
 															return
2357
 															return
2334
 														}
2358
 														}
2335
 														if prescribing_number > all_count {
2359
 														if prescribing_number > all_count {
2360
+															tx.Rollback()
2336
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2361
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2337
 															return
2362
 															return
2338
 														}
2363
 														}
2340
 
2365
 
2341
 													if adminInfo.CurrentOrgId == 10215 {
2366
 													if adminInfo.CurrentOrgId == 10215 {
2342
 														if prescribing_number > batch_number_all_count {
2367
 														if prescribing_number > batch_number_all_count {
2368
+															tx.Rollback()
2343
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2369
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2344
 															return
2370
 															return
2345
 														}
2371
 														}
2354
 													if drug.IsUse != 1 {
2380
 													if drug.IsUse != 1 {
2355
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2381
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2356
 															if all_count == 0 {
2382
 															if all_count == 0 {
2383
+																tx.Rollback()
2357
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2384
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2358
 																return
2385
 																return
2359
 															}
2386
 															}
2360
 															if num > all_count {
2387
 															if num > all_count {
2388
+																tx.Rollback()
2361
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2389
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2362
 																return
2390
 																return
2363
 															}
2391
 															}
2365
 
2393
 
2366
 														if adminInfo.CurrentOrgId == 10215 {
2394
 														if adminInfo.CurrentOrgId == 10215 {
2367
 															if prescribing_number > batch_number_all_count {
2395
 															if prescribing_number > batch_number_all_count {
2396
+																tx.Rollback()
2368
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2397
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2369
 																return
2398
 																return
2370
 															}
2399
 															}
2412
 												if drug.IsUse != 1 {
2441
 												if drug.IsUse != 1 {
2413
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2442
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2414
 														if total_count == 0 {
2443
 														if total_count == 0 {
2444
+															tx.Rollback()
2415
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2445
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2416
 															return
2446
 															return
2417
 														}
2447
 														}
2418
 														if (number_count - device_number) > total_count {
2448
 														if (number_count - device_number) > total_count {
2449
+															tx.Rollback()
2419
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2450
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2420
 															return
2451
 															return
2421
 														}
2452
 														}
2422
 
2453
 
2423
 														if (number_count - device_number) > batch_number_count {
2454
 														if (number_count - device_number) > batch_number_count {
2455
+															tx.Rollback()
2424
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2456
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2425
 															return
2457
 															return
2426
 														}
2458
 														}
2449
 
2481
 
2450
 														if out_count > 0 {
2482
 														if out_count > 0 {
2451
 															if (number_count - device_number) > in_count {
2483
 															if (number_count - device_number) > in_count {
2484
+																tx.Rollback()
2452
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2485
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2453
 																return
2486
 																return
2454
 															}
2487
 															}
2461
 															fmt.Println("sum_in_count", sum_in_count)
2494
 															fmt.Println("sum_in_count", sum_in_count)
2462
 															//如果修改的数量大于有库存的第一个批次
2495
 															//如果修改的数量大于有库存的第一个批次
2463
 															if number_count > sum_in_count {
2496
 															if number_count > sum_in_count {
2497
+																tx.Rollback()
2464
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2498
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2465
 																return
2499
 																return
2466
 															}
2500
 															}
2584
 												if drug.IsUse != 1 {
2618
 												if drug.IsUse != 1 {
2585
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2619
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2586
 														if all_count == 0 {
2620
 														if all_count == 0 {
2621
+															tx.Rollback()
2587
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2622
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2588
 															return
2623
 															return
2589
 														}
2624
 														}
2590
 														if prescribing_number > all_count {
2625
 														if prescribing_number > all_count {
2626
+															tx.Rollback()
2591
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2627
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2592
 															return
2628
 															return
2593
 														}
2629
 														}
2595
 
2631
 
2596
 													if adminInfo.CurrentOrgId == 10215 {
2632
 													if adminInfo.CurrentOrgId == 10215 {
2597
 														if prescribing_number > batch_number_all_count {
2633
 														if prescribing_number > batch_number_all_count {
2634
+															tx.Rollback()
2598
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2635
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2599
 															return
2636
 															return
2600
 														}
2637
 														}
2609
 													if drug.IsUse != 1 {
2646
 													if drug.IsUse != 1 {
2610
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2647
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2611
 															if all_count == 0 {
2648
 															if all_count == 0 {
2649
+																tx.Rollback()
2612
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2650
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2613
 																return
2651
 																return
2614
 															}
2652
 															}
2615
 															if num > all_count {
2653
 															if num > all_count {
2654
+																tx.Rollback()
2616
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2655
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2617
 																return
2656
 																return
2618
 															}
2657
 															}
2620
 
2659
 
2621
 														if adminInfo.CurrentOrgId == 10215 {
2660
 														if adminInfo.CurrentOrgId == 10215 {
2622
 															if prescribing_number > batch_number_all_count {
2661
 															if prescribing_number > batch_number_all_count {
2662
+																tx.Rollback()
2623
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2663
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2624
 																return
2664
 																return
2625
 															}
2665
 															}
2659
 												prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
2699
 												prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
2660
 												number_count = prescribingNumberInt
2700
 												number_count = prescribingNumberInt
2661
 											}
2701
 											}
2702
+											fmt.Println("number_count--------------", number_count)
2703
+											fmt.Println("device_number--------------", device_number)
2704
+											fmt.Println("batch_number_count", batch_number_count)
2662
 											//如果修改的数量大于之前修改的数量
2705
 											//如果修改的数量大于之前修改的数量
2663
 											if (number_count - device_number) > 0 {
2706
 											if (number_count - device_number) > 0 {
2664
 												//如果修改的差数量 大于库存数量
2707
 												//如果修改的差数量 大于库存数量
2665
 												if drug.IsUse != 1 {
2708
 												if drug.IsUse != 1 {
2666
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2709
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2667
 														if total_count == 0 {
2710
 														if total_count == 0 {
2711
+															tx.Rollback()
2668
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2712
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2669
 															return
2713
 															return
2670
 														}
2714
 														}
2671
 														if (number_count - device_number) > total_count {
2715
 														if (number_count - device_number) > total_count {
2716
+															tx.Rollback()
2672
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2717
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2673
 															return
2718
 															return
2674
 														}
2719
 														}
2676
 
2721
 
2677
 													if adminInfo.CurrentOrgId == 10215 {
2722
 													if adminInfo.CurrentOrgId == 10215 {
2678
 														if (number_count - device_number) > batch_number_count {
2723
 														if (number_count - device_number) > batch_number_count {
2724
+															tx.Rollback()
2679
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2725
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2680
 															return
2726
 															return
2681
 														}
2727
 														}
2703
 
2749
 
2704
 														if out_count > 0 {
2750
 														if out_count > 0 {
2705
 															if (number_count - device_number) > in_count {
2751
 															if (number_count - device_number) > in_count {
2752
+																tx.Rollback()
2706
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2753
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2707
 																return
2754
 																return
2708
 															}
2755
 															}
2714
 															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
2761
 															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
2715
 															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
2762
 															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
2716
 															if sum_in_count == 0 {
2763
 															if sum_in_count == 0 {
2764
+																tx.Rollback()
2717
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2765
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2718
 																return
2766
 																return
2719
 															}
2767
 															}
2720
 															//如果修改的数量大于有库存的第一个批次
2768
 															//如果修改的数量大于有库存的第一个批次
2721
 															if number_count > sum_in_count {
2769
 															if number_count > sum_in_count {
2770
+																tx.Rollback()
2722
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2771
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2723
 																return
2772
 																return
2724
 															}
2773
 															}
2790
 										stock_counts := strconv.FormatInt(stock_count, 10)
2839
 										stock_counts := strconv.FormatInt(stock_count, 10)
2791
 										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2840
 										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2792
 										if stock_total_count == 0 {
2841
 										if stock_total_count == 0 {
2842
+											tx.Rollback()
2793
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2843
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2794
 											return
2844
 											return
2795
 										}
2845
 										}
2796
 										if totals > stock_total_count {
2846
 										if totals > stock_total_count {
2847
+											tx.Rollback()
2797
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2848
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2798
 											return
2849
 											return
2799
 										}
2850
 										}
2817
 
2868
 
2818
 												//库存不足
2869
 												//库存不足
2819
 												if stock_count == 0 {
2870
 												if stock_count == 0 {
2871
+													tx.Rollback()
2820
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2872
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2821
 													return
2873
 													return
2822
 												}
2874
 												}
2823
 												if (parsetotal - count) > stock_count {
2875
 												if (parsetotal - count) > stock_count {
2876
+													tx.Rollback()
2824
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2877
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2825
 													return
2878
 													return
2826
 												}
2879
 												}
2896
 											stock_counts := strconv.FormatInt(stock_count, 10)
2949
 											stock_counts := strconv.FormatInt(stock_count, 10)
2897
 											stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2950
 											stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2898
 											if stock_total_count == 0 {
2951
 											if stock_total_count == 0 {
2952
+												tx.Rollback()
2899
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2953
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2900
 												return
2954
 												return
2901
 											}
2955
 											}
2902
 											if totals > stock_total_count {
2956
 											if totals > stock_total_count {
2957
+												tx.Rollback()
2903
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2958
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2904
 												return
2959
 												return
2905
 											}
2960
 											}
3117
 	var adviceList []models.HisDoctorAdviceInfo
3172
 	var adviceList []models.HisDoctorAdviceInfo
3118
 	var projectList []models.HisPrescriptionProject
3173
 	var projectList []models.HisPrescriptionProject
3119
 
3174
 
3120
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 {
3175
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 {
3121
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3176
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3122
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3177
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3123
 
3178
 
3308
 										s.Price = lastWarehouse.RetailPrice
3363
 										s.Price = lastWarehouse.RetailPrice
3309
 									}
3364
 									}
3310
 									if s.Price == 0 {
3365
 									if s.Price == 0 {
3311
-										s.Price = lastWarehouse.RetailPrice
3366
+										if lastWarehouse.ID == 0 {
3367
+											lastWarehouseTwo, _ := service.FindLastDrugWarehousingInfoByIDTwo(s.DrugId, storeConfig.DrugStorehouseOut)
3368
+											s.Price = lastWarehouseTwo.RetailPrice
3369
+										}
3370
+
3312
 									}
3371
 									}
3313
 								}
3372
 								}
3314
 
3373
 
3315
 								//查询保存处方出库开关是否打开
3374
 								//查询保存处方出库开关是否打开
3316
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3375
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3376
+
3317
 								if drugOutConfig.IsOpen == 1 {
3377
 								if drugOutConfig.IsOpen == 1 {
3378
+
3318
 									drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
3379
 									drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
3319
 									// 查询该药品最后一次出库记录
3380
 									// 查询该药品最后一次出库记录
3320
 									druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3381
 									druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3382
+
3321
 									if len(druginfo) > 0 {
3383
 									if len(druginfo) > 0 {
3322
 										//回退库存
3384
 										//回退库存
3323
 										for _, it := range druginfo {
3385
 										for _, it := range druginfo {
3337
 
3399
 
3338
 											}
3400
 											}
3339
 										}
3401
 										}
3402
+
3340
 										//删除记录
3403
 										//删除记录
3341
-										service.DeleteDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3404
+										service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3405
+
3342
 									}
3406
 									}
3343
 
3407
 
3344
 									service.CreateHisDoctorAdviceOne(&s, tx)
3408
 									service.CreateHisDoctorAdviceOne(&s, tx)
3472
 								timeFormat := tempTime.Format("20060102150405")
3536
 								timeFormat := tempTime.Format("20060102150405")
3473
 								s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
3537
 								s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
3474
 								service.CreateHisDoctorAdviceOne(&s, tx)
3538
 								service.CreateHisDoctorAdviceOne(&s, tx)
3475
-
3539
+								//list, _ := service.GetHisToday(s.PatientId, s.AdviceDate, s.UserOrgId, s.DrugId, tx)
3540
+								//var count_total int64
3541
+								//var count_one int64
3542
+								//for _, its := range list {
3543
+								//	baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3544
+								//	if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3545
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3546
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3547
+								//		count_total += prescribingNumberSevenTy * baseDrug.MinNumber
3548
+								//	}
3549
+								//
3550
+								//	if its.PrescribingNumberUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3551
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3552
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3553
+								//		count_total += prescribingNumberSevenTy
3554
+								//	}
3555
+								//
3556
+								//	if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
3557
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3558
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3559
+								//		count_total += prescribingNumberSevenTy
3560
+								//	}
3561
+								//
3562
+								//	drugAuto, _ := service.GetLastDrugAuto(its.ID, its.DrugId, its.AdviceDate, its.PatientId,its.UserOrgId, tx)
3563
+								//
3564
+								//	if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3565
+								//
3566
+								//		count_one = drugAuto.Count * baseDrug.MinNumber
3567
+								//	}
3568
+								//
3569
+								//	if drugAuto.CountUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3570
+								//
3571
+								//		count_one = drugAuto.Count
3572
+								//	}
3573
+								//
3574
+								//	if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
3575
+								//
3576
+								//		count_one = drugAuto.Count
3577
+								//	}
3578
+								//	fmt.Println("count_one==================", count_one)
3579
+								//	fmt.Println("count_total==================", count_total)
3580
+								//	if count_total != count_one {
3581
+								//
3582
+								//		service.UpdateTodayHis(its.DrugId, its.AdviceDate, its.PatientId, its.UserOrgId, baseDrug.MinUnit, count_total, its.ID, tx)
3583
+								//	}
3584
+								//
3585
+								//}
3476
 								tx.Commit()
3586
 								tx.Commit()
3587
+
3477
 								keySix := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
3588
 								keySix := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
3478
 								redis.Set(keySix, "", time.Second)
3589
 								redis.Set(keySix, "", time.Second)
3479
 								keyFive := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
3590
 								keyFive := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
3859
 				}
3970
 				}
3860
 
3971
 
3861
 			}
3972
 			}
3862
-
3863
-			//查询今日该患者开的药品处方
3864
-			//hisdoctorlist, _ := service.GetNewHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId, tx)
3865
-			//drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3866
-
3867
-			//药品出库
3868
-			//if drugOutConfig.IsOpen == 1 {
3869
-			//	for _, item := range hisdoctorlist {
3870
-			//		drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
3871
-			//
3872
-			//		// 查询该药品最后一次出库记录
3873
-			//		druginfo, _ := service.GetLastNewDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID, tx)
3874
-			//
3875
-			//		if len(druginfo) > 0 {
3876
-			//			//回退库存
3877
-			//			for _, it := range druginfo {
3878
-			//
3879
-			//				if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3880
-			//
3881
-			//					service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3882
-			//
3883
-			//				}
3884
-			//				if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3885
-			//
3886
-			//					service.ModifyNewDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3887
-			//
3888
-			//				}
3889
-			//				if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3890
-			//
3891
-			//					service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3892
-			//
3893
-			//				}
3894
-			//			}
3895
-			//		}
3896
-			//
3897
-			//		//删除记录
3898
-			//		service.DeleteNewDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID, tx)
3899
-			//		//查询最后一次数据
3900
-			//		if drugOutConfig.IsOpen == 1 {
3901
-			//			//出库
3902
-			//			if drug.IsUse == 2 {
3903
-			//				creater := adminInfo.AdminUser.Id
3904
-			//
3905
-			//				service.NewHisDrugsDelivery(item.UserOrgId, creater, item, tx)
3906
-			//
3907
-			//			}
3908
-			//
3909
-			//			//更新字典里面的库存
3910
-			//			stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
3911
-			//			var sum_count int64
3912
-			//			for _, its := range stockInfo {
3913
-			//				baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3914
-			//				if its.MaxUnit == baseDrug.MaxUnit {
3915
-			//					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3916
-			//				}
3917
-			//				sum_count += its.StockMaxNumber + its.StockMinNumber
3918
-			//			}
3919
-			//			//更新基础库存
3920
-			//			service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
3921
-			//			//剩余库存
3922
-			//			service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
3923
-			//
3924
-			//			over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
3925
-			//			service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
3926
-			//
3927
-			//		}
3928
-			//	}
3929
-			//}
3930
-
3931
-			//耗材保存处方出库
3932
-			//if goodOutConfig.IsOpen == 1 {
3933
-			//
3934
-			//	//查询今日耗材出库数量
3935
-			//	hisgoodlist, _ := service.GetHisGoodList(patient_id, recordDateTime, adminInfo.CurrentOrgId)
3936
-			//
3937
-			//	for _, item := range hisgoodlist {
3938
-			//
3939
-			//		//查询历史出库数据
3940
-			//		flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
3941
-			//		var out_count_five int64
3942
-			//		for _, item := range flowGood {
3943
-			//			out_count_five += item.Count
3944
-			//		}
3945
-			//
3946
-			//		parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
3947
-			//
3948
-			//		if out_count_five != parseIntCount {
3949
-			//
3950
-			//			//查询耗材最后一次出库记录
3951
-			//			wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(item.ProjectId, patient_id, recordDateTime, item.ID)
3952
-			//			//查询默认出库仓库库存
3953
-			//			storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
3954
-			//			if len(wareOut) > 0 {
3955
-			//
3956
-			//				for _, it := range wareOut {
3957
-			//					//回退库存
3958
-			//					service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
3959
-			//
3960
-			//					//删除出库记录
3961
-			//					service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
3962
-			//
3963
-			//				}
3964
-			//			}
3965
-			//
3966
-			//			timeStr := time.Now().Format("2006-01-02")
3967
-			//			timeArr := strings.Split(timeStr, "-")
3968
-			//			total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
3969
-			//
3970
-			//			total = total + 1
3971
-			//			warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
3972
-			//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
3973
-			//			number = number + total
3974
-			//			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
3975
-			//
3976
-			//			operation_time := time.Now().Unix()
3977
-			//			creater := c.GetAdminUserInfo().AdminUser.Id
3978
-			//
3979
-			//			recordDateStr := time.Now().Format("2006-01-02")
3980
-			//			recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3981
-			//			nowtime := recordDate.Unix()
3982
-			//			warehouseOut := models.WarehouseOut{
3983
-			//				WarehouseOutOrderNumber: warehousing_out_order,
3984
-			//				OperationTime:           operation_time,
3985
-			//				OrgId:                   adminInfo.CurrentOrgId,
3986
-			//				Creater:                 creater,
3987
-			//				Ctime:                   time.Now().Unix(),
3988
-			//				Status:                  1,
3989
-			//				WarehouseOutTime:        nowtime,
3990
-			//				Type:                    1,
3991
-			//				StorehouseId:            storeConfig.StorehouseOutInfo,
3992
-			//				IsCheck:                 1,
3993
-			//				IsSys:                   1,
3994
-			//			}
3995
-			//			//查询是否生成出库单
3996
-			//			out, _ := service.FindPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
3997
-			//
3998
-			//			if out.ID == 0 {
3999
-			//				service.AddSigleWarehouseOut(&warehouseOut)
4000
-			//			}
4001
-			//
4002
-			//			lastOut, _ := service.FindLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
4003
-			//
4004
-			//			goodObj, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
4005
-			//			houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
4006
-			//
4007
-			//			dialyPrepareOne := models.DialysisBeforePrepare{
4008
-			//				GoodTypeId:   goodObj.GoodTypeId,
4009
-			//				GoodId:       item.ProjectId,
4010
-			//				PatientId:    item.PatientId,
4011
-			//				RecordDate:   item.RecordDate,
4012
-			//				UserOrgId:    adminInfo.CurrentOrgId,
4013
-			//				Count:        parseIntCount,
4014
-			//				Ctime:        time.Now().Unix(),
4015
-			//				Creater:      creater,
4016
-			//				Status:       1,
4017
-			//				StorehouseId: houseConfig.StorehouseOutInfo,
4018
-			//				ProjectId:    item.ID,
4019
-			//			}
4020
-			//			goodinfo, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
4021
-			//			if goodinfo.IsUser == 2 || goodinfo.IsUser == 0 {
4022
-			//
4023
-			//				//查询历史出库数据
4024
-			//				flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4025
-			//				var out_count int64
4026
-			//				for _, item := range flowGood {
4027
-			//					out_count += item.Count
4028
-			//				}
4029
-			//
4030
-			//				//如果历史数和当前数据不想等才进行退库出库
4031
-			//				if out_count != parseIntCount {
4032
-			//					service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
4033
-			//
4034
-			//					service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4035
-			//					detail := models.AutomaticReduceDetail{
4036
-			//						WarehouseOutId:          0,
4037
-			//						WarehouseOutOrderNumber: "",
4038
-			//						PatientId:               item.PatientId,
4039
-			//						Ctime:                   time.Now().Unix(),
4040
-			//						Mtime:                   0,
4041
-			//						Status:                  1,
4042
-			//						RecordTime:              item.RecordDate,
4043
-			//						OrgId:                   item.UserOrgId,
4044
-			//						GoodId:                  item.ProjectId,
4045
-			//						GoodTypeId:              0,
4046
-			//						Count:                   parseIntCount,
4047
-			//						Type:                    0,
4048
-			//						ProjectId:               item.ID,
4049
-			//						StorehouseId:            0,
4050
-			//					}
4051
-			//
4052
-			//					service.CreateAutoDetail(detail)
4053
-			//
4054
-			//					//查询剩余库存
4055
-			//					goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
4056
-			//					var sum_count int64
4057
-			//					for _, item := range goodList {
4058
-			//						sum_count += item.StockCount
4059
-			//					}
4060
-			//
4061
-			//					//更新剩余库存
4062
-			//					service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
4063
-			//
4064
-			//					//耗材
4065
-			//					service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
4066
-			//				}
4067
-			//
4068
-			//			}
4069
-			//
4070
-			//			if goodinfo.IsUser == 1 && goodinfo.IsWarehouse == 1 {
4071
-			//				//查询历史出库数据
4072
-			//				flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4073
-			//				var out_count int64
4074
-			//				for _, item := range flowGood {
4075
-			//					out_count += item.Count
4076
-			//				}
4077
-			//				//如果历史数和当前数据不想等才进行退库出库
4078
-			//				if out_count != parseIntCount {
4079
-			//					service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
4080
-			//
4081
-			//					service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4082
-			//					detail := models.AutomaticReduceDetail{
4083
-			//						WarehouseOutId:          0,
4084
-			//						WarehouseOutOrderNumber: "",
4085
-			//						PatientId:               item.PatientId,
4086
-			//						Ctime:                   time.Now().Unix(),
4087
-			//						Mtime:                   0,
4088
-			//						Status:                  1,
4089
-			//						RecordTime:              item.RecordDate,
4090
-			//						OrgId:                   item.UserOrgId,
4091
-			//						GoodId:                  item.ProjectId,
4092
-			//						GoodTypeId:              0,
4093
-			//						Count:                   parseIntCount,
4094
-			//						Type:                    0,
4095
-			//						ProjectId:               item.ID,
4096
-			//						StorehouseId:            0,
4097
-			//					}
4098
-			//
4099
-			//					service.CreateAutoDetail(detail)
4100
-			//
4101
-			//					//查询剩余库存
4102
-			//					goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
4103
-			//					var sum_count int64
4104
-			//					for _, item := range goodList {
4105
-			//						sum_count += item.StockCount
4106
-			//					}
4107
-			//
4108
-			//					//更新剩余库存
4109
-			//					service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
4110
-			//
4111
-			//					//耗材
4112
-			//					service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
4113
-			//				}
4114
-			//
4115
-			//			}
4116
-			//
4117
-			//		}
4118
-			//	}
4119
-			//}
4120
 		}
3973
 		}
3974
+
4121
 		tx.Commit()
3975
 		tx.Commit()
4122
 		if err == nil {
3976
 		if err == nil {
4123
 			c.ServeSuccessJSON(map[string]interface{}{
3977
 			c.ServeSuccessJSON(map[string]interface{}{

+ 0 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go Visa fil

9628
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
9628
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
9629
 		}
9629
 		}
9630
 	}
9630
 	}
9631
-
9632
-	fmt.Println("config233322333223", config.IsOpen)
9633
-
9634
 	//血透客户
9631
 	//血透客户
9635
 	if config.IsOpen == 2 || config.IsOpen == 0 {
9632
 	if config.IsOpen == 2 || config.IsOpen == 0 {
9636
 
9633
 

+ 13 - 33
controllers/mobile_api_controllers/patient_api_controller.go Visa fil

1288
 		ids = strings.Split(advice_ids, ",")
1288
 		ids = strings.Split(advice_ids, ",")
1289
 		if len(execution_time) <= 0 {
1289
 		if len(execution_time) <= 0 {
1290
 			utils.ErrorLog("execution_time")
1290
 			utils.ErrorLog("execution_time")
1291
+			tx.Rollback()
1291
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1292
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1292
 			return
1293
 			return
1293
 		}
1294
 		}
1297
 
1298
 
1298
 		if errs != nil {
1299
 		if errs != nil {
1299
 			utils.ErrorLog(errs.Error())
1300
 			utils.ErrorLog(errs.Error())
1301
+			tx.Rollback()
1300
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1302
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1301
 			return
1303
 			return
1302
 		}
1304
 		}
1304
 		var err error
1306
 		var err error
1305
 		for _, item := range advices {
1307
 		for _, item := range advices {
1306
 			if item.ExecutionState == 1 {
1308
 			if item.ExecutionState == 1 {
1309
+				tx.Rollback()
1307
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
1310
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
1308
 				return
1311
 				return
1309
 			}
1312
 			}
1310
 
1313
 
1311
 			if item.Checker >= 0 && item.Checker == adminInfo.AdminUser.Id {
1314
 			if item.Checker >= 0 && item.Checker == adminInfo.AdminUser.Id {
1315
+				tx.Rollback()
1312
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1316
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1313
 				return
1317
 				return
1314
 			}
1318
 			}
1315
 
1319
 
1316
 			if item.StartTime > theTime.Unix() {
1320
 			if item.StartTime > theTime.Unix() {
1321
+				tx.Rollback()
1317
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1322
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1318
 				return
1323
 				return
1319
 			}
1324
 			}
1341
 					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId, 4)
1346
 					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId, 4)
1342
 					//申请状态不允许的情况 拒绝修改
1347
 					//申请状态不允许的情况 拒绝修改
1343
 					if infor.ApplicationStatus != 1 {
1348
 					if infor.ApplicationStatus != 1 {
1349
+						tx.Rollback()
1344
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1350
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1345
 						return
1351
 						return
1346
 					}
1352
 					}
1436
 						}
1442
 						}
1437
 					}
1443
 					}
1438
 					advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
1444
 					advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
1439
-					tx.Commit()
1445
+					tx.Rollback()
1440
 					c.ServeSuccessJSON(map[string]interface{}{
1446
 					c.ServeSuccessJSON(map[string]interface{}{
1441
 						"msg":    "7",
1447
 						"msg":    "7",
1442
 						"advice": advice,
1448
 						"advice": advice,
1489
 				var total int64
1495
 				var total int64
1490
 				var prescribing_number_total int64
1496
 				var prescribing_number_total int64
1491
 
1497
 
1498
+				//保存处方出库
1492
 				config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
1499
 				config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
1493
 
1500
 
1494
 				if config.IsOpen != 1 {
1501
 				if config.IsOpen != 1 {
1529
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1536
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1530
 							}
1537
 							}
1531
 							service.CreateDrugError(drugError)
1538
 							service.CreateDrugError(drugError)
1532
-							tx.Commit()
1539
+							tx.Rollback()
1533
 							c.ServeSuccessJSON(map[string]interface{}{
1540
 							c.ServeSuccessJSON(map[string]interface{}{
1534
 								"msg":    "1",
1541
 								"msg":    "1",
1535
 								"advice": advice,
1542
 								"advice": advice,
1555
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1562
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1556
 							}
1563
 							}
1557
 							service.CreateDrugError(drugError)
1564
 							service.CreateDrugError(drugError)
1558
-							tx.Commit()
1565
+							tx.Rollback()
1559
 							c.ServeSuccessJSON(map[string]interface{}{
1566
 							c.ServeSuccessJSON(map[string]interface{}{
1560
 								"msg":    "3",
1567
 								"msg":    "3",
1561
 								"advice": advice,
1568
 								"advice": advice,
1578
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1585
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1579
 							}
1586
 							}
1580
 							service.CreateDrugError(drugError)
1587
 							service.CreateDrugError(drugError)
1581
-							tx.Commit()
1588
+							tx.Rollback()
1582
 							c.ServeSuccessJSON(map[string]interface{}{
1589
 							c.ServeSuccessJSON(map[string]interface{}{
1583
 								"msg":    "2",
1590
 								"msg":    "2",
1584
 								"advice": advice,
1591
 								"advice": advice,
1588
 						}
1595
 						}
1589
 					}
1596
 					}
1590
 
1597
 
1591
-					fmt.Println("hhahhahahahhhhhha", prescribing_number_total)
1592
-					fmt.Println("total0000000000000", total)
1593
-					fmt.Println("medical22222222222222", medical.IsUse)
1594
-					fmt.Println("config.isp", config.IsOpen)
1595
 					if prescribing_number_total <= total {
1598
 					if prescribing_number_total <= total {
1596
 
1599
 
1597
 						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
1600
 						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
1601
 							if config.IsOpen != 1 {
1604
 							if config.IsOpen != 1 {
1602
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1605
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1603
 
1606
 
1604
-									//service.NewHisDrugsDelivery(adminInfo.Org.Id, creater, &advice, tx)
1605
-									//service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1606
-
1607
 									if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1607
 									if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1608
 										//查询该药品是否有出库记录
1608
 										//查询该药品是否有出库记录
1609
 										flowMap, _ := service.GetDrugFLowByAdviceByIdOne(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate, tx)
1609
 										flowMap, _ := service.GetDrugFLowByAdviceByIdOne(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate, tx)
1625
 												}
1625
 												}
1626
 												service.CreateDrugError(drugError)
1626
 												service.CreateDrugError(drugError)
1627
 											}
1627
 											}
1628
-											tx.Commit()
1628
+											tx.Rollback()
1629
 											c.ServeSuccessJSON(map[string]interface{}{
1629
 											c.ServeSuccessJSON(map[string]interface{}{
1630
 												"msg":    "6",
1630
 												"msg":    "6",
1631
 												"advice": advice,
1631
 												"advice": advice,
1662
 												}
1662
 												}
1663
 												service.CreateDrugError(drugError)
1663
 												service.CreateDrugError(drugError)
1664
 											}
1664
 											}
1665
-											tx.Commit()
1665
+											tx.Rollback()
1666
 											c.ServeSuccessJSON(map[string]interface{}{
1666
 											c.ServeSuccessJSON(map[string]interface{}{
1667
 												"msg":    "6",
1667
 												"msg":    "6",
1668
 												"advice": advice,
1668
 												"advice": advice,
1693
 					}
1693
 					}
1694
 				}
1694
 				}
1695
 
1695
 
1696
-				//fmt.Println("config+++++++++++", config.IsOpen)
1697
-				//fmt.Println("config+++++++++++", item.UserOrgId)
1698
-				//
1699
-				//if config.IsOpen == 1 && item.UserOrgId == 10402 {
1700
-				//
1701
-				//	service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1702
-				//	//更新字典里面的库存
1703
-				//	stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1704
-				//	var sum_count int64
1705
-				//	for _, its := range stockInfo {
1706
-				//		if its.MaxUnit == medical.MaxUnit {
1707
-				//			its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1708
-				//		}
1709
-				//		sum_count += its.StockMaxNumber + its.StockMinNumber
1710
-				//	}
1711
-				//	service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1712
-				//	//剩余库存
1713
-				//	service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1714
-				//}
1715
-
1716
 			}
1696
 			}
1717
 		}
1697
 		}
1718
 		tx.Commit()
1698
 		tx.Commit()

+ 10 - 10
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Visa fil

1431
 			}
1431
 			}
1432
 		}
1432
 		}
1433
 
1433
 
1434
-		if org_id == 10206 || org_id == 10344 {
1435
-			hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1436
-			project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1437
-			if len(hisAdvice) > 0 {
1438
-				service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1439
-			}
1440
-			if len(project) > 0 {
1441
-				service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1442
-			}
1443
-		}
1434
+		//if org_id == 10206 || org_id == 10344 {
1435
+		//	hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1436
+		//	project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1437
+		//	if len(hisAdvice) > 0 {
1438
+		//		service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1439
+		//	}
1440
+		//	if len(project) > 0 {
1441
+		//		service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1442
+		//	}
1443
+		//}
1444
 		if err == nil {
1444
 		if err == nil {
1445
 			c.ServeSuccessJSON(map[string]interface{}{
1445
 			c.ServeSuccessJSON(map[string]interface{}{
1446
 				"msg": "ok",
1446
 				"msg": "ok",

+ 2 - 38
controllers/patient_api_controller.go Visa fil

2798
 
2798
 
2799
 		//1.判断是否启用药品管理和自备药出库功能
2799
 		//1.判断是否启用药品管理和自备药出库功能
2800
 
2800
 
2801
-		//药品管理信息
2801
+		//药品自动出库开关管理信息
2802
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
2802
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
2803
 
2803
 
2804
 		if drugStockConfig.IsOpen == 1 {
2804
 		if drugStockConfig.IsOpen == 1 {
2806
 			advices, _ := service.GetHisExecutionDoctorsTwo(adminUserInfo.CurrentOrgId, patient, id)
2806
 			advices, _ := service.GetHisExecutionDoctorsTwo(adminUserInfo.CurrentOrgId, patient, id)
2807
 			for _, item := range advices {
2807
 			for _, item := range advices {
2808
 				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
2808
 				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
2809
-				//查询这个患者这个患者这个药已经出库的所有数量
2810
-				//advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
2811
-				//drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
2812
-				//var total_count int64 // 现在出库的
2813
-				//var drug_count int64  // 已经出库的
2814
-				//for _, it := range advicelist {
2815
-				//	if it.PrescribingNumberUnit == medical.MaxUnit {
2816
-				//		prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
2817
-				//		prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
2818
-				//		total_count += prenumber * medical.MinNumber
2819
-				//	}
2820
-				//	if it.PrescribingNumberUnit == medical.MinUnit {
2821
-				//		prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
2822
-				//		prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
2823
-				//		total_count += prenumber
2824
-				//	}
2825
-				//
2826
-				//}
2827
-				//
2828
-				//
2829
-				//for _, its := range drugoutlist {
2830
-				//	if its.CountUnit == medical.MaxUnit {
2831
-				//		drug_count += its.Count * medical.MinNumber
2832
-				//	}
2833
-				//	if its.CountUnit == medical.MinUnit {
2834
-				//		drug_count += its.Count
2835
-				//	}
2836
-				//}
2837
-				//fmt.Println("total_count23232323232323232wode",total_count)
2838
-				//fmt.Println("total_count23232323232323232wode",drug_count)
2839
-				//if total_count == drug_count {
2840
-				//	c.ServeSuccessJSON(map[string]interface{}{
2841
-				//		"msg":    "1",
2842
-				//		"advice": advice,
2843
-				//	})
2844
-				//	return
2845
-				//}
2846
 
2809
 
2847
 				var total int64
2810
 				var total int64
2848
 				var prescribing_number_total int64
2811
 				var prescribing_number_total int64
2812
+				//药品保存处方出库
2849
 				config, _ := service.GetDrugOpenConfigOne(adminUserInfo.CurrentOrgId)
2813
 				config, _ := service.GetDrugOpenConfigOne(adminUserInfo.CurrentOrgId)
2850
 				if config.IsOpen != 1 {
2814
 				if config.IsOpen != 1 {
2851
 					//查询默认出库仓库
2815
 					//查询默认出库仓库

+ 3 - 0
controllers/pharmacy_controller.go Visa fil

335
 	appId := this.GetAdminUserInfo().CurrentAppId
335
 	appId := this.GetAdminUserInfo().CurrentAppId
336
 	adminUserES, _ := service.GetAllAdminUserES(orgid, appId)
336
 	adminUserES, _ := service.GetAllAdminUserES(orgid, appId)
337
 	allDoctor, _ := service.GetAllDoctor(orgid, appId)
337
 	allDoctor, _ := service.GetAllDoctor(orgid, appId)
338
+
339
+	prescriptionListByToDay, _ := service.GetPrescriptionListByToDay(orgid, patient_id, stime)
338
 	if err != nil {
340
 	if err != nil {
339
 		utils.ErrorLog(err.Error())
341
 		utils.ErrorLog(err.Error())
340
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
342
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
349
 	return_value["zoneList"] = zoneList
351
 	return_value["zoneList"] = zoneList
350
 	return_value["adminUserES"] = adminUserES
352
 	return_value["adminUserES"] = adminUserES
351
 	return_value["doctors"] = allDoctor
353
 	return_value["doctors"] = allDoctor
354
+	return_value["prescription"] = prescriptionListByToDay
352
 
355
 
353
 	//if is_medicine == 1{发药时间先不展示
356
 	//if is_medicine == 1{发药时间先不展示
354
 	//	return_value["time"] = time
357
 	//	return_value["time"] = time

+ 10 - 10
controllers/schedule_api_controller.go Visa fil

742
 						}
742
 						}
743
 					}
743
 					}
744
 
744
 
745
-					if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
746
-						hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
-						project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
748
-						if len(hisAdvice) > 0 {
749
-							service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
750
-						}
751
-						if len(project) > 0 {
752
-							service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
753
-						}
754
-					}
745
+					//if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
746
+					//	hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
+					//	project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
748
+					//	if len(hisAdvice) > 0 {
749
+					//		service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
750
+					//	}
751
+					//	if len(project) > 0 {
752
+					//		service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
753
+					//	}
754
+					//}
755
 					service.SaveSch(&schedule)
755
 					service.SaveSch(&schedule)
756
 				}
756
 				}
757
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
757
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)

+ 1 - 1
controllers/self_drug_api_congtroller.go Visa fil

2950
 		goodIds = append(goodIds, it.ID)
2950
 		goodIds = append(goodIds, it.ID)
2951
 	}
2951
 	}
2952
 	list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
2952
 	list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
2953
-	fmt.Println("total233223322332323232323223", total)
2953
+
2954
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2954
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2955
 
2955
 
2956
 	if err != nil {
2956
 	if err != nil {

+ 3 - 2
controllers/sign_api_controller.go Visa fil

1238
 	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1238
 	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1239
 	//}
1239
 	//}
1240
 
1240
 
1241
-	list, _ := service.GetAllDialysisOrder(10490)
1241
+	list, _ := service.GetAllDialysisOrder(10469)
1242
 	for _, item := range list {
1242
 	for _, item := range list {
1243
-		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1243
+		schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1244
+		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
1244
 	}
1245
 	}
1245
 
1246
 
1246
 	//drugList, _ := service.GetAllBaseDrugList(10571)
1247
 	//drugList, _ := service.GetAllBaseDrugList(10571)

+ 9 - 0
service/gobal_config_service.go Visa fil

1368
 
1368
 
1369
 	return dialysisOrder, err
1369
 	return dialysisOrder, err
1370
 }
1370
 }
1371
+
1372
+func GetPrescriptionListByToDay(user_org_id int64, patient_id int64, record_Date int64) (models.HisPrescriptionInfo, error) {
1373
+
1374
+	prescriptionInfo := models.HisPrescriptionInfo{}
1375
+
1376
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status =1", user_org_id, patient_id, record_Date).Find(&prescriptionInfo).Error
1377
+
1378
+	return prescriptionInfo, err
1379
+}

+ 38 - 0
service/his_service.go Visa fil

905
 	return
905
 	return
906
 }
906
 }
907
 
907
 
908
+func GetHisToday(patient_id int64, advice_date int64, user_org_id int64, drug_id int64, tx *gorm.DB) (list []*models.HisDoctorAdviceInfo, err error) {
909
+
910
+	err = tx.Where("patient_id = ? and advice_date = ? and user_org_id = ? and status =1 and drug_id = ?", patient_id, advice_date, user_org_id, drug_id).Find(&list).Error
911
+	if err != gorm.ErrRecordNotFound {
912
+		if err != nil {
913
+			tx.Rollback()
914
+			return list, err
915
+		}
916
+	}
917
+	return list, err
918
+}
919
+
920
+func GetLastDrugAuto(advice_id int64, drug_id int64, advice_date int64, patient_id int64, user_org_id int64, tx *gorm.DB) (models.DrugAutomaticReduceDetail, error) {
921
+
922
+	automaticReduceDetail := models.DrugAutomaticReduceDetail{}
923
+
924
+	err := XTReadDB().Where("advice_id = ? and drug_id = ? and record_time= ? and patient_id =? and status=1 and org_id = ?", advice_id, drug_id, advice_date, patient_id, user_org_id).Find(&automaticReduceDetail).Error
925
+	if err != gorm.ErrRecordNotFound {
926
+		if err != nil {
927
+			tx.Rollback()
928
+			return automaticReduceDetail, err
929
+		}
930
+	}
931
+	return automaticReduceDetail, err
932
+}
933
+
934
+func UpdateTodayHis(drug_id int64, advice_date int64, patient_id int64, user_org_id int64, min_unit string, count_total int64, id int64, tx *gorm.DB) (models.XtDrugAutomaticReduceDetail, error) {
935
+
936
+	drugAutomaticReduceDetail := models.XtDrugAutomaticReduceDetail{}
937
+
938
+	err = tx.Model(&drugAutomaticReduceDetail).Where("drug_id = ? and record_time = ? and patient_id =? and org_id = ? and status=1 and advice_id = ?", drug_id, advice_date, patient_id, user_org_id, id).Updates(map[string]interface{}{"count": count_total, "count_unit": min_unit}).Error
939
+	if err != nil {
940
+		tx.Rollback()
941
+		return drugAutomaticReduceDetail, err
942
+	}
943
+	return drugAutomaticReduceDetail, err
944
+}
945
+
908
 func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
946
 func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
909
 
947
 
910
 	tx := writeDb.Begin()
948
 	tx := writeDb.Begin()

+ 1 - 0
service/new_warehouse_service.go Visa fil

4144
 			AdviceId:                advice.ID,
4144
 			AdviceId:                advice.ID,
4145
 		}
4145
 		}
4146
 
4146
 
4147
+		fmt.Println("天激发阿凡达阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫")
4147
 		AddNewSigleDrugAutoReduceRecordInfo(details, tx)
4148
 		AddNewSigleDrugAutoReduceRecordInfo(details, tx)
4148
 
4149
 
4149
 		return nil
4150
 		return nil

+ 9 - 5
service/pharmacy_service.go Visa fil

865
 	if len(adviceList) > 0 {
865
 	if len(adviceList) > 0 {
866
 		for _, item := range adviceList {
866
 		for _, item := range adviceList {
867
 
867
 
868
-			//扣减库存
869
-			err = HisDrugsDelivery(orgid, creater, item)
870
-			if err != nil {
871
-				err = fmt.Errorf("!:%v", err)
872
-				return
868
+			pharmacyConfig := IsPharmacyConfig(orgid)
869
+			if pharmacyConfig == true {
870
+				//扣减库存
871
+				err = HisDrugsDelivery(orgid, creater, item)
872
+				if err != nil {
873
+					err = fmt.Errorf("!:%v", err)
874
+					return
875
+				}
873
 			}
876
 			}
877
+
874
 			//修改发药状态
878
 			//修改发药状态
875
 			err = UpdateIsMedicalHisAdvice(item.ID)
879
 			err = UpdateIsMedicalHisAdvice(item.ID)
876
 			if err != nil {
880
 			if err != nil {

+ 13 - 7
service/schedule_service.go Visa fil

1524
 func GetLastDialysisPrescriptionTwo(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.NewDialysisPrescription, error) {
1524
 func GetLastDialysisPrescriptionTwo(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.NewDialysisPrescription, error) {
1525
 
1525
 
1526
 	dialysisprescription := models.NewDialysisPrescription{}
1526
 	dialysisprescription := models.NewDialysisPrescription{}
1527
-	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date = ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1528
-	return dialysisprescription, err
1527
+
1528
+	if org_id == 10340 {
1529
+		err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date <= ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").Last(&dialysisprescription).Error
1530
+		return dialysisprescription, err
1531
+	} else {
1532
+		err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date = ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1533
+		return dialysisprescription, err
1534
+	}
1529
 
1535
 
1530
 }
1536
 }
1531
 
1537
 
1838
 
1844
 
1839
 func UpdateProjectObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1845
 func UpdateProjectObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1840
 
1846
 
1841
-	err = XTWriteDB().Model(&models.HisPrescriptionProject{}).Where("patient_id = ? and record_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1847
+	err = XTWriteDB().Model(&models.HisPrescriptionProject{}).Where("patient_id = ? and record_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1842
 
1848
 
1843
-	err = XTWriteDB().Model(&models.HisPrescription{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1849
+	err = XTWriteDB().Model(&models.HisPrescription{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1844
 
1850
 
1845
-	err = XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1851
+	err = XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1846
 	return err
1852
 	return err
1847
 }
1853
 }
1848
 
1854
 
1849
 func UpdateAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1855
 func UpdateAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1850
 
1856
 
1851
-	err = XTWriteDB().Model(&models.XtDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1857
+	err = XTWriteDB().Model(&models.XtDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1852
 	return err
1858
 	return err
1853
 }
1859
 }
1854
 
1860
 
1855
 func UpdateHisAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1861
 func UpdateHisAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1856
 
1862
 
1857
-	err = XTWriteDB().Model(&models.HisDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1863
+	err = XTWriteDB().Model(&models.HisDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1858
 	return err
1864
 	return err
1859
 }
1865
 }
1860
 
1866
 

+ 1 - 1
service/self_drug_service.go Visa fil

2002
 
2002
 
2003
 func UpdateDrugById(id int64, orgid int64, limit_count int64, total_count int64) error {
2003
 func UpdateDrugById(id int64, orgid int64, limit_count int64, total_count int64) error {
2004
 
2004
 
2005
-	err := XTWriteDB().Model(&models.BaseDrugLibTen{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_stock_limit_count": limit_count, "total_count": total_count}).Error
2005
+	err := XTWriteDB().Model(&models.BaseDrugLibTen{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_stock_limit_count": limit_count, "sum_count": total_count}).Error
2006
 	return err
2006
 	return err
2007
 }
2007
 }
2008
 
2008
 

+ 11 - 3
service/sign_service.go Visa fil

2112
 
2112
 
2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2114
 
2114
 
2115
-	err = XTReadDB().Where("patient_id = ? and status =1", 21767).Find(&list).Error
2115
+	err = XTReadDB().Where("patient_id = ? and status =1", 28449).Find(&list).Error
2116
 
2116
 
2117
 	return list, err
2117
 	return list, err
2118
 }
2118
 }
2119
 
2119
 
2120
-func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) error {
2120
+func GetLastScheduleByUserOrg(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) (models.Schedule, error) {
2121
 
2121
 
2122
-	err := XTWriteDB().Model(&models.XtSchedule{}).Where("schedule_date =? and user_org_id =? and patient_id =?", schedule_date, user_org_id, patient_id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type, "status": 1}).Error
2122
+	schedule := models.Schedule{}
2123
+	err := XTReadDB().Where("patient_id = ? and schedule_date = ? and status=0", patient_id, schedule_date).First(&schedule).Error
2124
+
2125
+	return schedule, err
2126
+}
2127
+
2128
+func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64, id int64) error {
2129
+
2130
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ?", id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type, "status": 1}).Error
2123
 	return err
2131
 	return err
2124
 }
2132
 }
2125
 
2133
 

+ 9 - 7
service/stock_service.go Visa fil

876
 	return info, err
876
 	return info, err
877
 }
877
 }
878
 
878
 
879
+func FindLastDrugWarehousingInfoByIDTwo(drug_id int64, storehouse_id int64) (info models.XtDrugWarehouseInfo, err error) {
880
+	err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").Last(&info).Error
881
+	return info, err
882
+}
883
+
879
 func FindNewLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64, tx *gorm.DB) (info models.XtDrugWarehouseInfo, err error) {
884
 func FindNewLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64, tx *gorm.DB) (info models.XtDrugWarehouseInfo, err error) {
880
 	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
885
 	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
881
 	if err != gorm.ErrRecordNotFound {
886
 	if err != gorm.ErrRecordNotFound {
5923
 	return err
5928
 	return err
5924
 }
5929
 }
5925
 
5930
 
5926
-func DeleteNewDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64, tx *gorm.DB) error {
5931
+func DeleteNewDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5932
+
5933
+	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
5934
+	err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5927
 
5935
 
5928
-	err := tx.Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5929
-	err = tx.Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5930
-	if err != nil {
5931
-		tx.Rollback()
5932
-		return err
5933
-	}
5934
 	return err
5936
 	return err
5935
 }
5937
 }
5936
 
5938
 

+ 0 - 1
service/warhouse_service.go Visa fil

7849
 	if isHasWay {
7849
 	if isHasWay {
7850
 		//判断当天当前机构有没有创建出库单,没有则创建
7850
 		//判断当天当前机构有没有创建出库单,没有则创建
7851
 		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
7851
 		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
7852
-		fmt.Println(out)
7853
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
7852
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
7854
 		if err == gorm.ErrRecordNotFound {
7853
 		if err == gorm.ErrRecordNotFound {
7855
 			timeStr := time.Now().Format("2006-01-02")
7854
 			timeStr := time.Now().Format("2006-01-02")