Browse Source

后台代码提交

oyq28 1 year ago
parent
commit
932b5dd005

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

@@ -41,12 +41,6 @@
             <version>RELEASE</version>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>com.github.zuihou</groupId>
-            <artifactId>imcs-authority-biz</artifactId>
-            <version>b.2.5-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
         <dependency>
             <groupId>com.github.zuihou</groupId>
             <artifactId>imcs-tenant-biz</artifactId>

+ 0 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/DemoLine/DemoLineConstant.java

@@ -1,7 +1,5 @@
 package com.github.zuihou.business.DemoLine;
 
-import jdk.internal.dynalink.beans.StaticClass;
-
 /**
  * 示范线用到的常量
  */

+ 8 - 14
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java

@@ -3,13 +3,10 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.ttl.threadpool.agent.TtlAgent;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -37,7 +34,10 @@ import com.github.zuihou.business.productionReadyCenter.service.*;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ResourceBusinessMapper;
-import com.github.zuihou.business.productionResourceCenter.entity.*;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceBusiness;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
@@ -45,35 +45,29 @@ import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.ManualTaskOperatorUtil;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.business.util.ZplPrinter;
-import com.github.zuihou.common.constant.*;
+import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.constant.CacheKey;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.common.util.StringUtil;
 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.database.mybatis.conditions.query.QueryWrap;
-import com.github.zuihou.exception.BizException;
 import com.github.zuihou.security.model.SysUser;
 import com.github.zuihou.tenant.entity.Productionline;
 import com.github.zuihou.tenant.entity.ProductionlineUser;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.tenant.service.ProductionlineService;
 import com.github.zuihou.tenant.service.ProductionlineUserService;
-import com.github.zuihou.utils.SpringUtils;
-import javafx.concurrent.Task;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.ArrayStack;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 

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

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.util;
 
 import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
 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;
@@ -9,6 +10,7 @@ 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 org.springframework.stereotype.Component;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -18,15 +20,16 @@ import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+@Component
 public class KEDEUtils {
 
-    private static List<NodeId> list=new ArrayList<NodeId>(){};
+    private List<NodeId> list=new ArrayList<NodeId>(){};
 
-    private static OpcUaClient opcUaClient = null;
+    private OpcUaClient opcUaClient = null;
 
-    private static String endPointUrl = "opc.tcp://192.168.11.63:12686";
+    private String endPointUrl = "opc.tcp://192.168.11.63:12686";
 
-    public static OpcUaClient createOpcClient(String endPointUrl)  throws Exception {
+    public OpcUaClient createOpcClient(String endPointUrl)  throws Exception {
         //opc ua服务端地址
         //String endPointUrl = "opc.tcp://192.168.11.63:12686";
 
@@ -55,9 +58,9 @@ public class KEDEUtils {
     }
 
     //获取机床指标数据+机床加工状态指标
-    public static List<DataValue> getMachineData() throws Exception {
+    public List<DataValue> getMachineData(String url) throws Exception {
         if(opcUaClient==null) {
-            opcUaClient = createOpcClient(endPointUrl);
+            opcUaClient = createOpcClient(!StringUtils.isEmpty(url)? url: 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());
@@ -67,9 +70,9 @@ public class KEDEUtils {
     }
 
     //获取机床刀具信息
-    public static List<DataValue> getToolsData() throws Exception {
+    public List<DataValue> getToolsData(String url) throws Exception {
         if(opcUaClient==null) {
-            opcUaClient = createOpcClient(endPointUrl);
+            opcUaClient = createOpcClient(!StringUtils.isEmpty(url)? url: 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());

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

@@ -150,6 +150,9 @@ public class MsgUtil implements ApplicationContextAware {
     @Autowired
     private AAutoNodeLogService autoNodeLogService;
 
+    @Autowired
+    private KEDEUtils kedeUtils;
+
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         MsgUtil.applicationContext = applicationContext;
@@ -918,14 +921,14 @@ public class MsgUtil implements ApplicationContextAware {
         return returnData;
     }
 
-    public Map<String, String> getKEDEMachineInfo() throws Exception {
-        List<DataValue> datas = KEDEUtils.getMachineData();
+    public Map<String, String> getKEDEMachineInfo(String url) throws Exception {
+        List<DataValue> datas = kedeUtils.getMachineData(url);
         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();
+    public Map<String, List<String>> getKEDEToolsInfo(String url) throws Exception {
+        List<DataValue> datas = kedeUtils.getToolsData(url);
         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;
     }

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

@@ -817,7 +817,7 @@
         </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>
+                <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>
@@ -892,7 +892,6 @@
                 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,
@@ -915,14 +914,14 @@
         </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>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(ifnull(n.start_time, Now()), '%Y-%m') AS time</when>
+                <otherwise>DATE_FORMAT(ifnull(c.start_time,Now()), '%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>
+                <when test="params.taskType !=null and params.taskType !=''">DATE_FORMAT(ifnull(n.start_time, Now()), '%Y') AS time</when>
+                <otherwise>DATE_FORMAT(ifnull(c.start_time,Now()), '%Y') AS time</otherwise>
             </choose>
         </if>
         <if test="params.today !=null and params.today !=''">
@@ -957,7 +956,7 @@
         </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>
+                <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>

+ 53 - 4
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ProductionTasksController.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.controller.externalApi;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -60,6 +61,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 import  com.github.zuihou.business.externalApi.entity.R2;
 
 @Slf4j
@@ -531,27 +534,47 @@ public class ProductionTasksController {
         BaseContextHandler.setTenant("0000");
         String instructionUrl="http://192.168.123.7/api-acq/v1/devicecltdata/saveDeviceInfoToIOTDB";
         String ccsUrl="http://192.168.11.240:8089/api/GetDigitalTwins";
-        JSONArray jsonArray = new JSONArray();
 
+        JSONArray jsonArray = new JSONArray();
         String resultData = msgUtil.httpForPost(ccsUrl, "");
         JSONArray returnArr = JSONObject.parseArray(resultData);
-        returnArr.stream().filter(item->{
+        List<Object> deviceList = returnArr.stream().filter(item->{
             JSONObject itemObject = (JSONObject)item;
             Productionresource productionresource = productionresourceBizService.getById(itemObject.getString("resourceId"));
             return StringUtil.isNotEmpty(productionresource.getModeSpecification());
-        }).forEach(item->{
+        }).collect(Collectors.toList());
+
+        Map<String, String> dataMap = null;
+        List<Productionresource> KEDEList = productionresourceBizService.list(new LbqWrapper<Productionresource>().eq(Productionresource::getModeSpecification, "KEDE").orderByAsc(Productionresource::getId));
+        JSONObject template = (JSONObject)deviceList.get(0);
+          if(KEDEList.size()>0) {
+              KEDEList.stream().forEach(obj -> {
+                  JSONObject instance = new JSONObject();
+                  BeanUtil.copyProperties(template, instance);
+                  instance.put("resourceId", obj.getId());
+                  instance.put("deviceName", obj.getName());
+                  deviceList.add(instance);
+              });
+          }
+
+        deviceList.stream().forEach(item->{
             JSONObject jsonParam= new JSONObject();
-            JSONObject itemObject = (JSONObject)item;
+            JSONObject itemObject =  (JSONObject)item;
             Productionresource productionresource = productionresourceBizService.getById(itemObject.getString("resourceId"));
             itemObject.remove("id");
             itemObject.put("ip", productionresource.getIp());
             itemObject.put("ACQ_SERVICE_STATUS", "1");
+            if(productionresource.getModeSpecification().equals("KEDE")){
+                //处理机床数据
+                itemObject = this.getKEDEMachineData(productionresource, itemObject);
+            }
             jsonParam.put("cltParamInfo", itemObject);
             jsonParam.put("deviceNo", productionresource.getCode());
             jsonParam.put("recordTime", new Date());
             jsonArray.add(jsonParam);
         });
         //System.out.println(jsonArray.toJSONString());
+
         String returnData = msgUtil.httpForPost(instructionUrl,jsonArray.toJSONString());
         return R2.success(returnData);
     }
@@ -560,4 +583,30 @@ public class ProductionTasksController {
     public void syncMesDeviceInfo(){
         this.saveDeviceInfoToIOTDB(new HashMap());
     }
+
+    //@ApiOperation(value = "科德机床数据采集", notes = "科德机床数据采集")
+    //@PostMapping("/DataCollector/getKEDEMachineInfo")
+    private JSONObject getKEDEMachineData(Productionresource productionresource, JSONObject instance) {
+           boolean bool = productionresource.getOnlineStatus()=="0" || productionresource.getStatus()=="0" ? true:false;
+           List<String> urls = Stream.of("opc.tcp://192.168.11.63:12686","opc.tcp://192.168.11.64:12686","opc.tcp://192.168.11.65:12686").collect(Collectors.toList());
+           String url = productionresource.getName().contains("1")? urls.get(0) :(productionresource.getName().contains("2")? urls.get(1):urls.get(2));
+
+           List<String> dataList = null;
+           //解析数据
+           try{
+               Map dataMap = msgUtil.getKEDEMachineInfo(url);
+               dataList = new ArrayList<String>(dataMap.values());
+               instance.put("feedRate", !bool?dataList.get(0): null);
+               instance.put("spindleMagnification", !bool?dataList.get(1): null);
+               instance.put("spindleSpeed", !bool?dataList.get(2): null);
+               instance.put("spindleLoad", !bool?dataList.get(3): null);
+           }
+           catch (Exception ex){
+               instance.put("feedRate", null);
+               instance.put("spindleMagnification", null);
+               instance.put("spindleSpeed", null);
+               instance.put("spindleLoad", null);
+           }
+          return instance;
+    }
 }

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

@@ -291,7 +291,8 @@ public class ProductLinePerformanceController extends SuperController<ProductLin
     @PostMapping("/unFinishedBiz")
     @SysLog("未完成业务统计详情")
     public R unFinishedBiz(@RequestBody Map<String,Object> params) {
-        String type = params.containsKey("taskType")? params.get("taskType").toString() : null;
+        //String taskType = params.containsKey("taskType")? params.get("taskType").toString() : null;
+        String type = params.containsKey("type")? params.get("type").toString() : null;
         Page page = new Page<>(1,1000);
         if(StringUtils.isEmpty(type)) return success(baseService.unFinishedTask(page, params));
         if(type.equals("agv")) return success(baseService.unFinishedAGV(page, params));