From 1cbbb341d22e3c46b15af65b6f97d738bae7ca95 Mon Sep 17 00:00:00 2001
From: yangbin <yangbin>
Date: 星期二, 20 五月 2025 10:46:57 +0800
Subject: [PATCH] 自动化

---
 lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java |  167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 167 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java
index ab23abd..72e2db6 100644
--- a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java
+++ b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java
@@ -1,11 +1,178 @@
 package org.jeecg.modules.msi.webapi.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.msi.webapi.entity.MsiWebapiJsonEntity;
 import org.jeecg.modules.msi.webapi.mapper.MsiWebapiJsonMapper;
 import org.jeecg.modules.msi.webapi.service.IMsiWebapiJsonService;
+import org.jeecg.modules.msi.webapi.vo.DetailedListVo;
+import org.jeecg.modules.msi.webapi.vo.MachineEquipentInfo;
 import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Service
 public class MsiWebapiJsonServiceImpl extends ServiceImpl<MsiWebapiJsonMapper, MsiWebapiJsonEntity> implements IMsiWebapiJsonService {
+
+
+    @Override
+    public boolean saveTableAutomationOne(List<MachineEquipentInfo> data) {
+        if (data ==null || data.isEmpty()) {
+            return false;
+        }
+        List<String> listStatus = new ArrayList<>();
+        List<String> listParameter = new ArrayList<>();
+        for (MachineEquipentInfo machineInfo : data) {
+            System.out.println(machineInfo);
+            String stutus = listSqls(machineInfo);
+            if (stutus != null && !stutus.equals("")) {
+                listStatus.add(stutus);
+            }
+            String parameter = listSqlParameter(machineInfo);
+            if (parameter != null && !parameter.equals("")) {
+                listParameter.add(parameter);
+            }
+        }
+        //鐘舵�佹暟鎹�
+
+        return false;
+    }
+
+
+    /**
+     *  鎻掑叆鍒癊quipmentLog
+     * @param machineInfo
+     * @return
+     */
+    public String listSqlParameter(MachineEquipentInfo machineInfo) {
+        String listSqls = null;
+        List<DetailedListVo> itemList = machineInfo.getItemList();
+        Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>();
+        for (DetailedListVo item: itemList) {
+            itemMap.put(item.getItemName(),item);
+        }
+        String sql = "insert into ";
+        sql = sql + "ZDH_" + machineInfo.getMachineNo() + " ";
+        sql = sql + "(EquipmentID,EquipmentName,CollectTime,runningStatus,spindleSpeed,feedRatio,runDuration,spindleDuration,progName,progStatus,toolNo) values (  ";
+        //EquipmentID
+        if (machineInfo.getMachineNo() == null ||  machineInfo.getMachineNo().equals("")) {
+            return null;
+        } else {
+            sql = sql + "'" + machineInfo.getMachineNo() + "', ";
+        }
+        //EquipmentName
+        sql = sql + null + ", ";
+        //CollectTime
+        if (machineInfo.getEndTime() != null) {
+            sql = sql + "'" + DateUtils.formattedDate(machineInfo.getEndTime(),DateUtils.STR_DD_MM_YYYY,DateUtils.STR_DATE_TIME_SMALL) + "', ";
+        } else {
+            sql = sql + "'" + DateUtils.format(DateUtils.getDate(),DateUtils.STR_DATE_TIME) + "', ";
+        }
+        //runningStatus
+        if (itemMap.containsKey("runningStatus")) {
+            sql = sql + "'" + itemMap.get("runningStatus").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //spindleSpeed
+        if (itemMap.containsKey("spindleSpeed")) {
+            sql = sql + "'" + itemMap.get("spindleSpeed").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //runDuration
+        if (itemMap.containsKey("runDuration")) {
+            sql = sql + "'" + itemMap.get("runDuration").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //spindleDuration
+        if (itemMap.containsKey("spindleDuration")) {
+            sql = sql + "'" + itemMap.get("spindleDuration").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //progName
+        if (itemMap.containsKey("spindleSpeed")) {
+            sql = sql + "'" + itemMap.get("spindleSpeed").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //progStatus
+        if (itemMap.containsKey("progStatus")) {
+            sql = sql + "'" + itemMap.get("progStatus").getItemValue() + "', ";
+        } else {
+            sql = sql + null + ", ";
+        }
+        //toolNo
+        if (itemMap.containsKey("toolNo")) {
+            sql = sql + "'" + itemMap.get("toolNo").getItemValue() + "'  ";
+        } else {
+            sql = sql + null;
+        }
+
+        sql = sql + "); \n";
+        if (StringUtils.isBlank(listSqls) ) {
+            listSqls = sql;
+        } else {
+            listSqls += sql;
+        }
+        return listSqls;
+    }
+
+
+    /**
+     *  鎻掑叆鍒癊quipmentLog
+     * @param machineInfo
+     * @return
+     */
+    public String listSqls(MachineEquipentInfo machineInfo) {
+        String listSqls = null;
+        List<DetailedListVo> itemList = machineInfo.getItemList();
+        String sql = "insert into EquipmentLog (EquipmentID,EquipmentName,CollectTime,Oporation,Alarm) values ( ";
+        if (machineInfo.getMachineNo() == null) {
+            return null;
+        } else {
+            sql = sql + "'" + machineInfo.getMachineNo() + "', ";
+        }
+        sql = sql + null + ", ";
+        if (machineInfo.getEndTime() != null) {
+
+            sql = sql + "'" + DateUtils.formattedDate(machineInfo.getEndTime(),DateUtils.STR_DD_MM_YYYY,DateUtils.STR_DATE_TIME_SMALL) + "', ";
+        } else {
+            return null;
+        }
+        Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>();
+        for (DetailedListVo item: itemList) {
+            itemMap.put(item.getItemName(),item);
+        }
+        if (itemMap.containsKey("runningStatus")) {
+            int oporation = 0;
+            switch (itemMap.get("runningStatus").getItemValue()) {
+                case "0" : oporation =0;break;
+                case "1" : oporation =2;break;
+                case "2" : oporation =3;break;
+                case "3" : oporation =2;break;
+                case "4" : oporation =2;break;
+                case "10" : oporation =2;break;
+                case "13" : oporation =2;break;
+                case "14" : oporation =2;break;
+                case "10001" : oporation =2;break;
+                default: break;
+            }
+            sql = sql + " " + oporation  + ", ";
+        } else {
+            return null;
+        }
+        sql = sql + null +   " ); \n";
+        if (StringUtils.isBlank(listSqls) ) {
+            listSqls = sql;
+        }
+        return listSqls;
+    }
 }

--
Gitblit v1.9.3