Bläddra i källkod

采购自动生成申购数据表

fgd 1 år sedan
förälder
incheckning
4b7e274bfc

+ 9 - 0
sd-business/src/main/java/com/sd/business/service/purchase/PurchaseBomService.java

@@ -9,6 +9,8 @@ import com.sd.business.entity.purchase.dto.PurchaseInTransitBomSelectDto;
 import com.sd.business.entity.purchase.po.PurchaseBom;
 import com.sd.business.entity.purchase.vo.*;
 
+import java.math.BigDecimal;
+
 
 /**
  * <p>
@@ -55,4 +57,11 @@ public interface PurchaseBomService extends BaseService<PurchaseBom> {
      * @return
      */
     Page<PurchaseBomDetailsVo> getDetailsPage(PurchaseBomDetailsSelectDto dto);
+
+    /**
+     * 获取采购bom的在途数量
+     * @param bomSpecId
+     * @return
+     */
+    BigDecimal getPurchaseBomInTransitSum(Long bomSpecId);
 }

+ 6 - 0
sd-business/src/main/java/com/sd/business/service/purchase/PurchaseService.java

@@ -64,4 +64,10 @@ public interface PurchaseService extends BaseService<Purchase> {
      * @param id
      */
     void purchaseTermination(Long id);
+
+    /**
+     * 获取采购合同下拉框列表
+     * @return
+     */
+    Page<PurchaseVo> getPurchaseSelectList(PurchaseSelectDto dto);
 }

+ 17 - 12
sd-business/src/main/java/com/sd/business/service/purchase/impl/PurchaseBomServiceImpl.java

@@ -155,6 +155,7 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         Page<PurchaseBomBoardVo> page = new Page<>();
         page.setSize(bomSpecVoPage.getSize());
         page.setTotal(bomSpecVoPage.getTotal());
+        Date date = new Date();
         List<PurchaseBomBoardVo> list = new ArrayList<>();
         for (BomSpecVo record : records) {
             PurchaseBomBoardVo purchaseBomBoard = new PurchaseBomBoardVo();
@@ -164,16 +165,16 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
             // 当前库存数
             BigDecimal inventoryQuantity = ObjectUtil.isEmpty(inventoryList) ? BigDecimal.ZERO : StreamUtil.bigDecimalAdd(inventoryList, Inventory::getQuantity);
             // 近7天消耗量
-            BigDecimal quantitySevenDays = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), 7);
+            BigDecimal quantitySevenDays = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), DateUtil.offsetDay(date, -7), date);
             // 近30天消耗量
-            BigDecimal quantityThirtyDays = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), 30);
+            BigDecimal quantityThirtyDays = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), DateUtil.offsetDay(date, -30), date);
 
             // 40天安全库存
             BigDecimal safetyInventoryQuantity = quantityThirtyDays.divide(new BigDecimal("30"), 2, RoundingMode.HALF_UP)
                     .multiply(new BigDecimal("40")).setScale(0, RoundingMode.HALF_UP);
 
             // 近14天消耗量
-            BigDecimal quantityTwoWeek = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), 14);
+            BigDecimal quantityTwoWeek = orderService.getOrderBomSpecOutStorageQuantity(record.getId(), DateUtil.offsetDay(date, -14), date);
             // 近两周减去近一周的消耗量为上周数量
             BigDecimal quantityLastWeek = quantityTwoWeek.subtract(quantitySevenDays);
             // 周环比率
@@ -192,15 +193,10 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
             }
 
             // 获取在途总数
-            IWrapper<PurchaseBom> wrapper = getWrapper();
-            wrapper.eq("pb", PurchaseBom::getBomSpecId, bomSpecId);
-            wrapper.eq("p", Purchase::getStatus, PurchaseStatusEnum.UNDER_PURCHASE.getKey());
-            wrapper.apply("pb.purchase_quantity > pb.arrival_quantity");
-            purchaseBomBoard.setInTransitSum(this.baseMapper.getPurchaseBomInTransitSum(wrapper));
+            purchaseBomBoard.setInTransitSum(this.getPurchaseBomInTransitSum(bomSpecId));
 
             // 获取下一批到货天数
-            wrapper = IWrapper.getWrapper();
-            Date date = new Date();
+            IWrapper<PurchaseBom> wrapper = IWrapper.getWrapper();
             wrapper.eq("pb", PurchaseBom::getBomSpecId, bomSpecId);
             wrapper.apply("pb.purchase_quantity > pb.arrival_quantity");
             wrapper.eq("p", Purchase::getStorageStatus, StatusConstant.NO);
@@ -226,8 +222,8 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
             purchaseBomBoard.setSafetyInventoryQuantity(safetyInventoryQuantity);
             purchaseBomBoard.setOutStorageQuantitySevenDays(quantitySevenDays);
             purchaseBomBoard.setOutStorageQuantityThirtyDays(quantityThirtyDays);
-            purchaseBomBoard.setOutStorageQuantityFifteenDays(orderService.getOrderBomSpecOutStorageQuantity(record.getId(), 15));
-            purchaseBomBoard.setOutStorageQuantitySixtyDays(orderService.getOrderBomSpecOutStorageQuantity(record.getId(), 60));
+            purchaseBomBoard.setOutStorageQuantityFifteenDays(orderService.getOrderBomSpecOutStorageQuantity(record.getId(),DateUtil.offsetDay(date, -15), date));
+            purchaseBomBoard.setOutStorageQuantitySixtyDays(orderService.getOrderBomSpecOutStorageQuantity(record.getId(), DateUtil.offsetDay(date, -60), date));
             purchaseBomBoard.setOutStorageWeekOnWeekRatio(weekOnWeekRatio);
             purchaseBomBoard.setNextDeliveryDays((int) nextDeliveryDays);
             list.add(purchaseBomBoard);
@@ -245,4 +241,13 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         wrapper.orderByDesc("p", Purchase::getId);
         return this.baseMapper.getDetailsPage(dto.getPage(), wrapper);
     }
+
+    @Override
+    public BigDecimal getPurchaseBomInTransitSum(Long bomSpecId) {
+        IWrapper<PurchaseBom> wrapper = getWrapper();
+        wrapper.eq("pb", PurchaseBom::getBomSpecId, bomSpecId);
+        wrapper.eq("p", Purchase::getStatus, PurchaseStatusEnum.UNDER_PURCHASE.getKey());
+        wrapper.apply("pb.purchase_quantity > pb.arrival_quantity");
+        return this.baseMapper.getPurchaseBomInTransitSum(wrapper);
+    }
 }

+ 157 - 4
sd-business/src/main/java/com/sd/business/service/purchase/impl/PurchaseServiceImpl.java

@@ -1,10 +1,15 @@
 package com.sd.business.service.purchase.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.file.entity.FileInfo;
+import com.fjhx.file.entity.ObsFile;
+import com.fjhx.file.service.FileInfoService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.enums.FlowStatusEnum;
 import com.ruoyi.common.constant.StatusConstant;
@@ -12,7 +17,11 @@ import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.sd.business.entity.apply.po.ApplyBuyBom;
+import com.sd.business.entity.apply.vo.ApplyBuyBomAccessoryVo;
+import com.sd.business.entity.bom.po.BomSpec;
+import com.sd.business.entity.department.constant.DepartmentConstant;
 import com.sd.business.entity.in.po.InOutStorageBom;
+import com.sd.business.entity.inventory.po.Inventory;
 import com.sd.business.entity.purchase.dto.PurchaseDto;
 import com.sd.business.entity.purchase.dto.PurchaseSelectDto;
 import com.sd.business.entity.purchase.enums.PurchaseStatusEnum;
@@ -24,17 +33,21 @@ import com.sd.business.entity.supplier.po.Supplier;
 import com.sd.business.mapper.purchase.PurchaseMapper;
 import com.sd.business.service.apply.ApplyBuyBomService;
 import com.sd.business.service.bom.BomSpecService;
+import com.sd.business.service.inventory.InventoryService;
+import com.sd.business.service.order.OrderService;
 import com.sd.business.service.purchase.PurchaseBomService;
 import com.sd.business.service.purchase.PurchaseService;
+import com.sd.business.upload.ObsUploadService;
 import com.sd.business.util.CodeEnum;
+import com.sd.framework.util.StreamUtil;
+import com.sd.framework.util.excel.util.ExcelUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.*;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.math.RoundingMode;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -58,6 +71,18 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
     @Autowired
     private ApplyBuyBomService applyBuyBomService;
 
+    @Autowired
+    private OrderService orderService;
+
+    @Autowired
+    private InventoryService inventoryService;
+
+    @Autowired
+    private FileInfoService fileInfoService;
+
+    @Autowired
+    private ObsUploadService obsUploadService;
+
     @Override
     public Page<PurchaseVo> getPage(PurchaseSelectDto dto) {
         IWrapper<Purchase> wrapper = getWrapper();
@@ -160,6 +185,39 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
         ArrayList<ApplyBuyBom> applyBuyBomList = new ArrayList<>(applyBuyBomMap.values());
         applyBuyBomService.updateBatchById(applyBuyBomList);
 
+        // 新增备货需求附件
+        List<ApplyBuyBomAccessoryVo> applyData = this.getApplyData(purchaseDto.getApplyBuyId());
+        // 修改表头
+        Map<String, String> keys = new HashMap<>();
+        Date date = DateUtil.date();
+        Date lastMonthDate = DateUtil.offsetMonth(date, -1);
+        Date beforeLastMonthDate = DateUtil.offsetMonth(date, -2);
+        keys.put("currentMonthSales", (DateUtil.month(date) + 1) + "月销量");
+        keys.put("lastMonthSales", (DateUtil.month(lastMonthDate) + 1) + "月销量");
+        keys.put("beforeLastMonthSales", (DateUtil.month(beforeLastMonthDate) + 1) + "月销量");
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        EasyExcel.write(os, ExcelUtil.getClassNew(new ApplyBuyBomAccessoryVo(), keys)).sheet("sheetName").doWrite(applyData);
+        String fileName = "胜德体育备货需求.xlsx";
+        // 上传文件
+        ByteArrayInputStream bis = new ByteArrayInputStream(os.toByteArray());
+        String fileUrl = obsUploadService.uploadFileByte(bis, fileName);
+
+        // 保存文件
+        FileInfo fileInfo = new FileInfo();
+        fileInfo.setFileUrl(fileUrl);
+        fileInfo.setFileName(fileName);
+        fileInfoService.save(fileInfo);
+        // 新增附件列表
+        ObsFile obsFile = new ObsFile();
+        obsFile.setId(fileInfo.getId());
+        obsFile.setFileName(fileName);
+        obsFile.setFileUrl(fileUrl);
+        if (purchaseDto.getFileList() == null) {
+            purchaseDto.setFileList(new ArrayList<>());
+        }
+        purchaseDto.getFileList().add(obsFile);
+
         ObsFileUtil.saveFile(purchaseDto.getFileList(), purchaseDto.getId());
     }
 
@@ -282,4 +340,99 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
         }
         purchaseBomService.updateBatchById(purchaseBomList);
     }
+
+    @Override
+    public Page<PurchaseVo> getPurchaseSelectList(PurchaseSelectDto dto) {
+        IWrapper<Purchase> wrapper = getWrapper();
+        wrapper.like("p", Purchase::getCode, dto.getCode());
+        wrapper.eq("p", Purchase::getFlowStatus, dto.getFlowStatus());
+        wrapper.like("s", Supplier::getName, dto.getSupplierName());
+        wrapper.orderByDesc("p", Purchase::getId);
+
+        // 查询采购单数据
+        return this.baseMapper.getPage(dto.getPage(), wrapper);
+    }
+
+    /**
+     * 获取需求单数据
+     * @param applyBuyId
+     * @return
+     */
+    private List<ApplyBuyBomAccessoryVo> getApplyData(Long applyBuyId) {
+        List<ApplyBuyBomAccessoryVo> accessoryList = new ArrayList<>();
+        List<ApplyBuyBom> list = applyBuyBomService.list(q -> q.eq(ApplyBuyBom::getApplyBuyId, applyBuyId));
+        Map<Long, BomSpec> bomSpecMap = bomSpecService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, list.stream().map(ApplyBuyBom::getBomSpecId).collect(Collectors.toList())));
+        for (ApplyBuyBom applyBuyBom : list) {
+            Long bomSpecId = applyBuyBom.getBomSpecId();
+            BomSpec bomSpec = bomSpecMap.get(bomSpecId);
+            ApplyBuyBomAccessoryVo vo = new ApplyBuyBomAccessoryVo();
+            // 当月时间
+            Date date = DateUtil.date();
+            Date currentMonthBeginDate = DateUtil.beginOfMonth(date);
+            BigDecimal currentMonthSalesQuantity = orderService.getOrderBomSpecOutStorageQuantity(bomSpecId, currentMonthBeginDate, date);
+            // 上个月时间
+            Date lastMonthDate = DateUtil.offsetMonth(date, -1);
+            Date lastMonthBeginDate = DateUtil.beginOfMonth(lastMonthDate);
+            Date lastMonthEndDate = DateUtil.endOfMonth(lastMonthDate);
+            BigDecimal lastMonthSalesQuantity = orderService.getOrderBomSpecOutStorageQuantity(bomSpecId, lastMonthBeginDate, lastMonthEndDate);
+            // 上上个月时间
+            Date beforeLastMonthDate = DateUtil.offsetMonth(date, -2);
+            Date beforeLastMonthBeginDate = DateUtil.beginOfMonth(beforeLastMonthDate);
+            Date beforeLastMonthEndDate = DateUtil.endOfMonth(beforeLastMonthDate);
+            BigDecimal beforeLastMonth00Quantity = orderService.getOrderBomSpecOutStorageQuantity(bomSpecId, beforeLastMonthBeginDate, beforeLastMonthEndDate);
+            List<Inventory> inventoryList = inventoryService.list(q -> q
+                    .eq(Inventory::getBomSpecId, bomSpecId)
+                    .eq(Inventory::getDepartmentId, DepartmentConstant.SD_SPORTS));
+            // 当前库存数
+            BigDecimal inventoryQuantity = ObjectUtil.isEmpty(inventoryList) ? BigDecimal.ZERO : StreamUtil.bigDecimalAdd(inventoryList, Inventory::getQuantity);
+            // 在途数量
+            BigDecimal inTransitSum = purchaseBomService.getPurchaseBomInTransitSum(bomSpecId);
+            // 月平均消耗
+            BigDecimal averageMonthSales = currentMonthSalesQuantity
+                    .add(lastMonthSalesQuantity)
+                    .add(beforeLastMonth00Quantity)
+                    .divide(new BigDecimal(90), 2, RoundingMode.HALF_UP);
+            // 实际销量可消耗天数
+            BigDecimal actualSalesDays;
+            if (ObjectUtil.equals(averageMonthSales, BigDecimal.ZERO)) {
+                actualSalesDays = BigDecimal.ZERO;
+            } else {
+                actualSalesDays = inventoryQuantity.divide(averageMonthSales, 0, RoundingMode.HALF_UP);
+            }
+            // 短缺数量合计
+            BigDecimal shortageQuantity;
+            if (ObjectUtil.equals(currentMonthSalesQuantity, BigDecimal.ZERO)) {
+                shortageQuantity = BigDecimal.ZERO;
+            } else {
+                shortageQuantity = inventoryQuantity
+                        .add(inTransitSum)
+                        .subtract(currentMonthSalesQuantity
+                                .divide(new BigDecimal(90), 2, RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(60))
+                        );
+            }
+            // 规格
+            String length = bomSpec.getLength() == null ? "0" : bomSpec.getLength().stripTrailingZeros().toPlainString();
+            String width = bomSpec.getWidth() == null ? "0" : bomSpec.getWidth().stripTrailingZeros().toPlainString();
+            String height = bomSpec.getHeight() == null ? "0" : bomSpec.getHeight().stripTrailingZeros().toPlainString();
+            // 赋值
+            vo.setBomSpecCode(bomSpec.getCode());
+            vo.setBomSpecName(bomSpec.getName());
+            vo.setSpecification(length + " * " + width + " * " + height);
+            vo.setColour(bomSpec.getColour());
+            vo.setStockQuantity(inventoryQuantity);
+            vo.setInTransitQuantity(inTransitSum);
+            vo.setCurrentMonthSales(currentMonthSalesQuantity);
+            vo.setLastMonthSales(lastMonthSalesQuantity);
+            vo.setBeforeLastMonthSales(beforeLastMonth00Quantity);
+            vo.setAverageMonthSales(averageMonthSales);
+            vo.setActualSalesDays(actualSalesDays);
+            vo.setShortageQuantity(shortageQuantity);
+            vo.setApplyBuyQuantity(applyBuyBom.getQuantity());
+            vo.setApplyBuyQuantity(applyBuyBom.getQuantity());
+            accessoryList.add(vo);
+        }
+
+        return accessoryList;
+    }
 }

+ 84 - 0
sd-business/src/main/java/com/sd/business/upload/ObsUploadService.java

@@ -0,0 +1,84 @@
+package com.sd.business.upload;
+
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.obs.services.ObsClient;
+import com.ruoyi.common.exception.ServiceException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.ByteArrayInputStream;
+import java.util.Date;
+import java.util.StringJoiner;
+
+/**
+ * 文件上传服务
+ */
+@Component
+public class ObsUploadService {
+    @Value("${obs.ak}")
+    private String ak;
+
+    @Value("${obs.sk}")
+    private String sk;
+
+    @Value("${obs.endPoint}")
+    private String endPoint;
+
+    @Value("${obs.url}")
+    private String url;
+
+    @Value("${obs.bucketName}")
+    private String bucketName;
+
+    @Value("${spring.profiles.active}")
+    private String active;
+
+    @Value("${ruoyi.name}")
+    private String name;
+
+    public String uploadFileByte(ByteArrayInputStream bis, String fileName) {
+        if (fileName.length() > 100) {
+            throw new ServiceException("文件名过长,请缩短后重试!!!");
+        }
+
+        // 文件后缀名
+        String suffix = FileUtil.getSuffix(fileName);
+
+        // 文件路径
+        String objectKey = new StringJoiner("/")
+                .add(name)
+                .add(active)
+                .add(DateUtil.format(new Date(), "yyyy/MM/dd"))
+                .add(IdUtil.fastSimpleUUID() + (ObjectUtil.isEmpty(suffix) ? "" : "." + suffix))
+                .toString();
+
+        ObsClient obsClient = null;
+
+        try {
+            // 获取oss链接客户端
+            obsClient = getObsClient();
+            // 上传
+            getObsClient().putObject(bucketName, objectKey, bis);
+        } catch (Exception e) {
+            throw new ServiceException("上传失败");
+        } finally {
+            IoUtil.close(obsClient);
+            IoUtil.close(bis);
+        }
+
+        return objectKey;
+    }
+
+
+    /**
+     * 获取oss链接客户端
+     */
+    private ObsClient getObsClient() {
+        return new ObsClient(ak, sk, endPoint);
+    }
+}

+ 2 - 2
sd-business/src/main/resources/mapper/purchase/PurchaseReturnBomMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sd.business.mapper.purchase.PurchaseReturnBomMapper">
 
-    <select id="getPage" resultType="com.sd.business.entity.purchase.vo.PurchaseReturnBomVo">
+    <select id="getList" resultType="com.sd.business.entity.purchase.vo.PurchaseReturnBomVo">
         select
             prb.id,
             prb.purchase_return_id,
@@ -18,7 +18,7 @@
             bs.name bomSpecName,
             pb.unit_price unitPrice,
             pb.purchase_quantity purchaseQuantity,
-            pb.arrival_quantity arrivalQuantity,
+            (pb.arrival_quantity - pb.return_quantity) canReturnQuantity,
             pb.return_quantity finishReturnQuantity
         from purchase_return_bom prb
             left join purchase_bom pb on prb.purchase_bom_id = pb.id

+ 35 - 0
sd-framework/src/main/java/com/sd/framework/util/excel/util/ExcelUtil.java

@@ -16,7 +16,9 @@
  */
 package com.sd.framework.util.excel.util;
 
+import cn.hutool.core.convert.Convert;
 import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.read.builder.ExcelReaderBuilder;
 import com.alibaba.excel.read.listener.ReadListener;
 import com.alibaba.excel.util.DateUtils;
@@ -35,10 +37,14 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Excel工具类
@@ -176,4 +182,33 @@ public class ExcelUtil {
         }
     }
 
+    /**
+     * 获取修改ExcelProperty的value值的class,用于导出
+     * @param t 类对象
+     * @param keys key为修改的字段和value为它对应表头值
+     * @return
+     */
+    public static <T> Class<T> getClassNew(T t, Map<String, String> keys) {
+        if(t == null) {
+            return null;
+        }
+        try{
+            for(String key: keys.keySet()) {
+                Field value = t.getClass().getDeclaredField(key);
+                value.setAccessible(true);
+                ExcelProperty property = value.getAnnotation(ExcelProperty.class);
+                InvocationHandler invocationHandler = Proxy.getInvocationHandler(property);
+                Field memberValues = invocationHandler.getClass().getDeclaredField("memberValues");
+                memberValues.setAccessible(true);
+                Map<String, Object> values = Convert.toMap(String.class, Object.class, memberValues.get(invocationHandler));
+                values.put("value", new String[]{keys.get(key)});
+                memberValues.set(invocationHandler, values);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return (Class<T>) t.getClass();
+    }
+
 }