Explorar o código

统计分析日期格式调整,bug优化

paidaxin666 %!s(int64=2) %!d(string=hai) anos
pai
achega
8dd217f6d5

+ 10 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/AgvHikOrderDetailInfoServiceImpl.java

@@ -3,17 +3,16 @@ package com.github.zuihou.business.externalApi.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.zuihou.authority.service.common.ParameterService;
 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.common.constant.CacheKey;
+import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -23,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * <p>
@@ -49,7 +49,14 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
     @Override
     @InjectionResult
     public IPage<AgvHikOrderDetailInfo> pageList(IPage page,String statisticalBeginDate,String statisticalEndDate, LbqWrapper<AgvHikOrderDetailInfo> wrapper) {
-        return baseMapper.pageList(page, statisticalBeginDate, statisticalEndDate, wrapper);
+        IPage<AgvHikOrderDetailInfo> pageList = baseMapper.pageList(page, statisticalBeginDate, statisticalEndDate, wrapper);
+        List<AgvHikOrderDetailInfo> records = pageList.getRecords();
+        records.forEach(item->{
+            String datePoor = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+            item.setStatisticalHours(datePoor);
+        });
+        pageList.setRecords(records);
+        return pageList;
     }
 
     @Override

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

@@ -64,12 +64,28 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
     @Override
     @InjectionResult
     public IPage<TaskNode> pageList(IPage page, LbqWrapper<TaskNode> wrapper) {
-        return baseMapper.pageList(page, wrapper, new DataScope());
+        IPage<TaskNode> taskNodeIPage = baseMapper.pageList(page, wrapper, new DataScope());
+        List<TaskNode> records = taskNodeIPage.getRecords();
+        records.forEach(item->{
+            if (item.getEndTime() != null && item.getStartTime() != null){
+                String datePoor = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                item.setStatisticalHours(datePoor);
+            }
+        });
+        taskNodeIPage.setRecords(records);
+        return taskNodeIPage;
     }
 
     @Override
     public List<TaskNode> queryOperatorDetailPerformance(TaskNode taskNode){
-        return baseMapper.queryOperatorDetailPerformance(taskNode);
+        List<TaskNode> taskNodes = baseMapper.queryOperatorDetailPerformance(taskNode);
+        taskNodes.forEach(item->{
+            if (item.getEndTime() != null && item.getStartTime() != null){
+                String datePoor = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                item.setStatisticalHours(datePoor);
+            }
+        });
+        return taskNodes;
     }
 
     @Override
@@ -100,6 +116,12 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
     public IPage<ProductDto> getProductStatistics(Long page, Long limit, ProductVo vo){
         List<ProductDto> statistics = workpieceMapper.getProductStatistics(vo);
         if (!CollectionUtil.isEmpty(statistics)) {
+            statistics.stream().forEach(item->{
+                if (item.getEndTime() != null && item.getStartTime() != null){
+                    String datePoor = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                    item.setHour(datePoor);
+                }
+            });
             Page pages = IPageUtils.getPages(page, limit, statistics);
             return pages;
         }
@@ -202,6 +224,12 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
     public IPage<ProductionStatisticalDto> queryProcedure(Long page, Long limit, ProductVo vo) {
         List<ProductionStatisticalDto> list = baseMapper.queryProcedure(vo);
         if (!CollectionUtil.isEmpty(list)){
+            list.stream().forEach(item->{
+                if (item.getEndTime() != null && item.getStartTime() != null){
+                    String datePoor = DateUtil.getDatePoor(item.getEndTime(), item.getStartTime());
+                    item.setHour(datePoor);
+                }
+            });
             Page pages = IPageUtils.getPages(page, limit, list);
             return pages;
         }

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/AgvHikOrderDetailInfoMapper.xml

@@ -34,6 +34,8 @@
     <select id="pageList" resultMap="BaseResultMap">
         SELECT
             LEFT(ihadi.request_time, 10) AS statisticalDate,
+            STR_TO_DATE(ihadi.request_time, '%Y-%m-%d %H:%i:%s') as startTime,
+            STR_TO_DATE(ihadi.callback_time, '%Y-%m-%d %H:%i:%s') as endTime,
             SUM(TIMESTAMPDIFF(MINUTE, STR_TO_DATE(ihadi.request_time, '%Y-%m-%d %H:%i:%s'), STR_TO_DATE(ihadi.callback_time, '%Y-%m-%d %H:%i:%s')) / 60) AS statisticalHours
         FROM imcs_hik_agv_detail_info ihadi where 1=1
         <if test="statisticalBeginDate != null and statisticalBeginDate != ''">

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

@@ -3,7 +3,7 @@
 <mapper namespace="com.github.zuihou.business.statisticalAnalysis.dao.ProductLinePerformanceMapper">
     <!-- 分页 -->
     <select id="pageList" resultType="com.github.zuihou.business.operationManagementCenter.entity.TaskNode">
-        SELECT tmp1.productionlineId,tmp1.productionlineName,tmp1.statisticalDate,SUM(TIMESTAMPDIFF(MINUTE, tmp1.start_time, tmp1.end_time) / 60) AS statisticalHours, tmp1.org_id FROM
+        SELECT tmp1.productionlineId,tmp1.productionlineName,tmp1.statisticalDate,tmp1.start_time,tmp1.end_time,SUM(TIMESTAMPDIFF(MINUTE, tmp1.start_time, tmp1.end_time) / 60) AS statisticalHours, tmp1.org_id FROM
         (SELECT
           izz.id AS productionlineId,
           izz.name AS productionlineName,
@@ -30,6 +30,8 @@
           e.name,
           (select f.label from c_core_org f where e.org_id = f.id) as orgName,
           date_format(d.start_time,'%Y-%m') AS statisticalDate,
+          d.start_time,
+          d.end_time,
           SUM(TIMESTAMPDIFF(MINUTE, d.start_time,d.end_time) / 60) AS statisticalHours
         FROM zuihou_base_yj_0000.imcs_z_zone izz,
              zuihou_base_yj_0000.imcs_o_order ioo,
@@ -90,10 +92,11 @@
     </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
+        select itp.name,itt.procedure_name,itt.start_time,itt.end_time,itw.bom_name,
+        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
+        left join imcs_tenant_productionresource itp on itt.resource_id = itp.id
+        left join imcs_t_workpiece itw on itt.order_no = itw.order_no
         <where>
             <if test=" vo.bomName != null and vo.bomName != ''">
                 itp.name like concat('%', #{vo.bomName}, '%')

+ 15 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/entity/AgvHikOrderDetailInfo.java

@@ -1,7 +1,6 @@
 package com.github.zuihou.business.externalApi.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
 import io.swagger.annotations.ApiModel;
@@ -9,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 import lombok.experimental.Accessors;
 
+import java.util.Date;
+
 /**
  * <p>
  * 实体类
@@ -136,5 +137,18 @@ public class AgvHikOrderDetailInfo extends Entity<Long> {
     @TableField(exist = false)
     private String statisticalHours;
 
+    /**
+     * 开始时间
+     */
+    @ApiModelProperty(value = "开始时间")
+    @TableField(exist = false)
+    private Date startTime;
+
+    /**
+     * 截止时间
+     */
+    @ApiModelProperty(value = "截止时间")
+    @TableField(exist = false)
+    private Date endTime;
 
 }

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

@@ -9,6 +9,8 @@ import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotEmpty;
 
+import java.util.Date;
+
 import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
 
 /**
@@ -47,11 +49,11 @@ public class ProductDto {
 
     @ApiModelProperty(value = "开始时间")
     @Excel(name = "开始时间" , width = 25)
-    private String startTime;
+    private Date startTime;
 
     @ApiModelProperty(value = "结束时间")
     @Excel(name = "结束时间" , width = 25)
-    private String endTime;
+    private Date endTime;
 
     @ApiModelProperty(value = "时长(小时)")
     @Excel(name = "时长(小时)" , width = 20)

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

@@ -24,6 +24,10 @@ public class ProductionStatisticalDto {
     @Excel(name = "机床名称",width = 20)
     private String name;
 
+    @ApiModelProperty(value = "产品名称")
+    @Excel(name = "产品名称",width = 20)
+    private String bomName;
+
     /**
      * 工序ID
      */
@@ -55,7 +59,7 @@ public class ProductionStatisticalDto {
     @ApiModelProperty(value = "小时")
     @TableField("hour")
     @Excel(name = "小时")
-    private Float hour;
+    private String hour;
 }