Răsfoiți Sursa

报表统计

paidaxin666 2 ani în urmă
părinte
comite
9f7e594388
14 a modificat fișierele cu 642 adăugiri și 55 ștergeri
  1. 12 3
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/WorkpieceMapper.java
  2. 37 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/ProductLinePerformanceService.java
  3. 7 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/dao/ProductLinePerformanceMapper.java
  4. 146 5
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/impl/ProductLinePerformanceServiceImpl.java
  5. 51 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/IPageUtils.java
  6. 25 26
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TWorkpieceMapper.xml
  7. 7 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/statisticalAnalysis/ProductLinePerformanceMapper.xml
  8. 56 19
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/statisticalAnalysis/ProductLinePerformanceController.java
  9. 17 0
      imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/DateUtil.java
  10. 63 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductDto.java
  11. 68 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductInfoDto.java
  12. 67 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductInfoExcelDto.java
  13. 61 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductionStatisticalDto.java
  14. 25 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/vo/ProductVo.java

+ 12 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/WorkpieceMapper.java

@@ -4,8 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
-import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.tenant.dto.ProductDto;
+import com.github.zuihou.tenant.dto.ProductInfoDto;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -27,7 +28,15 @@ public interface WorkpieceMapper extends SuperMapper<TWorkpiece> {
 
     void updatePlanWorkpiecePrority(Map workPieceParam);
 
-    List<Map> workpieceStatistics(Map map);
+    /**
+     * 产品流转详情
+     * @return
+     */
+    List<ProductInfoDto> selectProductInfo();
 
-    List<Map> resourceStatistics(Map map);
+    /**
+     * 产品流转汇总
+     * @return
+     */
+    List<ProductDto> getProductStatistics();
 }

+ 37 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/ProductLinePerformanceService.java

@@ -2,10 +2,15 @@ package com.github.zuihou.business.statisticalAnalysis;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.service.SuperCacheService;
-import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.tenant.dto.ProductDto;
+import com.github.zuihou.tenant.dto.ProductInfoDto;
+import com.github.zuihou.tenant.dto.ProductionStatisticalDto;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -26,4 +31,35 @@ public interface ProductLinePerformanceService extends SuperCacheService<TaskNod
     List<TaskNode> queryOperatorDetailsPerformance(TaskNode params);
 
     List<TaskNode> queryProductionLineOee(TaskNode params);
+
+
+    /**
+     * 产品流转详汇总
+     */
+    List<ProductDto> getProductStatistics();
+
+    /**
+     * 产品流转详情
+     * @return
+     */
+    IPage<ProductInfoDto>  getProductInfoStatistics(Long page, Long limit);
+
+    void expectProductInfo(HttpServletResponse response)  throws IOException;
+
+    void expectProduct(HttpServletRequest request, HttpServletResponse response)throws IOException;
+
+    /**
+     * 设备工时统计
+     * @param page
+     * @param limit
+     * @return
+     */
+    IPage<ProductionStatisticalDto> queryProcedure(Long page, Long limit);
+
+    /**
+     * 设备工时导出
+     * @param request
+     * @param response
+     */
+    void expectProcedure(HttpServletRequest request, HttpServletResponse response)throws IOException ;
 }

+ 7 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/dao/ProductLinePerformanceMapper.java

@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
-import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.database.mybatis.auth.DataScope;
+import com.github.zuihou.tenant.dto.ProductionStatisticalDto;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -38,4 +38,10 @@ public interface ProductLinePerformanceMapper extends SuperMapper<TaskNode> {
     List<TaskNode> queryOperatorDetailsPerformance(TaskNode taskNode);
 
     List<TaskNode> queryProductionLineOee(TaskNode taskNode);
+
+    /**
+     * 设备工时统计
+     * @return
+     */
+    List<ProductionStatisticalDto> queryProcedure();
 }

+ 146 - 5
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/impl/ProductLinePerformanceServiceImpl.java

@@ -1,27 +1,41 @@
 package com.github.zuihou.business.statisticalAnalysis.impl;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
-import com.github.zuihou.business.externalApi.dao.AgvHikOrderDetailInfoMapper;
-import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
-import com.github.zuihou.business.externalApi.service.AgvHikOrderDetailInfoService;
+import com.github.zuihou.business.operationManagementCenter.dao.WorkpieceMapper;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.statisticalAnalysis.ProductLinePerformanceService;
 import com.github.zuihou.business.statisticalAnalysis.dao.ProductLinePerformanceMapper;
+import com.github.zuihou.business.util.IPageUtils;
 import com.github.zuihou.common.constant.CacheKey;
+import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
-import com.github.zuihou.utils.BeanPlusUtil;
+import com.github.zuihou.tenant.dto.ProductDto;
+import com.github.zuihou.tenant.dto.ProductInfoDto;
+import com.github.zuihou.tenant.dto.ProductInfoExcelDto;
+import com.github.zuihou.tenant.dto.ProductionStatisticalDto;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -37,6 +51,10 @@ import java.util.List;
 
 public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<ProductLinePerformanceMapper, TaskNode> implements ProductLinePerformanceService {
 
+
+    @Autowired
+    private WorkpieceMapper workpieceMapper;
+
     @Override
     protected String getRegion() {
         return CacheKey.USER;
@@ -77,4 +95,127 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
     }
 
 
+    @Override
+    public List<ProductDto> getProductStatistics(){
+        List<ProductDto> statistics = workpieceMapper.getProductStatistics();
+        return statistics;
+    }
+
+    /**
+     * 产品流转详情
+     * @return
+     */
+    @Override
+    public IPage<ProductInfoDto> getProductInfoStatistics(Long page, Long limit) {
+        List<ProductInfoDto> productInfoDtos = workpieceMapper.selectProductInfo();
+        if (!CollectionUtil.isEmpty(productInfoDtos)) {
+            List<ProductInfoDto> productInfos = productInfoDtos.stream().map(item -> {
+                ProductInfoDto productInfoDto = BeanUtil.toBean(item, ProductInfoDto.class);
+                if (item.getEndTime() != null && item.getStartTime() != null) {
+                    String hour = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                    productInfoDto.setHour(hour);
+                } else {
+                    productInfoDto.setHour("0");
+                }
+                return productInfoDto;
+            }).collect(Collectors.toList());
+            if (!CollectionUtil.isEmpty(productInfos)) {
+                productInfos.sort((o1, o2) -> {
+                    return o2.getPlanStartTime().compareTo(o1.getPlanStartTime());
+                });
+            }
+            Page pages = IPageUtils.getPages(page, limit, productInfos);
+            return pages;
+        }
+        return null;
+    }
+
+    @Override
+    public void expectProduct(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        List<ProductDto> productStatistics = getProductStatistics();
+        // 设置响应输出的头类型
+        // 设置响应输出的头类型
+        response.setHeader("content-Type", "application/vnd.ms-excel");
+        // 设计导出文件的名称,尽量不要中文
+        String fileName = new String("产品流转详汇总.xls".getBytes(), "ISO-8859-1");
+        response.setHeader("Content-Disposition","attachment;filename="+ fileName);
+        //输出流。
+        ServletOutputStream out = response.getOutputStream();
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("产品流转详汇总", "产品流转详汇总"), ProductDto.class, productStatistics);
+        workbook.write(out);
+    }
+
+    @Override
+    public void expectProductInfo(HttpServletResponse response) throws IOException {
+        List<ProductInfoDto> productInfoDtos = workpieceMapper.selectProductInfo();
+        List<ProductInfoDto> productInfos = productInfoDtos.stream().map(item->{
+            ProductInfoDto productInfoDto = BeanUtil.toBean(item, ProductInfoDto.class);
+            if (item.getEndTime() != null && item.getStartTime() != null) {
+                String hour = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                productInfoDto.setHour(hour);
+            }else {
+                productInfoDto.setHour("0");
+            }
+            return productInfoDto;
+        }).collect(Collectors.toList());
+        List<ProductInfoExcelDto> excels =productInfos.stream().map(item->{
+            ProductInfoExcelDto excelDto = BeanUtil.toBean(item,ProductInfoExcelDto.class);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            excelDto.setPlanStartTime(item.getPlanStartTime()!=null ? simpleDateFormat.format(item.getPlanStartTime()):"");
+            excelDto.setPlanEndTime(item.getPlanEndTime()!=null ? simpleDateFormat.format(item.getPlanEndTime()):"");
+            excelDto.setStartTime(item.getStartTime()!=null ? simpleDateFormat.format(item.getStartTime()):"");
+            excelDto.setEndTime(item.getEndTime()!=null ? simpleDateFormat.format(item.getEndTime()):"");
+            return excelDto;
+        }).collect(Collectors.toList());
+        // 设置响应输出的头类型
+        // 设置响应输出的头类型
+        response.setHeader("content-Type", "application/vnd.ms-excel");
+        // 设计导出文件的名称,尽量不要中文
+        String fileName = new String("产品流转详情.xls".getBytes(), "ISO-8859-1");
+        response.setHeader("Content-Disposition","attachment;filename="+ fileName);
+        //输出流。
+        ServletOutputStream out = response.getOutputStream();
+        //将数据导出到Excel
+        //参数1:ExportParams对象 参数2:导出的类型  参数3:导出的数据集合
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("产品流转详情", "产品流转详情"), ProductInfoExcelDto.class, excels);
+        //使用流将excel写入到指定的位置
+        workbook.write(out);//将数据输出
+    }
+
+
+
+    /**
+     * 设备工时统计
+     * @param page
+     * @param limit
+     * @return
+     */
+    @Override
+    public IPage<ProductionStatisticalDto> queryProcedure(Long page, Long limit) {
+        List<ProductionStatisticalDto> list = baseMapper.queryProcedure();
+        Page pages = IPageUtils.getPages(page, limit, list);
+        return pages;
+    }
+
+    /**
+     * 设备工时导出
+     * @param request
+     * @param response
+     */
+    @Override
+    public void expectProcedure(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        List<ProductionStatisticalDto> list = baseMapper.queryProcedure();
+        // 设置响应输出的头类型
+        // 设置响应输出的头类型
+        response.setHeader("content-Type", "application/vnd.ms-excel");
+        // 设计导出文件的名称,尽量不要中文
+        String fileName = new String("设备工时管理.xls".getBytes(), "ISO-8859-1");
+        response.setHeader("Content-Disposition","attachment;filename="+ fileName);
+        //输出流。
+        ServletOutputStream out = response.getOutputStream();
+        // 创建参数对象(用来设定excel得sheet的内容等信息)
+        // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("设备工时管理", "设备工时管理"), ProductionStatisticalDto.class, list);
+        workbook.write(out);
+    }
 }

+ 51 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/IPageUtils.java

@@ -0,0 +1,51 @@
+package com.github.zuihou.business.util;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zhengxin
+ * @since 2022/11/14 15:39
+ */
+public class IPageUtils {
+    /**
+     * 分页函数
+     * @param pageNo   当前页数
+     * @param limit  每一页的数据条数
+     * @param list  要进行分页的数据列表
+     * @return  当前页要展示的数据
+     */
+    public static Page getPages(Long pageNo, Long limit, List list) {
+        Integer currentPage = Math.toIntExact(pageNo);
+        Integer pageSize = Math.toIntExact(limit);
+
+        Page page = new Page();
+        int size = list.size();
+
+        if(pageSize > size) {
+            pageSize = size;
+        }
+
+        // 求出最大页数,防止currentPage越界
+        int maxPage = size % pageSize == 0 ? size / pageSize : size / pageSize + 1;
+
+        if(currentPage > maxPage) {
+            currentPage = maxPage;
+        }
+
+        // 当前页第一条数据的下标
+        int curIdx = currentPage > 1 ? (currentPage - 1) * pageSize : 0;
+
+        List pageList = new ArrayList();
+
+        // 将当前页的数据放进pageList
+        for(int i = 0; i < pageSize && curIdx + i < size; i++) {
+            pageList.add(list.get(curIdx + i));
+        }
+
+        page.setCurrent(currentPage).setSize(pageSize).setTotal(list.size()).setRecords(pageList);
+        return page;
+    }
+}

+ 25 - 26
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TWorkpieceMapper.xml

@@ -40,33 +40,32 @@
          where itw.plan_id = #{planId}
     </update>
 
-    <select id="workpieceStatistics" resultType="map">
-        select * from (
-        select count(DISTINCT w.complete_batch_no) as cnt, t.procedure_no, t.procedure_name, t.procedure_order, t.procedure_id as id from imcs_t_workpiece w
-        left join imcs_t_task t on w.procedure_id = t.procedure_id
-        where w.order_id = #{orderId} and w.is_end = '0' and t.procedure_no is not null
-        group by t.procedure_no order by t.procedure_order desc ) s LIMIT 10
+
+    <!--产品流转详情-->
+    <select id="selectProductInfo" resultType="com.github.zuihou.tenant.dto.ProductInfoDto">
+        select ioo.order_no,ipp.start_time as planStartTime,ipp.end_time as planEndTime,
+               itt.start_time,itt.end_time,TIMESTAMPDIFF(HOUR,itt.start_time,itt.end_time) as hour,
+       itw.bom_name,itw.procedure_name,ioo.remark,itp.name
+        from imcs_o_order ioo left join imcs_p_plan ipp on ioo.id = ipp.order_id
+            left join imcs_t_task itt on ioo.id = itt.order_id
+            left join imcs_t_workpiece itw on ioo.id = itw.order_id
+            left join imcs_tenant_productionresource itp on itp.id = itt.resource_id
     </select>
 
-    <select id="resourceStatistics" resultType="map">
-        SELECT * FROM  (
-                SELECT
-                    count(
-                            DISTINCT w.complete_batch_no
-                        ) AS cnt,
-                    t.`name`
-                FROM
-                    imcs_t_workpiece w
-                        LEFT JOIN imcs_p_productionresource_position p ON w.storge_id = p.storge_id
-                        LEFT JOIN imcs_tenant_productionresource t ON t.id = p.resource_id
-                WHERE
-                    w.order_id = #{orderId} and
-                    w.is_end = '0' and t.name is not null
-                GROUP BY
-                    t.id
-                ORDER BY
-                    t.id DESC
-            ) s order by cnt DESC
-            LIMIT 10
+
+    <!--产品流转汇总-->
+    <select id="getProductStatistics" resultType="com.github.zuihou.tenant.dto.ProductDto">
+        select ioo.order_no,ioo.remark,
+               ipp.start_time as planStartTime,
+               ipp.end_time as planEndTime,
+               min(itt.start_time) as startTime ,max(itt.end_time) as endTime ,count(itt.procedure_no) as num,
+               TIME_TO_SEC(TIMEDIFF( max(itt.end_time),min(itt.start_time)))/3600 as hour,
+       itw.bom_name
+        from imcs_o_order ioo
+            left join imcs_p_plan ipp on ioo.order_no = ipp.order_no
+            left join imcs_t_task itt on ioo.order_no = itt.order_no
+            left join imcs_t_workpiece itw on ioo.order_no = itw.order_no
+        group by ioo.order_no
     </select>
+
 </mapper>

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/statisticalAnalysis/ProductLinePerformanceMapper.xml

@@ -88,4 +88,11 @@
         </if>
         GROUP BY  itp.id  order by itp.id
     </select>
+
+    <select id="queryProcedure" resultType="com.github.zuihou.tenant.dto.ProductionStatisticalDto">
+        select itp.name,itt.procedure_name,itt.start_time,itt.end_time,
+               TIME_TO_SEC(TIMEDIFF(itt.end_time,itt.start_time))/3600 as hour
+        from imcs_t_task itt
+            left join imcs_tenant_productionresource itp on itt.resource_id = itp.id
+    </select>
 </mapper>

+ 56 - 19
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/statisticalAnalysis/ProductLinePerformanceController.java

@@ -1,45 +1,33 @@
 package com.github.zuihou.business.controller.statisticalAnalysis;
 
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.convert.Convert;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.zuihou.authority.entity.auth.User;
-import com.github.zuihou.authority.entity.core.Org;
-import com.github.zuihou.authority.enumeration.auth.AuthorizeType;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.request.PageParams;
-import com.github.zuihou.business.externalApi.dto.AgvHikOrderDetailInfoPageDTO;
-import com.github.zuihou.business.externalApi.dto.AgvHikOrderDetailInfoSaveDTO;
-import com.github.zuihou.business.externalApi.dto.AgvHikOrderDetailInfoUpdateDTO;
-import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
-import com.github.zuihou.business.externalApi.service.AgvHikOrderDetailInfoService;
 import com.github.zuihou.business.operationManagementCenter.dto.TaskNodePageDTO;
 import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeSaveDTO;
 import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeUpdateDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
-import com.github.zuihou.business.productionReadyCenter.entity.MToolClamp;
 import com.github.zuihou.business.statisticalAnalysis.ProductLinePerformanceService;
 import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
-import com.github.zuihou.tenant.entity.TenantRoleAuthority;
+import com.github.zuihou.tenant.dto.ProductDto;
+import com.github.zuihou.tenant.dto.ProductInfoDto;
+import com.github.zuihou.tenant.dto.ProductionStatisticalDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.github.zuihou.utils.StrPool.EMPTY;
-
 
 /**
  * <p>
@@ -109,4 +97,53 @@ public class ProductLinePerformanceController extends SuperController<ProductLin
         oee.put("yData",yData);
         return success(oee);
     }
+
+    @ApiOperation(value = "产品流转详汇总", notes = "产品流转详汇总")
+    @PostMapping("/getProductStatistics")
+    @SysLog("产品流转详汇总")
+    public R<List<ProductDto>> getProductStatistics() {
+        return success(baseService.getProductStatistics());
+    }
+
+    @ApiOperation(value = "产品流转详情", notes = "产品流转详情")
+    @PostMapping("/getProductInfoStatistics/{page}/{limit}")
+    @SysLog("产品流转详情")
+    public R<IPage<ProductInfoDto>> getProductInfoStatistics(@PathVariable long page,
+                                                             @PathVariable long limit) {
+        return success(baseService.getProductInfoStatistics(page,limit));
+    }
+
+    @ApiOperation(value = "产品流转详情excle导出", notes = "产品流转详情excle导出")
+    @GetMapping("/expectProductInfo")
+    @SysLog("产品流转详情excle导出")
+    public void expectProductInfo(HttpServletResponse response) throws IOException {
+        baseService.expectProductInfo(response);
+    }
+
+    @ApiOperation(value = "产品流转详汇总导出", notes = "产品流转详汇总导出")
+    @GetMapping("/expectProduct")
+    @SysLog("产品流转详汇总导出")
+    public void expectProduct(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        baseService.expectProduct(request,response);
+    }
+
+    /**
+     * 设备工时统计
+     * @param page
+     * @param limit
+     * @return
+     */
+    @ApiOperation(value = "设备工时统计", notes = "查询设备工时管理")
+    @PostMapping("/queryProcedure/{page}/{limit}")
+    public R<IPage<ProductionStatisticalDto>> queryProcedure(@PathVariable Long page,
+                                                             @PathVariable Long limit) {
+        return success(baseService.queryProcedure(page,limit));
+    }
+
+    @ApiOperation(value = "设备工时导出", notes = "设备工时导出管理")
+    @GetMapping("/expectProcedure")
+    @SysLog("设备工时导出")
+    public void expectProcedure(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        baseService.expectProcedure(request,response);
+    }
 }

+ 17 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/DateUtil.java

@@ -544,6 +544,23 @@ public class DateUtil {
 		return dt;
 	}
 
+	public static String getDatePoor(Date endDate, Date nowDate) {
+		long nd = 1000 * 24 * 60 * 60;
+		long nh = 1000 * 60 * 60;
+		long nm = 1000 * 60;
+		// 获得两个时间的毫秒时间差异
+		long diff = endDate.getTime() - nowDate.getTime();
+		// 计算差多少天
+		long day = diff / nd;
+		// 计算差多少小时
+		long hour = diff % nd / nh;
+		// 计算差多少分钟
+		long min = diff % nd % nh / nm;
+		// 计算差多少秒//输出结果
+		// long sec = diff % nd % nh % nm / ns;
+		return day + "天" + hour + "小时" + min + "分钟";
+	}
+
 	public static void main(String[] args) throws Exception {
 //    	System.out.println(DateUtil.formatTime(DateUtil.stringToDate5("13/06/2016")));
 //    	System.out.println(DateUtil.formatTime(new Date("13/06/2016")));

+ 63 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductDto.java

@@ -0,0 +1,63 @@
+package com.github.zuihou.tenant.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+/**
+ * @author zx
+ * @date 2023-04-03 14:41
+ */
+@Data
+@ApiModel(value = "ProductInfoDto", description = "产品流转详汇总")
+public class ProductDto {
+
+    /**
+     * 订单编号
+     */
+    @ApiModelProperty(value = "订单编号")
+    @NotEmpty(message = "订单编号不能为空")
+    @Length(max = 128, message = "订单编号长度不能超过128")
+    @TableField(value = "order_no", condition = LIKE)
+    @Excel(name = "订单编号" , width = 20)
+    private String orderNo;
+
+    @ApiModelProperty(value = "产品名称")
+    @Excel(name = "产品名称" , width = 20)
+    private String bomName;
+
+    @ApiModelProperty(value = "工序数量")
+    @Excel(name = "工序数量" , width = 10)
+    private Integer num;
+
+    @ApiModelProperty(value = "计划开始时间")
+    @Excel(name = "计划开始时间" , width = 25)
+    private String planStartTime;
+
+    @ApiModelProperty(value = "计划结束时间")
+    @Excel(name = "计划结束时间" , width = 25)
+    private String planEndTime;
+
+    @ApiModelProperty(value = "开始时间")
+    @Excel(name = "开始时间" , width = 25)
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @Excel(name = "结束时间" , width = 25)
+    private String endTime;
+
+    @ApiModelProperty(value = "时长(小时)")
+    @Excel(name = "时长(小时)" , width = 20)
+    private String hour;
+
+    @ApiModelProperty(value = "说明")
+    @Excel(name = "说明" , width = 35)
+    private String remark;
+}

+ 68 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductInfoDto.java

@@ -0,0 +1,68 @@
+package com.github.zuihou.tenant.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.Date;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+/**
+ * @author zx
+ * @date 2023-04-03 14:41
+ */
+@Data
+@ApiModel(value = "ProductInfoDto", description = "产品流转详情")
+public class ProductInfoDto {
+
+    /**
+     * 订单编号
+     */
+    @ApiModelProperty(value = "订单编号")
+    @NotEmpty(message = "订单编号不能为空")
+    @Length(max = 128, message = "订单编号长度不能超过128")
+    @TableField(value = "order_no", condition = LIKE)
+    @Excel(name = "订单编号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "产品名称")
+    @Excel(name = "产品名称")
+    private String bomName;
+
+    /**
+     * 分配设备ID
+     */
+    @ApiModelProperty(value = "分配设备ID")
+    @TableField("resource_id")
+    @Excel(name = "分配设备ID")
+    private String name;
+
+    @ApiModelProperty(value = "计划开始时间")
+    @Excel(name = "计划开始时间")
+    private Date planStartTime;
+
+    @ApiModelProperty(value = "计划结束时间")
+    @Excel(name = "计划结束时间")
+    private Date planEndTime;
+
+    @ApiModelProperty(value = "开始时间")
+    @Excel(name = "开始时间")
+    private Date startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @Excel(name = "结束时间")
+    private Date endTime;
+
+    @ApiModelProperty(value = "时长(小时)")
+    @Excel(name = "时长(小时)")
+    private String hour;
+
+    @ApiModelProperty(value = "说明")
+    @Excel(name = "说明")
+    private String remark;
+}

+ 67 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductInfoExcelDto.java

@@ -0,0 +1,67 @@
+package com.github.zuihou.tenant.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+/**
+ * @author zx
+ * @date 2023-04-03 14:41
+ */
+@Data
+@ApiModel(value = "ProductInfoExcelDto", description = "产品流转详情")
+public class ProductInfoExcelDto {
+
+    /**
+     * 订单编号
+     */
+    @ApiModelProperty(value = "订单编号")
+    @NotEmpty(message = "订单编号不能为空")
+    @Length(max = 128, message = "订单编号长度不能超过128")
+    @TableField(value = "order_no", condition = LIKE)
+    @Excel(name = "订单编号" , width = 20)
+    private String orderNo;
+
+    @ApiModelProperty(value = "产品名称")
+    @Excel(name = "产品名称" , width = 20)
+    private String bomName;
+
+    /**
+     * 分配设备ID
+     */
+    @ApiModelProperty(value = "分配设备ID")
+    @TableField("resource_id")
+    @Excel(name = "设备" , width = 25)
+    private String name;
+
+    @ApiModelProperty(value = "计划开始时间")
+    @Excel(name = "计划开始时间" , width = 25)
+    private String planStartTime;
+
+    @ApiModelProperty(value = "计划结束时间")
+    @Excel(name = "计划结束时间" , width = 25)
+    private String planEndTime;
+
+    @ApiModelProperty(value = "开始时间")
+    @Excel(name = "开始时间" , width = 25)
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @Excel(name = "结束时间" , width = 25)
+    private String endTime;
+
+    @ApiModelProperty(value = "时长(小时)")
+    @Excel(name = "时长(小时)" , width = 25)
+    private String hour;
+
+    @ApiModelProperty(value = "说明")
+    @Excel(name = "说明" , width = 35)
+    private String remark;
+}

+ 61 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/dto/ProductionStatisticalDto.java

@@ -0,0 +1,61 @@
+package com.github.zuihou.tenant.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+import static com.github.zuihou.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
+
+/**
+ * @author zx
+ * @date 2023-04-14 12:46
+ */
+@Data
+@ApiModel(value = "ProductionStatisticalDto", description = "设备工时统计")
+public class ProductionStatisticalDto {
+
+    @ApiModelProperty(value = "机床名称")
+    @Length(max = 256, message = "名称长度不能超过256")
+    @Excel(name = "机床名称",width = 20)
+    private String name;
+
+    /**
+     * 工序ID
+     */
+    @ApiModelProperty(value = "工序名称")
+    @TableField("procedure_name")
+    @Excel(name = "工序名称")
+    private String procedureName;
+
+
+    /**
+     * 开始时间
+     */
+    @ApiModelProperty(value = "开始时间")
+    @TableField("start_time")
+    @Excel(name = "开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
+    private Date startTime;
+
+    /**
+     * 截止时间
+     */
+    @ApiModelProperty(value = "截止时间")
+    @TableField("end_time")
+    @Excel(name = "截止时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
+    private Date endTime;
+
+    /**
+     * 截止时间
+     */
+    @ApiModelProperty(value = "小时")
+    @TableField("hour")
+    @Excel(name = "小时")
+    private Float hour;
+}
+
+

+ 25 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/vo/ProductVo.java

@@ -0,0 +1,25 @@
+package com.github.zuihou.tenant.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author zx
+ * @date 2023-04-17 8:57
+ */
+@Data
+public class ProductVo {
+
+    @ApiModelProperty(value = "产品名称")
+    @Excel(name = "产品名称" , width = 20)
+    private String bomName;
+
+    @ApiModelProperty(value = "开始时间")
+    @Excel(name = "开始时间" , width = 25)
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @Excel(name = "结束时间" , width = 25)
+    private String endTime;
+}