|
@@ -129,7 +129,8 @@ func StockManagerApiRegistRouters() {
|
129
|
129
|
beego.Router("/api/stock/proofinventory", &StockManagerApiController{}, "Get:ProofInventory")
|
130
|
130
|
beego.Router("/api/stock/getwarehousetotal", &StockManagerApiController{}, "Get:GetWarehouseTotal")
|
131
|
131
|
beego.Router("/api/stock/getgoodinventorywarehouselist", &StockManagerApiController{}, "Get:GetGoodInventoryWarehouseList")
|
132
|
|
-
|
|
132
|
+ beego.Router("/api/stock/savestockinentorylist", &StockManagerApiController{}, "Post:SaveStockInventoryList")
|
|
133
|
+ beego.Router("/api/sotck/getdamagedetailbygoodid", &StockManagerApiController{}, "Get:GetDamageDetailByGoodId")
|
133
|
134
|
}
|
134
|
135
|
|
135
|
136
|
func (c *StockManagerApiController) CreateWarehouse() {
|
|
@@ -574,32 +575,8 @@ func (c *StockManagerApiController) EditWarehouse() {
|
574
|
575
|
}
|
575
|
576
|
warehousingInfo = append(warehousingInfo, warehouseInfo)
|
576
|
577
|
|
577
|
|
- flow := &models.VmStockFlow{
|
578
|
|
- WarehousingOrder: warehousing.WarehousingOrder,
|
579
|
|
- WarehousingId: warehousing.ID,
|
580
|
|
- GoodId: good_id,
|
581
|
|
- Number: number,
|
582
|
|
- ProductDate: productDates,
|
583
|
|
- ExpireDate: expiryDates,
|
584
|
|
- Count: warehousing_count,
|
585
|
|
- Price: price,
|
586
|
|
- Status: 1,
|
587
|
|
- Ctime: ctime,
|
588
|
|
- UserOrgId: adminUserInfo.CurrentOrgId,
|
589
|
|
- Manufacturer: manufacturer,
|
590
|
|
- Dealer: dealer,
|
591
|
|
- LicenseNumber: license_number,
|
592
|
|
- IsEdit: 1,
|
593
|
|
- Creator: adminUserInfo.AdminUser.Id,
|
594
|
|
- SystemTime: ctime,
|
595
|
|
- ConsumableType: 1,
|
596
|
|
- WarehousingDetailId: warehouseInfo.ID,
|
597
|
|
- }
|
598
|
|
-
|
599
|
|
- stockFlow = append(stockFlow, flow)
|
600
|
|
-
|
601
|
578
|
} else {
|
602
|
|
- fmt.Println("id23233232323232323232323223", id)
|
|
579
|
+
|
603
|
580
|
warehouseInfo := &models.WarehousingInfo{
|
604
|
581
|
ID: id,
|
605
|
582
|
WarehousingOrder: warehouse.WarehousingOrder,
|
|
@@ -653,27 +630,98 @@ func (c *StockManagerApiController) EditWarehouse() {
|
653
|
630
|
var errs error
|
654
|
631
|
if len(warehousingInfo) > 0 {
|
655
|
632
|
errs = service.CreateWarehousingInfo(warehousingInfo)
|
656
|
|
- service.CreateStockFlow(stockFlow)
|
|
633
|
+
|
|
634
|
+ for _, its := range warehousingInfo {
|
|
635
|
+ //查询
|
|
636
|
+ info, _ := service.GetLastGoodWarehouseInfo(its.GoodId)
|
|
637
|
+ fmt.Println("hh23323232323233232323322323", info)
|
|
638
|
+ flows := models.VmStockFlow{
|
|
639
|
+ WarehousingOrder: info.WarehousingOrder,
|
|
640
|
+ WarehousingId: info.ID,
|
|
641
|
+ GoodId: info.GoodId,
|
|
642
|
+ Number: info.Number,
|
|
643
|
+ ProductDate: info.ProductDate,
|
|
644
|
+ ExpireDate: info.ExpiryDate,
|
|
645
|
+ Count: info.WarehousingCount,
|
|
646
|
+ Price: info.Price,
|
|
647
|
+ Status: 1,
|
|
648
|
+ Ctime: ctime,
|
|
649
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
650
|
+ Manufacturer: info.Manufacturer,
|
|
651
|
+ Dealer: info.Dealer,
|
|
652
|
+ LicenseNumber: info.LicenseNumber,
|
|
653
|
+ IsEdit: 1,
|
|
654
|
+ Creator: adminUserInfo.AdminUser.Id,
|
|
655
|
+ SystemTime: ctime,
|
|
656
|
+ ConsumableType: 1,
|
|
657
|
+ WarehousingDetailId: info.ID,
|
|
658
|
+ }
|
|
659
|
+ _, errcodescode := service.GetGoodStockFlowInfo(info.ID, info.GoodId)
|
|
660
|
+ fmt.Println("wodeshijehh23322333223233223323232", errcodescode)
|
|
661
|
+ if errcodescode == gorm.ErrRecordNotFound {
|
|
662
|
+ service.CreateStockFlowOne(flows)
|
|
663
|
+ }
|
|
664
|
+
|
|
665
|
+ //改变库存
|
|
666
|
+ good, _ := service.GetLastInfoMationById(info.GoodId)
|
|
667
|
+ warhouseCount := strconv.FormatInt(info.WarehousingCount, 10)
|
|
668
|
+ total, _ := strconv.ParseFloat(warhouseCount, 64)
|
|
669
|
+ goodInfo := models.GoodInfo{
|
|
670
|
+ Total: good.Total + total,
|
|
671
|
+ }
|
|
672
|
+ errcodescode = service.UpdateGoodInfoMation(info.GoodId, goodInfo)
|
|
673
|
+ fmt.Println(errcodescode)
|
|
674
|
+ }
|
657
|
675
|
}
|
658
|
676
|
|
659
|
677
|
if len(upDateWarehousingInfo) > 0 {
|
660
|
678
|
|
661
|
679
|
for _, item := range upDateWarehousingInfo {
|
662
|
|
-
|
663
|
680
|
var total int64
|
664
|
|
- var all_total int64
|
665
|
681
|
//获取该批次该型号的库存
|
666
|
682
|
info, _ := service.GetLastWarehousingByIdOne(item.ID, item.GoodId)
|
667
|
|
- fmt.Println("oooooooooo", info.WarehousingCount)
|
668
|
|
- //判断 该批次的入库数量
|
669
|
|
- total = item.WarehousingCount - info.WarehousingCount
|
670
|
|
- fmt.Println("total232323322332232332", total)
|
671
|
|
- all_total = info.StockCount + total
|
672
|
683
|
|
673
|
|
- item.StockCount = all_total
|
674
|
|
- fmt.Println("hhhhhhhhhhhhh", item.StockCount)
|
|
684
|
+ //判断 该批次的库存数量 和 编辑库存数量
|
|
685
|
+ fmt.Println("库存11111111111111", item.WarehousingCount)
|
|
686
|
+ fmt.Println("库存22222222222222", info.WarehousingCount)
|
|
687
|
+ //增加库存
|
|
688
|
+ if item.WarehousingCount > info.WarehousingCount {
|
|
689
|
+
|
|
690
|
+ total = item.WarehousingCount - info.WarehousingCount
|
|
691
|
+ goodinfo := models.WarehousingInfo{
|
|
692
|
+ WarehousingCount: item.WarehousingCount,
|
|
693
|
+ StockCount: info.StockCount + total,
|
|
694
|
+ }
|
675
|
695
|
|
676
|
|
- errs = service.UpDateWarehousingInfo(item)
|
|
696
|
+ service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
|
|
697
|
+ //改变库存
|
|
698
|
+ good, _ := service.GetLastInfoMationById(info.GoodId)
|
|
699
|
+ warhouseCount := strconv.FormatInt(total, 10)
|
|
700
|
+ all_total, _ := strconv.ParseFloat(warhouseCount, 64)
|
|
701
|
+ goodInfo := models.GoodInfo{
|
|
702
|
+ Total: good.Total + all_total,
|
|
703
|
+ }
|
|
704
|
+ service.UpdateGoodInfoMation(info.GoodId, goodInfo)
|
|
705
|
+
|
|
706
|
+ }
|
|
707
|
+
|
|
708
|
+ if item.WarehousingCount < info.WarehousingCount {
|
|
709
|
+
|
|
710
|
+ total = info.WarehousingCount - item.WarehousingCount
|
|
711
|
+ goodinfo := models.WarehousingInfo{
|
|
712
|
+ WarehousingCount: item.WarehousingCount,
|
|
713
|
+ StockCount: info.StockCount - total,
|
|
714
|
+ }
|
|
715
|
+ service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
|
|
716
|
+ //改变库存
|
|
717
|
+ good, _ := service.GetLastInfoMationById(info.GoodId)
|
|
718
|
+ warhouseCount := strconv.FormatInt(total, 10)
|
|
719
|
+ all_total, _ := strconv.ParseFloat(warhouseCount, 64)
|
|
720
|
+ goodInfo := models.GoodInfo{
|
|
721
|
+ Total: good.Total - all_total,
|
|
722
|
+ }
|
|
723
|
+ service.UpdateGoodInfoMation(info.GoodId, goodInfo)
|
|
724
|
+ }
|
677
|
725
|
}
|
678
|
726
|
}
|
679
|
727
|
|
|
@@ -1242,13 +1290,10 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1242
|
1290
|
|
1243
|
1291
|
//出库逻辑
|
1244
|
1292
|
for _, item := range warehousingOutInfo {
|
1245
|
|
- //查询库存
|
1246
|
|
- //warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
|
1247
|
|
- //查询该批次的库存
|
1248
|
1293
|
|
1249
|
|
- warehouseOne, _ := service.FindWarehousingInfoByIdSeven(item.WarehouseInfotId)
|
1250
|
|
- fmt.Println("数据232323232323232323323232", warehouseOne)
|
1251
|
|
- fmt.Println("库存查询23322332233232233232322323232323", warehouseOne.StockCount)
|
|
1294
|
+ // 查询该耗材是否有库存
|
|
1295
|
+ warehouseOne, _ := service.FindWarehousingInfoTen(item.GoodId)
|
|
1296
|
+ // 如果出库数量大于该批次剩余库存数量
|
1252
|
1297
|
if item.Count > warehouseOne.StockCount {
|
1253
|
1298
|
goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
1254
|
1299
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -1259,11 +1304,12 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1259
|
1304
|
return
|
1260
|
1305
|
|
1261
|
1306
|
} else {
|
1262
|
|
-
|
|
1307
|
+ //查询是否生成出库单
|
1263
|
1308
|
_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
|
1264
|
1309
|
if errcodes == gorm.ErrRecordNotFound {
|
1265
|
1310
|
service.AddSigleWarehouseOut(&warehouseOut)
|
1266
|
1311
|
}
|
|
1312
|
+ //出库逻辑
|
1267
|
1313
|
parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count, creater)
|
1268
|
1314
|
if parseDateErr != nil {
|
1269
|
1315
|
utils.ErrorLog(parseDateErr.Error())
|
|
@@ -1279,10 +1325,6 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1279
|
1325
|
}
|
1280
|
1326
|
|
1281
|
1327
|
}
|
1282
|
|
-
|
1283
|
|
- //errs := service.CreateWarehousingOutInfo(warehousingOutInfo)
|
1284
|
|
- //info, _ := service.FindLastWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
|
1285
|
|
-
|
1286
|
1328
|
}
|
1287
|
1329
|
func (c *StockManagerApiController) GetWarehouseOutList() {
|
1288
|
1330
|
page, _ := c.GetInt64("page", -1)
|
|
@@ -1396,7 +1438,6 @@ func (c *StockManagerApiController) GetWarehouseOutInfoList() {
|
1396
|
1438
|
}
|
1397
|
1439
|
func (c *StockManagerApiController) EditWarehouseOut() {
|
1398
|
1440
|
warehouse_out_time := c.GetString("warehouse_out_time")
|
1399
|
|
-
|
1400
|
1441
|
id, _ := c.GetInt64("id", 0)
|
1401
|
1442
|
types, _ := c.GetInt64("type", 0)
|
1402
|
1443
|
|
|
@@ -1592,18 +1633,50 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1592
|
1633
|
}
|
1593
|
1634
|
}
|
1594
|
1635
|
var errs error
|
|
1636
|
+ //新增出库
|
1595
|
1637
|
if len(warehousingOutInfo) > 0 {
|
1596
|
1638
|
|
1597
|
|
- errs = service.CreateWarehousingOutInfo(warehousingOutInfo)
|
|
1639
|
+ warehousingOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehouse_out_time)
|
|
1640
|
+ if parseDateErr != nil {
|
|
1641
|
+ c.ErrorLog("日期(%v)解析错误:%v", warehousingOutDate, parseDateErr)
|
|
1642
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1643
|
+ return
|
|
1644
|
+ }
|
|
1645
|
+ creater := adminUserInfo.AdminUser.Id
|
|
1646
|
+
|
|
1647
|
+ for _, item := range warehousingOutInfo {
|
|
1648
|
+ // 查询该耗材是否有库存
|
|
1649
|
+ warehouseOne, _ := service.FindWarehousingInfoTen(item.GoodId)
|
|
1650
|
+ // 如果出库数量大于该批次剩余库存数量
|
|
1651
|
+ if item.Count > warehouseOne.StockCount {
|
|
1652
|
+ goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
|
1653
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1654
|
+ "msg": "7",
|
|
1655
|
+ "good_name": goodObj.GoodName,
|
|
1656
|
+ "specification_name": goodObj.SpecificationName,
|
|
1657
|
+ })
|
|
1658
|
+ return
|
|
1659
|
+
|
|
1660
|
+ } else {
|
|
1661
|
+
|
|
1662
|
+ warehouseOut, _ := service.GetWarehouseById(id)
|
|
1663
|
+
|
|
1664
|
+ //出库逻辑
|
|
1665
|
+ parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count, creater)
|
|
1666
|
+ if parseDateErr != nil {
|
|
1667
|
+ utils.ErrorLog(parseDateErr.Error())
|
|
1668
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
|
|
1669
|
+ return
|
|
1670
|
+ }
|
|
1671
|
+ }
|
|
1672
|
+ }
|
1598
|
1673
|
}
|
1599
|
1674
|
|
1600
|
1675
|
if len(upDateWarehouseOutInfos) > 0 {
|
1601
|
1676
|
for _, item := range upDateWarehouseOutInfos {
|
1602
|
1677
|
|
1603
|
1678
|
//1.查询该耗材该批次的最后一次出库记录
|
1604
|
|
- lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, adminUserInfo.CurrentOrgId)
|
1605
|
|
- fmt.Println("lastGood", lastGood.Count)
|
1606
|
|
- fmt.Println("item2323232", item.Count)
|
|
1679
|
+ lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId)
|
1607
|
1680
|
|
1608
|
1681
|
// 退库的库存和该耗材该批次最后一次出库数量进行比较
|
1609
|
1682
|
//如果退库数量大于 最后一次批次的数量(要么要进行出库)
|
|
@@ -1612,7 +1685,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1612
|
1685
|
|
1613
|
1686
|
//查询该耗材是否还有库存
|
1614
|
1687
|
warehouseinfo, _ := service.GetTotalCountByGoodId(item.GoodId)
|
1615
|
|
- fmt.Println("hhhhhh23h2323232", warehouseinfo.StockCount)
|
|
1688
|
+
|
1616
|
1689
|
//无库存
|
1617
|
1690
|
if warehouseinfo.StockCount <= 0 {
|
1618
|
1691
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -1628,10 +1701,10 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1628
|
1701
|
var total_count int64
|
1629
|
1702
|
//计算和最后一次出库数据的差
|
1630
|
1703
|
total = item.Count - lastGood.Count
|
1631
|
|
- fmt.Println("total22323232", total)
|
|
1704
|
+
|
1632
|
1705
|
//获取该耗材该批次的剩余库存量
|
1633
|
1706
|
info, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
|
1634
|
|
- fmt.Println("info2232323232323", info)
|
|
1707
|
+
|
1635
|
1708
|
//判断该批次的剩余库存 和出库的库存进行比较
|
1636
|
1709
|
//如果出库的库存大于该批次的剩余库存,那么需要出库下一批次的库存
|
1637
|
1710
|
|
|
@@ -1641,12 +1714,20 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1641
|
1714
|
//清空本批次次库存
|
1642
|
1715
|
service.DeleteWarehouseInfo(item.WarehouseInfotId)
|
1643
|
1716
|
//调用出库逻辑
|
1644
|
|
- service.ConsumablesDeliveryTwo(item.OrgId, item, total_count)
|
|
1717
|
+ parseDateErr := service.ConsumablesDeliveryTwo(item.OrgId, item, total_count)
|
|
1718
|
+ if parseDateErr != nil {
|
|
1719
|
+ utils.ErrorLog(errs.Error())
|
|
1720
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
|
|
1721
|
+ return
|
|
1722
|
+ }
|
|
1723
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1724
|
+ "msg": "1",
|
|
1725
|
+ })
|
1645
|
1726
|
}
|
1646
|
1727
|
//如果出库的库存小于或等于于该批次的剩余库存,那么需要该批次出库
|
1647
|
1728
|
if item.Count <= info.StockCount {
|
1648
|
1729
|
stock_cout = lastGood.Count + total
|
1649
|
|
- fmt.Println("232323223232323232323232", stock_cout)
|
|
1730
|
+ fmt.Println(stock_cout)
|
1650
|
1731
|
//扣减库存
|
1651
|
1732
|
warehouse := models.WarehousingInfo{
|
1652
|
1733
|
StockCount: info.StockCount - total,
|
|
@@ -1689,8 +1770,13 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1689
|
1770
|
c.ServeSuccessJSON(map[string]interface{}{
|
1690
|
1771
|
"msg": "1",
|
1691
|
1772
|
})
|
|
1773
|
+ return
|
1692
|
1774
|
} else if errcode == nil {
|
1693
|
1775
|
service.UpDateWarehouseOutInfo(item)
|
|
1776
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1777
|
+ "msg": "1",
|
|
1778
|
+ })
|
|
1779
|
+ return
|
1694
|
1780
|
}
|
1695
|
1781
|
|
1696
|
1782
|
}
|
|
@@ -1702,31 +1788,30 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1702
|
1788
|
var stock_total int64
|
1703
|
1789
|
//如果退库数量小于最后一次批次的数量(要么要进行退库)
|
1704
|
1790
|
if item.Count < lastGood.Count {
|
1705
|
|
- fmt.Println("hh232323h2h3hh23hh23hh2h3h23")
|
|
1791
|
+
|
1706
|
1792
|
//退库数量和最后一次出库数据进行计算
|
1707
|
1793
|
last_count = lastGood.Count - item.Count
|
1708
|
|
- fmt.Println("last_count", last_count)
|
|
1794
|
+
|
1709
|
1795
|
//获取该耗材该批次的剩余库存量
|
1710
|
1796
|
infoInfo, _ := service.GetLastGoodCountById(item.GoodId, item.WarehouseInfotId)
|
1711
|
1797
|
|
1712
|
1798
|
//退库数量和最后一次出库数据进行计算的差 加上 剩余库存的数量与 该批次的入库数量进行比较
|
1713
|
1799
|
all_total = last_count + infoInfo.StockCount
|
1714
|
|
- fmt.Println("all_total", all_total)
|
|
1800
|
+
|
1715
|
1801
|
//如果库存大于总数量,则退回到这个批次
|
1716
|
|
- fmt.Println("inf232323", infoInfo.WarehousingCount)
|
1717
|
1802
|
|
1718
|
1803
|
if infoInfo.WarehousingCount > all_total {
|
1719
|
1804
|
stock_total = last_count + infoInfo.StockCount
|
1720
|
|
- fmt.Println("经历323232323232232", last_count, stock_total)
|
|
1805
|
+
|
1721
|
1806
|
//退回该批次,计算数量
|
1722
|
1807
|
warehousingInfoOne := models.WarehousingInfo{
|
1723
|
1808
|
StockCount: stock_total,
|
1724
|
1809
|
ID: item.WarehouseInfotId,
|
1725
|
1810
|
OrgId: item.OrgId,
|
1726
|
1811
|
}
|
1727
|
|
- fmt.Println("********************", warehousingInfoOne, item.WarehouseInfotId)
|
|
1812
|
+
|
1728
|
1813
|
parseDateErr := service.UpdateWarehousingInfo(warehousingInfoOne, item.WarehouseInfotId)
|
1729
|
|
- fmt.Println("parseDateErr2323232322323", parseDateErr)
|
|
1814
|
+ fmt.Println("parseDateErr", parseDateErr)
|
1730
|
1815
|
//插入一条新纪录
|
1731
|
1816
|
warehouseOutInfoThree := &models.WarehouseOutInfo{
|
1732
|
1817
|
WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
|
|
@@ -1762,8 +1847,10 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1762
|
1847
|
c.ServeSuccessJSON(map[string]interface{}{
|
1763
|
1848
|
"msg": "1",
|
1764
|
1849
|
})
|
|
1850
|
+ return
|
1765
|
1851
|
} else if errcode == nil {
|
1766
|
1852
|
service.UpDateWarehouseOutInfo(item)
|
|
1853
|
+ return
|
1767
|
1854
|
}
|
1768
|
1855
|
}
|
1769
|
1856
|
|
|
@@ -1777,6 +1864,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1777
|
1864
|
}
|
1778
|
1865
|
|
1779
|
1866
|
if item.Count == lastGood.Count {
|
|
1867
|
+
|
1780
|
1868
|
errs = service.UpDateWarehouseOutInfo(item)
|
1781
|
1869
|
if errs != nil {
|
1782
|
1870
|
utils.ErrorLog(errs.Error())
|
|
@@ -1786,6 +1874,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1786
|
1874
|
c.ServeSuccessJSON(map[string]interface{}{
|
1787
|
1875
|
"msg": "1",
|
1788
|
1876
|
})
|
|
1877
|
+ return
|
1789
|
1878
|
}
|
1790
|
1879
|
|
1791
|
1880
|
}
|
|
@@ -4357,7 +4446,6 @@ func (this *StockManagerApiController) GetAllStockList() {
|
4357
|
4446
|
orgId := adminUserInfo.CurrentOrgId
|
4358
|
4447
|
|
4359
|
4448
|
list, total, _ := service.GetAllGoodInfoStockList(page, limit, startTime, endTime, types, keywords, orgId)
|
4360
|
|
- fmt.Println("耗材总计23323232232323232323", total)
|
4361
|
4449
|
manufacturerList, _ := service.GetAllManufacturerList(orgId)
|
4362
|
4450
|
this.ServeSuccessJSON(map[string]interface{}{
|
4363
|
4451
|
"list": list,
|
|
@@ -4492,15 +4580,9 @@ func (this *StockManagerApiController) GetOrderDetialByOrderId() {
|
4492
|
4580
|
ids := this.GetString("id")
|
4493
|
4581
|
idsArray := strings.Split(ids, ",")
|
4494
|
4582
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
4495
|
|
- order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
|
4496
|
4583
|
list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
|
4497
|
|
- //获取该耗材的最后一条数据
|
4498
|
|
- info, _ := service.GetLastWarehouseOutInfo(idsArray, orgId)
|
4499
|
|
- fmt.Println("info323e2342342342432342342432", info)
|
4500
|
4584
|
this.ServeSuccessJSON(map[string]interface{}{
|
4501
|
|
- "order": order,
|
4502
|
|
- "list": list,
|
4503
|
|
- "info": info,
|
|
4585
|
+ "list": list,
|
4504
|
4586
|
})
|
4505
|
4587
|
}
|
4506
|
4588
|
|
|
@@ -5237,13 +5319,17 @@ func (this *StockManagerApiController) GetReportStockList() {
|
5237
|
5319
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
5238
|
5320
|
keyword := this.GetString("keyword")
|
5239
|
5321
|
fmt.Println("startTime", startTime, "endTime", endTime)
|
5240
|
|
- list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
|
|
5322
|
+ //list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
|
|
5323
|
+
|
|
5324
|
+ list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit)
|
|
5325
|
+ damageList, _ := service.GetStockDamagedCount(orgId)
|
5241
|
5326
|
doctorlist, _ := service.GetAllDoctorThree(orgId)
|
5242
|
5327
|
|
5243
|
5328
|
this.ServeSuccessJSON(map[string]interface{}{
|
5244
|
5329
|
"list": list,
|
5245
|
5330
|
"total": total,
|
5246
|
5331
|
"doctorlist": doctorlist,
|
|
5332
|
+ "damageList": damageList,
|
5247
|
5333
|
})
|
5248
|
5334
|
}
|
5249
|
5335
|
|
|
@@ -6158,3 +6244,231 @@ func (this *StockManagerApiController) GetGoodInventoryWarehouseList() {
|
6158
|
6244
|
"list": list,
|
6159
|
6245
|
})
|
6160
|
6246
|
}
|
|
6247
|
+
|
|
6248
|
+func (this *StockManagerApiController) SaveStockInventoryList() {
|
|
6249
|
+
|
|
6250
|
+ dataBody := make(map[string]interface{}, 0)
|
|
6251
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
6252
|
+ fmt.Println(err)
|
|
6253
|
+
|
|
6254
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
6255
|
+
|
|
6256
|
+ if len(tableData) > 0 {
|
|
6257
|
+ for _, item := range tableData {
|
|
6258
|
+ items := item.(map[string]interface{})
|
|
6259
|
+ good_name := items["good_name"].(string)
|
|
6260
|
+ if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
|
|
6261
|
+ utils.ErrorLog("good_name")
|
|
6262
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6263
|
+ return
|
|
6264
|
+ }
|
|
6265
|
+
|
|
6266
|
+ specification_name := items["specification_name"].(string)
|
|
6267
|
+ if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
|
6268
|
+ utils.ErrorLog("specification_name")
|
|
6269
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6270
|
+ return
|
|
6271
|
+ }
|
|
6272
|
+
|
|
6273
|
+ warehousing_unit := items["warehousing_unit"].(string)
|
|
6274
|
+ if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
|
|
6275
|
+ utils.ErrorLog("warehousing_unit")
|
|
6276
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6277
|
+ return
|
|
6278
|
+ }
|
|
6279
|
+
|
|
6280
|
+ stock_count := int64(items["stock_count"].(float64))
|
|
6281
|
+ if items["stock_count"] == nil || reflect.TypeOf(items["stock_count"]).String() != "float64" {
|
|
6282
|
+ utils.ErrorLog("stock_count")
|
|
6283
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6284
|
+ return
|
|
6285
|
+ }
|
|
6286
|
+
|
|
6287
|
+ price := items["price"].(float64)
|
|
6288
|
+ if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "float64" {
|
|
6289
|
+ utils.ErrorLog("price")
|
|
6290
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6291
|
+ return
|
|
6292
|
+ }
|
|
6293
|
+
|
|
6294
|
+ manufacturer_name := items["manufacturer_name"].(string)
|
|
6295
|
+ if items["manufacturer_name"] == nil || reflect.TypeOf(items["manufacturer_name"]).String() != "string" {
|
|
6296
|
+ utils.ErrorLog("manufacturer_name")
|
|
6297
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6298
|
+ return
|
|
6299
|
+ }
|
|
6300
|
+
|
|
6301
|
+ good_id := int64(items["good_id"].(float64))
|
|
6302
|
+ if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
|
|
6303
|
+ utils.ErrorLog("good_id")
|
|
6304
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6305
|
+ return
|
|
6306
|
+ }
|
|
6307
|
+
|
|
6308
|
+ manufacturer := int64(items["manufacturer"].(float64))
|
|
6309
|
+ if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "float64" {
|
|
6310
|
+ utils.ErrorLog("manufacturer")
|
|
6311
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6312
|
+ return
|
|
6313
|
+ }
|
|
6314
|
+
|
|
6315
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
6316
|
+ if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
|
|
6317
|
+ utils.ErrorLog("warehousing_order")
|
|
6318
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6319
|
+ return
|
|
6320
|
+ }
|
|
6321
|
+
|
|
6322
|
+ number := items["number"].(string)
|
|
6323
|
+ if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
|
|
6324
|
+ utils.ErrorLog("number")
|
|
6325
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6326
|
+ return
|
|
6327
|
+ }
|
|
6328
|
+
|
|
6329
|
+ id := int64(items["id"].(float64))
|
|
6330
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
6331
|
+ utils.ErrorLog("id")
|
|
6332
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6333
|
+ return
|
|
6334
|
+ }
|
|
6335
|
+
|
|
6336
|
+ if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
|
|
6337
|
+ utils.ErrorLog("expiry_date")
|
|
6338
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6339
|
+ return
|
|
6340
|
+ }
|
|
6341
|
+ expiry_date := int64(items["expiry_date"].(float64))
|
|
6342
|
+
|
|
6343
|
+ if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
|
|
6344
|
+ utils.ErrorLog("product_date")
|
|
6345
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6346
|
+ return
|
|
6347
|
+ }
|
|
6348
|
+ product_date := int64(items["product_date"].(float64))
|
|
6349
|
+
|
|
6350
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
6351
|
+ adminId := this.GetAdminUserInfo().AdminUser.Id
|
|
6352
|
+
|
|
6353
|
+ stock_type := int64(items["type"].(float64))
|
|
6354
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
6355
|
+ utils.ErrorLog("type")
|
|
6356
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6357
|
+ return
|
|
6358
|
+ }
|
|
6359
|
+
|
|
6360
|
+ last_stock_count := int64(items["last_stock_count"].(float64))
|
|
6361
|
+ if items["last_stock_count"] == nil || reflect.TypeOf(items["last_stock_count"]).String() != "float64" {
|
|
6362
|
+ utils.ErrorLog("last_stock_count")
|
|
6363
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
6364
|
+ return
|
|
6365
|
+ }
|
|
6366
|
+ var total_count int64
|
|
6367
|
+ var inventory_type int64
|
|
6368
|
+ fmt.Println("盘点前", stock_count)
|
|
6369
|
+ fmt.Println("盘点后", last_stock_count)
|
|
6370
|
+ if stock_count > last_stock_count {
|
|
6371
|
+ total_count = stock_count - last_stock_count
|
|
6372
|
+ inventory_type = 11
|
|
6373
|
+ }
|
|
6374
|
+ if stock_count < last_stock_count {
|
|
6375
|
+ total_count = last_stock_count - stock_count
|
|
6376
|
+ inventory_type = 10
|
|
6377
|
+ }
|
|
6378
|
+
|
|
6379
|
+ creater := this.GetAdminUserInfo().AdminUser.Id
|
|
6380
|
+ inventory := models.XtStockInventory{
|
|
6381
|
+ GoodName: good_name,
|
|
6382
|
+ SpecificationName: specification_name,
|
|
6383
|
+ WarehousingUnit: warehousing_unit,
|
|
6384
|
+ Count: total_count,
|
|
6385
|
+ BuyPrice: price,
|
|
6386
|
+ PackingPrice: price,
|
|
6387
|
+ NewPrice: 0,
|
|
6388
|
+ Manufacturer: manufacturer_name,
|
|
6389
|
+ Dealer: "",
|
|
6390
|
+ Remark: "",
|
|
6391
|
+ GoodId: good_id,
|
|
6392
|
+ UserOrgId: orgId,
|
|
6393
|
+ Ctime: time.Now().Unix(),
|
|
6394
|
+ Mtime: 0,
|
|
6395
|
+ Status: 1,
|
|
6396
|
+ WarehousingOrder: warehousing_order,
|
|
6397
|
+ LicenseNumber: number,
|
|
6398
|
+ StartTime: time.Now().Unix(),
|
|
6399
|
+ Creater: adminId,
|
|
6400
|
+ Checker: 0,
|
|
6401
|
+ CheckerStatus: 0,
|
|
6402
|
+ CheckerTime: 0,
|
|
6403
|
+ Total: 0,
|
|
6404
|
+ Number: number,
|
|
6405
|
+ WarehousingInfoId: id,
|
|
6406
|
+ ExpireDate: expiry_date,
|
|
6407
|
+ ProductDate: product_date,
|
|
6408
|
+ GoodOriginPlace: "",
|
|
6409
|
+ Type: 10,
|
|
6410
|
+ InventoryType: stock_type,
|
|
6411
|
+ LastStockCount: last_stock_count,
|
|
6412
|
+ StockCount: stock_count,
|
|
6413
|
+ }
|
|
6414
|
+ service.CreateInentory(inventory)
|
|
6415
|
+
|
|
6416
|
+ stockFlow := models.VmStockFlow{
|
|
6417
|
+ WarehousingId: 0,
|
|
6418
|
+ GoodId: good_id,
|
|
6419
|
+ Number: number,
|
|
6420
|
+ LicenseNumber: "",
|
|
6421
|
+ Count: total_count,
|
|
6422
|
+ UserOrgId: orgId,
|
|
6423
|
+ PatientId: 0,
|
|
6424
|
+ SystemTime: 0,
|
|
6425
|
+ ConsumableType: inventory_type,
|
|
6426
|
+ IsSys: 0,
|
|
6427
|
+ WarehousingOrder: "",
|
|
6428
|
+ WarehouseOutId: 0,
|
|
6429
|
+ WarehouseOutOrderNumber: warehousing_order,
|
|
6430
|
+ IsEdit: 0,
|
|
6431
|
+ CancelStockId: 0,
|
|
6432
|
+ CancelOrderNumber: "",
|
|
6433
|
+ Manufacturer: manufacturer,
|
|
6434
|
+ Dealer: 0,
|
|
6435
|
+ Creator: creater,
|
|
6436
|
+ UpdateCreator: 0,
|
|
6437
|
+ Status: 1,
|
|
6438
|
+ Ctime: time.Now().Unix(),
|
|
6439
|
+ Mtime: 0,
|
|
6440
|
+ Price: price,
|
|
6441
|
+ WarehousingDetailId: 0,
|
|
6442
|
+ WarehouseOutDetailId: 0,
|
|
6443
|
+ CancelOutDetailId: 0,
|
|
6444
|
+ ProductDate: product_date,
|
|
6445
|
+ ExpireDate: expiry_date,
|
|
6446
|
+ ReturnCount: 0,
|
|
6447
|
+ }
|
|
6448
|
+
|
|
6449
|
+ info := models.WarehousingInfo{
|
|
6450
|
+ StockCount: last_stock_count,
|
|
6451
|
+ }
|
|
6452
|
+ //更改库存
|
|
6453
|
+ service.UpdatedWarehousingInfo(info, id)
|
|
6454
|
+ if stock_count != last_stock_count {
|
|
6455
|
+ service.CreateStockFlowOne(stockFlow)
|
|
6456
|
+ }
|
|
6457
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
6458
|
+ "inventory": inventory,
|
|
6459
|
+ })
|
|
6460
|
+ }
|
|
6461
|
+ }
|
|
6462
|
+}
|
|
6463
|
+
|
|
6464
|
+func (this *StockManagerApiController) GetDamageDetailByGoodId() {
|
|
6465
|
+
|
|
6466
|
+ good_id, _ := this.GetInt64("good_id")
|
|
6467
|
+ list, _ := service.GetDamageDetailByGoodId(good_id)
|
|
6468
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
6469
|
+ damageList, _ := service.GetStockDamagedCount(orgId)
|
|
6470
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
6471
|
+ "list": list,
|
|
6472
|
+ "damageList": damageList,
|
|
6473
|
+ })
|
|
6474
|
+}
|