From 5ae1b71ab6b57140d46e6a8b9e606bb4a390ce27 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期一, 03 三月 2025 11:11:46 +0800
Subject: [PATCH] webservice接口

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java |  220 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 120 insertions(+), 100 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
index c5db8a6..6c195c4 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -1,6 +1,5 @@
 package org.jeecg.modules.mdc.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -9,9 +8,11 @@
 import org.jeecg.common.api.dto.message.MessageDTO;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.api.ISysBaseAPI;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.mdc.dto.MdcEquDepDto;
 import org.jeecg.modules.mdc.dto.MdcEquProDto;
+import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto;
 import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
 import org.jeecg.modules.mdc.entity.*;
 import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper;
@@ -28,10 +29,7 @@
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper;
 import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper;
-import org.jeecg.modules.system.service.IMdcProductionService;
-import org.jeecg.modules.system.service.IMdcUserProductionService;
-import org.jeecg.modules.system.service.ISysDepartService;
-import org.jeecg.modules.system.service.ISysUserDepartService;
+import org.jeecg.modules.system.service.*;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -66,8 +64,6 @@
     @Resource
     private IMdcProductionService mdcProductionService;
     @Resource
-    private IControlSystemService controlSystemService;
-    @Resource
     private IEquipmentWorkLineService equipmentWorkLineService;
     @Resource
     private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService;
@@ -76,9 +72,6 @@
 
     @Resource
     private IEquipmentLogService equipmentLogService;
-
-    @Resource
-    private IEquipmentBaseInfoService equipmentBaseInfoService;
 
     @Resource
     private ISysBaseAPI sysBaseApi;
@@ -92,6 +85,11 @@
     @Resource
     private IMdcOverrunAlarmService mdcOverrunAlarmService;
 
+    @Resource
+    private IEquipmentXYZService equipmentXYZService;
+
+    @Resource
+    private ISysDictService sysDictService;
 
     @Override
     public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) {
@@ -325,25 +323,35 @@
         List<MdcEquipmentMonitor> result = this.baseMapper.checkStatusFromEquipmentIds(equipmentIds);
         if (result != null && !result.isEmpty()) {
             for (MdcEquipmentMonitor mdcEquipmentMonitor : result) {
-                if (mdcEquipmentMonitor.getOporation() != null) {
-                    switch (mdcEquipmentMonitor.getOporation()) {
-                        case 1:
-                        case 2:
-                            mdcEquipmentMonitor.setOporationDict("寰呮満");
-                            break;
-                        case 3:
-                            mdcEquipmentMonitor.setOporationDict("杩愯");
-                            break;
-                        case 22:
-                            mdcEquipmentMonitor.setOporationDict("鎶ヨ");
-                            break;
-                        default:
-                            mdcEquipmentMonitor.setOporationDict("鍏虫満");
-                            break;
+                if (mdcEquipmentMonitor.getEquipmentStatus() == 0) {
+                    if (mdcEquipmentMonitor.getOporation() != null) {
+                        switch (mdcEquipmentMonitor.getOporation()) {
+                            case 1:
+                            case 2:
+                                mdcEquipmentMonitor.setOporationDict("寰呮満");
+                                break;
+                            case 3:
+                                mdcEquipmentMonitor.setOporationDict("杩愯");
+                                break;
+                            case 22:
+                                mdcEquipmentMonitor.setOporationDict("鎶ヨ");
+                                break;
+                            default:
+                                mdcEquipmentMonitor.setOporationDict("鍏虫満");
+                                break;
+                        }
+                    } else {
+                        mdcEquipmentMonitor.setOporationDict("鍏虫満");
+                        mdcEquipmentMonitor.setOporation(0);
                     }
                 } else {
-                    mdcEquipmentMonitor.setOporationDict("鍏虫満");
-                    mdcEquipmentMonitor.setOporation(0);
+                    List<DictModel> dictList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_STATUS);
+                    for (DictModel dictModel : dictList) {
+                        if (Integer.valueOf(dictModel.getValue()).equals(mdcEquipmentMonitor.getEquipmentStatus())) {
+                            mdcEquipmentMonitor.setOporationDict(dictModel.getLabel());
+                            mdcEquipmentMonitor.setOporation(88);
+                        }
+                    }
                 }
             }
         }
@@ -354,87 +362,55 @@
      * 璁惧鐩戞帶 - 璁惧璇︾粏淇℃伅
      */
     @Override
-    public MdcEquipmentDto mdcEquipmentDetailedInfo(String id) {
-        MdcEquipmentDto mdcEquipmentDto = new MdcEquipmentDto();
-        MdcEquipment mdcEquipment = this.baseMapper.selectById(id);
-        //灏佽鍩虹淇℃伅
-        mdcEquipmentDto.setSystemVersion(mdcEquipment.getSystemVersion());
-        mdcEquipmentDto.setSystemType(mdcEquipment.getControlSystem());
-        mdcEquipmentDto.setDevicePower(mdcEquipment.getDevicePower());
-        mdcEquipmentDto.setDeviceType(mdcEquipment.getDriveType());
-        mdcEquipmentDto.setRemark(mdcEquipment.getRemark());
-        //璁惧缂栧彿
-        mdcEquipmentDto.setEquipmentID(mdcEquipment.getEquipmentId());
-        mdcEquipmentDto.setEquipmentName(mdcEquipment.getEquipmentName());
-        mdcEquipmentDto.setEquipmentIP(mdcEquipment.getEquipmentIp());
-        //璁惧鍨嬪彿
-        mdcEquipmentDto.setEquipmentModel(mdcEquipment.getEquipmentModel());
-        mdcEquipmentDto.setDriveType(mdcEquipment.getDriveType());
-        mdcEquipmentDto.setDataPort(mdcEquipment.getDataPort());
-        mdcEquipmentDto.setDataFlag(Integer.parseInt(CommonConstant.STATUS_1));
-        ControlSystem controlSystem = controlSystemService.getByDriveType(mdcEquipmentDto.getDriveType());
+    public Map<String, Object> mdcEquipmentDetailedInfo(String id) {
+        Map<String, Object> result = new HashMap<>();
+        MdcEquipmentDetailedDto mdcEquipmentDetailedDto = this.baseMapper.findById(id);
+        result.put("equipment", mdcEquipmentDetailedDto);
         // 鏌ヨ璁惧鐘舵��
-        EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId());
+        EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipmentDetailedDto.getEquipmentId());
         if (equipmentLog == null) {
-            return mdcEquipmentDto;
+            return result;
         }
         Integer oporation = equipmentLog.getOporation();
-
-        if (controlSystem != null) {
-            //鑾峰彇宸ヤ綔鏁版嵁骞跺垵濮嬪寲
-            String saveTableName = mdcEquipment.getSaveTableName();
-            MdcEquipmentDto dto = equipmentWorkLineService.getMacingDataList(saveTableName);
-            if (dto != null) {
-                mdcEquipmentDto.setCollectTime(dto.getCollectTime());
-                mdcEquipmentDto.setSpindlespeed(dto.getSpindlespeed());
-                mdcEquipmentDto.setSpindleload(dto.getSpindleload());
-                mdcEquipmentDto.setSpindlebeilv(dto.getSpindlebeilv());
-                mdcEquipmentDto.setFeedrate(dto.getFeedrate());
-                mdcEquipmentDto.setFeedbeilv(dto.getFeedbeilv());
-                mdcEquipmentDto.setProgramnumber(dto.getProgramnumber());
-                mdcEquipmentDto.setSequencenumber(dto.getSequencenumber());
-                mdcEquipmentDto.setExecutingcode(dto.getExecutingcode());
-                mdcEquipmentDto.setProductName(dto.getProductName());
-                if ("LSV2".equals(mdcEquipment.getDriveType())) {
-                    mdcEquipmentDto.setSpindlebeilv(dto.getSFeed());
-                    mdcEquipmentDto.setFeedbeilv(dto.getFFeed());
-                    mdcEquipmentDto.setRapidfeed(dto.getRapidfeed());
-                    mdcEquipmentDto.setNCVersion(dto.getNCVersion());
-                    mdcEquipmentDto.setTNCVersion(dto.getTNCVersion());
-                    mdcEquipmentDto.setOPTVersion(dto.getOPTVersion());
-                    mdcEquipmentDto.setPLCVersion(dto.getPLCVersion());
-                }
-
-                //鑾峰彇 MDC 椹卞姩瀵瑰簲鐨勫睍绀哄弬鏁�   骞舵牴鎹甼ey 鎷艰浠� workData  鏌ヨ鐨勬暟鎹�
-                List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipment.getDriveType());
-                if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) {
-                    for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) {
-                        String englishName = mdcDriveTypeParamConfig.getEnglishName();
-                        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(dto);
-                        Object result = jsonObject.get(englishName);
+        //鑾峰彇宸ヤ綔鏁版嵁骞跺垵濮嬪寲
+        String saveTableName = mdcEquipmentDetailedDto.getSaveTableName();
+        Map<String, Object> mapData = equipmentWorkLineService.getDataList(saveTableName);
+        if (mapData != null) {
+//            Map<String, Object> runData = new LinkedHashMap<>();
+            List<Map<String, Object>> runData = new ArrayList<>();
+            //鑾峰彇 MDC 椹卞姩瀵瑰簲鐨勫睍绀哄弬鏁�   骞舵牴鎹甼ey 鎷艰浠� workData  鏌ヨ鐨勬暟鎹�
+            List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipmentDetailedDto.getDriveType());
+            if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) {
+                for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) {
+                    Map<String, Object> map = new LinkedHashMap<>();
+                    String englishName = mdcDriveTypeParamConfig.getEnglishName();
+                    String chineseName = mdcDriveTypeParamConfig.getChineseName();
+                    map.put("key", chineseName);
+                    if (mapData.containsKey(englishName)) {
+                        Object object = mapData.get(englishName);
                         String value = "";
                         if ("CollectTime".equals(englishName)) {
-                            Date date = result == null ? null : (Date) result;
+                            Date date = object == null ? null : (Date) object;
                             value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL);
-                        } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "AI01".equals(englishName) && oporation == 3) {
+                        } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "AI01".equals(englishName) && oporation == 3) {
                             // ZUOLAN璁惧鐢垫祦瀛楁AI01
                             value = BigDecimal.valueOf(Math.random() * 15 + 0).setScale(1, RoundingMode.HALF_UP).toString();
-                        } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) {
+                        } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) {
                             // ZUOLAN璁惧涓昏酱杞�熷瓧娈祍pindlespeed
                             value = String.valueOf(((new Random().nextInt(35)) + 1) * 100);
-                        } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) {
+                        } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) {
                             // ZUOLAN璁惧涓昏酱璐熻嵎瀛楁spindleload
                             value = String.valueOf(Integer.valueOf(new Random().nextInt(21)));
-                        } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlebeilv".equals(englishName) && oporation == 3) {
+                        } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindlebeilv".equals(englishName) && oporation == 3) {
                             // ZUOLAN璁惧涓昏酱鍊嶇巼瀛楁spindlebeilv
                             value = String.valueOf((new Random().nextInt(13)) * 10);
-                        } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "feedbeilv".equals(englishName) && oporation == 3) {
+                        } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "feedbeilv".equals(englishName) && oporation == 3) {
                             // ZUOLAN璁惧杩涚粰鍊嶇巼瀛楁feedbeilv
                             value = String.valueOf((new Random().nextInt(13)) * 10);
                         } else if ("spindle_current".equals(englishName)) {
                             // 鍏朵粬璁惧鐢垫祦瀛楁
-                            String devicePower = mdcEquipment.getDevicePower();
-                            Object spindleload = jsonObject.get("spindleload");
+                            String devicePower = mdcEquipmentDetailedDto.getDevicePower();
+                            Object spindleload = mapData.get("spindleload");
                             BigDecimal load = spindleload == null ? BigDecimal.ZERO : new BigDecimal(spindleload.toString());
                             if (StringUtils.isNotEmpty(devicePower) && oporation == 3) {
                                 value = new BigDecimal(devicePower).divide(new BigDecimal("380"), 2, BigDecimal.ROUND_HALF_UP).add(load).toString();
@@ -443,7 +419,7 @@
                             }
                         } else if ("torque".equals(englishName)) {
                             // 鎵煩瀛楁
-                            MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipment.getEquipmentId());
+                            MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipmentDetailedDto.getEquipmentId());
                             if (mdcTorqueConfig != null) {
                                 value = String.valueOf(mdcTorqueConfig.getTorqueValue());
                             } else {
@@ -457,7 +433,7 @@
                             }
                         } else if ("alarmContent".equals(englishName)) {
                             if (oporation == 22) {
-                                List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, mdcEquipment.getDriveType()).eq(MdcAlarmInfo::getAlarmCode, equipmentLog.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0));
+                                List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, mdcEquipmentDetailedDto.getDriveType()).eq(MdcAlarmInfo::getAlarmCode, equipmentLog.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0));
                                 if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) {
                                     value = mdcAlarmInfo.get(0).getAlarmContent();
                                 }
@@ -465,20 +441,49 @@
                                 value = "鏃�";
                             }
                         } else {
-                            value = result == null ? null : result.toString();
+                            value = object == null ? "" : object.toString();
                         }
-                        mdcDriveTypeParamConfig.setValue(value);
+                        map.put("value", value);
+                        runData.add(map);
+                        if ("spindlebeilv".equals(englishName) && !"".equals(value)) {
+                            result.put("spindlebeilv", value);
+                        }
+                        if ("feedbeilv".equals(englishName) && !"".equals(value)) {
+                            result.put("feedbeilv", value);
+                        }
+                        if ("spindleload".equals(englishName) && !"".equals(value)) {
+                            result.put("spindleload", value);
+                        }
+                        if ("rapidfeed".equals(englishName) && !"".equals(value)) {
+                            result.put("rapidfeed", value);
+                        }
                     }
-                    mdcEquipmentDto.setMdcDriveTypeParamConfigList(mdcDriveTypeParamList);
-                }
-                EquipmentBaseInfo equipmentBaseInfo = equipmentBaseInfoService.getByEquipmentId(mdcEquipment.getEquipmentId());
-                if (equipmentBaseInfo != null) {
-                    mdcEquipmentDto.setMaxAxis(equipmentBaseInfo.getMaxAxis());
-                    mdcEquipmentDto.setValidAxis(equipmentBaseInfo.getValidAxis());
                 }
             }
+            result.put("runData", runData);
+
+            // 鏌ヨ鍧愭爣淇℃伅
+            if (!"ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && !"CurrentState".equals(mdcEquipmentDetailedDto.getDriveType())) {
+                EquipmentXYZ equipmentXYZ = equipmentXYZService.getByEquipmentId(mdcEquipmentDetailedDto.getEquipmentId());
+                if (equipmentXYZ != null) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("xmachine", equipmentXYZ.getXMachine());
+                    map.put("ymachine", equipmentXYZ.getYMachine());
+                    map.put("zmachine", equipmentXYZ.getZMachine());
+                    map.put("amachine", equipmentXYZ.getAMachine());
+                    map.put("bmachine", equipmentXYZ.getBMachine());
+
+                    map.put("xabsolute", equipmentXYZ.getXAbsolute());
+                    map.put("yabsolute", equipmentXYZ.getYAbsolute());
+                    map.put("zabsolute", equipmentXYZ.getZAbsolute());
+                    map.put("aabsolute", equipmentXYZ.getAAbsolute());
+                    map.put("babsolute", equipmentXYZ.getBAbsolute());
+                    result.put("xyzList", map);
+                }
+            }
+
         }
-        return mdcEquipmentDto;
+        return result;
     }
 
     /**
@@ -600,6 +605,9 @@
         }
         if (StringUtils.isNotEmpty(mdcEquipment.getEquipmentName())) {
             queryWrapper.like(MdcEquipment::getEquipmentName, mdcEquipment.getEquipmentName());
+        }
+        if (mdcEquipment.getEquipmentStatus() != null) {
+            queryWrapper.eq(MdcEquipment::getEquipmentStatus, mdcEquipment.getEquipmentStatus());
         }
         if (!allEquipments.isEmpty()) {
             queryWrapper.in(MdcEquipment::getEquipmentId, allEquipments);
@@ -861,6 +869,7 @@
 
     /**
      * 鏌ヨ鍗曡〃鏁版嵁
+     *
      * @param tableName
      * @return
      */
@@ -896,4 +905,15 @@
         return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());
     }
 
+    /**
+     * 鏍规嵁浜х嚎id鑾峰彇璁惧鐘舵�佸垪琛�
+     *
+     * @param workshopId
+     * @return
+     */
+    @Override
+    public List<MdcEquipmentMonitor> getEquipmentMonitorList(String workshopId) {
+        return this.baseMapper.getEquipmentMonitorList(workshopId);
+    }
+
 }

--
Gitblit v1.9.3