Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
49d67aa4e9
2 changed files with 110 additions and 0 deletions
  1. 98 0
      controllers/supply_order_api_contorller.go
  2. 12 0
      service/supply_service.go

+ 98 - 0
controllers/supply_order_api_contorller.go View File

@@ -52,6 +52,8 @@ func SupplyOrderApiRegistRouters() {
52 52
 	beego.Router("/api/supply/getgoodorderlist", &SupplyOrderApiController{}, "Get:GetGoodOrderList")
53 53
 	//反审核购货订单
54 54
 	beego.Router("/api/supply/getreturnorder", &SupplyOrderApiController{}, "Get:GetReturnOrder")
55
+	//判断是否全部入库
56
+	beego.Router("/api/supply/getgoodordercountlist", &SupplyOrderApiController{}, "Get:GetGoodOrderCountList")
55 57
 }
56 58
 
57 59
 func (this *SupplyOrderApiController) GetInitOrder() {
@@ -1446,3 +1448,99 @@ func (this *SupplyOrderApiController) GetReturnOrder() {
1446 1448
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1447 1449
 	}
1448 1450
 }
1451
+
1452
+func (this *SupplyOrderApiController) GetGoodOrderCountList() {
1453
+	id, _ := this.GetInt64("id")
1454
+	warehousing_id, _ := this.GetInt64("warehousing_id")
1455
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1456
+	checker := this.GetAdminUserInfo().AdminUser.Id
1457
+	recordDateStr := time.Now().Format("2006-01-02")
1458
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1459
+	record_date := recordDate.Unix()
1460
+	out := models.SpSupplierWarehouseOut{
1461
+		IsCheck:   1,
1462
+		Checker:   checker,
1463
+		CheckTime: record_date,
1464
+	}
1465
+	err := service.CheckGoodOrder(id, orgId, out)
1466
+	//获取购货订单的数据
1467
+	purcaseOrder, _ := service.GetAllPurcaseOrderById(warehousing_id, orgId)
1468
+	//获取购货单的数据
1469
+	goodOrder, _ := service.GetAllGoodOrderByIdTwo(warehousing_id, orgId)
1470
+
1471
+	//查询该购货单是否审核成功
1472
+	detail, _ := service.GetGoodOrderDetail(id, orgId)
1473
+	var warehousingInfo []*models.WarehousingInfo
1474
+	//如果审核成功
1475
+	if detail.IsCheck == 1 {
1476
+		//入库
1477
+		if len(goodOrder) > 0 {
1478
+			for _, item := range goodOrder {
1479
+				//药品
1480
+				if item.IsSource == 1 {
1481
+
1482
+				}
1483
+				//耗材
1484
+				if item.IsSource == 2 {
1485
+					//获取耗材类型
1486
+					good, _ := service.GetGoodInformationByGoodId(item.ProjectId)
1487
+					timeStr := time.Now().Format("2006-01-02")
1488
+					timeArr := strings.Split(timeStr, "-")
1489
+					total, _ := service.FindAllWarehouseTotal(orgId)
1490
+					total = total + 1
1491
+					warehousing_order := "RKD" + strconv.FormatInt(orgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1492
+					operation_time := time.Now().Unix()
1493
+					creater := this.GetAdminUserInfo().AdminUser.Id
1494
+					warehousing := models.Warehousing{
1495
+						WarehousingOrder: warehousing_order,
1496
+						OperationTime:    operation_time,
1497
+						OrgId:            orgId,
1498
+						Creater:          creater,
1499
+						Ctime:            time.Now().Unix(),
1500
+						Status:           1,
1501
+						WarehousingTime:  record_date,
1502
+						Type:             1,
1503
+					}
1504
+					service.AddSigleWarehouse(&warehousing)
1505
+
1506
+					//入库单表格
1507
+					warehouseInfo := &models.WarehousingInfo{
1508
+						WarehousingOrder: warehousing.WarehousingOrder,
1509
+						WarehousingId:    warehousing.ID,
1510
+						GoodId:           item.ProjectId,
1511
+						Number:           item.SupplyBatchNumber,
1512
+						GoodTypeId:       good.GoodTypeId,
1513
+						ProductDate:      item.SupplyProductDate,
1514
+						ExpiryDate:       item.SupplyExpiryDate,
1515
+						WarehousingCount: item.Count,
1516
+						Price:            item.Price,
1517
+						TotalPrice:       0,
1518
+						Status:           1,
1519
+						Ctime:            time.Now().Unix(),
1520
+						Remark:           item.Remark,
1521
+						OrgId:            orgId,
1522
+						Type:             1,
1523
+						Manufacturer:     item.ManufacturerId,
1524
+						StockCount:       item.Count,
1525
+						Dealer:           good.Dealer,
1526
+						LicenseNumber:    item.SupplyLicenseNumber,
1527
+						PackingPrice:     good.PackingPrice,
1528
+					}
1529
+					warehousingInfo = append(warehousingInfo, warehouseInfo)
1530
+
1531
+				}
1532
+			}
1533
+		}
1534
+	}
1535
+
1536
+	drugList, _ := service.GetSupplyDrugList(orgId)
1537
+	if err == nil {
1538
+		this.ServeSuccessJSON(map[string]interface{}{
1539
+			"purcaseOrder": purcaseOrder,
1540
+			"goodOrder":    goodOrder,
1541
+			"drugList":     drugList,
1542
+		})
1543
+	} else {
1544
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1545
+	}
1546
+}

+ 12 - 0
service/supply_service.go View File

@@ -219,6 +219,12 @@ func GetAllGoodOrderById(id int64, orgid int64) (order []*models.VSpSupplierWare
219 219
 	return order, err
220 220
 }
221 221
 
222
+func GetAllGoodOrderByIdTwo(id int64, orgid int64) (order []*models.SpSupplierWarehousingOutOrder, err error) {
223
+
224
+	err = XTReadDB().Where("warehousing_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&order).Error
225
+	return order, err
226
+}
227
+
222 228
 func GetGoodOrderList(id int64, orgid int64) (info []*models.SpSupplierWarehouseOut, err error) {
223 229
 
224 230
 	err = XTReadDB().Where("warehousing_id = ? and status = 1 and user_org_id = ?", id, orgid).Find(&info).Error
@@ -230,3 +236,9 @@ func GetReturnOrder(id int64, orgid int64) error {
230 236
 	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"is_check": 2, "mtime": time.Now().Unix(), "check_time": 0, "checker": 0}).Error
231 237
 	return err
232 238
 }
239
+
240
+func CheckGoodOrder(id int64, orgid int64, out models.SpSupplierWarehouseOut) error {
241
+
242
+	err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and user_org_id =? and status = 1", id, orgid).Updates(map[string]interface{}{"is_check": out.IsCheck, "checker": out.Checker, "check_time": out.CheckTime, "mtime": time.Now().Unix()}).Error
243
+	return err
244
+}