oyq28 1 год назад
Родитель
Сommit
b93711198d

+ 18 - 0
imcs-admin-boot/imcs-business-biz/pom.xml

@@ -111,6 +111,24 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
+
+        <!-- 科德机床采集 -->
+        <dependency>
+            <groupId>org.eclipse.milo</groupId>
+            <artifactId>sdk-client</artifactId>
+            <version>0.6.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.milo</groupId>
+            <artifactId>dictionary-reader</artifactId>
+            <version>0.6.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.milo</groupId>
+            <artifactId>sdk-server</artifactId>
+            <version>0.6.0</version>
+        </dependency>
+
         <!--<dependency>-->
             <!--<groupId>com.matlab.tool</groupId>-->
             <!--<artifactId>javabuilder</artifactId>-->

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

@@ -0,0 +1,81 @@
+package com.github.zuihou.business.util;
+
+import com.google.common.collect.Lists;
+import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
+import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
+import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
+import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
+import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText;
+import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
+import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
+import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class KEDEUtils {
+
+    private static List<NodeId> list=new ArrayList<NodeId>(){};
+
+    private static OpcUaClient opcUaClient = null;
+
+    private static String endPointUrl = "opc.tcp://192.168.11.63:12686";
+
+    public static OpcUaClient createOpcClient(String endPointUrl)  throws Exception {
+        //opc ua服务端地址
+        //String endPointUrl = "opc.tcp://192.168.11.63:12686";
+
+        Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"),
+                "security");
+        Files.createDirectories(securityTempDir);
+        if (!Files.exists(securityTempDir)) {
+            throw new Exception("unable to create security dir: " + securityTempDir);
+        }
+        opcUaClient = OpcUaClient.create(endPointUrl,
+                endpoints ->
+                        endpoints.stream()
+                                .filter(e ->
+                                        e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri()))
+                                .findFirst(),
+                configBuilder ->
+                        configBuilder
+                                .setApplicationName(LocalizedText.english("eclipse milo opc-ua client"))
+                                .setApplicationUri("urn:eclipse:milo:examples:client")
+                                //访问方式
+                                .setIdentityProvider(new AnonymousProvider())
+                                .setRequestTimeout(UInteger.valueOf(500))
+                                .build()
+        );
+        return opcUaClient;
+    }
+
+    //获取机床指标数据+机床加工状态指标
+    public static List<DataValue> getMachineData() throws Exception {
+        if(opcUaClient==null) {
+            opcUaClient = createOpcClient(endPointUrl);
+        }
+        opcUaClient.connect().get();
+        list = Stream.of(new NodeId(2, "cncFeedInfo/feed-overf0"), new NodeId(2, "cncFeedInfo/feed-over"), new NodeId(2, "cncSpindleInfo/spindle-over1"), new NodeId(2, "cncSpindleInfo/spindle-act1")).collect(Collectors.toList());
+        List<DataValue> listCompletableFuture = opcUaClient.readValues(0.0, TimestampsToReturn.Neither,
+                list).get();
+        return listCompletableFuture;
+    }
+
+    //获取机床刀具信息
+    public static List<DataValue> getToolsData() throws Exception {
+        if(opcUaClient==null) {
+            opcUaClient = createOpcClient(endPointUrl);
+        }
+        opcUaClient.connect().get();
+        list = Stream.of(new NodeId(2, "cncRecordInfo/record-tool:1"), new NodeId(2, "cncRecordInfo/record-tool:65537"), new NodeId(2, "cncRecordInfo/record-tool:65546")).collect(Collectors.toList());
+        List<DataValue> listCompletableFuture = opcUaClient.readValues(0.0, TimestampsToReturn.Neither,
+                list).get();
+
+        return listCompletableFuture;
+    }
+}

+ 18 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -23,7 +23,6 @@ import com.github.zuihou.business.productionReadyCenter.entity.BBom;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
-import com.github.zuihou.business.productionReadyCenter.service.AutoNodeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
@@ -41,9 +40,7 @@ import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.common.util.SmbShareFileUtil;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
-import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.exception.BizException;
-import com.github.zuihou.tenant.service.ProductionresourceService;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -52,6 +49,7 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
@@ -67,11 +65,15 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @Component
 public class MsgUtil implements ApplicationContextAware {
@@ -915,4 +917,16 @@ public class MsgUtil implements ApplicationContextAware {
         }
         return returnData;
     }
+
+    public Map<String, String> getKEDEMachineInfo() throws Exception {
+        List<DataValue> datas = KEDEUtils.getMachineData();
+        Map<String, String> map =  datas.stream().collect(Collectors.toMap(item->item.getValue().toString(), item->item.getValue().getValue().toString(), (value1, value2) -> value1));
+        return map;
+    }
+
+    public Map<String, List<String>> getKEDEToolsInfo() throws Exception {
+        List<DataValue> datas = KEDEUtils.getToolsData();
+        Map<String, List<String>> map =  datas.stream().collect(Collectors.toMap(item->item.getValue().toString(), item-> Stream.of(item.getValue().getValue().toString().split(";")).collect(Collectors.toList()), (value1, value2) -> value1));
+        return map;
+    }
 }

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

@@ -885,22 +885,32 @@
     <select id="unFinishedTask" resultType="java.util.Map">
         SELECT * from (
         SELECT
+          z.name as zoneName,p.name as resourceName,o.single_task_flag,
         <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,
+                n.node_name AS bizName,
+                n.id AS bizId,
+                n.complete_batch_no as completeBatchNo,
+                n.start_time,
+                n.create_time,
+                n.complete_batch_no as completeBatchNo,
             </when>
             <otherwise>
                 c.resource_id as resourceId,
-                c.end_time AS completeTime,
                 TIMESTAMPDIFF(MINUTE, c.start_time, c.end_time) AS runTime,
+                c.procedure_name AS bizName,
+                c.id AS bizId,
+                c.complete_batch_no as completeBatchNo,
+                c.start_time,
+                c.create_time,
             </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>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(ifnull(n.start_time, Now()), '%Y-%m-%d') AS time</when>
+                <otherwise>DATE_FORMAT(ifnull(c.start_time,Now()), '%Y-%m-%d') AS time</otherwise>
             </choose>
         </if>
         <if test="params.month !=null and params.month !=''">
@@ -917,14 +927,17 @@
         </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>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(ifnull(n.start_time, Now()), '%Y-%m-%d') AS time</when>
+                <otherwise> DATE_FORMAT(ifnull(c.start_time,Now()), '%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 ,
+        <choose>
+            <when test="params.taskType !=null and params.taskType !=''">LEFT JOIN imcs_t_task_node n ON c.id = n.task_id</when>
+        </choose>
         LEFT JOIN imcs_tenant_productionresource p ON c.resource_id = p.id
+        LEFT JOIN imcs_o_order o ON c.order_id = o.id
+        LEFT JOIN imcs_z_zone z ON o.zone_id = z.id
         WHERE
         <choose>
             <when test="params.taskType !=null and params.taskType !=''">n.exe_status <![CDATA[ <> ]]> '3'</when>
@@ -968,7 +981,11 @@
         SELECT
         ihai.*,
         ihadi.callback_time AS completeTime,
-        TIMESTAMPDIFF(MINUTE, ihai.response_time, ihadi.callback_time) AS runTime,
+        ioo.order_name AS orderName,
+        ioo.order_no AS orderNo,
+        ibb.name  AS partName,
+        itw.unique_code  AS partNo,
+        itt.procedure_no AS procedureNo,
         <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>
@@ -982,8 +999,18 @@
             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
+        imcs_hik_agv_detail_info ihadi,
+        imcs_t_task itt,
+        imcs_t_workpiece itw,
+        imcs_o_order ioo,
+        imcs_o_order_product ioop,
+        imcs_b_bom ibb
+        WHERE ihadi.task_code = ihai.task_code
+        AND ihai.task_id = itt.id
+        AND itt.complete_batch_no = itw.complete_batch_no
+        AND itt.order_id = ioo.id
+        AND ioo.id = ioop.order_id
+        AND ioop.bom_id = ibb.id
         <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>

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

@@ -290,12 +290,12 @@ public class ProductLinePerformanceController extends SuperController<ProductLin
     @ApiOperation(value = "未完成业务统计详情", notes = "未完成业务统计详情")
     @PostMapping("/unFinishedBiz")
     @SysLog("未完成业务统计详情")
-    public R unFinishedBiz(@RequestBody String type, @RequestBody Map<String,Object> params) {
-         if(StringUtils.isEmpty(type)) return R.fail("传参有误");
+    public R unFinishedBiz(@RequestBody Map<String,Object> params) {
+        String type = params.containsKey("taskType")? params.get("taskType").toString() : null;
         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));
+        if(StringUtils.isEmpty(type)) return success(baseService.unFinishedTask(page, params));
+        if(type.equals("agv")) return success(baseService.unFinishedAGV(page, params));
+        return success(baseService.unFinishedTask(page, params));
     }
 
 }

+ 3 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/TTaskPageDTO.java

@@ -189,4 +189,7 @@ public class TTaskPageDTO implements Serializable {
 
     @ApiModelProperty(value = "工序名称")
     private String procedureDesc;
+
+    @ApiModelProperty(value = "开始日期")
+    private String time;
 }

+ 2 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TTask.java

@@ -598,6 +598,8 @@ public class TTask extends Entity<Long> implements Serializable,Comparable<TTask
     private int overTime;
     @TableField(exist = false)
     private String userName;
+    @TableField(exist = false)
+    private String time;
 
 
     @Override