wuyouming666
2023-12-21 81826e66f68a37486516ee93c4e11d92a00c3fb6
增加清除id调用终止出片任务
9个文件已修改
420 ■■■■ 已修改文件
CanadaMes-ui/src/configuration/parameter2.json 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/lang/locales/zh-CN.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/views/home/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/S7control.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/resources/com/example/springboot/mapper/DeviceMapper.xml 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/configuration/parameter2.json
@@ -3,7 +3,8 @@
    {
      "button": {
        "name": "D01手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -11,7 +12,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -21,14 +23,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "D02手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -36,7 +40,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -46,14 +51,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "D03手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -61,7 +68,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -71,14 +79,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "D04手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -86,7 +96,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -96,14 +107,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "D05手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -111,7 +124,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -121,14 +135,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "D06手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -136,7 +152,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -146,14 +163,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "A01手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -161,7 +180,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -171,14 +191,16 @@
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "ID2",
      "read": 33,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
    
  ],
@@ -187,7 +209,8 @@
    {
      "button": {
        "name": "A02手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -195,7 +218,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "3"
@@ -205,14 +229,16 @@
      "read": "ID28",
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "B01手动状态",
        "value": 0
        "value": 0,
"value2": 0
      
      },
      "type": "4"
@@ -220,7 +246,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0
        "value": 0,
"value2": 0
        
      },
      "type": "3"
@@ -230,14 +257,16 @@
      "read": "ID29",
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
    {
      "button": {
        "name": "B02手动状态",
        "value": 0,
        "value": 0,
"value2": 0,
        "address": "DB10.0"
      },
      "type": "4"
@@ -245,7 +274,8 @@
    {
      "button": {
        "name": "清除ID",
        "value": 0
        "value": 0,
"value2": 0
    
      },
      "type": "3"
@@ -255,7 +285,8 @@
      "read": "ID210",
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
@@ -264,14 +295,16 @@
      "read": 0,
      "sending": 0,
      
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "ID1",
      "read": 66,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
@@ -280,14 +313,16 @@
      "read": 0,
      "sending": 0,
      
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "ID2",
      "read": 666,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ],
  [
@@ -296,28 +331,32 @@
      "read": 333,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "A02所在格子",
      "read": 333,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "B01所在格子",
      "read": 333,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    },
    {
      "name": "B02所在格子",
      "read": 333,
      "sending": 0,
      "type": "0",
      "value": 0
      "value": 0,
"value2": 0
    }
  ]
  ,
@@ -351,7 +390,8 @@
          "read": 666,
          "sending": 0,
          "type": "0",
          "value": 0
          "value": 0,
"value2": 0
        }
      
      
CanadaMes-ui/src/lang/locales/zh-CN.json
@@ -1,5 +1,5 @@
{
  "ip": "192.168.10.113",
  "ip": "localhost",
  "systemTitle": "登录系统",
  "usernamePlaceholder": "请输入用户名",
  "passwordPlaceholder": "请输入密码",
CanadaMes-ui/src/views/home/index.vue
@@ -1654,7 +1654,7 @@
            });
        }
        ,
        cellStyle({ row, column, rowIndex, columnIndex }) {
        cellStyle({  column, rowIndex, columnIndex }) {
            // console.log(row, column, "ss");
            column = rowIndex;
            rowIndex = column;
springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
@@ -152,4 +152,63 @@
            System.err.println("An error occurred while writing string to PLC: " + e.getMessage());
        }
    }
    public void writeBitandrenwuToPLC(JSONArray messageArray, List<String> addresses, int index) {
        try {
            // 检查索引是否有效
            if (messageArray.getJSONArray(index).size() > 0) {
                // 获取消息数组
                JSONArray jsonArray = messageArray.getJSONArray(index);
                // 创建一个布尔值列表
                List<Boolean> sValue = new ArrayList<>();
                // 遍历消息数组
                for (int i = 0; i < jsonArray.size(); i++) {
                    // 获取消息数组中的值
                    Object value = jsonArray.get(i);
                    // 检查值是否有效
                    if (value != null && !value.toString().equals("null")) {
                        try {
                            // 移除非数字和数字字符
                            String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
                            // 解析为布尔值
                            boolean val = "1".equals(cleanedValue.trim());
                            // 将布尔值添加到布尔值列表中
                            sValue.add(val);
                            System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
                       if(sValue.get(1)){
                       }
                        } catch (NumberFormatException e) {
                            // 如果无法解析为 boolean 类型,则忽略该部分
                            System.err.println("Could not parse value: " + value);
                        }
                    }
                }
                // 检查布尔值列表是否为空
                if (!sValue.isEmpty()) {
                    // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表
                    S7control.getinstance().WriteBit(addresses, sValue);
                    System.out.println("Values " + sValue + " written to PLC at address " + addresses);
                }
            }
        } catch (Exception e) {
            System.err.println("An error occurred while writing bit to PLC: " + e.getMessage());
        }
    }
}
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
@@ -2,6 +2,7 @@
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.springboot.controller.HomeController;
import org.apache.commons.io.FileUtils;
import java.io.*;
@@ -140,9 +141,138 @@
//        System.out.println("lastMessage:" + lastMessage);
                            JSONArray messageArray = new JSONArray(lastMessage);
                            //清除ID
                            customS7Control.writeBitToPLC(messageArray, addressList0, 0);
                           // customS7Control.writeBitToPLC(messageArray, addressList0, 0);
                            try {
                                // 检查索引是否有效
                                if (messageArray.getJSONArray(0).size() > 0) {
                                    // 获取消息数组
                                    JSONArray jsonArray = messageArray.getJSONArray(0);
                                    // 创建一个布尔值列表
                                    List<Boolean> sValue = new ArrayList<>();
                                    // 遍历消息数组
                                    for (int i = 0; i < jsonArray.size(); i++) {
                                        // 获取消息数组中的值
                                        Object value = jsonArray.get(i);
                                        // 检查值是否有效
                                        if (value != null && !value.toString().equals("null")) {
                                            try {
                                                // 移除非数字和数字字符
                                                String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
                                                // 解析为布尔值
                                                boolean val = "1".equals(cleanedValue.trim());
                                                // 将布尔值添加到布尔值列表中
                                                sValue.add(val);
                                                System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
                                            } catch (NumberFormatException e) {
                                                // 如果无法解析为 boolean 类型,则忽略该部分
                                                System.err.println("Could not parse value: " + value);
                                            }
                                        }
                                    }
                                    for (int i = 1; i <= 5; i++) {
                                        boolean value = sValue.get(i);
                                        if (value) {
                                            switch (i) {
                                                case 1:
                                                    HomeController.UpdateTask(0, 0, paramlist.get(i));
                                                    break;
                                                case 2:
                                                case 3:
                                                case 4:
                                                case 5:
                                                    HomeController.UpdateTask(1, 0, paramlist.get(i));
                                                    break;
                                                default:
                                                    // 处理索引值不在范围内的情况
                                                    break;
                                            }
                                        }
                                    }
                                    // 检查布尔值列表是否为空
                                    if (!sValue.isEmpty()) {
                                        // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表
                                        S7control.getinstance().WriteBit(addressList0, sValue);
                                        System.out.println("Values " + sValue + " written to PLC at address " + addressList0);
                                    }
                                }
                            } catch (Exception e) {
                                System.err.println("An error occurred while writing bit to PLC: " + e.getMessage());
                            }
                            //急停
                            customS7Control.writeBitToPLC(messageArray, niuanaddressList3, 1);
//                            customS7Control.writeBitToPLC(messageArray, niuanaddressList3, 1);
                            try {
                                // 检查索引是否有效
                                if (messageArray.getJSONArray(1).size() > 0) {
                                    // 获取消息数组
                                    JSONArray jsonArray = messageArray.getJSONArray(1);
                                    // 创建一个布尔值列表
                                    List<Boolean> sValue = new ArrayList<>();
                                    // 遍历消息数组
                                    for (int i = 0; i < jsonArray.size(); i++) {
                                        // 获取消息数组中的值
                                        Object value = jsonArray.get(i);
                                        // 检查值是否有效
                                        if (value != null && !value.toString().equals("null")) {
                                            try {
                                                // 移除非数字和数字字符
                                                String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
                                                // 解析为布尔值
                                                boolean val = "1".equals(cleanedValue.trim());
                                                // 将布尔值添加到布尔值列表中
                                                sValue.add(val);
                                                System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
                                            } catch (NumberFormatException e) {
                                                // 如果无法解析为 boolean 类型,则忽略该部分
                                                System.err.println("Could not parse value: " + value);
                                            }
                                        }
                                    }
                                    boolean Value1 = sValue.get(0);
                                    boolean Value2 = sValue.get(1);
                                    if (Value1) {
                                        HomeController.EndTask(0);
                                    }
                                    if (Value2) {
                                        HomeController.EndTask(0);
                                    }
                                    // 检查布尔值列表是否为空
                                    if (!sValue.isEmpty()) {
                                        // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表
                                        S7control.getinstance().WriteBit(addressList0, sValue);
                                        System.out.println("Values " + sValue + " written to PLC at address " + addressList0);
                                    }
                                }
                            } catch (Exception e) {
                                System.err.println("An error occurred while writing bit to PLC: " + e.getMessage());
                            }
                            //存片等待延迟
                            customS7Control.Writetime(messageArray, timeout2, 2);
springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
@@ -331,11 +331,17 @@
    }
//读取时间
    public Long readtime(String address) {
        if (s7PLC==null)
            return null;
public Long readtime(String address) {
    if (s7PLC == null)
        return null;
    try {
        return s7PLC.readTime(address);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
    public void writetime(String address, long datas) {
        if (s7PLC == null)
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -17,25 +17,25 @@
        //
        System.out.println("启动完成");
    // new PlcHold().start();
   new PlcHold().start();
        new Plchome().start();
        //  new Plcalarm().start();
          new Plcalarm().start();
        //  new Plcsign().start();
          new Plcsign().start();
        //  new Plcstate().start();
        //  new PlcPositioning1().start();
          new Plcstate().start();
          new PlcPositioning1().start();
        //  new PlcParameter2().start();
         new PlcParameter2().start();
        //  new PLCAutomaticParameterSetting().start();
          new PLCAutomaticParameterSetting().start();
        //  new PlcManualonePosition().start();
        //  new PlcManualonePosition2().start();
        //  new PlcServoManualone().start();
        //  new PLCManualJog().start();
          new PlcManualonePosition().start();
          new PlcManualonePosition2().start();
          new PlcServoManualone().start();
          new PLCManualJog().start();
    }
}
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java
@@ -47,18 +47,21 @@
@RequestMapping("/home")
public class HomeController {
  @Autowired
  static
  HomeMapper homeMapper;
  @Autowired
  HomeService storageRackService;
  @Autowired
  static
  SpianService spianService;
  @Autowired
  SpianMapper spianMapper;
  @Autowired
  static
  OutSliceServive outSliceServive;
  @Autowired
@@ -139,7 +142,7 @@
  // 手动完成进/出片任务 终止进片/出片任务
  @GetMapping("/UpdateTask")
  public Result UpdateTask(Integer types, Integer shelfrack, String glassid) {
  public static Result UpdateTask(Integer types, Integer shelfrack, String glassid) {
    Map<String, Object> map = new HashMap<>();
    if (types == 0) {// 完成进片
      spianService.overtask(glassid);
@@ -157,7 +160,7 @@
  //终止进片/出片任务
  @GetMapping("/EndTask")
  public Result EndTask(int types) {
  public static Result EndTask(int types) {
     if (types == 0) {// 终止进片任务
      List<StorageTask> cageList = homeMapper.SelectTaskByState(types);
      for (StorageTask storageTask : cageList) {
springboot-vue3/src/main/resources/com/example/springboot/mapper/DeviceMapper.xml
@@ -2,39 +2,39 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.springboot.mapper.device.DeviceMapper">
    <resultMap id="myResultMap" type="com.example.springboot.entity.device.DeviceEntity">
        <!-- 根据你的实际情况定义结果映射 -->
        <!-- 示例中将结果映射到实体类的属性 -->
        <id property="id" column="id"/>
        <result property="name" column="device_name"/>
        <!-- 其他属性映射 -->
    </resultMap>
<!--    <resultMap id="myResultMap" type="com.example.springboot.entity.device.DeviceEntity">-->
<!--        &lt;!&ndash; 根据你的实际情况定义结果映射 &ndash;&gt;-->
<!--        &lt;!&ndash; 示例中将结果映射到实体类的属性 &ndash;&gt;-->
<!--        <id property="id" column="id"/>-->
<!--        <result property="name" column="device_name"/>-->
<!--        &lt;!&ndash; 其他属性映射 &ndash;&gt;-->
<!--    </resultMap>-->
    <select id="selectAllDevices" resultMap="myResultMap">
        SELECT *
        FROM device
    </select>
<!--    <select id="selectAllDevices" resultMap="myResultMap">-->
<!--        SELECT *-->
<!--        FROM device-->
<!--    </select>-->
    <select id="callStoredProc" statementType="CALLABLE" resultMap="myResultMap">
        { call Your_Stored_Procedure(
                #{id, mode=IN, jdbcType=VARCHAR},
                #{name, mode=IN, jdbcType=VARCHAR}
<!--    <select id="callStoredProc" statementType="CALLABLE" resultMap="myResultMap">-->
<!--        { call Your_Stored_Procedure(-->
<!--                #{id, mode=IN, jdbcType=VARCHAR},-->
<!--                #{name, mode=IN, jdbcType=VARCHAR}-->
            ) }
    </select>
<!--            ) }-->
<!--    </select>-->
    <update id="updateDeviceName">
        UPDATE device SET
                          device_name = #{deviceName},
                          address = #{address}
        WHERE id = #{id}
    </update>
    <update id="updateMultipleDevices" parameterType="java.util.List">
        <foreach collection="list" item="device" separator=";">
            UPDATE device SET
            device_name = #{device.deviceName},
            address = #{device.address}
            WHERE id = #{device.id}
        </foreach>
    </update>
<!--    <update id="updateDeviceName">-->
<!--        UPDATE device SET-->
<!--                          device_name = #{deviceName},-->
<!--                          address = #{address}-->
<!--        WHERE id = #{id}-->
<!--    </update>-->
<!--    <update id="updateMultipleDevices" parameterType="java.util.List">-->
<!--        <foreach collection="list" item="device" separator=";">-->
<!--            UPDATE device SET-->
<!--            device_name = #{device.deviceName},-->
<!--            address = #{device.address}-->
<!--            WHERE id = #{device.id}-->
<!--        </foreach>-->
<!--    </update>-->
</mapper>