|
@@ -77,6 +77,7 @@ func SelfDrugRouters() {
|
77
|
77
|
beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Delete:DeleteDrugInventory")
|
78
|
78
|
beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
|
79
|
79
|
beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
|
|
80
|
+ beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
|
80
|
81
|
}
|
81
|
82
|
|
82
|
83
|
func (this *SelfDrugApiController) GetCurrentPatient() {
|
|
@@ -1196,13 +1197,19 @@ func (this *SelfDrugApiController) SaveCheckDrugPrice() {
|
1196
|
1197
|
}
|
1197
|
1198
|
err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
|
1198
|
1199
|
fmt.Println("err", err)
|
|
1200
|
+ list, _ := service.GetDrugAdjuestPrice(ids)
|
|
1201
|
+ for _, item := range list {
|
|
1202
|
+ drug := models.BaseDrugLib{
|
|
1203
|
+ RetailPrice: item.RetailPrice,
|
|
1204
|
+ }
|
|
1205
|
+ service.UpdateBaseDrugOne(drug, item.DrugId)
|
|
1206
|
+ }
|
1199
|
1207
|
this.ServeSuccessJSON(map[string]interface{}{
|
1200
|
1208
|
"adjustPrice": adjustPrice,
|
1201
|
1209
|
})
|
1202
|
1210
|
}
|
1203
|
1211
|
|
1204
|
1212
|
func (this *SelfDrugApiController) SaveDrugDamage() {
|
1205
|
|
- fmt.Println("999999999999999999999")
|
1206
|
1213
|
timeLayout := "2006-01-02"
|
1207
|
1214
|
loc, _ := time.LoadLocation("Local")
|
1208
|
1215
|
dataBody := make(map[string]interface{}, 0)
|
|
@@ -1243,12 +1250,12 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
|
1243
|
1250
|
}
|
1244
|
1251
|
number := items["number"].(string)
|
1245
|
1252
|
|
1246
|
|
- //if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
|
1247
|
|
- // utils.ErrorLog("dealer")
|
1248
|
|
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1249
|
|
- // return
|
1250
|
|
- //}
|
1251
|
|
- //dealer := items["dealer"].(string)
|
|
1253
|
+ if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
|
|
1254
|
+ utils.ErrorLog("dealer")
|
|
1255
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1256
|
+ return
|
|
1257
|
+ }
|
|
1258
|
+ dealer := items["dealer"].(string)
|
1252
|
1259
|
|
1253
|
1260
|
if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
|
1254
|
1261
|
utils.ErrorLog("manufacturer")
|
|
@@ -1257,12 +1264,12 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
|
1257
|
1264
|
}
|
1258
|
1265
|
manufacturer := items["manufacturer"].(string)
|
1259
|
1266
|
|
1260
|
|
- //if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
1261
|
|
- // utils.ErrorLog("specification_name")
|
1262
|
|
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1263
|
|
- // return
|
1264
|
|
- //}
|
1265
|
|
- //specification_name := items["specification_name"].(string)
|
|
1267
|
+ if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
|
1268
|
+ utils.ErrorLog("specification_name")
|
|
1269
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1270
|
+ return
|
|
1271
|
+ }
|
|
1272
|
+ specification_name := items["specification_name"].(string)
|
1266
|
1273
|
|
1267
|
1274
|
if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
|
1268
|
1275
|
utils.ErrorLog("remark")
|
|
@@ -1322,19 +1329,48 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
|
1322
|
1329
|
}
|
1323
|
1330
|
startTime = theTime.Unix()
|
1324
|
1331
|
}
|
|
1332
|
+
|
|
1333
|
+ if items["warehousing_info_id"] == nil || reflect.TypeOf(items["warehousing_info_id"]).String() != "float64" {
|
|
1334
|
+ utils.ErrorLog("warehousing_info_id")
|
|
1335
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1336
|
+ return
|
|
1337
|
+ }
|
|
1338
|
+ warehousing_info_id := int64(items["warehousing_info_id"].(float64))
|
|
1339
|
+
|
|
1340
|
+ if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
|
|
1341
|
+ utils.ErrorLog("expiry_date")
|
|
1342
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1343
|
+ return
|
|
1344
|
+ }
|
|
1345
|
+ expiry_date := int64(items["expiry_date"].(float64))
|
|
1346
|
+
|
|
1347
|
+ if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
|
|
1348
|
+ utils.ErrorLog("product_date")
|
|
1349
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1350
|
+ return
|
|
1351
|
+ }
|
|
1352
|
+ product_date := int64(items["product_date"].(float64))
|
|
1353
|
+
|
|
1354
|
+ if items["drug_origin_place"] == nil || reflect.TypeOf(items["drug_origin_place"]).String() != "string" {
|
|
1355
|
+ utils.ErrorLog("drug_origin_place")
|
|
1356
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1357
|
+ return
|
|
1358
|
+ }
|
|
1359
|
+ drug_origin_place := items["drug_origin_place"].(string)
|
|
1360
|
+
|
1325
|
1361
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
1326
|
1362
|
Creater := this.GetAdminUserInfo().AdminUser.Id
|
1327
|
1363
|
|
1328
|
1364
|
drugDamage := models.XtDrugDamage{
|
1329
|
1365
|
DrugName: drug_name,
|
1330
|
|
- SpecificationName: "",
|
|
1366
|
+ SpecificationName: specification_name,
|
1331
|
1367
|
WarehousingUnit: warehousing_unit,
|
1332
|
1368
|
Count: count,
|
1333
|
1369
|
LastPrice: last_price,
|
1334
|
1370
|
RetailPrice: retail_price,
|
1335
|
1371
|
NewPrice: new_price,
|
1336
|
1372
|
Manufacturer: manufacturer,
|
1337
|
|
- Dealer: "",
|
|
1373
|
+ Dealer: dealer,
|
1338
|
1374
|
Remark: remark,
|
1339
|
1375
|
DrugId: drug_id,
|
1340
|
1376
|
UserOrgId: orgId,
|
|
@@ -1348,6 +1384,10 @@ func (this *SelfDrugApiController) SaveDrugDamage() {
|
1348
|
1384
|
Checker: 0,
|
1349
|
1385
|
CheckerStatus: 2,
|
1350
|
1386
|
CheckerTime: 0,
|
|
1387
|
+ ExpiryDate: expiry_date,
|
|
1388
|
+ ProductDate: product_date,
|
|
1389
|
+ WarehousingInfoId: warehousing_info_id,
|
|
1390
|
+ DrugOriginPlace: drug_origin_place,
|
1351
|
1391
|
}
|
1352
|
1392
|
|
1353
|
1393
|
err := service.CreateDrugDamage(drugDamage)
|
|
@@ -1435,6 +1475,98 @@ func (this *SelfDrugApiController) SaveDrugDamagePrice() {
|
1435
|
1475
|
}
|
1436
|
1476
|
err = service.UpdateDrugDamage(ids, damage)
|
1437
|
1477
|
fmt.Println(err)
|
|
1478
|
+ list, _ := service.GetDrugDamage(ids)
|
|
1479
|
+ ctime := time.Now().Unix()
|
|
1480
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
1481
|
+ manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
|
1482
|
+ dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
|
|
1483
|
+ var manufacturer_id int64
|
|
1484
|
+ var dealer_id int64
|
|
1485
|
+ for _, item := range list {
|
|
1486
|
+ for _, it := range manufacturerList {
|
|
1487
|
+ if item.Manufacturer == it.ManufacturerName {
|
|
1488
|
+ manufacturer_id = it.ID
|
|
1489
|
+ }
|
|
1490
|
+ }
|
|
1491
|
+
|
|
1492
|
+ for _, its := range dealerList {
|
|
1493
|
+ if its.DealerName == item.Dealer {
|
|
1494
|
+ dealer_id = its.ID
|
|
1495
|
+ }
|
|
1496
|
+ }
|
|
1497
|
+
|
|
1498
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
1499
|
+ timeArr := strings.Split(timeStr, "-")
|
|
1500
|
+ total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1501
|
+
|
|
1502
|
+ total = total + 1
|
|
1503
|
+ warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1504
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1505
|
+ number = number + total
|
|
1506
|
+ warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
|
1507
|
+ operation_time := time.Now().Unix()
|
|
1508
|
+ creater := adminUserInfo.AdminUser.Id
|
|
1509
|
+
|
|
1510
|
+ warehouseOut := models.DrugWarehouseOut{
|
|
1511
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
1512
|
+ OperationTime: operation_time,
|
|
1513
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1514
|
+ Creater: creater,
|
|
1515
|
+ Ctime: ctime,
|
|
1516
|
+ Status: 1,
|
|
1517
|
+ WarehouseOutTime: time.Now().Unix(),
|
|
1518
|
+ Type: 1,
|
|
1519
|
+ }
|
|
1520
|
+
|
|
1521
|
+ warehouseOutInfo := models.XtDrugWarehouseOutInfo{
|
|
1522
|
+ WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
1523
|
+ WarehouseOutId: warehouseOut.ID,
|
|
1524
|
+ DrugId: item.DrugId,
|
|
1525
|
+ Count: item.Count,
|
|
1526
|
+ Price: item.RetailPrice,
|
|
1527
|
+ Status: 1,
|
|
1528
|
+ Ctime: ctime,
|
|
1529
|
+ Remark: item.Remark,
|
|
1530
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1531
|
+ Type: 1,
|
|
1532
|
+ Manufacturer: manufacturer_id,
|
|
1533
|
+ Dealer: dealer_id,
|
|
1534
|
+ RetailPrice: item.RetailPrice,
|
|
1535
|
+ CountUnit: item.WarehousingUnit,
|
|
1536
|
+ ExpiryDate: item.ExpiryDate,
|
|
1537
|
+ ProductDate: item.ProductDate,
|
|
1538
|
+ Number: item.Number,
|
|
1539
|
+ BatchNumber: item.BatchNumber,
|
|
1540
|
+ IsSys: 0,
|
|
1541
|
+ WarehouseInfoId: item.WarehousingInfoId,
|
|
1542
|
+ }
|
|
1543
|
+
|
|
1544
|
+ drugflow := models.DrugFlow{
|
|
1545
|
+ WarehouseOutId: warehouseOut.ID,
|
|
1546
|
+ WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
1547
|
+ DrugId: item.DrugId,
|
|
1548
|
+ Number: item.Number,
|
|
1549
|
+ ProductDate: item.ProductDate,
|
|
1550
|
+ ExpireDate: item.ExpiryDate,
|
|
1551
|
+ Count: item.Count,
|
|
1552
|
+ Price: item.RetailPrice,
|
|
1553
|
+ Status: 1,
|
|
1554
|
+ Ctime: ctime,
|
|
1555
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
1556
|
+ Manufacturer: manufacturer_id,
|
|
1557
|
+ Dealer: dealer_id,
|
|
1558
|
+ BatchNumber: item.BatchNumber,
|
|
1559
|
+ MaxUnit: item.WarehousingUnit,
|
|
1560
|
+ ConsumableType: 5,
|
|
1561
|
+ IsEdit: 1,
|
|
1562
|
+ Creator: adminUserInfo.AdminUser.Id,
|
|
1563
|
+ IsSys: 0,
|
|
1564
|
+ }
|
|
1565
|
+ service.CreateWareHouseOutInfo(&warehouseOutInfo)
|
|
1566
|
+ service.AddSigleDrugWarehouseOut(&warehouseOut)
|
|
1567
|
+ service.CreateDrugFlowOne(drugflow)
|
|
1568
|
+
|
|
1569
|
+ }
|
1438
|
1570
|
this.ServeSuccessJSON(map[string]interface{}{
|
1439
|
1571
|
"damage": damage,
|
1440
|
1572
|
})
|
|
@@ -1576,7 +1708,7 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
|
1576
|
1708
|
for _, item := range tableData {
|
1577
|
1709
|
items := item.(map[string]interface{})
|
1578
|
1710
|
drug_name := items["drug_name"].(string)
|
1579
|
|
- fmt.Println("durg_nae232333223332232323323223232323", drug_name)
|
|
1711
|
+
|
1580
|
1712
|
if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
|
1581
|
1713
|
utils.ErrorLog("drug_name")
|
1582
|
1714
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -1700,14 +1832,20 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
|
1700
|
1832
|
|
1701
|
1833
|
numbers := items["number"].(string)
|
1702
|
1834
|
|
1703
|
|
- if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
|
1704
|
|
- utils.ErrorLog("batch_number")
|
|
1835
|
+ //if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
|
|
1836
|
+ // utils.ErrorLog("batch_number")
|
|
1837
|
+ // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1838
|
+ // return
|
|
1839
|
+ //}
|
|
1840
|
+ //
|
|
1841
|
+ //batch_number := items["batch_number"].(string)
|
|
1842
|
+
|
|
1843
|
+ if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
|
|
1844
|
+ utils.ErrorLog("warehouse_info_id")
|
1705
|
1845
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1706
|
1846
|
return
|
1707
|
1847
|
}
|
1708
|
|
-
|
1709
|
|
- batch_number := items["batch_number"].(string)
|
1710
|
|
-
|
|
1848
|
+ warehouse_info_id := int64(items["warehouse_info_id"].(float64))
|
1711
|
1849
|
inventory := models.XtDrugInventory{
|
1712
|
1850
|
|
1713
|
1851
|
DrugName: drug_name,
|
|
@@ -1735,7 +1873,8 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
|
1735
|
1873
|
ExpiryDate: expiry_date,
|
1736
|
1874
|
ProductDate: product_date,
|
1737
|
1875
|
Number: numbers,
|
1738
|
|
- BatchNumber: batch_number,
|
|
1876
|
+ //BatchNumber: batch_number,
|
|
1877
|
+ WarehouseInfoId: warehouse_info_id,
|
1739
|
1878
|
}
|
1740
|
1879
|
err = service.CreateDrugInventory(inventory)
|
1741
|
1880
|
fmt.Println(err)
|
|
@@ -1854,7 +1993,7 @@ func (this *SelfDrugApiController) ModifyInventory() {
|
1854
|
1993
|
manufacturer := this.GetString("manufacturer")
|
1855
|
1994
|
remark := this.GetString("remark")
|
1856
|
1995
|
warehousing_unit := this.GetString("warehousing_unit")
|
1857
|
|
- total, _ := this.GetInt64("total")
|
|
1996
|
+ total := this.GetString("total")
|
1858
|
1997
|
lastPrice := this.GetString("last_price")
|
1859
|
1998
|
last_price, _ := strconv.ParseFloat(lastPrice, 64)
|
1860
|
1999
|
count, _ := this.GetInt64("count")
|
|
@@ -1931,3 +2070,33 @@ func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
|
1931
|
2070
|
"doctorList": doctorList,
|
1932
|
2071
|
})
|
1933
|
2072
|
}
|
|
2073
|
+
|
|
2074
|
+func (this *SelfDrugApiController) SaveDrugProofInventory() {
|
|
2075
|
+
|
|
2076
|
+ id, _ := this.GetInt64("id")
|
|
2077
|
+ warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
|
|
2078
|
+ warehousing_unit := this.GetString("warehousing_unit")
|
|
2079
|
+ remark := this.GetString("remark")
|
|
2080
|
+ //total := this.GetString("total")
|
|
2081
|
+ prof_count, _ := this.GetInt64("prof_count")
|
|
2082
|
+
|
|
2083
|
+ inventory := models.XtDrugInventory{
|
|
2084
|
+ WarehouseInfoId: warehouse_info_id,
|
|
2085
|
+ ProofCount: prof_count,
|
|
2086
|
+ WarehousingUnit: warehousing_unit,
|
|
2087
|
+ Remark: remark,
|
|
2088
|
+ }
|
|
2089
|
+ err := service.UpdateDrugProofInventory(warehouse_info_id, &inventory)
|
|
2090
|
+ info := models.XtDrugWarehouseInfo{
|
|
2091
|
+ StockMaxNumber: prof_count,
|
|
2092
|
+ }
|
|
2093
|
+ service.UpdateDrugWarehouseInfoById(id, &info)
|
|
2094
|
+ if err != nil {
|
|
2095
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
|
|
2096
|
+ return
|
|
2097
|
+ }
|
|
2098
|
+
|
|
2099
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
2100
|
+ "inventory": inventory,
|
|
2101
|
+ })
|
|
2102
|
+}
|