|
@@ -152,6 +152,12 @@ func SelfDrugRouters() {
|
152
|
152
|
beego.Router("/api/drug/getselfdrugbatchnumber", &SelfDrugApiController{}, "Get:GetSelfDrugBatchNumber")
|
153
|
153
|
|
154
|
154
|
beego.Router("/api/drug/postsetfdrugwarehouseout", &SelfDrugApiController{}, "Post:PostSelfDrugWarehouseOut")
|
|
155
|
+
|
|
156
|
+ beego.Router("/api/drug/getallselfdrugwarehouseoutlist", &SelfDrugApiController{}, "Get:GetAllSelfDrugWarehouseOutList")
|
|
157
|
+
|
|
158
|
+ beego.Router("/api/drug/deleteselfwarehouseout", &SelfDrugApiController{}, "Get:DeleteSelfWarehouseOut")
|
|
159
|
+
|
|
160
|
+ beego.Router("/api/drug/getselfdrugwarehouseoutbyid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseOutById")
|
155
|
161
|
}
|
156
|
162
|
|
157
|
163
|
func (this *SelfDrugApiController) GetCurrentPatient() {
|
|
@@ -5005,7 +5011,7 @@ func (c *SelfDrugApiController) DeleteSelfDrugWarehouse() {
|
5005
|
5011
|
|
5006
|
5012
|
func (c *SelfDrugApiController) TocheckSelfWarehouseingInfo() {
|
5007
|
5013
|
|
5008
|
|
- id, _ := c.GetInt64("id")
|
|
5014
|
+ id, _ := c.GetInt64("warehousing_id")
|
5009
|
5015
|
patient_id, _ := c.GetInt64("patient_id")
|
5010
|
5016
|
orgId := c.GetAdminUserInfo().CurrentOrgId
|
5011
|
5017
|
info, _ := service.GetSelfWarehouseInfoByWarehouseInfo(id, patient_id, orgId)
|
|
@@ -5153,8 +5159,6 @@ func (c *SelfDrugApiController) GetSelfDrugBatchNumber() {
|
5153
|
5159
|
|
5154
|
5160
|
func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5155
|
5161
|
|
5156
|
|
- fmt.Println("开启===========================================================")
|
5157
|
|
-
|
5158
|
5162
|
db := service.XTWriteDB()
|
5159
|
5163
|
tx := db.Begin()
|
5160
|
5164
|
defer func() {
|
|
@@ -5166,11 +5170,14 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5166
|
5170
|
}()
|
5167
|
5171
|
patient_id, _ := c.GetInt64("patient_id")
|
5168
|
5172
|
warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
|
|
5173
|
+
|
5169
|
5174
|
ctime := time.Now().Unix()
|
5170
|
5175
|
adminUserInfo := c.GetAdminUserInfo()
|
5171
|
5176
|
|
5172
|
5177
|
warehousing_out_time := c.GetString("warehousing_out_time")
|
|
5178
|
+
|
5173
|
5179
|
warehousingOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_out_time)
|
|
5180
|
+
|
5174
|
5181
|
if parseDateErr != nil {
|
5175
|
5182
|
c.ErrorLog("日期(%v)解析错误:%v", warehousingOutDate, parseDateErr)
|
5176
|
5183
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -5186,7 +5193,7 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5186
|
5193
|
number = number + total
|
5187
|
5194
|
warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
5188
|
5195
|
operation_time := time.Now().Unix()
|
5189
|
|
- fmt.Println("operation_time=================================", operation_time)
|
|
5196
|
+
|
5190
|
5197
|
creater := adminUserInfo.AdminUser.Id
|
5191
|
5198
|
//创建一个出库单
|
5192
|
5199
|
warehouseOut := models.XtSelfDrugWarehouseOut{
|
|
@@ -5240,24 +5247,14 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5240
|
5247
|
return
|
5241
|
5248
|
}
|
5242
|
5249
|
|
5243
|
|
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
|
5244
|
|
- utils.ErrorLog("price")
|
5245
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
5246
|
|
- return
|
5247
|
|
- }
|
5248
|
|
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
|
5249
|
|
-
|
5250
|
5250
|
count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
5251
|
5251
|
|
5252
|
|
- total := float64(count) * price
|
5253
|
|
- retail_price_total := float64(count) * price
|
5254
|
5252
|
remark := items["remark"].(string)
|
5255
|
5253
|
max_unit := items["max_unit"].(string)
|
5256
|
5254
|
dealer := int64(items["dealer"].(float64))
|
5257
|
5255
|
|
5258
|
5256
|
manufacturer := int64(items["manufacturer"].(float64))
|
5259
|
5257
|
|
5260
|
|
- number := items["number"].(string)
|
5261
|
5258
|
batch_number := items["batch_number"].(string)
|
5262
|
5259
|
|
5263
|
5260
|
warehouse_info_id := int64(items["warehouse_info_id"].(float64))
|
|
@@ -5290,15 +5287,6 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5290
|
5287
|
}
|
5291
|
5288
|
}
|
5292
|
5289
|
|
5293
|
|
- admin_user_id := int64(items["admin_user_id"].(float64))
|
5294
|
|
-
|
5295
|
|
- //if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
|
5296
|
|
- // utils.ErrorLog("last_price")
|
5297
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
5298
|
|
- // return
|
5299
|
|
- //}
|
5300
|
|
- //last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
|
5301
|
|
-
|
5302
|
5290
|
stock_count, _ := items["stock_count"].(string)
|
5303
|
5291
|
|
5304
|
5292
|
patient_id := int64(items["patient_id"].(float64))
|
|
@@ -5313,8 +5301,8 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5313
|
5301
|
WarehouseOutId: lastWarehouseOut.ID,
|
5314
|
5302
|
DrugId: drug_id,
|
5315
|
5303
|
Count: count,
|
5316
|
|
- Price: price,
|
5317
|
|
- TotalPrice: total,
|
|
5304
|
+ Price: 0,
|
|
5305
|
+ TotalPrice: 0,
|
5318
|
5306
|
Status: 1,
|
5319
|
5307
|
Ctime: warehousingOutDate.Unix(),
|
5320
|
5308
|
Mtime: ctime,
|
|
@@ -5323,16 +5311,16 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5323
|
5311
|
Type: 0,
|
5324
|
5312
|
Manufacturer: manufacturer,
|
5325
|
5313
|
Dealer: dealer,
|
5326
|
|
- RetailPrice: price,
|
5327
|
|
- RetailTotalPrice: retail_price_total,
|
|
5314
|
+ RetailPrice: 0,
|
|
5315
|
+ RetailTotalPrice: 0,
|
5328
|
5316
|
CountUnit: max_unit,
|
5329
|
5317
|
ExpiryDate: expiryDates,
|
5330
|
5318
|
ProductDate: productDates,
|
5331
|
|
- Number: number,
|
|
5319
|
+ Number: "",
|
5332
|
5320
|
BatchNumber: batch_number,
|
5333
|
5321
|
IsSys: 0,
|
5334
|
5322
|
WarehouseInfoId: warehouse_info_id,
|
5335
|
|
- AdminUserId: admin_user_id,
|
|
5323
|
+ AdminUserId: 0,
|
5336
|
5324
|
StockCount: stock_count,
|
5337
|
5325
|
IsCheck: 2,
|
5338
|
5326
|
SysRecordTime: warehousingOutDate.Unix(),
|
|
@@ -5361,7 +5349,7 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5361
|
5349
|
|
5362
|
5350
|
manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
5363
|
5351
|
|
5364
|
|
- warehousingOutInfoList, _ := service.GetDrugWarehouseOutListById(lastWarehouseOut.ID, adminUserInfo.CurrentOrgId)
|
|
5352
|
+ warehousingOutInfoList, _ := service.GetSelfDrugWarehouseOutListById(lastWarehouseOut.ID, adminUserInfo.CurrentOrgId, tx)
|
5365
|
5353
|
|
5366
|
5354
|
var drugType = "药品类型"
|
5367
|
5355
|
drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
|
|
@@ -5382,3 +5370,81 @@ func (c *SelfDrugApiController) PostSelfDrugWarehouseOut() {
|
5382
|
5370
|
})
|
5383
|
5371
|
return
|
5384
|
5372
|
}
|
|
5373
|
+
|
|
5374
|
+func (c *SelfDrugApiController) GetAllSelfDrugWarehouseOutList() {
|
|
5375
|
+
|
|
5376
|
+ keyword := c.GetString("keyword")
|
|
5377
|
+
|
|
5378
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
5379
|
+
|
|
5380
|
+ start_time := c.GetString("start_time")
|
|
5381
|
+
|
|
5382
|
+ end_time := c.GetString("end_time")
|
|
5383
|
+
|
|
5384
|
+ timeLayout := "2006-01-02"
|
|
5385
|
+ loc, _ := time.LoadLocation("Local")
|
|
5386
|
+ var startTime int64
|
|
5387
|
+ if len(start_time) > 0 {
|
|
5388
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
5389
|
+ if err != nil {
|
|
5390
|
+ fmt.Println(err)
|
|
5391
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5392
|
+ return
|
|
5393
|
+ }
|
|
5394
|
+ startTime = theTime.Unix()
|
|
5395
|
+ }
|
|
5396
|
+ var endTime int64
|
|
5397
|
+ if len(end_time) > 0 {
|
|
5398
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
5399
|
+ if err != nil {
|
|
5400
|
+ utils.ErrorLog(err.Error())
|
|
5401
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5402
|
+ return
|
|
5403
|
+ }
|
|
5404
|
+ endTime = theTime.Unix()
|
|
5405
|
+ }
|
|
5406
|
+ orgId := c.GetAdminUserInfo().CurrentOrgId
|
|
5407
|
+ baseList, _ := service.GetAllBaseDrugListByKeyWord(keyword, orgId)
|
|
5408
|
+ var ids []int64
|
|
5409
|
+ for _, item := range baseList {
|
|
5410
|
+ ids = append(ids, item.ID)
|
|
5411
|
+ }
|
|
5412
|
+ outInfo, _ := service.GetAllSelfDrugWarehouseOutList(ids, patient_id, startTime, endTime, orgId)
|
|
5413
|
+
|
|
5414
|
+ manufacturerList, _ := service.GetAllManufacturerList(orgId)
|
|
5415
|
+ dealerList, _ := service.GetAllDealerList(orgId)
|
|
5416
|
+ var drugType = "药品类型"
|
|
5417
|
+ drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
|
|
5418
|
+ drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
|
|
5419
|
+
|
|
5420
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
5421
|
+ "outInfo": outInfo,
|
|
5422
|
+ "manufacturerList": manufacturerList,
|
|
5423
|
+ "dealerList": dealerList,
|
|
5424
|
+ "drugTypeList": drugTypeList,
|
|
5425
|
+ })
|
|
5426
|
+}
|
|
5427
|
+
|
|
5428
|
+func (c *SelfDrugApiController) DeleteSelfWarehouseOut() {
|
|
5429
|
+
|
|
5430
|
+ id, _ := c.GetInt64("id")
|
|
5431
|
+
|
|
5432
|
+ service.DeleteSelfWarehouseOut(id)
|
|
5433
|
+
|
|
5434
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
5435
|
+ "msg": "ok",
|
|
5436
|
+ })
|
|
5437
|
+
|
|
5438
|
+ return
|
|
5439
|
+}
|
|
5440
|
+
|
|
5441
|
+func (c *SelfDrugApiController) GetSelfDrugWarehouseOutById() {
|
|
5442
|
+
|
|
5443
|
+ id, _ := c.GetInt64("id")
|
|
5444
|
+
|
|
5445
|
+ outInfo, _ := service.GetSelfDrugWarehouseOutById(id)
|
|
5446
|
+
|
|
5447
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
5448
|
+ "outInfo": outInfo,
|
|
5449
|
+ })
|
|
5450
|
+}
|