Ver código fonte

补充新增代码

oyq28 1 ano atrás
pai
commit
87e41e29b4
12 arquivos alterados com 706 adições e 0 exclusões
  1. 204 0
      imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/DyTaskNode.java
  2. 10 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/dao/MesAttachmentMapper.java
  3. 11 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/MesAttachmentService.java
  4. 13 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/MesAttachmentServiceImpl.java
  5. 5 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/ProductLinePerformanceService.java
  6. 6 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/dao/ProductLinePerformanceMapper.java
  7. 22 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/statisticalAnalysis/impl/ProductLinePerformanceServiceImpl.java
  8. 156 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ZipFileUtils.java
  9. 51 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/MesNoticeMapper.xml
  10. 120 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/statisticalAnalysis/ProductLinePerformanceMapper.xml
  11. 12 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/statisticalAnalysis/ProductLinePerformanceController.java
  12. 96 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/entity/MesAttachment.java

+ 204 - 0
imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/DyTaskNode.java

@@ -0,0 +1,204 @@
+package com.github.zuihou;
+
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
+import com.github.zuihou.business.util.CommonUtil;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.DictionaryKey;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.tenant.service.CodeRuleService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.groupingBy;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@RunWith(SpringJUnit4ClassRunner.class)
+@Slf4j
+public class DyTaskNode {
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private BomProcedureService bomProcedureService;
+
+    @Autowired
+    private ResourceAutoCodeService resourceAutoCodeService;
+
+    @Autowired
+    private CodeRuleService codeRuleService;
+
+    @Autowired
+    private ProductionresourceBizMapper productionresourceBizMapper;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Before
+    public void setTenant() {
+        BaseContextHandler.setUserId(3L);
+        BaseContextHandler.setTenant("0000");
+    }
+
+    private Long getResourceIdByAutoCode(String resourceType) {
+        String robotName = DictionaryKey.YJ_ROBOT_NODES.get(resourceType);
+        //String robotName = DictionaryKey.LINE_ROBOT_NODES.get(resourceType);
+        Productionresource productionresource =
+                productionresourceBizMapper.selectOne(new LbqWrapper<Productionresource>().eq(Productionresource::getName,
+                        robotName));
+        return productionresource.getId();
+    }
+
+    @Test
+    public void createNode(){
+        /*
+        String[] ids = {"1623916114629099520","1623916114633293824","1623916114645876736","1623916114687819776","1623916114687819779","1623916114700402688","1623916114738151424","1623916114738151427","1623916114750734336"};
+
+        List<TTask> taskList = taskService.list(new LbqWrapper<TTask>().in(TTask::getId, ids).orderByDesc(TTask::getPrority));
+
+        Map<String, List<TTask>> taskMap = taskList.stream().collect(groupingBy(TTask::getCompleteBatchNo));
+
+        List<Long> procedureList = taskList.stream().map(p -> p.getProcedureId()).collect(Collectors.toList());
+        List<BomProcedure> bomProcedureList =
+                bomProcedureService.list(Wraps.<BomProcedure>lbQ().in(BomProcedure::getId, procedureList));
+
+        Map<Long, BomProcedure> bpMap = bomProcedureList.stream().collect(Collectors.toMap(BomProcedure::getId,
+                t -> t));
+
+        List<ResourceAutoCode> resourceAutoCodeList =
+                resourceAutoCodeService.list(Wraps.<ResourceAutoCode>lbQ().orderByAsc(ResourceAutoCode::getWeight));
+        Map<Long, List<ResourceAutoCode>> resourceAutoCodeMap =
+                resourceAutoCodeList.stream().collect(groupingBy(ResourceAutoCode::getBusinessId));
+
+        List<TaskNode> taskNodeList = new ArrayList<TaskNode>();
+
+        for (String key : taskMap.keySet()) {
+            int i = 1;
+            for (TTask t : taskList) {
+                //taskList里面包含了所有的一次勾选的所有任务
+                if (!key.equals(t.getCompleteBatchNo())) {
+                    continue;
+                }
+
+                //取出resrouceId
+                Long resourceBusinessId = t.getResourceBusinessId();
+                List<ResourceAutoCode> autoCodeList = resourceAutoCodeMap.get(resourceBusinessId);
+
+                //查询所有的父节点
+                List<ResourceAutoCode> parentResourceAutoCodeList =
+                        autoCodeList.stream().filter(a -> a.getParentId().longValue() == 0L).collect(Collectors.toList());
+//                for (ResourceAutoCode pautoCode : parentResourceAutoCodeList) {//父节点
+                for (int parentCount = 0; parentCount < parentResourceAutoCodeList.size(); parentCount++) { //父节点
+                    ResourceAutoCode pautoCode = parentResourceAutoCodeList.get(parentCount);
+                    List<ResourceAutoCode> childResourceAutoCodeList =
+                            autoCodeList.stream().filter(a -> pautoCode.getId().toString().equals(a.getParentId().toString())).collect(Collectors.toList());
+                    List<ResourceAutoCode> agvlist =
+                            childResourceAutoCodeList.stream().filter(a -> "2".equals(a.getCategory())).collect(Collectors.toList());
+                    for (int count = 0; count < childResourceAutoCodeList.size(); count++) { //子节点
+                        ResourceAutoCode autoCode = childResourceAutoCodeList.get(count);
+                        ResourceAutoCode nextAutoCode = null;
+                        if (count < childResourceAutoCodeList.size() - 1) {
+                            nextAutoCode = childResourceAutoCodeList.get(count + 1);
+                        }
+                        TaskNode taskNode = new TaskNode();
+                        // 包含agv动作
+                        if (count == 0 && agvlist.size() > 0) {
+                            taskNode.setFindAgvFlag("1");
+                        } else {
+                            taskNode.setFindAgvFlag("0");
+                        }
+                        taskNode.setTaskId(t.getId()).setOrderId(t.getOrderId())
+                                .setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
+                        taskNode.setAutoNode(autoCode).setNodeNo(autoCode.getNo()).setCompleteBatchNo(t.getCompleteBatchNo())
+                                .setExeStatus("1").setPrority(autoCode.getWeight()).setNodeName(autoCode.getName()).setProcedureId(t.getProcedureId());
+
+                        String taskType = bpMap.get(t.getProcedureId()).getType();
+                        //依据设备类型判断调用接口类型
+                        if ("1".equals(taskNode.getAutoNode().getCategory())) {
+                            taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
+                            //加工设备的设备ID来源于加工任务设备
+                            taskNode.setResourceId(t.getResourceId());
+                            taskNode.setTargetResourceId(t.getResourceId());
+                        } else if ("3".equals(taskNode.getAutoNode().getCategory())) {
+                            String command = autoCode.getCommand();
+                            taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
+                            //根据配置确定操作设备ID
+                            //String resourceType = autoCode.getResourceId()!=null? autoCode.getResourceId().toString
+                            // () : null;
+                            // 放,判断后一个动作节点是否是agv搬运,如果是,这个targetResourceId设置成空
+                            if ("2".equals(command)) {
+                                // 最后一个节点
+                                if (count == childResourceAutoCodeList.size() - 1) {
+                                    taskNode.setTargetResourceId(t.getResourceId());
+                                } else {
+                                    if (null == nextAutoCode.getResourceId()) {
+                                        taskNode.setTargetResourceId(null);
+                                    }
+                                }
+                            }
+
+                            if (null != autoCode.getResourceId()) {
+                                taskNode.setResourceId(getResourceIdByAutoCode(autoCode.getResourceId().toString()));
+                            }
+                        } else if ("2".equals(taskNode.getAutoNode().getCategory())) {
+                            taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_AGV);
+                        } else if ("4".equals(taskNode.getAutoNode().getCategory())) {
+                            taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_WMS);
+
+                            if (taskType.contains("上料") || taskType.contains("换料")) {
+                                taskNode.setNodeType("1");
+                                taskNode.setResourceId(t.getResourceId());
+                            } else if (taskType.contains("下料")) {
+                                taskNode.setNodeType("2");
+                                taskNode.setResourceId(t.getResourceId());
+                            } else if (taskType.contains("翻面")) {
+                                taskNode.setNodeType("4");
+                                taskNode.setResourceId(t.getResourceId());
+                            } else {
+                                taskNode.setNodeType("0");
+                            }
+                        }
+                        taskNode.setCompleteBatchSort(i);
+
+
+                        taskNodeList.add(taskNode);
+                        i++;
+                    }
+                }
+            }
+        }
+         //批量更新操作
+        //taskNodeService.saveOrUpdateBatch(taskNodeList);
+        taskNodeList.stream().forEach(item->System.out.println(item));
+        taskNodeService.saveOrUpdateBatch(taskNodeList);  */
+        //taskNodeService.
+        TaskNode taskNode = taskNodeService.getById(1635272408348585995L);
+        List<TaskNode> taskNodeList = taskNodeService.getFanManNodes(taskNode, "3");
+        taskNodeList.stream().forEach(item->{
+            System.out.println(item.toString());
+        });
+    }
+}

+ 10 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/dao/MesAttachmentMapper.java

@@ -0,0 +1,10 @@
+package com.github.zuihou.business.externalApi.dao;
+
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.externalApi.entity.MesAttachment;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MesAttachmentMapper extends SuperMapper<MesAttachment> {
+
+}

+ 11 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/MesAttachmentService.java

@@ -0,0 +1,11 @@
+package com.github.zuihou.business.externalApi.service;
+
+import com.github.zuihou.base.service.SuperService;
+import com.github.zuihou.business.externalApi.entity.MesAttachment;
+import com.github.zuihou.business.externalApi.entity.MesNotice;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+
+public interface MesAttachmentService extends SuperService<MesAttachment> {
+}

+ 13 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/MesAttachmentServiceImpl.java

@@ -0,0 +1,13 @@
+package com.github.zuihou.business.externalApi.service.impl;
+
+import com.github.zuihou.base.service.SuperServiceImpl;
+import com.github.zuihou.business.externalApi.dao.MesAttachmentMapper;
+import com.github.zuihou.business.externalApi.entity.MesAttachment;
+import com.github.zuihou.business.externalApi.service.MesAttachmentService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class MesAttachmentServiceImpl extends SuperServiceImpl<MesAttachmentMapper, MesAttachment> implements MesAttachmentService {
+}

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.base.service.SuperCacheService;
+import com.github.zuihou.business.externalApi.dto.AgvHikOrderInfoPageDTO;
 import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
@@ -136,4 +137,8 @@ public interface ProductLinePerformanceService extends SuperCacheService<TaskNod
     Map<String,List<String>> taskStatusSum(Map<String, Object> params);
 
     Map<String,List<String>> taskAGVSum(Map<String, Object> params);
+
+    IPage<TTaskPageDTO> unFinishedTask(Page page, Map<String, Object> params);
+
+    IPage<AgvHikOrderInfoPageDTO> unFinishedAGV(Page page, Map<String, Object> params);
 }

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

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.externalApi.dto.AgvHikOrderInfoPageDTO;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.database.mybatis.auth.DataScope;
@@ -88,4 +90,8 @@ public interface ProductLinePerformanceMapper extends SuperMapper<TaskNode> {
     Map<String, List<String>> taskStatusSum(@Param("params") Map<String, Object> params);
 
     Map<String, List<String>> taskAGVSum(@Param("params") Map<String, Object> params);
+
+    IPage<TTaskPageDTO> unFinishedTask(Page page, @Param("params")Map<String, Object> params);
+
+    IPage<AgvHikOrderInfoPageDTO> unFinishedAGV(Page page, @Param("params")Map<String, Object> params);
 }

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

@@ -8,8 +8,10 @@ import cn.hutool.core.date.DateUnit;
 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.dto.AgvHikOrderInfoPageDTO;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.WorkpieceMapper;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.statisticalAnalysis.ProductLinePerformanceService;
@@ -639,4 +641,24 @@ public class ProductLinePerformanceServiceImpl extends SuperCacheServiceImpl<Pro
         }
         return baseMapper.taskAGVSum(params);
     }
+
+    @Override
+    public IPage<TTaskPageDTO> unFinishedTask(Page page, Map<String, Object> params) {
+        if((Objects.isNull(params.get("startDate")) || Objects.isNull(params.get("endDate")))
+                && Objects.isNull(params.get("month")) && Objects.isNull(params.get("years"))){
+            //默认当天
+            params.put("today",DateUtil.dateToString0(new Date(),"yyyy-MM-dd"));
+        }
+        return baseMapper.unFinishedTask(page, params);
+    }
+
+    @Override
+    public IPage<AgvHikOrderInfoPageDTO> unFinishedAGV(Page page, Map<String, Object> params) {
+        if((Objects.isNull(params.get("startDate")) || Objects.isNull(params.get("endDate")))
+                && Objects.isNull(params.get("month")) && Objects.isNull(params.get("years"))){
+            //默认当天
+            params.put("today",DateUtil.dateToString0(new Date(),"yyyy-MM-dd"));
+        }
+        return baseMapper.unFinishedAGV(page, params);
+    }
 }

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

@@ -0,0 +1,156 @@
+package com.github.zuihou.business.util;
+
+import com.github.zuihou.business.externalApi.entity.MesAttachment;
+import com.github.zuihou.file.entity.Attachment;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class ZipFileUtils {
+
+        /**
+         * web下载打成压缩包的文件--流方式
+         *
+         * @param response 响应
+         * @param fileList 文件列表
+         * @param zipName  压缩包名
+         */
+        public static void downloadZipFiles(HttpServletResponse response, List<String> fileList, String zipName) {
+            ZipOutputStream zipOutputStream = null;
+            try {
+                //设置响应头
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                //设置文件名称
+                response.setHeader("Content-Disposition", "attachment;filename=" + zipName);
+                zipOutputStream = new ZipOutputStream(response.getOutputStream());
+                for (String file : fileList) {
+                    toZip(zipOutputStream, new File(file));
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            } finally {
+                //关闭资源
+                if (null != zipOutputStream) {
+                    try {
+                        zipOutputStream.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        /**
+         * 压缩文件
+         *
+         * @param zipOutputStream 压缩文件流
+         * @param file            待压缩文件
+         */
+        private static void toZip(ZipOutputStream zipOutputStream, File file) {
+            String filename = file.getName();
+            BufferedInputStream bis = null;
+            try {
+                bis = new BufferedInputStream(Files.newInputStream(file.toPath()));
+                //设置压缩包内文件的名称
+                zipOutputStream.putNextEntry(new ZipEntry(filename));
+                int size;
+                byte[] buffer = new byte[4096];
+                while ((size = bis.read(buffer)) > 0) {
+                    zipOutputStream.write(buffer, 0, size);
+                }
+                zipOutputStream.closeEntry();
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            } finally {
+                //关闭资源
+                if (null != bis) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+    /**
+     * 批量文件压缩下载
+     * @param urlList 需要批量下载文件的链接地址列表
+     * @param zipName 输出的压缩包名称
+     */
+    public static void downZip(List<MesAttachment> urlList, String zipName, HttpServletRequest request, HttpServletResponse response){
+        //响应头的设置
+        response.reset();
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("multipart/form-data");
+        String downloadName = zipName+".zip";
+        //返回客户端浏览器的版本号、类型
+        String agent = request.getHeader("USER-AGENT");
+        try {
+            //针对IE或者以IE为内核的浏览器:
+            if (agent.contains("MSIE")||agent.contains("Trident")) {
+                downloadName = java.net.URLEncoder.encode(downloadName, "UTF-8");
+            } else {
+                //非IE浏览器的处理:
+                downloadName = new String(downloadName.getBytes("UTF-8"),"ISO-8859-1");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
+
+        //设置压缩流:直接写入response,实现边压缩边下载
+        ZipOutputStream zipos = null;
+        try {
+            zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
+            zipos.setMethod(ZipOutputStream.DEFLATED); //设置压缩方法
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        //循环将文件写入压缩流
+        DataOutputStream os = null;
+
+        for (MesAttachment mesAttachment : urlList) {
+            try {
+                URL url = new URL(mesAttachment.getUrl());
+                URLConnection urlConnection = url.openConnection();
+                //File file = new File(mesAttachment.getUrl());
+                //此处应该加个文件是否存在的判断
+                String filename = mesAttachment.getName();
+                //添加ZipEntry,并ZipEntry中写入文件流
+                zipos.putNextEntry(new ZipEntry(filename));
+                os = new DataOutputStream(zipos);
+                InputStream is =  urlConnection.getInputStream();
+                byte[] b = new byte[1024];
+                int length = 0;
+                while((length = is.read(b))!= -1){
+                    os.write(b, 0, length);
+                }
+                is.close();
+                zipos.closeEntry();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        //关闭流
+        try {
+            os.flush();
+            os.close();
+            zipos.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+}

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

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.github.zuihou.business.externalApi.dao.MesNoticeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.github.zuihou.business.externalApi.entity.MesNotice">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="create_user" jdbcType="BIGINT" property="createUser"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="update_user" jdbcType="BIGINT" property="updateUser"/>
+        <result column="bu_type" jdbcType="VARCHAR" property="buType"/>
+        <result column="line_code" jdbcType="VARCHAR" property="lineCode"/>
+        <result column="api_address" jdbcType="VARCHAR" property="apiAddress"/>
+        <result column="api_type" jdbcType="VARCHAR" property="apiType"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
+        <result column="status" jdbcType="VARCHAR" property="status"/>
+        <result column="order_info" jdbcType="VARCHAR" property="orderInfo"/>
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id,bu_type,line_code,api_address,api_type,order_no,status,order_info,api_sort,create_time,create_user,update_time,update_user
+    </sql>
+
+    <select id="pageList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from (
+        SELECT
+        m.*
+        FROM
+        zuihou_base_yj_0000.imcs_mes_notice m,
+        (
+        SELECT
+        MAX(m2.api_sort) AS msort,
+        m2.order_no
+        FROM
+        zuihou_base_yj_0000.imcs_mes_notice m2
+        WHERE m2.`status` in ('1','2')
+        GROUP BY
+        m2.order_no
+        ) n
+        WHERE
+        m.`status` in ('1','2')
+        AND m.api_sort = n.msort and m.order_no = n.order_no
+        order by m.api_sort asc, m.status desc
+        ) s ${ew.customSqlSegment}
+    </select>
+
+</mapper>

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

@@ -881,4 +881,124 @@
          order by ihai.id desc
        ) s
     </select>
+
+    <select id="unFinishedTask" resultType="java.util.Map">
+        SELECT * from (
+        SELECT
+        <choose>
+            <when test="params.taskType !=null and params.taskType !=''">
+                n.resource_id as resourceId,
+                n.end_time AS completeTime,
+                TIMESTAMPDIFF(MINUTE, n.start_time, n.end_time) AS runTime,
+            </when>
+            <otherwise>
+                c.resource_id as resourceId,
+                c.end_time AS completeTime,
+                TIMESTAMPDIFF(MINUTE, c.start_time, c.end_time) AS runTime,
+            </otherwise>
+        </choose>
+        <if test="params.startDate !=null and params.startDate !='' and params.endDate !=null and params.endDate !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(n.start_time, '%Y-%m-%d') AS time</when>
+                <otherwise>DATE_FORMAT(c.start_time, '%Y-%m-%d') AS time</otherwise>
+            </choose>
+        </if>
+        <if test="params.month !=null and params.month !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(n.start_time, '%Y-%m') AS time</when>
+                <otherwise>DATE_FORMAT(c.start_time, '%Y-%m') AS time</otherwise>
+            </choose>
+        </if>
+        <if test="params.years !=null and params.years !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(n.start_time, '%Y') AS time</when>
+                <otherwise>DATE_FORMAT(c.start_time, '%Y') AS time</otherwise>
+            </choose>
+        </if>
+        <if test="params.today !=null and params.today !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(n.start_time, '%Y-%m-%d') AS time</when>
+                <otherwise> DATE_FORMAT(c.start_time, '%Y-%m-%d') AS time</otherwise>
+            </choose>
+        </if>
+        c.*
+        FROM imcs_t_task c
+        LEFT JOIN imcs_t_task_node n ON c.id = n.task_id ,
+        LEFT JOIN imcs_tenant_productionresource p ON c.resource_id = p.id
+        WHERE
+        <choose>
+            <when test="params.taskType !=null and params.taskType !=''">n.exe_status <![CDATA[ <> ]]> '3'</when>
+            <otherwise>c.status <![CDATA[ <> ]]> '3'</otherwise>
+        </choose>
+        <if test="params.startDate !=null and params.startDate !='' and params.endDate !=null and params.endDate !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">AND (( n.start_time BETWEEN #{params.startDate} AND #{params.endDate} ) or n.start_time is null )</when>
+                <otherwise> AND ( (c.start_time BETWEEN #{params.startDate} AND #{params.endDate}) or c.start_time is null )</otherwise>
+            </choose>
+        </if>
+        <if test="params.month !=null and params.month !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">AND (DATE_FORMAT(n.start_time, '%Y-%m') = #{params.month}  or n.start_time is null) </when>
+                <otherwise> AND (DATE_FORMAT(c.start_time, '%Y-%m') = #{params.month} or c.start_time is null)</otherwise>
+            </choose>
+        </if>
+        <if test="params.years !=null and params.years !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">AND (DATE_FORMAT(n.start_time, '%Y') = #{params.years} or n.start_time is null</when>
+                <otherwise> AND (DATE_FORMAT(c.start_time, '%Y') = #{params.years} or  c.start_time is null)</otherwise>
+            </choose>
+        </if>
+        <if test="params.today !=null and params.today !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''"> AND (DATE_FORMAT(n.start_time, '%Y-%m-%d') = #{params.today} or n.start_time is null)</when>
+                <otherwise>  AND (DATE_FORMAT(c.start_time, '%Y-%m-%d') = #{params.today} or c.start_time is null)</otherwise>
+            </choose>
+        </if>
+        <if test="params.resourceId !=null and params.resourceId !=''">
+            <choose>
+                <when test="params.taskType !=null and params.taskType !=''">  AND n.resource_id = #{params.resourceId}</when>
+                <otherwise> AND c.resource_id = #{params.resourceId}</otherwise>
+            </choose>
+        </if>
+        ) s ${params.customSqlSegment}
+    </select>
+
+    <select id="unFinishedAGV" resultType="java.util.Map">
+        SELECT * from (
+        SELECT
+        ihai.*,
+        ihadi.callback_time AS completeTime,
+        TIMESTAMPDIFF(MINUTE, ihai.response_time, ihadi.callback_time) AS runTime,
+        <if test="params.startDate !=null and params.startDate !='' and params.endDate !=null and params.endDate !=''">
+            DATE_FORMAT(ihadi.callback_time, '%Y-%m-%d') AS time
+        </if>
+        <if test="params.month !=null and params.month !=''">
+            DATE_FORMAT(ihadi.callback_time, '%Y-%m') AS time
+        </if>
+        <if test="params.years !=null and params.years !=''">
+            DATE_FORMAT(ihadi.callback_time, '%Y') AS time
+        </if>
+        <if test="params.today !=null and params.today !=''">
+            DATE_FORMAT(ihadi.callback_time, '%Y-%m-%d') AS time
+        </if>
+        FROM imcs_hik_agv_info ihai,
+        imcs_hik_agv_detail_info ihadi
+        WHERE ihai.task_code = ihadi.task_code
+        <if test="params.startDate !=null and params.startDate !='' and params.endDate !=null and params.endDate !=''">
+            AND ihadi.callback_time BETWEEN #{params.startDate} and #{params.endDate}
+        </if>
+        <if test="params.month !=null and params.month !=''">
+            AND DATE_FORMAT(ihadi.callback_time, '%Y-%m') = #{params.month}
+        </if>
+        <if test="params.years !=null and params.years !=''">
+            AND DATE_FORMAT(ihadi.callback_time, '%Y') = #{params.years}
+        </if>
+        <if test="params.today !=null and params.today !=''">
+            AND DATE_FORMAT(ihadi.callback_time, '%Y-%m-%d') = #{params.today}
+        </if>
+        AND ihai.response_code = '0'
+        order by ihai.id desc
+        )s  ${params.customSqlSegment}
+    </select>
+
 </mapper>

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

@@ -25,6 +25,7 @@ import com.github.zuihou.tenant.vo.ProductVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -286,4 +287,15 @@ public class ProductLinePerformanceController extends SuperController<ProductLin
         return success(baseService.taskAGVSum(params));
     }
 
+    @ApiOperation(value = "未完成业务统计详情", notes = "未完成业务统计详情")
+    @PostMapping("/unFinishedBiz")
+    @SysLog("未完成业务统计详情")
+    public R unFinishedBiz(@RequestBody String type, @RequestBody Map<String,Object> params) {
+         if(StringUtils.isEmpty(type)) return R.fail("传参有误");
+        Page page = new Page<>(1,1000);
+         if(type.equals("task"))  return success(baseService.unFinishedTask(page, params));
+         if(type.equals("agv")) return success(baseService.unFinishedAGV(page, params));
+         return success(baseService.unFinishedTask(page, params));
+    }
+
 }

+ 96 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/entity/MesAttachment.java

@@ -0,0 +1,96 @@
+package com.github.zuihou.business.externalApi.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import java.time.LocalDateTime;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_mes_attachment")
+@ApiModel(value = "MesNotice", description = "Mes通知")
+@AllArgsConstructor
+public class MesAttachment extends Entity<Long> {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ApiModelProperty(value = "订单编号")
+    @Length(max = 256, message = "订单编号长度不能超过128")
+    @TableField(value = "order_no", condition = LIKE)
+    @Excel(name = "订单编号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "工序编号")
+    @Length(max = 256, message = "工序编号长度不能超过128")
+    @TableField(value = "procedure_no", condition = LIKE)
+    @Excel(name = "工序编号")
+    private String procedureNo;
+
+    @ApiModelProperty(value = "附件名称")
+    @Length(max = 256, message = "附件名称长度不能超过128")
+    @TableField(value = "name", condition = LIKE)
+    @Excel(name = "附件名称")
+    private String name;
+
+    @ApiModelProperty(value = "附件类型")
+    @Length(max = 128, message = "附件类型长度不能超过128")
+    @TableField(value = "type", condition = LIKE)
+    @Excel(name = "附件类型")
+    private String type;
+
+    @ApiModelProperty(value = "附件地址")
+    @Length(max = 1000, message = "附件地址长度不能超过128")
+    @TableField(value = "url", condition = LIKE)
+    @Excel(name = "附件地址")
+    private String url;
+
+    @ApiModelProperty(value = "本地路径")
+    @Length(max = 1000, message = "本地路径长度不能超过128")
+    @TableField(value = "path", condition = LIKE)
+    @Excel(name = "本地路径")
+    private String path;
+
+    @ApiModelProperty(value = "版本")
+    @Length(max = 128, message = "附件地址长度不能超过128")
+    @TableField(value = "version", condition = LIKE)
+    @Excel(name = "版本")
+    private String version;
+
+    @ApiModelProperty(value = "状态")
+    @TableField(value = "status", condition = LIKE)
+    @Excel(name = "状态")
+    private int status;
+
+    @ApiModelProperty(value = "说明")
+    @Length(max = 1000, message = "附件地址长度不能超过128")
+    @TableField(value = "remark", condition = LIKE)
+    @Excel(name = "说明")
+    private String remark;
+
+    @Builder
+    public MesAttachment(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, String orderNo, String procedureNo, String name, String type, String url, String version, int status, String remark) {
+        super(id, createTime, createUser, updateTime, updateUser);
+        this.orderNo = orderNo;
+        this.procedureNo = procedureNo;
+        this.name = name;
+        this.type = type;
+        this.url = url;
+        this.version = version;
+        this.status = status;
+        this.remark = remark;
+    }
+}