Browse Source

11月8日库存管理

XMLWAN 2 years ago
parent
commit
71584f9e01

+ 343 - 122
controllers/drug_pharmacy_management_controller.go View File

@@ -2,10 +2,13 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"XT_New/utils"
7 8
 	"fmt"
8 9
 	"github.com/astaxie/beego"
10
+	"math"
11
+	"strconv"
9 12
 	"strings"
10 13
 	"time"
11 14
 )
@@ -16,9 +19,18 @@ type PharmacyApiController struct {
16 19
 
17 20
 func PharmacyApiControllersRegisterRouters() {
18 21
 
22
+	//获取设置为药房发药的药品数据
19 23
 	beego.Router("/api/advice/gettodayadvicelist", &PharmacyApiController{}, "Get:GetTodayAdviceList")
24
+	//获取今日未发药的数据
20 25
 	beego.Router("api/advice/getpharmacybasedrug", &PharmacyApiController{}, "Get:GetPharyMacyBaseDrug")
26
+	//发药
21 27
 	beego.Router("/api/advice/updatepharmacybasedrug", &PharmacyApiController{}, "Get:UpdatePharmacyBaseDrug")
28
+
29
+	//获取今日已发药的数据
30
+	beego.Router("api/advice/getpharmacybasedruglist", &PharmacyApiController{}, "Get:GetPharmacyBaseDrugList")
31
+	//退药流程
32
+	beego.Router("/api/advice/getreturnpharmacybasedrug", &PharmacyApiController{}, "Get:GetReturnPharmacyBaseDrug")
33
+
22 34
 }
23 35
 
24 36
 func (this *PharmacyApiController) GetTodayAdviceList() {
@@ -105,139 +117,348 @@ func (this *PharmacyApiController) UpdatePharmacyBaseDrug() {
105 117
 	adviceList, _ := service.GetPharmacyAdviceList(idArray, orgId)
106 118
 
107 119
 	hisAdviceList, _ := service.GetPharmacyHisAdviceList(idArray, orgId)
108
-	fmt.Print(hisAdviceList)
120
+
109 121
 	//查询是否通过药房出库
110 122
 	pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
111
-
112
-	medical, _ := service.GetBaseDrugMedical(orgId)
113
-	fmt.Print(medical)
123
+	creater := this.GetAdminUserInfo().AdminUser.Id
114 124
 	if pharmacyConfig.IsOpen == 1 {
125
+		var total int64
126
+		var prescribing_number_total int64
127
+		//创建流水
128
+		timeStr := time.Now().Format("2006-01-02")
129
+		timeArr := strings.Split(timeStr, "-")
130
+		totals, _ := service.FindAllPharmacyDrugWarehouseOut(orgId)
131
+		totals = totals + 1
132
+		warehousing_out_order := strconv.FormatInt(orgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
133
+		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
134
+		number = number + totals
135
+		warehousing_out_order = "FY" + strconv.FormatInt(number, 10)
115 136
 
137
+		//血透
116 138
 		for _, item := range adviceList {
117
-			fmt.Print(item)
118
-			//houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
139
+
140
+			pharmacy := models.Pharmacy{
141
+				UserOrgId:         item.UserOrgId,
142
+				PatientId:         item.PatientId,
143
+				HisPrescriptionId: 0,
144
+				XtAdviceId:        item.ID,
145
+				HisOrXt:           1,
146
+				Ctime:             time.Now().Unix(),
147
+				Mtime:             0,
148
+				Status:            1,
149
+				HisAdviceId:       0,
150
+				DrugId:            item.DrugId,
151
+				RecordDate:        item.AdviceDate,
152
+				OrdreNumber:       warehousing_out_order,
153
+				Creater:           creater,
154
+			}
155
+
156
+			service.CreatePharmacy(pharmacy)
157
+
158
+			lastPharmacy, _ := service.GetLastPharmary(item.UserOrgId, item.ID, item.AdviceDate)
159
+
160
+			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
119 161
 			////查询该药品是否有库存
120
-			//list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
162
+			list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
121 163
 			//
122 164
 			////查询改药品信息
123
-			//medical, _ := service.GetBaseDrugMedical(item.DrugId)
165
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
124 166
 			////判断单位是否相等
125
-			//if medical.MaxUnit == item.PrescribingNumberUnit {
126
-			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
127
-			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
128
-			//  //转化为最小单位
129
-			//  total = list.Count*medical.MinNumber + list.StockMinNumber
130
-			//  prescribing_number_total = count * medical.MinNumber
131
-			//}
132
-			//if medical.MinUnit == item.PrescribingNumberUnit {
133
-			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
134
-			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
135
-			//  total = list.Count*medical.MinNumber + list.StockMinNumber
136
-			//  prescribing_number_total = count
137
-			//}
138
-			//
139
-			//if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
140
-			//  c.ServeSuccessJSON(map[string]interface{}{
141
-			//    "msg":    "3",
142
-			//    "advice": advice,
143
-			//  })
144
-			//  return
145
-			//}
146
-			//if prescribing_number_total > total {
147
-			//  c.ServeSuccessJSON(map[string]interface{}{
148
-			//    "msg":    "2",
149
-			//    "advice": advice,
150
-			//  })
151
-			//  return
152
-			//}
153
-			//if prescribing_number_total <= total {
154
-			//
155
-			//  //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
156
-			//
157
-			//  adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
158
-			//  if adviceSetting.IsAdviceOpen == 1 {
159
-			//
160
-			//    //查询是否出库按钮开启
161
-			//    prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
162
-			//    if prescriptionConfig.IsOpen == 1 {
163
-			//      if medical.IsUse == 2 {
164
-			//        service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
165
-			//        //查询默认仓库
166
-			//        houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
167
-			//        //查询默认仓库剩余多少库存
168
-			//        list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
169
-			//        var sum_count int64
170
-			//        var sum_in_count int64
171
-			//        for _, it := range list {
172
-			//          baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
173
-			//          if it.MaxUnit == baseDrug.MaxUnit {
174
-			//            it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
175
-			//            it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
176
-			//          }
177
-			//          sum_count += it.StockMaxNumber + it.StockMinNumber
178
-			//          sum_in_count += it.WarehousingCount
179
-			//        }
180
-			//        service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
181
-			//        break
182
-			//        c.ServeSuccessJSON(map[string]interface{}{
183
-			//          "msg":    "1",
184
-			//          "advice": advice,
185
-			//        })
186
-			//        return
187
-			//      }
188
-			//      if medical.IsUse == 1 {
189
-			//        c.ServeSuccessJSON(map[string]interface{}{
190
-			//          "msg":    "1",
191
-			//          "advice": advice,
192
-			//        })
193
-			//        return
194
-			//      }
195
-			//    } else {
196
-			//      if medical.IsUse == 1 {
197
-			//        c.ServeSuccessJSON(map[string]interface{}{
198
-			//          "msg":    "1",
199
-			//          "advice": advice,
200
-			//        })
201
-			//        return
202
-			//      }
203
-			//    }
167
+			if medical.MaxUnit == item.PrescribingNumberUnit {
168
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
169
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
170
+				//转化为最小单位
171
+				total = list.Count*medical.MinNumber + list.StockMinNumber
172
+				prescribing_number_total = count * medical.MinNumber
173
+			}
174
+			if medical.MinUnit == item.PrescribingNumberUnit {
175
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
176
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
177
+				total = list.Count*medical.MinNumber + list.StockMinNumber
178
+				prescribing_number_total = count
179
+			}
180
+
181
+			if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
182
+				this.ServeSuccessJSON(map[string]interface{}{
183
+					"msg":     "3",
184
+					"medical": medical,
185
+				})
186
+				return
187
+			}
188
+			if prescribing_number_total > total {
189
+				this.ServeSuccessJSON(map[string]interface{}{
190
+					"msg":     "2",
191
+					"medical": medical,
192
+				})
193
+				return
194
+			}
195
+
196
+			if prescribing_number_total <= total {
197
+
198
+				//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
199
+				adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
200
+				if adviceSetting.IsAdviceOpen == 1 {
201
+					if medical.IsUse == 2 {
202
+						service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
203
+						//查询默认仓库
204
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
205
+						//查询默认仓库剩余多少库存
206
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
207
+						var sum_count int64
208
+						var sum_in_count int64
209
+						for _, it := range list {
210
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
211
+							if it.MaxUnit == baseDrug.MaxUnit {
212
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
213
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
214
+							}
215
+							sum_count += it.StockMaxNumber + it.StockMinNumber
216
+							sum_in_count += it.WarehousingCount
217
+						}
218
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
219
+						break
220
+						this.ServeSuccessJSON(map[string]interface{}{
221
+							"msg":     "1",
222
+							"medical": medical,
223
+						})
224
+						return
225
+					}
226
+					if medical.IsUse == 1 {
227
+						this.ServeSuccessJSON(map[string]interface{}{
228
+							"msg": "1",
229
+						})
230
+						return
231
+					}
232
+
233
+				} else {
234
+					if medical.IsUse == 2 {
235
+						service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
236
+						//查询默认仓库
237
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
238
+						//查询默认仓库剩余多少库存
239
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
240
+						var sum_count int64
241
+						var sum_in_count int64
242
+						for _, it := range list {
243
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
244
+							if it.MaxUnit == baseDrug.MaxUnit {
245
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
246
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
247
+							}
248
+							sum_count += it.StockMaxNumber + it.StockMinNumber
249
+							sum_in_count += it.WarehousingCount
250
+						}
251
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
252
+						this.ServeSuccessJSON(map[string]interface{}{
253
+							"msg":     "1",
254
+							"medical": medical,
255
+						})
256
+						return
257
+					}
258
+					if medical.IsUse == 1 {
259
+						this.ServeSuccessJSON(map[string]interface{}{
260
+							"msg":     "1",
261
+							"medical": medical,
262
+						})
263
+						return
264
+					}
265
+				}
266
+			}
267
+		}
268
+
269
+		//血透
270
+		for _, item := range hisAdviceList {
271
+
272
+			pharmacy := models.Pharmacy{
273
+				UserOrgId:         item.UserOrgId,
274
+				PatientId:         item.PatientId,
275
+				HisPrescriptionId: 0,
276
+				XtAdviceId:        0,
277
+				HisOrXt:           2,
278
+				Ctime:             time.Now().Unix(),
279
+				Mtime:             0,
280
+				Status:            1,
281
+				HisAdviceId:       item.ID,
282
+				DrugId:            item.DrugId,
283
+				RecordDate:        item.AdviceDate,
284
+				OrdreNumber:       warehousing_out_order,
285
+				Creater:           creater,
286
+			}
287
+
288
+			service.CreatePharmacy(pharmacy)
289
+
290
+			lastPharmary, _ := service.GetLastHisPharmary(item.UserOrgId, item.ID, item.AdviceDate)
291
+
292
+			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
293
+			////查询该药品是否有库存
294
+			list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
204 295
 			//
205
-			//  } else {
206
-			//    if medical.IsUse == 2 {
207
-			//      service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
208
-			//      //查询默认仓库
209
-			//      houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
210
-			//      //查询默认仓库剩余多少库存
211
-			//      list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
212
-			//      var sum_count int64
213
-			//      var sum_in_count int64
214
-			//      for _, it := range list {
215
-			//        baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
216
-			//        if it.MaxUnit == baseDrug.MaxUnit {
217
-			//          it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
218
-			//          it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
219
-			//        }
220
-			//        sum_count += it.StockMaxNumber + it.StockMinNumber
221
-			//        sum_in_count += it.WarehousingCount
222
-			//      }
223
-			//      service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
224
-			//      break
225
-			//      c.ServeSuccessJSON(map[string]interface{}{
226
-			//        "msg":    "1",
227
-			//        "advice": advice,
228
-			//      })
229
-			//      return
230
-			//    }
231
-			//    if medical.IsUse == 1 {
232
-			//      c.ServeSuccessJSON(map[string]interface{}{
233
-			//        "msg":    "1",
234
-			//        "advice": advice,
235
-			//      })
236
-			//      return
237
-			//    }
238
-			//  }
239
-			//}
296
+			////查询改药品信息
297
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
298
+			////判断单位是否相等
299
+			if medical.MaxUnit == item.PrescribingNumberUnit {
300
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
301
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
302
+				//转化为最小单位
303
+				total = list.Count*medical.MinNumber + list.StockMinNumber
304
+				prescribing_number_total = count * medical.MinNumber
305
+			}
306
+			if medical.MinUnit == item.PrescribingNumberUnit {
307
+				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
308
+				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
309
+				total = list.Count*medical.MinNumber + list.StockMinNumber
310
+				prescribing_number_total = count
311
+			}
312
+
313
+			if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
314
+				this.ServeSuccessJSON(map[string]interface{}{
315
+					"msg":     "3",
316
+					"medical": medical,
317
+				})
318
+				return
319
+			}
320
+			if prescribing_number_total > total {
321
+				this.ServeSuccessJSON(map[string]interface{}{
322
+					"msg":     "2",
323
+					"medical": medical,
324
+				})
325
+				return
326
+			}
327
+
328
+			if prescribing_number_total <= total {
329
+
330
+				//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
331
+				adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
332
+				if adviceSetting.IsAdviceOpen == 1 {
333
+					if medical.IsUse == 2 {
334
+						service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
335
+						//查询默认仓库
336
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
337
+						//查询默认仓库剩余多少库存
338
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
339
+						var sum_count int64
340
+						var sum_in_count int64
341
+						for _, it := range list {
342
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
343
+							if it.MaxUnit == baseDrug.MaxUnit {
344
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
345
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
346
+							}
347
+							sum_count += it.StockMaxNumber + it.StockMinNumber
348
+							sum_in_count += it.WarehousingCount
349
+						}
350
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
351
+						break
352
+						this.ServeSuccessJSON(map[string]interface{}{
353
+							"msg":     "1",
354
+							"medical": medical,
355
+						})
356
+						return
357
+					}
358
+					if medical.IsUse == 1 {
359
+						this.ServeSuccessJSON(map[string]interface{}{
360
+							"msg": "1",
361
+						})
362
+						return
363
+					}
364
+
365
+				} else {
366
+					if medical.IsUse == 2 {
367
+						service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
368
+						//查询默认仓库
369
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
370
+						//查询默认仓库剩余多少库存
371
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
372
+						var sum_count int64
373
+						var sum_in_count int64
374
+						for _, it := range list {
375
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
376
+							if it.MaxUnit == baseDrug.MaxUnit {
377
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
378
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
379
+							}
380
+							sum_count += it.StockMaxNumber + it.StockMinNumber
381
+							sum_in_count += it.WarehousingCount
382
+						}
383
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
384
+						this.ServeSuccessJSON(map[string]interface{}{
385
+							"msg":     "1",
386
+							"medical": medical,
387
+						})
388
+						return
389
+					}
390
+					if medical.IsUse == 1 {
391
+						this.ServeSuccessJSON(map[string]interface{}{
392
+							"msg":     "1",
393
+							"medical": medical,
394
+						})
395
+						return
396
+					}
397
+				}
398
+			}
240 399
 		}
241 400
 	}
401
+}
402
+
403
+func (this *PharmacyApiController) GetPharmacyBaseDrugList() {
404
+
405
+	start_time := this.GetString("start_time")
406
+	timeLayout := "2006-01-02"
407
+	loc, _ := time.LoadLocation("Local")
408
+	var theStartTime int64
409
+	if len(start_time) > 0 {
410
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
411
+		if err != nil {
412
+			utils.ErrorLog(err.Error())
413
+		}
414
+		theStartTime = theTime.Unix()
415
+	}
242 416
 
417
+	drug_id, _ := this.GetInt64("drug_id")
418
+
419
+	orgId := this.GetAdminUserInfo().CurrentOrgId
420
+	//获取血透医嘱
421
+	advicelist, _ := service.GetUseredBloodAdviceList(theStartTime, drug_id, orgId)
422
+
423
+	//获取医保医嘱
424
+	hisAdviceList, err := service.GetUseredHisAdviceList(theStartTime, drug_id, orgId)
425
+
426
+	patient, _ := service.GetAllPatientListSix(orgId)
427
+	if err == nil {
428
+		this.ServeSuccessJSON(map[string]interface{}{
429
+			"advicelist":    advicelist,
430
+			"hisAdviceList": hisAdviceList,
431
+			"patient":       patient,
432
+		})
433
+	} else {
434
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
435
+	}
436
+}
437
+
438
+func (this *PharmacyApiController) GetReturnPharmacyBaseDrug() {
439
+
440
+	bloodStr := this.GetString("bloodStr")
441
+
442
+	hisStr := this.GetString("hisStr")
443
+
444
+	if len(bloodStr) == 0 {
445
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
446
+		return
447
+	}
448
+
449
+	idArray := strings.Split(bloodStr, ",")
450
+
451
+	if len(hisStr) == 0 {
452
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
453
+		return
454
+	}
455
+
456
+	idArrayOne := strings.Split(hisStr, ",")
457
+
458
+	fmt.Println("idArray23332233223", idArray)
459
+	fmt.Println("idArrayOne23332233223", idArrayOne)
460
+
461
+	orgId := this.GetAdminUserInfo().CurrentOrgId
462
+	service.UpdateReturnPharmacyAdviceBaseDrug(idArray, orgId)
463
+	service.UpdateReturnPharmacyHisAdviceBaseDrug(idArray, orgId)
243 464
 }

+ 25 - 1
controllers/drug_stock_api_contorller.go View File

@@ -71,6 +71,8 @@ func DrugStockManagerApiRegistRouters() {
71 71
 	beego.Router("/api/drug/getdrugwarehouseinfoprint", &StockDrugApiController{}, "get:GetDrugWarehouseInfoPrint")
72 72
 	beego.Router("/api/drug/getdrugoutorderprint", &StockDrugApiController{}, "get:GetDrugOutOrderPrint")
73 73
 
74
+	beego.Router("/api/drugstock/config/list", &StockDrugApiController{}, "get:GetConfigList")
75
+
74 76
 }
75 77
 
76 78
 func (c *StockDrugApiController) CreateDrugWarehouse() {
@@ -986,7 +988,10 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
986 988
 						fmt.Println(parseDateErr)
987 989
 					}
988 990
 				}
989
-				errs = service.UpDateDrugWarehousingInfoSix(item.ID, warehouseinfo)
991
+				if item.MaxUnit == warehouseInfo.MaxUnit {
992
+					errs = service.UpDateDrugWarehousingInfoSix(item.ID, warehouseinfo)
993
+				}
994
+
990 995
 				//查询默认仓库
991 996
 				houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
992 997
 				//查询默认仓库剩余多少库存
@@ -3865,3 +3870,22 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3865 3870
 	}
3866 3871
 
3867 3872
 }
3873
+
3874
+func (c *StockDrugApiController) GetConfigList() {
3875
+	adminUserInfo := c.GetAdminUserInfo()
3876
+	manufacturer, _ := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
3877
+	dealer, _ := service.FindAllDealer(adminUserInfo.CurrentOrgId)
3878
+	stockIns, _ := service.FindStockInNumber(adminUserInfo.CurrentOrgId)
3879
+	list, _ := service.GetAllStoreHouseListThree(adminUserInfo.CurrentOrgId)
3880
+	configlist, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
3881
+	appId := c.GetAdminUserInfo().CurrentAppId
3882
+	doctorList, _ := service.GetAllDoctorListSix(adminUserInfo.CurrentOrgId, appId)
3883
+	c.ServeSuccessJSON(map[string]interface{}{
3884
+		"manufacturer": manufacturer,
3885
+		"dealer":       dealer,
3886
+		"numbers":      stockIns,
3887
+		"list":         list,
3888
+		"configlist":   configlist,
3889
+		"doctorList":   doctorList,
3890
+	})
3891
+}

+ 3 - 2
controllers/manager_center_api_controller.go View File

@@ -2285,8 +2285,9 @@ func (c *ManagerCenterApiController) GetAllDrugList() {
2285 2285
 func (c *ManagerCenterApiController) GetSearchDrugList() {
2286 2286
 	keyword := c.GetString("keyword")
2287 2287
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2288
-	config, _ := service.GetAllStoreHouseConfig(orgId)
2289
-	list, err := service.GetSearchDrugListSix(keyword, orgId, config.DrugStorehouseOut)
2288
+	storehouse_id, _ := c.GetInt64("storehouse_id")
2289
+	list, err := service.GetSearchDrugListSix(keyword, orgId, storehouse_id)
2290
+
2290 2291
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2291 2292
 	dealerList, _ := service.GetAllDealerList(orgId)
2292 2293
 	if err == nil {

+ 55 - 122
controllers/stock_in_api_controller.go View File

@@ -4382,36 +4382,36 @@ func (this *StockManagerApiController) AddDrugInformation() {
4382 4382
 		drug.Dealer = dealer_id
4383 4383
 
4384 4384
 		delivery_way := goodNameM["delivery_way"].(string)
4385
-		if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4386
-			err_log := models.ExportErrLog{
4387
-				LogType:    4,
4388
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4389
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4390
-				Status:     1,
4391
-				CreateTime: time.Now().Unix(),
4392
-				UpdateTime: time.Now().Unix(),
4393
-				ExportTime: time.Now().Unix(),
4394
-			}
4395
-			service.CreateExportErrLog(&err_log)
4396
-			continue
4397
-		}
4385
+		//if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4386
+		//	err_log := models.ExportErrLog{
4387
+		//		LogType:    4,
4388
+		//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4389
+		//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4390
+		//		Status:     1,
4391
+		//		CreateTime: time.Now().Unix(),
4392
+		//		UpdateTime: time.Now().Unix(),
4393
+		//		ExportTime: time.Now().Unix(),
4394
+		//	}
4395
+		//	service.CreateExportErrLog(&err_log)
4396
+		//	continue
4397
+		//}
4398 4398
 
4399 4399
 		drug.DeliveryWay = delivery_way
4400 4400
 
4401 4401
 		execution_frequency := goodNameM["execution_frequency"].(string)
4402
-		if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4403
-			err_log := models.ExportErrLog{
4404
-				LogType:    4,
4405
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4406
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
4407
-				Status:     1,
4408
-				CreateTime: time.Now().Unix(),
4409
-				UpdateTime: time.Now().Unix(),
4410
-				ExportTime: time.Now().Unix(),
4411
-			}
4412
-			service.CreateExportErrLog(&err_log)
4413
-			continue
4414
-		}
4402
+		//if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4403
+		//	err_log := models.ExportErrLog{
4404
+		//		LogType:    4,
4405
+		//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4406
+		//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
4407
+		//		Status:     1,
4408
+		//		CreateTime: time.Now().Unix(),
4409
+		//		UpdateTime: time.Now().Unix(),
4410
+		//		ExportTime: time.Now().Unix(),
4411
+		//	}
4412
+		//	service.CreateExportErrLog(&err_log)
4413
+		//	continue
4414
+		//}
4415 4415
 
4416 4416
 		drug.ExecutionFrequency = execution_frequency
4417 4417
 
@@ -4419,74 +4419,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
4419 4419
 
4420 4420
 		drug.LmtUsedFlag = lmt_used_flags
4421 4421
 
4422
-		//medical_insurance_level := goodNameM["medical_insurance_level"].(string)
4423
-		//var medical_insurance_level_id int64
4424
-		//if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
4425
-		//  err_log := models.ExportErrLog{
4426
-		//    LogType:    4,
4427
-		//    UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4428
-		//    ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的医保等级不能为空",
4429
-		//    Status:     1,
4430
-		//    CreateTime: time.Now().Unix(),
4431
-		//    UpdateTime: time.Now().Unix(),
4432
-		//    ExportTime: time.Now().Unix(),
4433
-		//  }
4434
-		//  service.CreateExportErrLog(&err_log)
4435
-		//  continue
4436
-		//}
4437
-		//var medicalInsuranceName = "医保等级"
4438
-		//medicalInsuranceConfig, _ := service.GetDrugDataConfig(0, medicalInsuranceName)
4439
-		//if len(medical_insurance_level) != 0 {
4440
-		//  _, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
4441
-		//  if errcodemedical == gorm.ErrRecordNotFound {
4442
-		//    medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
4443
-		//    dataconfig := models.DictDataconfig{
4444
-		//      ParentId:       medicalInsuranceConfig.ID,
4445
-		//      Module:         "system",
4446
-		//      OrgId:          orgId,
4447
-		//      Name:           medical_insurance_level,
4448
-		//      FieldName:      "",
4449
-		//      Value:          medConfig.Value + 1,
4450
-		//      CreatedTime:    "",
4451
-		//      UpdatedTime:    "",
4452
-		//      CreateUserId:   adminUser.AdminUser.Id,
4453
-		//      Status:         1,
4454
-		//      Remark:         "",
4455
-		//      DeleteIdSystem: 0,
4456
-		//      Title:          "",
4457
-		//      Content:        "",
4458
-		//      Order:          0,
4459
-		//      Code:           "",
4460
-		//    }
4461
-		//    service.CreatedDicConfig(&dataconfig)
4462
-		//  }
4463
-		//}
4464
-
4465
-		//medicalInsuranceList, _ := service.GetParentDataConfig(medicalInsuranceConfig.ID, orgId)
4466
-		//for _, it := range medicalInsuranceList {
4467
-		//  if medical_insurance_level == it.Name {
4468
-		//    medical_insurance_level_id = int64(it.Value)
4469
-		//  }
4470
-		//}
4471
-		//drug.MedicalInsuranceLevel = medical_insurance_level_id
4472
-
4473
-		//unit_matrixing := goodNameM["unit_matrixing"].(string)
4474
-		//if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
4475
-		//  err_log := models.ExportErrLog{
4476
-		//    LogType:    4,
4477
-		//    UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4478
-		//    ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
4479
-		//    Status:     1,
4480
-		//    CreateTime: time.Now().Unix(),
4481
-		//    UpdateTime: time.Now().Unix(),
4482
-		//    ExportTime: time.Now().Unix(),
4483
-		//  }
4484
-		//  service.CreateExportErrLog(&err_log)
4485
-		//  continue
4486
-		//}
4487
-		//
4488
-		//drug.UnitMatrixing = unit_matrixing
4489
-
4490 4422
 		dataConfig, _ := service.GetDataConfigIsExist(0, units)
4491 4423
 		if len(drugDoseUnit) != 0 {
4492 4424
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
@@ -5045,36 +4977,36 @@ func (this *StockManagerApiController) AddDrugInformation() {
5045 4977
 			drug.Dealer = dealer_id
5046 4978
 
5047 4979
 			delivery_way := goodNameM["delivery_way"].(string)
5048
-			if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
5049
-				err_log := models.ExportErrLog{
5050
-					LogType:    4,
5051
-					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5052
-					ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
5053
-					Status:     1,
5054
-					CreateTime: time.Now().Unix(),
5055
-					UpdateTime: time.Now().Unix(),
5056
-					ExportTime: time.Now().Unix(),
5057
-				}
5058
-				service.CreateExportErrLog(&err_log)
5059
-				continue
5060
-			}
4980
+			//if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
4981
+			//	err_log := models.ExportErrLog{
4982
+			//		LogType:    4,
4983
+			//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4984
+			//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4985
+			//		Status:     1,
4986
+			//		CreateTime: time.Now().Unix(),
4987
+			//		UpdateTime: time.Now().Unix(),
4988
+			//		ExportTime: time.Now().Unix(),
4989
+			//	}
4990
+			//	service.CreateExportErrLog(&err_log)
4991
+			//	continue
4992
+			//}
5061 4993
 
5062 4994
 			drug.DeliveryWay = delivery_way
5063 4995
 
5064 4996
 			execution_frequency := goodNameM["execution_frequency"].(string)
5065
-			if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
5066
-				err_log := models.ExportErrLog{
5067
-					LogType:    4,
5068
-					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5069
-					ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
5070
-					Status:     1,
5071
-					CreateTime: time.Now().Unix(),
5072
-					UpdateTime: time.Now().Unix(),
5073
-					ExportTime: time.Now().Unix(),
5074
-				}
5075
-				service.CreateExportErrLog(&err_log)
5076
-				continue
5077
-			}
4997
+			//if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
4998
+			//	err_log := models.ExportErrLog{
4999
+			//		LogType:    4,
5000
+			//		UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
5001
+			//		ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
5002
+			//		Status:     1,
5003
+			//		CreateTime: time.Now().Unix(),
5004
+			//		UpdateTime: time.Now().Unix(),
5005
+			//		ExportTime: time.Now().Unix(),
5006
+			//	}
5007
+			//	service.CreateExportErrLog(&err_log)
5008
+			//	continue
5009
+			//}
5078 5010
 
5079 5011
 			drug.ExecutionFrequency = execution_frequency
5080 5012
 
@@ -5379,6 +5311,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
5379 5311
 					DoseUnit:                    item.DoseUnit,
5380 5312
 					Dose:                        item.Dose,
5381 5313
 					MinNumber:                   item.MinNumber,
5314
+					IsUse:                       2,
5382 5315
 				}
5383 5316
 
5384 5317
 				//查询同种药品同种规格是否存在
@@ -5510,8 +5443,8 @@ func (this *StockManagerApiController) PostSearchGoodList() {
5510 5443
 	adminUserInfo := this.GetAdminUserInfo()
5511 5444
 	orgId := adminUserInfo.CurrentOrgId
5512 5445
 
5513
-	config, _ := service.GetAllStoreHouseConfig(orgId)
5514
-	list, _ := service.GetSearchGoodListSix(keyword, orgId, config.StorehouseOutInfo)
5446
+	storehouse_id, _ := this.GetInt64("storehouse_id")
5447
+	list, _ := service.GetSearchGoodListSix(keyword, orgId, storehouse_id)
5515 5448
 
5516 5449
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5517 5450
 	dealerList, _ := service.GetAllDealerList(orgId)

+ 21 - 0
models/drug_pharmacy_management_models.go View File

@@ -213,3 +213,24 @@ type PharmacyConfig struct {
213 213
 func (PharmacyConfig) TableName() string {
214 214
 	return "xt_pharmacy_config"
215 215
 }
216
+
217
+type Pharmacy struct {
218
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
219
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
220
+	PatientId         int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
221
+	HisPrescriptionId int64  `gorm:"column:his_prescription_id" json:"his_prescription_id" form:"his_prescription_id"`
222
+	XtAdviceId        int64  `gorm:"column:xt_advice_id" json:"xt_advice_id" form:"xt_advice_id"`
223
+	HisOrXt           int64  `gorm:"column:his_or_xt" json:"his_or_xt" form:"his_or_xt"`
224
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
225
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
226
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
227
+	HisAdviceId       int64  `gorm:"column:his_advice_id" json:"his_advice_id" form:"his_advice_id"`
228
+	DrugId            int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
229
+	RecordDate        int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
230
+	OrdreNumber       string `gorm:"column:ordre_number" json:"ordre_number" form:"ordre_number"`
231
+	Creater           int64  `gorm:"column:creater" json:"creater" form:"creater"`
232
+}
233
+
234
+func (Pharmacy) TableName() string {
235
+	return "xt_pharmacy"
236
+}

+ 2 - 0
models/drug_stock.go View File

@@ -167,6 +167,7 @@ type DrugWarehouseOutInfo struct {
167 167
 	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
168 168
 	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
169 169
 	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
170
+	PharmacyId              int64   `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
170 171
 }
171 172
 
172 173
 func (DrugWarehouseOutInfo) TableName() string {
@@ -414,6 +415,7 @@ type DrugFlow struct {
414 415
 	AdminUserId               int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
415 416
 	LastPrice                 float64              `gorm:"column:last_price" json:"last_price" form:"last_price"`
416 417
 	StockCount                string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
418
+	PharmacyId                int64                `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
417 419
 }
418 420
 
419 421
 func (DrugFlow) TableName() string {

File diff suppressed because it is too large
+ 1530 - 0
service/drug_pharmacy_management_service.go