Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
# Conflicts:
# UI-Project/src/views/TL/Temperedlayout/Temperedlayout.vue
20个文件已修改
19个文件已添加
20个文件已删除
| | |
| | | package com.mes.common.PlcTools; |
| | | |
| | | |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.sql.Time; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import com.google.common.primitives.Bytes; |
| | | import org.apache.ibatis.jdbc.Null; |
| | | |
| | | public class S7control { |
| | | |
| | | S7PLC s7PLC; // PLC通讯类实例 |
| | | |
| | | public S7control(EPlcType plcType, String ip, int port, int rack, int slot) { |
| | | private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型 |
| | | private String ip = "192.168.10.1"; // plc ip地址 |
| | | private int port = 102; // plc 端口号 |
| | | |
| | | private static volatile S7control instance = null; |
| | | |
| | | private S7control() { |
| | | if (s7PLC == null) |
| | | s7PLC = new S7PLC(plcType, ip, port,0,0); |
| | | } |
| | | } |
| | | public S7control(EPlcType plcType,String ip,int port,int a,int b) { |
| | | if (s7PLC == null) |
| | | s7PLC = new S7PLC(plcType, ip, port,a,b); |
| | | } |
| | | |
| | | // 单例模式 获取类的唯一实例 |
| | | public static S7control getinstance() { |
| | | if (instance == null) { |
| | | synchronized (S7control.class) { |
| | | if (instance == null) |
| | | instance = new S7control(); |
| | | } |
| | | } |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | | * 关闭西门子s7通讯连接 |
| | | */ |
| | |
| | | public boolean CheckConnected() { |
| | | return s7PLC.checkConnected(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 按指定的地址 写入一个word |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private int getIndexFromAddress(String address) { |
| | |
| | | public List<Short> ReadWord(String address, int count) { |
| | | if (s7PLC == null) |
| | | return null; |
| | | |
| | | List<String> addresslist = GetAddressList(address, count, 16); |
| | | try { |
| | | return s7PLC.readInt16(addresslist); |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public byte[] Readbyte(String address, int count) { |
| | | byte[] byt=new byte[count]; |
| | | int wordcount=((count%2==0)?count/2:count+1); |
| | | List<Short> word=ReadWord(address,wordcount); |
| | | |
| | | return byt; |
| | | } |
| | | /** |
| | | * 按指定的地址 读取byte结果集 |
| | | * |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public List<String> readStringsandword(List<String> addressList) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | List<String> result = new ArrayList<>(); |
| | | for (String address : addressList) { |
| | | try { |
| | | if (address.contains("-")) { |
| | | address = address.substring(0, address.indexOf("-")); |
| | | |
| | | byte[] bytes = s7PLC.readByte(address, 14); |
| | | if (bytes != null) { |
| | | String str = new String(bytes, StandardCharsets.UTF_8); |
| | | result.add(str); |
| | | } |
| | | |
| | | } else { |
| | | Short value = s7PLC.readInt16(address); |
| | | result.add(value.toString()); |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("读取 " + address + " 失败:" + e.getMessage()); |
| | | result.add(null); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | //不连续地址写入Word |
| | | public void WriteWord(List<String> address, List<Short> datas) { |
| | | if (s7PLC == null) |
| | |
| | | glassidlist.add(Byte.valueOf(String.valueOf(iditem))); |
| | | } |
| | | byte[] bytes = Bytes.toArray(glassidlist); |
| | | WriteByte(addr, bytes); |
| | | S7control.getinstance().WriteByte(addr, bytes); |
| | | } |
| | | |
| | | //读取不连续word |
| | |
| | | } |
| | | return addresslist; |
| | | } |
| | | public void writeString(String addr,String data) { |
| | | s7PLC.writeString(addr,data); |
| | | } |
| | | |
| | | public String readStrings(String addr) { |
| | | return s7PLC.readString(addr); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.controller; |
| | | |
| | | import com.mes.mapper.SelectInfo; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.mes.common.Result; |
| | | import com.mes.entity.Tempered; |
| | | import com.mes.service.pp.SelectdppService; |
| | | import com.mes.service.hangzhoumes.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/TidyUpGlassModule") |
| | | |
| | | // TidyUpGlassModule 理片模块 |
| | | public class TidyUpGlassModuleController { |
| | | @Autowired |
| | | private SelectInfo SelectInfo; |
| | | |
| | | @Autowired |
| | | private SelectdppService SelectppService; |
| | | |
| | | @Autowired |
| | | private hangzhoumesService hangzhoumesService; |
| | | |
| | | @GetMapping("/SelectTerritoryInfo") // 查询钢化版图信息-根据 工程号 |
| | | @ResponseBody |
| | | public Result SelectTerritoryInfo(@RequestParam(name = "ProcessId", required = false) String ProcessId) { |
| | | List<Tempered> h = SelectppService.SelectTemperedTerritory(ProcessId); |
| | | System.out.println(h.size()+":"+ProcessId); |
| | | return Result.seccess(h); |
| | | } |
| | | |
| | | @GetMapping("/CutTerritory") // 查询切割版图信息-根据 工程号 |
| | | @ResponseBody |
| | | public Result CutTerritory(String ProcessId) { |
| | | List<Map> h = SelectppService.SelectCutTerritory(ProcessId); |
| | | System.out.println(h.size()); |
| | | return Result.seccess(h); |
| | | } |
| | | |
| | | @GetMapping("/SelectCutTerritory") // 识别显示 当前版图 |
| | | @ResponseBody |
| | | public Result SelectCutTerritory(String ProcessId) { |
| | | List<Map> h = SelectppService.SelectCutTerritory("P24032508"); |
| | | System.out.println(h.size()); |
| | | return Result.seccess(h); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/SelectCageInfo") // 查询笼内信息 |
| | | @ResponseBody |
| | | public Result SelectCageInfo(String ProcessId) { |
| | | List<Map> h = SelectppService.SelectCutTerritory("P24032508"); |
| | | System.out.println(h.size()); |
| | | return Result.seccess(h); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/SelectEdgTask") //磨边任务 |
| | | @ResponseBody |
| | | public Result SelectEdgTask(String ProcessId) { |
| | | List<Map> EdgTasks = hangzhoumesService.SelectEdgInfo("1"); |
| | | System.out.println(EdgTasks.size()); |
| | | return Result.seccess(EdgTasks); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | @Data //lombok 简写java代码 实体类的get与set |
| | | @TableName("task_cache") |
| | | public class TaskCache { |
| | | private String ID;//任务编号 |
| | | private String startcell;//起始 |
| | | private String endcell;//结束 |
| | | private String tasktype;//任务类型 |
| | | private String taskstauts;//任务状态 |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import com.mes.common.PlcTools.S7control; |
| | | |
| | | public class InitUtil { |
| | | //初始化word |
| | | public static PlcParameterObject initword(String jsonFilePath) { |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | PlcParameterObject plcParameterObject = new PlcParameterObject(); |
| | | plcParameterObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcParameterObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | PlcParameterInfo plcParameterInfo = new PlcParameterInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcParameterInfo.setCodeId(codeid); |
| | | plcParameterInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | //plcParameterInfo.setRatio(Integer.valueOf(parameterObj.getStr("ratio"))); |
| | | plcParameterInfo.setAddressLength(Integer.valueOf(parameterObj.getStr("addressLenght"))); |
| | | plcParameterInfo.setUnit(parameterObj.getStr("unit")); |
| | | plcParameterObject.addPlcParameter(plcParameterInfo); |
| | | } |
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | // plcParameterObject.setPlcParameterList(getplcvlues); |
| | | |
| | | return plcParameterObject; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //初始化bit |
| | | public static PlcBitObject initbit(String jsonFilePath) { |
| | | PlcBitObject plcBitObject = new PlcBitObject(); |
| | | |
| | | try { |
| | | FileReader fileReader = new FileReader(jsonFilePath); |
| | | BufferedReader bufferedReader = new BufferedReader(fileReader); |
| | | |
| | | StringBuilder content = new StringBuilder(); |
| | | String line; |
| | | |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | content.append(line); |
| | | } |
| | | |
| | | bufferedReader.close(); |
| | | fileReader.close(); |
| | | |
| | | JSONObject jsonfileobj = new JSONObject(content.toString()); |
| | | JSONArray jsonArray = jsonfileobj.getJSONArray("parameteInfor"); |
| | | plcBitObject.setPlcAddressBegin(jsonfileobj.getStr("plcAddressBegin"));//设置起始位地址 |
| | | plcBitObject.setPlcAddressLength(Integer.valueOf(jsonfileobj.getStr("plcAddressLenght")));//设置地址长度 |
| | | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject parameterObj = jsonArray.getJSONObject(i); |
| | | |
| | | PlcBitInfo plcBitInfo = new PlcBitInfo(jsonfileobj.getStr("plcAddressBegin")); //参数实例 |
| | | String codeid = parameterObj.getStr("codeId"); |
| | | plcBitInfo.setCodeId(codeid); |
| | | plcBitInfo.setAddressIndex(Integer.valueOf(parameterObj.getStr("addressIndex"))); |
| | | |
| | | plcBitObject.addPlcBit(plcBitInfo); |
| | | } |
| | | System.out.println(""); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | // false, true ,true }; |
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | |
| | | // List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | // plcBitObject.setPlcBitList(getplcvlues); |
| | | return plcBitObject; |
| | | } |
| | | |
| | | // |
| | | public static void readAndUpdateBitValues(PlcBitObject plcBitObject) { |
| | | |
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false, |
| | | // false, true ,true }; |
| | | // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1)); |
| | | List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength()); |
| | | plcBitObject.setPlcBitList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | public static void readAndUpdateWordValues(PlcParameterObject plcParameterObject) { |
| | | |
| | | // byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02}; |
| | | byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import static com.mes.entity.device.InitUtil.readAndUpdateWordValues; |
| | | public class PLCAutoMes extends Thread { |
| | | |
| | | // // 用于存储应用程序的配置信息 |
| | | // private Configuration config; |
| | | private static InitUtil initUtil; |
| | | // public static PlcParameterObject PlcMesObject; |
| | | // public static PlcParameterObject PlcReadObject; |
| | | // public static PlcParameterObject PlcframeObject; |
| | | |
| | | // // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | // MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | // 单例实例 |
| | | private static PLCAutoMes instance; |
| | | // private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); |
| | | private static String PlcAlbania = PLCAutoMes.class.getResource("/JsonFile/PlcAlbania.json").getPath(); |
| | | // private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); |
| | | // private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); |
| | | // private static String PlcParameter = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcParameter.json").getPath(); |
| | | |
| | | // private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json").getPath(); |
| | | |
| | | // private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath(); |
| | | |
| | | // private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath(); |
| | | // private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath(); |
| | | |
| | | // 调用initword方法 |
| | | |
| | | // public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter); |
| | | // public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest); |
| | | // public static PlcBitObject plcBitObject = initUtil.initbit(PlcSign); |
| | | // public static PlcParameterObject plcStateObject= initUtil.initword(PlcState); |
| | | // public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm); |
| | | public static PlcParameterObject PlcMesObject = InitUtil.initword(PlcAlbania); |
| | | // public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead); |
| | | // public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe); |
| | | |
| | | // 私有构造函数 |
| | | public PLCAutoMes() throws IOException { |
| | | //config = new Configuration("config.properties"); |
| | | initUtil = new InitUtil(); |
| | | } |
| | | |
| | | // 获取单例实例 |
| | | public static synchronized PLCAutoMes getInstance() throws IOException { |
| | | if (instance == null) { |
| | | instance = new PLCAutoMes(); |
| | | } |
| | | return instance; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(100); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // System.out.println(jsonFilePath); |
| | | |
| | | //readAndUpdateWordValues(PlcReadObject); |
| | | readAndUpdateWordValues(PlcMesObject); |
| | | //readAndUpdateWordValues(PlcframeObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | | // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // // System.out.println(index); |
| | | // PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("FeedID"); |
| | | // addresses.add("AddStart"); |
| | | // // System.out.println(addresses); |
| | | // // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | // List<String> addresses2 = new ArrayList<>(); |
| | | // addresses2.add("FeedID"); |
| | | // addresses2.add("FeedCarStatus"); |
| | | |
| | | //System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | |
| | | |
| | | |
| | | public class PlcBitInfo { |
| | | |
| | | public PlcBitInfo(String startAddress) { |
| | | this.startAddress = startAddress; |
| | | } |
| | | private String startAddress; |
| | | // 参数标识 |
| | | private String codeId; |
| | | |
| | | // 参数名称 |
| | | private String name; |
| | | |
| | | // 读取 参数值 |
| | | private Boolean value; |
| | | // 参数地址 |
| | | private int addressIndex; |
| | | |
| | | public String getCodeId() { |
| | | return this.codeId; |
| | | } |
| | | |
| | | public void setCodeId(String codeId) { |
| | | this.codeId = codeId; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public Boolean getValue() { |
| | | return this.value; |
| | | } |
| | | |
| | | public void setValue(Boolean value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | |
| | | public int getAddressIndex() { |
| | | return this.addressIndex; |
| | | } |
| | | /** |
| | | * 获取地址 |
| | | * |
| | | * @param index 索引地址 |
| | | */ |
| | | public String getAddress(int index) { |
| | | String[] stringdatas = this.startAddress.trim().split("\\."); |
| | | if (stringdatas.length < 2 ) |
| | | return null; |
| | | int dbwindex = 0; |
| | | int bitindex = 0; |
| | | if (stringdatas.length == 3) { |
| | | dbwindex = Integer.parseInt(stringdatas[1]); |
| | | bitindex = Integer.parseInt(stringdatas[2]); |
| | | } else |
| | | return null; |
| | | dbwindex+=index/8; |
| | | bitindex+=index%8; |
| | | return stringdatas[0]+"."+dbwindex+"."+bitindex; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void setAddressIndex(int addressindex) { |
| | | this.addressIndex = addressindex; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class PlcBitObject { |
| | | |
| | | // 该模块数据类型,数据起始位置 |
| | | private String plcAddressBegin; |
| | | // 数据地址长度:第一参数到最后一个参数的长度 |
| | | private int plcAddressLength; |
| | | private ArrayList<PlcBitInfo> plcBitList; |
| | | |
| | | /** |
| | | * @return 数据区开始地址 |
| | | */ |
| | | public String getPlcAddressBegin() { |
| | | return plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @param plcAddressBegin 设置数据区开始地址 |
| | | */ |
| | | public void setPlcAddressBegin(String plcAddressBegin) { |
| | | this.plcAddressBegin = plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @return 数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public int getPlcAddressLength() { |
| | | return plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public void setPlcAddressLength(int plcAddressLength) { |
| | | this.plcAddressLength = plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 获取参数实例集合 |
| | | */ |
| | | public ArrayList<PlcBitInfo> getBitList() { |
| | | return plcBitList; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public PlcBitInfo getPlcBit(String codeid) { |
| | | if (plcBitList != null) { |
| | | for (PlcBitInfo plcbitInfo : plcBitList) { |
| | | if (plcbitInfo.getCodeId().equals(codeid)) |
| | | return plcbitInfo; |
| | | } |
| | | return null; |
| | | } else |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public List<Boolean> getPlcBitValues(List<String> codeids) { |
| | | List<Boolean> arrayList = new ArrayList<>(); |
| | | if (plcBitList != null) { |
| | | Map<String, Boolean> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 |
| | | for (PlcBitInfo plcBitInfo : plcBitList) { |
| | | if (codeids.contains(plcBitInfo.getCodeId().toString())) { |
| | | resultMap.put(plcBitInfo.getCodeId().toString(), plcBitInfo.getValue()); |
| | | } |
| | | } |
| | | for (String codeId : codeids) { // 按照传入参数的顺序遍历 |
| | | Boolean value = resultMap.get(codeId); |
| | | if (value != null) { |
| | | arrayList.add(value); |
| | | } else { |
| | | arrayList.add(null); // 如果找不到对应的值,添加 null |
| | | } |
| | | } |
| | | } |
| | | return arrayList; |
| | | } |
| | | |
| | | |
| | | public List<String> getAddressListByCodeId(List<String> codeIdList) { |
| | | List<String> addressList = new ArrayList<>(); |
| | | for (String codeId : codeIdList) { |
| | | for (PlcBitInfo plcBitInfo : plcBitList) { |
| | | if (plcBitInfo.getCodeId().equals(codeId)) { |
| | | int index = plcBitInfo.getAddressIndex(); |
| | | String address = plcBitInfo.getAddress(index); |
| | | if (address != null) { |
| | | addressList.add(address); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return addressList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加参数实例 |
| | | * |
| | | * @param param 参数实例 |
| | | */ |
| | | public void addPlcBit(PlcBitInfo param) { |
| | | if (plcBitList != null) |
| | | plcBitList.add(param); |
| | | else { |
| | | plcBitList = new ArrayList<PlcBitInfo>(); |
| | | plcBitList.add(param); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC返回的数据 给参数实例赋值 |
| | | * |
| | | * @param plcValueArray PLC读取回来的byte类型数据集合 |
| | | */ |
| | | public void setPlcBitList(List<Boolean> plcValueArray) { |
| | | if (plcBitList != null) { |
| | | for (PlcBitInfo plcbitInfo : plcBitList) { |
| | | plcbitInfo.setValue(plcValueArray.get(plcbitInfo.getAddressIndex())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | public class PlcParameterInfo { |
| | | public PlcParameterInfo(String startAddress) { |
| | | this.startAddress = startAddress; |
| | | } |
| | | private String startAddress; |
| | | // 参数标识 |
| | | private String codeId; |
| | | |
| | | // 参数名称 |
| | | private String name; |
| | | |
| | | // 读取 参数值 |
| | | private String value; |
| | | |
| | | // // 写入 参数值 |
| | | // private String writeValue; |
| | | |
| | | // 参数单位 |
| | | private String unit; |
| | | |
| | | // 参数值转换系数 |
| | | private int ratio; |
| | | |
| | | // 参数地址 |
| | | private int addressIndex; |
| | | |
| | | // 参数地址位长度 |
| | | private int addressLength; |
| | | |
| | | public String getCodeId() { |
| | | return this.codeId; |
| | | } |
| | | |
| | | public void setCodeId(String codeId) { |
| | | this.codeId = codeId; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return this.value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | // public String getWriteValue() { |
| | | // return this.writeValue; |
| | | // } |
| | | |
| | | // public void setWriteValue(String writeValue) { |
| | | // this.writeValue = writeValue; |
| | | // } |
| | | |
| | | public String getUnit() { |
| | | return this.unit; |
| | | } |
| | | |
| | | public void setUnit(String unit) { |
| | | this.unit = unit; |
| | | } |
| | | |
| | | public int getAddressIndex() { |
| | | return this.addressIndex; |
| | | } |
| | | |
| | | public void setAddressIndex(int addressindex) { |
| | | this.addressIndex = addressindex; |
| | | } |
| | | |
| | | public int getAddressLength() { |
| | | return this.addressLength; |
| | | } |
| | | |
| | | public void setAddressLength(int addresslength) { |
| | | this.addressLength = addresslength; |
| | | } |
| | | |
| | | public int getRatio() { |
| | | return this.ratio; |
| | | } |
| | | |
| | | public void setRatio(int ratio) { |
| | | this.ratio = ratio; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取地址 |
| | | * |
| | | * @param index 索引地址 |
| | | */ |
| | | public String getAddress(int index) { |
| | | String[] stringdatas = this.startAddress.trim().split("\\."); |
| | | int addressLength=this.addressLength; |
| | | if (addressLength < 2 ){ |
| | | return null; |
| | | } |
| | | |
| | | if (addressLength == 2 ) { |
| | | int wordindex = index; |
| | | |
| | | return stringdatas[0] + "." + wordindex; |
| | | } |
| | | if (addressLength == 14 ) { |
| | | int wordindex = index; |
| | | //int newIndex = wordindex + 13; |
| | | return stringdatas[0] + "." + wordindex ; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public int getPlcAddress() { |
| | | |
| | | return addressIndex; |
| | | } |
| | | public String getAddress() { |
| | | return getAddress(this.addressIndex); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.entity.device; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class PlcParameterObject { |
| | | |
| | | // 该模块数据类型,数据起始位置 |
| | | private String plcAddressBegin; |
| | | // 数据地址长度:第一参数到最后一个参数的长度 |
| | | private int plcAddressLength; |
| | | private ArrayList<PlcParameterInfo> plcParameterList; |
| | | |
| | | /** |
| | | * @return 数据区开始地址 |
| | | */ |
| | | public String getPlcAddressBegin() { |
| | | return plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @param plcAddressBegin 设置数据区开始地址 |
| | | */ |
| | | public void setPlcAddressBegin(String plcAddressBegin) { |
| | | this.plcAddressBegin = plcAddressBegin; |
| | | } |
| | | |
| | | /** |
| | | * @return 数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public int getPlcAddressLength() { |
| | | return plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 设置:数据区 读取所有数据所需的长度(以byte类型为基准) |
| | | */ |
| | | public void setPlcAddressLength(int plcAddressLength) { |
| | | this.plcAddressLength = plcAddressLength; |
| | | } |
| | | |
| | | /** |
| | | * @return 获取参数实例集合 |
| | | */ |
| | | public ArrayList<PlcParameterInfo> getPlcParameterList() { |
| | | return plcParameterList; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeid 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public PlcParameterInfo getPlcParameter(String codeid) { |
| | | if (plcParameterList != null) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (plcParameterInfo.getCodeId().equals(codeid)) |
| | | return plcParameterInfo; |
| | | } |
| | | return null; |
| | | } else |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据参数标识 获取某个参数实例 |
| | | * |
| | | * @param codeids 参数标识 |
| | | * @return 获取某个参数实例 |
| | | */ |
| | | public List<String> getPlcParameterValues(List<String> codeids) { |
| | | List<String> arrayList = new ArrayList<>(); |
| | | if (plcParameterList != null) { |
| | | Map<String, PlcParameterInfo> resultMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保留插入顺序 |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (codeids.contains(plcParameterInfo.getCodeId())) { |
| | | resultMap.put(plcParameterInfo.getCodeId(), plcParameterInfo); |
| | | } |
| | | } |
| | | for (String codeId : codeids) { // 按照传入参数的顺序遍历 |
| | | PlcParameterInfo plcParameterInfo = resultMap.get(codeId); |
| | | if (plcParameterInfo != null) { |
| | | arrayList.add(plcParameterInfo.getValue()); |
| | | } else { |
| | | arrayList.add(null); // 如果找不到对应的值,添加 null |
| | | } |
| | | } |
| | | } |
| | | return arrayList; |
| | | } |
| | | |
| | | |
| | | public List<String> getAddressListByCodeId(List<String> codeIdList) { |
| | | List<String> addressList = new ArrayList<>(); |
| | | for (String codeId : codeIdList) { |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | if (plcParameterInfo.getCodeId().equals(codeId)) { |
| | | int index = plcParameterInfo.getAddressIndex(); |
| | | String address = plcParameterInfo.getAddress(index); |
| | | if (address != null) { |
| | | addressList.add(address); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return addressList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加参数实例 |
| | | * |
| | | * @param param 参数实例 |
| | | */ |
| | | public void addPlcParameter(PlcParameterInfo param) { |
| | | if (plcParameterList != null) |
| | | plcParameterList.add(param); |
| | | else { |
| | | plcParameterList = new ArrayList<PlcParameterInfo>(); |
| | | plcParameterList.add(param); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC返回的数据 给参数实例赋值 |
| | | * |
| | | * @param plcValueArray PLC读取回来的byte类型数据集合 |
| | | */ |
| | | public void setPlcParameterList(byte[] plcValueArray) { |
| | | if (plcParameterList != null) { |
| | | |
| | | for (PlcParameterInfo plcParameterInfo : plcParameterList) { |
| | | |
| | | byte[] valueList = new byte[plcParameterInfo.getAddressLength()]; |
| | | |
| | | // System.out.println(plcParameterInfo.getAddressLength()); |
| | | |
| | | for (int i = 0; i < plcParameterInfo.getAddressLength(); i++) { |
| | | Array.setByte(valueList, i, plcValueArray[plcParameterInfo.getAddressIndex() + i]); |
| | | |
| | | } |
| | | if (plcParameterInfo.getAddressLength()==2) { |
| | | plcParameterInfo.setValue(String.valueOf(byte2short(valueList))); |
| | | } |
| | | else if (plcParameterInfo.getAddressLength()==14) { |
| | | plcParameterInfo.setValue((byteToHexString(valueList))); |
| | | } |
| | | |
| | | else |
| | | { |
| | | String valuestr = new String(valueList); |
| | | plcParameterInfo.setValue(valuestr); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * short类型转byte[] |
| | | * |
| | | * @param s short类型值 |
| | | */ |
| | | public static byte[] short2byte(short s){ |
| | | byte[] b = new byte[2]; |
| | | for(int i = 0; i < 2; i++){ |
| | | int offset = 16 - (i+1)*8; //因为byte占4个字节,所以要计算偏移量 |
| | | b[i] = (byte)((s >> offset)&0xff); //把16位分为2个8位进行分别存储 |
| | | } |
| | | return b; |
| | | } |
| | | /** |
| | | * byte[]类型转short |
| | | * |
| | | * @param b byte[]类型值 |
| | | */ |
| | | public static short byte2short(byte[] b){ |
| | | short l = 0; |
| | | for (int i = 0; i < 2; i++) { |
| | | l<<=8; //<<=和我们的 +=是一样的,意思就是 l = l << 8 |
| | | l |= (b[i] & 0xff); //和上面也是一样的 l = l | (b[i]&0xff) |
| | | } |
| | | return l; |
| | | } |
| | | |
| | | public static String byteToHexString(byte[] bytes) { |
| | | |
| | | String str = new String(bytes, StandardCharsets.UTF_8); |
| | | return str; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.mes.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.entity.EdgStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.OrderTest; |
| | | import com.mes.entity.TaskCache; |
| | | import com.mes.entity.Tempered; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | | public interface SelectInfo { |
| | | //玻璃信息 按ID查询 |
| | | // 玻璃信息 按ID查询 |
| | | @Select("select * from `glass_info` where id=#{id}") |
| | | GlassInfo SelectGlassId(String id); |
| | | |
| | | //钢化按工程查询 |
| | | // 钢化按工程查询 |
| | | @Select("select * from `v_optimize_heat_layout` where project_no=#{projeceid} ") |
| | | List<Tempered> SelectTempered(String projeceid); |
| | | // |
| | | // @Insert("INSERT `order`(order_id)VALUES(#{order_id})") |
| | | // Integer insert(Order order); |
| | | // |
| | | // @Delete("delete from `order` where id=#{id}") |
| | | // Integer deleteById(@Param("id") Integer id); |
| | | // |
| | | // @Update("update `order` set order_id=#{order_id} where id=#{id}") |
| | | // Integer update(@Param("id") Integer id,@Param("order_id") String order_id); |
| | | List<Tempered> SelectTemperedTerritory(String projeceid); |
| | | |
| | | // 切割版图按工程查询 |
| | | @Select("select * from optimize_detail where project_no=#{projeceid} ") |
| | | List<Map> SelectCutTerritory(String projeceid); |
| | | |
| | | // 查询磨边信息 |
| | | @Select("select * from task_cache where task_type='2' and task_stauts='2' and end_cell=#{EndCell}") |
| | | List<Map> SelectEdgInfo(String EndCell); |
| | | |
| | | // 查询笼子内空闲 |
| | | @Select("select escd.* from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is null order by escd.slot") |
| | | List<EdgStorageCageDetails> SelectCacheLeisure(); |
| | | |
| | | // 查询笼子内出片任务 |
| | | @Select("select escd.* from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot WHERE escd.slot IS NOT NULL order by escd.tempering_layout_id,escd.tempering_feed_sequence") |
| | | List<EdgStorageCageDetails> SelectCacheOut(); |
| | | |
| | | // 查询笼子内信息 |
| | | @Select("select escd.* from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot order by esc.slot") |
| | | List<EdgStorageCageDetails> SelectCachInfo(); |
| | | |
| | | // 查询可进此片玻璃的栅格号 |
| | | @Select("select escd.* from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is not null escd.tempering_layout_id=#{tempering_layout_id} and escd.tempering_feed_sequence<#{tempering_feed_sequence} and esc.remain_width-#{width}>0 order by escd.tempering_feed_sequence") |
| | | List<EdgStorageCageDetails> SelectIsExistIntoCache(Integer tempering_layout_id, Integer tempering_feed_sequence, |
| | | double width); |
| | | |
| | | // 查询可进此片玻璃的栅格号 |
| | | @Select("select escd.* from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is not null escd.tempering_layout_id<#{tempering_layout_id} and esc.remain_width-#{width}>0 order by escd.tempering_layout_id desc,escd.tempering_feed_sequence") |
| | | List<EdgStorageCageDetails> SelectIsExistIntoCache(Integer tempering_layout_id, double width); |
| | | |
| | | // 查询全部任务 |
| | | @Select("select * from task_cache") |
| | | List<TaskCache> SelectCacheInfoAll(); |
| | | |
| | | // 查询进片任务 |
| | | @Select("select * from task_cache where task_type='1' and task_stauts='0'") |
| | | List<TaskCache> SelectInputCacheInfo(); |
| | | |
| | | // 查询出片任务 |
| | | @Select("select * from task_cache where task_type='2' and task_stauts='0'") |
| | | List<TaskCache> SelectOutCacheInfo(); |
| | | |
| | | // 查询 A09 或 A10 最新的一片 出片任务 |
| | | @Select("select * from task_cache where task_type='2' and task_stauts='2' and end_cell=#{EndCell} limit 1") |
| | | GlassInfo SelectLastOutCacheInfo(String EndCell); |
| | | |
| | | // 修改笼子内信息 |
| | | @Update("update") |
| | | Integer UpdateCache(@Param("id") Integer id, @Param("order_id") String order_id); |
| | | |
| | | // 添加理片任务 |
| | | @Insert("INSERT into task_cache VALUES(#{id},#{start},#{end},#{type},0)") |
| | | Integer insertCacheTask(String id, String start, String end, String type); |
| | | |
| | | // |
| | | // @Insert("INSERT `order`(order_id)VALUES(#{order_id})") |
| | | // Integer insert(Order order); |
| | | // |
| | | // @Delete("delete from `order` where id=#{id}") |
| | | // Integer deleteById(@Param("id") Integer id); |
| | | // |
| | | // @Update("update `order` set order_id=#{order_id} where id=#{id}") |
| | | // Integer update(@Param("id") Integer id,@Param("order_id") String order_id); |
| | | } |
| | |
| | | package com.mes.service.CacheGlassService; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.EdgStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.TaskCache; |
| | | import com.mes.entity.device.PLCAutoMes; |
| | | import com.mes.entity.device.PlcParameterObject; |
| | | import com.mes.mapper.SelectInfo; |
| | | |
| | | |
| | |
| | | public class Logic { |
| | | @Autowired |
| | | private SelectInfo selectInfo; |
| | | //识别逻辑 |
| | | //识别逻辑 不交互 |
| | | public void identify(String Number){ |
| | | //查询任务 |
| | | // PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | String s=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; |
| | | boolean isexist=isExist(Number); |
| | | if (isexist) { |
| | | //存在逻辑 1.添加信息 2.回复PLC存在 |
| | |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); |
| | | } |
| | | } |
| | | //理片 |
| | | public void Process(){ |
| | | String Result=S7control.getinstance().ReadWord("DB14.0", 1).get(0)+""; |
| | | String Number=S7control.getinstance().ReadWord("DB14.2", 1).get(0)+""; |
| | | if(Result=="1"){//进片请求 |
| | | processInto(Number); |
| | | }else if(Result=="2"){//出片请求 |
| | | processOut(); |
| | | }else if(Result=="3"){//进出片请求 |
| | | if (!processOut()) { //先出后进 |
| | | processInto(Number); |
| | | } |
| | | } |
| | | } |
| | | //理片 进 |
| | | public void process(String imagePath){ |
| | | public boolean processInto(String Number){ |
| | | //查询消息队列里的玻璃 |
| | | |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){//存在此玻璃编号 |
| | | //同钢化版图内的栅格号 |
| | | List<EdgStorageCageDetails> list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getTemperingfeedsequence(),GlassInfo.getWidth()); |
| | | //空栅格号 |
| | | if (list.size()==0) { |
| | | list=selectInfo.SelectCacheLeisure(); |
| | | } |
| | | //小于此玻璃钢化版图序号的栅格号 |
| | | if(list.size()==0){ |
| | | list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getWidth()); |
| | | } |
| | | if(list.size()>0){ |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | EdgStorageCageDetails item=list.get(0); |
| | | selectInfo.insertCacheTask(GlassInfo.getId()+"","0",item.getSlot()+"","1"); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | return true; |
| | | } |
| | | |
| | | }else{ |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | //理片 出 |
| | | public void processOut(String imagePath){ |
| | | public boolean processOut(){ |
| | | //查询任务 |
| | | |
| | | String A09=S7control.getinstance().ReadWord("DB14.56", 1).get(0)+""; |
| | | String A10=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | List<EdgStorageCageDetails> list=selectInfo.SelectCacheOut(); |
| | | boolean isOut=true;//其他情况条件 如:后续设备故障禁止理片出片 等 |
| | | if (list.size()>0&&isOut) { |
| | | EdgStorageCageDetails item=list.get(0); |
| | | if(A09=="0"&&A10=="1"){ |
| | | //出到 A09 |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0","09","2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(A09=="1"&&A10=="0"){ |
| | | //出到 A10 |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0","10","2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(A09=="0"&&A10=="0"){ |
| | | //都允许 A09/A10 上一片是否和此片玻璃尺寸尺寸相同 |
| | | String endcell="09"; |
| | | String SendEndcell="1"; |
| | | boolean If_=false; |
| | | GlassInfo glassInfo09= selectInfo.SelectLastOutCacheInfo("09"); |
| | | GlassInfo glassInfo10= selectInfo.SelectLastOutCacheInfo("10"); |
| | | if(glassInfo10!=null&&glassInfo10.getWidth()==item.getWidth()&&glassInfo10.getHeight()==item.getHeight()){ |
| | | endcell="10"; |
| | | SendEndcell="2"; |
| | | }else if(glassInfo10!=null&&If_){ |
| | | //其他条件 |
| | | } |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0",endcell,"2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | //磨边 |
| | | public void processMb(String imagePath){ |
| | | //查询任务 |
| | | |
| | | //磨边 不交互 理片和磨边机自己交互 |
| | | public void processMb(String Number){ |
| | | //查询任务 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){ |
| | | //发送任务 ID 长 宽 厚 倒角 工艺功能等 |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | } |
| | | //返回结果 |
| | | } |
| | | |
| | |
| | | } |
| | | return true;//返回 存在 |
| | | } |
| | | |
| | | //是否存在此编号玻璃 |
| | | public boolean isExist(String Number){ |
| | | //查询是否存在 |
New file |
| | |
| | | package com.mes.service.hangzhoumes; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.mes.entity.EdgStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.Tempered; |
| | | import com.mes.mapper.SelectInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @DS("hangzhoumes") |
| | | public class hangzhoumesService { |
| | | |
| | | @Autowired |
| | | private SelectInfo SelectInfo; |
| | | |
| | | public GlassInfo getUserInfo(String process_id){ |
| | | return SelectInfo.SelectGlassId(process_id); |
| | | } |
| | | // //识别信息 |
| | | // public List<Map> SelectCutTerritory(String process_id){ |
| | | // return SelectInfo.SelectCutTerritory(process_id); |
| | | // } |
| | | |
| | | //理片缓存 笼内信息 |
| | | public List<EdgStorageCageDetails> SelectCageInfo(){ |
| | | return SelectInfo.SelectCachInfo(); |
| | | } |
| | | |
| | | //磨边小片信息 |
| | | public List<Map> SelectEdgInfo(String line){ |
| | | |
| | | return SelectInfo.SelectEdgInfo(line); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.mes.service.pp; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.mes.common.CacheUtil; |
| | | import com.mes.common.Result; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.Tempered; |
| | | import com.mes.entity.userInfo.User; |
| | | import com.mes.mapper.SelectInfo; |
| | | import com.mes.mapper.userInfo.UserMapper; |
| | | import com.mes.controller.dto.UserDTO; |
| | | import com.mes.tools.TokenTools; |
| | | import org.apache.ibatis.jdbc.Null; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | |
| | | return SelectInfo.SelectGlassId(process_id); |
| | | } |
| | | |
| | | public List<Tempered> getSelectTempered(String process_id){ |
| | | return SelectInfo.SelectTempered(process_id); |
| | | public List<Tempered> SelectTemperedTerritory(String process_id){ |
| | | return SelectInfo.SelectTemperedTerritory(process_id); |
| | | } |
| | | //切割版图 |
| | | public List<Map> SelectCutTerritory(String process_id){ |
| | | return SelectInfo.SelectCutTerritory(process_id); |
| | | } |
| | | |
| | | |
| | |
| | | url: jdbc:mysql://10.153.19.150:3306/hangzhoumes?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | pp: |
| | | url: jdbc:mysql://10.153.19.150:3306/pp?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | url: jdbc:mysql://10.153.19.150:3306/hangzhoumes?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | pp: |
| | | url: jdbc:mysql://10.153.19.150:3306/pp?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | |
| | | // private BigStorageCageMapper bigStorageCageMapper; |
| | | |
| | | // // 获取玻璃存放格子 |
| | | // public BigStorageCageDetails FeedGlass(BigStorageCageDetails bigStorageCageDetails) { |
| | | // //获取同钢化版图id可进片的格子 |
| | | // BigStorageCageDetails LayoutSlotInfo=bigStorageCageMapper.SelectTemperingFeedSlot(bigStorageCageDetails); |
| | | // //有符合条件的格子时 |
| | | // if (LayoutSlotInfo!=null) { |
| | | // //将玻璃信息填入理片笼详情表 |
| | | // bigStorageCageDetails.setSlot(LayoutSlotInfo.getSlot()); |
| | | // }else{ |
| | | // //获取不到时: |
| | | // 获取玻璃存放格子 |
| | | public BigStorageCageDetails FeedGlass(BigStorageCageDetails bigStorageCageDetails) { |
| | | //获取同钢化版图id可进片的格子 |
| | | BigStorageCageDetails LayoutSlotInfo=bigStorageCageMapper.SelectTemperingFeedSlot(bigStorageCageDetails); |
| | | //有符合条件的格子时 |
| | | if (LayoutSlotInfo!=null) { |
| | | //将玻璃信息填入理片笼详情表 |
| | | bigStorageCageDetails.setSlot(LayoutSlotInfo.getSlot()); |
| | | }else{ |
| | | //获取不到时: |
| | | |
| | | // //获取可进片格子信息 |
| | | // BigStorageCageDetails EmptySlotInfo=bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | // bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | // //获取其他笼格子 |
| | | //获取可进片格子信息 |
| | | BigStorageCageDetails EmptySlotInfo=bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | //获取其他笼格子- |
| | | |
| | | // //将玻璃信息放入该格子 |
| | | //将玻璃信息放入该格子 |
| | | |
| | | // } |
| | | } |
| | | |
| | | // UpdateRemainWidth(bigStorageCageDetails.getSlot()); |
| | | // return bigStorageCageDetails; |
| | | // } |
| | | UpdateRemainWidth(bigStorageCageDetails.getSlot()); |
| | | return bigStorageCageDetails; |
| | | } |
| | | |
| | | // //修改格子剩余宽度 |
| | | // private void UpdateRemainWidth(int Slot){ |
| | | // //获取该格子内玻璃信息 |
| | | //修改格子剩余宽度 |
| | | private void UpdateRemainWidth(int Slot){ |
| | | //获取该格子内玻璃信息 |
| | | |
| | | // //修改格子剩余宽度 |
| | | // BigStorageCageMapper.UpdateRemainWidth(Slot); |
| | | // } |
| | | //修改格子剩余宽度 |
| | | BigStorageCageMapper.UpdateRemainWidth(Slot); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | url: jdbc:mysql://10.153.19.150:3306/erp_user_info?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | sd: |
| | | url: jdbc:mysql://10.153.19.150:3306/sd?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | mm: |
| | | url: jdbc:mysql://10.153.19.150:3306/mm?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | pp: |
| | | url: jdbc:mysql://10.153.19.150:3306/pp?serverTimezone=GMT%2b8 |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <link rel="icon" href="/favicon.ico"> |
| | | <!-- <link rel="icon" href="/favicon.ico"> --> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| | | <title>北玻</title> |
| | | </head> |
| | |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | public void writeString(String addr,String data) { |
| | | s7PLC.writeString(addr,data); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | @Autowired
|
| | | private DownGlassInfoService downGlassInfoService;
|
| | |
|
| | | // 获取指定ID的DownGlassInfo信息
|
| | | /**
|
| | | * @param id
|
| | | * @return
|
| | | * // 获取指定ID的DownGlassInfo信息
|
| | | */
|
| | |
|
| | | @GetMapping("/{id}")
|
| | | public DownGlassInfo getDownGlassInfoById(@PathVariable Integer id) {
|
| | | return downGlassInfoService.getDownGlassInfoById(id);
|
New file |
| | |
| | | package com.mes.controller;
|
| | |
|
| | | import com.mes.entity.DownWorkstation;
|
| | | import com.mes.service.DownWorkstationService;
|
| | | import com.mes.service.GlassInfoService;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @RestController
|
| | | @RequestMapping("/downWorkstation")
|
| | | public class DownWorkstationController {
|
| | |
|
| | | @Autowired
|
| | | private DownWorkstationService downWorkstationService;
|
| | | @Autowired
|
| | | private GlassInfoService glassInfoService;
|
| | |
|
| | | @GetMapping("/getone")
|
| | | public List<DownWorkstation> getoneDownWorkstations() {
|
| | | return downWorkstationService.getoneDownWorkstations();
|
| | | }
|
| | |
|
| | | @GetMapping("/gettwo")
|
| | | public List<DownWorkstation> gettwoDownWorkstations() {
|
| | | return downWorkstationService.gettwoDownWorkstations();
|
| | | }
|
| | | @GetMapping("/getflowCardId")
|
| | | public List<Map<String, Object>> getflowCardId() {
|
| | | return downWorkstationService.getflowCardId();
|
| | | }
|
| | |
|
| | |
|
| | | @PostMapping("/updateFlowCardId")
|
| | | public String updateFlowCardId(@RequestBody Map<String, Object> requestData) {
|
| | | // 从 requestData 中获取传入的 flowCardId
|
| | | String flowCardId = (String) requestData.get("flowCardId");
|
| | |
|
| | | // 查询对应 flowCardId 的玻璃信息总数量
|
| | | int glassInfoCount = glassInfoService.getGlassInfoCountByFlowCardId(flowCardId);
|
| | |
|
| | | // 更新 down_workstation 表中的总数量
|
| | | glassInfoService.updateFlowCardIdAndCount(flowCardId, glassInfoCount);
|
| | |
|
| | | // 返回处理结果,比如成功或失败信息
|
| | | return "updated successfully";
|
| | | }
|
| | |
|
| | |
|
| | | @DeleteMapping("/clear/{workstationId}")
|
| | | public String clearWorkstationInfo(@PathVariable("workstationId") int workstationId) {
|
| | | // 调用 DownWorkstationService 中的方法清除指定工位ID的信息
|
| | | downWorkstationService.clearFlowCardId(workstationId);
|
| | | // 返回处理结果,比如成功或失败信息
|
| | | return "cleared successfully";
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | |
| | | import com.baomidou.mybatisplus.annotation.IdType;
|
| | | import com.baomidou.mybatisplus.annotation.TableId;
|
| | | import lombok.Data;
|
| | |
|
| | | /**
|
| | | * 下片前理片笼明细实体类
|
| | | */
|
| | | /**
|
| | | * 下片前理片笼明细实体类
|
| | | * @author SNG-012
|
| | | */
|
| | | @Data
|
| | | public class DownStorageCageDetails {
|
| | |
|
| | | @TableId(type = IdType.AUTO)
|
| | | private int id; // 下片前理片笼明细表id
|
| | | /**
|
| | | * 下片前理片笼明细表id
|
| | | */
|
| | | private int id;
|
| | |
|
| | | private int deviceId; // 设备id
|
| | | private int slot; // 栅格号
|
| | | private int glassId; // 玻璃id
|
| | | private int sequence; // 小片在格内的顺序
|
| | | private String flowCardId; // 流程卡号
|
| | | private int glassType; // 玻璃类型
|
| | | private double width; // 宽
|
| | | private double height; // 高
|
| | | private double thickness; // 厚度
|
| | | private int temperingLayoutId; // 钢化版图id
|
| | | private int temperingFeedSequence; // 钢化版图片序
|
| | | private int state; // 状态
|
| | | private int gap; // 玻璃间隙
|
| | | } |
| | | /**
|
| | | * 设备id
|
| | | */
|
| | | private int deviceId;
|
| | |
|
| | | /**
|
| | | * 栅格号
|
| | | */
|
| | | private int slot;
|
| | |
|
| | | /**
|
| | | * 玻璃id
|
| | | */
|
| | | private int glassId;
|
| | |
|
| | | /**
|
| | | * 小片在格内的顺序
|
| | | */
|
| | | private int sequence;
|
| | |
|
| | | /**
|
| | | * 流程卡号
|
| | | */
|
| | | private String flowCardId;
|
| | |
|
| | | /**
|
| | | * 玻璃类型
|
| | | */
|
| | | private int glassType;
|
| | |
|
| | | /**
|
| | | * 宽
|
| | | */
|
| | | private double width;
|
| | |
|
| | | /**
|
| | | * 高
|
| | | */
|
| | | private double height;
|
| | |
|
| | | /**
|
| | | * 厚度
|
| | | */
|
| | | private double thickness;
|
| | |
|
| | | /**
|
| | | * 钢化版图id
|
| | | */
|
| | | private int temperingFeedSequence;
|
| | |
|
| | | /**
|
| | | * 钢化版图片序
|
| | | */
|
| | | private int temperingLayoutId;
|
| | |
|
| | | /**
|
| | | * 状态
|
| | | */
|
| | | private int state;
|
| | |
|
| | | /**
|
| | | * 玻璃间隙
|
| | | */
|
| | | private int gap;
|
| | | }
|
| | |
|
| | |
| | | package com.mes.entity;
|
| | |
|
| | | import com.baomidou.mybatisplus.annotation.IdType;
|
| | | import com.baomidou.mybatisplus.annotation.TableId;
|
| | | import lombok.Data;
|
| | | import com.baomidou.mybatisplus.annotation.TableField;
|
| | | import com.baomidou.mybatisplus.annotation.TableId;
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class DownWorkstation {
|
| | |
|
| | | /**
|
| | | * // 下片工位表
|
| | | */
|
| | | @TableId(type = IdType.AUTO)
|
| | | private int id; // 下片工位表id
|
| | | private Integer workstationId; // 工位id
|
| | | private String flowCardId; // 流程卡号
|
| | | private Integer deviceId; // 设备id
|
| | | private Integer enableState; // 启用状态
|
| | | private Integer workState; // 工作状态
|
| | | private Integer racks_number; // 已落架数量
|
| | | private Integer total_quantity; // 总数量
|
| | | private int id;
|
| | |
|
| | | /**
|
| | | * // 工位id
|
| | | */
|
| | | private Integer workstationId;
|
| | |
|
| | | /**
|
| | | * // 流程卡号
|
| | | */
|
| | | private String flowCardId;
|
| | |
|
| | | /**
|
| | | * // 设备id
|
| | | */
|
| | | private Integer deviceId;
|
| | |
|
| | | /**
|
| | | * // 启用状态
|
| | | */
|
| | | private Integer enableState;
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * // 工作状态
|
| | | */
|
| | | private Integer workState;
|
| | |
|
| | | /**
|
| | | * // 已落架数量
|
| | | */
|
| | | @TableField(value = "racks_number")
|
| | | private int racksnumber;
|
| | |
|
| | | /**
|
| | | * // 总数量
|
| | | */
|
| | | @TableField(value = "total_quantity")
|
| | | private Integer totalquantity;
|
| | |
|
| | | } |
New file |
| | |
| | | package com.mes.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | @Data //lombok 简写java代码 实体类的get与set |
| | | @TableName("`edg_storage_cage_details`") |
| | | public class EdgStorageCageDetails { |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id;//磨边前理片笼详情表id |
| | | private Integer deviceid;//设备id |
| | | private Integer slot;//栅格号 |
| | | private Integer glassid;//玻璃id |
| | | private Integer sequence;//小片在格内的顺序 |
| | | private String flowcardid;//流程卡号 |
| | | private Integer glasstype;//玻璃类型 |
| | | private Double width;//宽 |
| | | private Double height;//高 |
| | | private Double thickness;//厚度 |
| | | private Double edgwidth;//磨前宽 |
| | | private Double edgheight;//磨前高 |
| | | private Integer temperinglayoutid;//钢化版图id |
| | | private Integer temperingfeedsequence;//钢化版图片序 |
| | | private Integer patternsequence;//原片顺序 |
| | | private Integer state;//状态 |
| | | private Integer gap;//玻璃间隙 |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigInteger; |
| | | |
| | | @Data //lombok 简写java代码 实体类的get与set |
| | | @TableName("`glass_info`") |
| | | public class GlassInfo { |
| | | @TableId(type = IdType.AUTO) |
| | | private BigInteger id;//玻璃信息表id |
| | | private String flowcardid;//流程卡 |
| | | private Integer glasstype;//流程卡玻璃类型 |
| | | private Double width;//宽 |
| | | private Double height;//高 |
| | | private Double thickness;//厚度 |
| | | private Integer filmsid;//膜系 |
| | | private Double edgwidth;//磨前宽 |
| | | private Double edgheight;//磨前高 |
| | | private Integer ismultiple;//是否配片 |
| | | private Double maxwidth;//配片最大宽 |
| | | private Double maxheight;//配片最大高 |
| | | private Integer ishorizontal;//钢化是否接受横放 |
| | | private Integer patternsequence;//原片顺序 |
| | | private Integer temperinglayoutid;//钢化版图id |
| | | private Integer temperingfeedsequence;//钢化版图片序 |
| | | private Integer xcoordinate;//x坐标 |
| | | private Integer ycoordinate;//y坐标 |
| | | private Integer angle;//旋转角度(逆时针) |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | @Data //lombok 简写java代码 实体类的get与set |
| | | |
| | | public class TaskCache { |
| | | @TableId(type = IdType.AUTO) |
| | | private int id;//id |
| | | private String startCell;//起始 |
| | | private String endCell;//结束 |
| | | private String taskType;//类型 |
| | | private double width;//宽 |
| | | private double height;//搞 |
| | | private String filmsId;//膜系 |
| | | private double thickness;//厚度 |
| | | private String flowCardId;//流程卡号 |
| | | private int taskStatus;//状态 |
| | | |
| | | } |
| | |
| | | |
| | | return addressIndex; |
| | | } |
| | | |
| | | public String getAddress() { |
| | | return getAddress(this.addressIndex); |
| | | } |
| | | } |
| | |
| | | public interface DownGlassInfoMapper extends BaseMapper<DownGlassInfo> {
|
| | |
|
| | | // 查询下片任务表中状态为1的下片信息
|
| | | @Select("SELECT flow_card_id,filmsid,width,height,thickness FROM down_glass_task WHERE state = 1;")
|
| | | @Select("SELECT flow_card_id,filmsid,width,height,thickness FROM down_glass_task WHERE task_stauts = 1;")
|
| | | List<DownGlassInfo> selectunloadingtaskstate();
|
| | |
|
| | | @Update("UPDATE down_glass_task SET state = 0 WHERE flow_card_id = #{flowCardId}")
|
| | | @Update("UPDATE down_glass_task SET task_stauts = 0 WHERE flow_card_id = #{flowCardId}")
|
| | | void updateTaskStateToZero(@Param("flowCardId") String flowCardId);
|
| | |
|
| | | @Select("SELECT MAX(sequence) FROM down_glass_info WHERE flow_card_id = #{flowCardId} LIMIT 1")
|
| | |
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @Mapper
|
| | | @Component
|
| | |
| | | //从机械手任务表查询状态为1的流程卡号
|
| | | // @Select("SELECT * FROM down_workstation_task WHERE state = 1")
|
| | | // List<DownWorkstation> selectdownWorkstationstate();
|
| | |
|
| | | @Select("SELECT dw.flow_card_id,dw.racks_number FROM down_workstation_task dwt JOIN down_workstation dw ON dwt.flow_card_id = dw.flow_card_id WHERE dwt.state = 1 LIMIT 1")
|
| | | //查询工位表和任务表中状态为1的流程卡号和已落架数量
|
| | | @Select("SELECT dwt.flow_card_id,dw.id,dw.racks_number FROM down_workstation_task dwt JOIN down_workstation dw ON dwt.flow_card_id = dw.flow_card_id WHERE dwt.state = 1 LIMIT 1")
|
| | | List<DownWorkstation> selectdownWorkstationstate();
|
| | |
|
| | | //更新落架数量
|
| | | @Update("UPDATE down_workstation SET racks_number = #{racksNumber} " +
|
| | | "WHERE flow_card_id = #{flowCardId}")
|
| | | void update_racks_number(@Param("flowCardId") String flowCardId,
|
| | | @Param("racksNumber") Integer racksNumber);
|
| | |
|
| | |
|
| | | //插入机械任务表
|
| | | @Insert("INSERT INTO down_workstation_task (flow_card_id, width, height, thickness, filmsid,state) " +
|
| | | "VALUES (#{flowCardId}, #{width}, #{height}, #{thickness}, #{filmsid},1)")
|
| | | void insertdownWorkstationtask(DownGlassInfo downGlassInfo);
|
| | |
|
| | | //根据工位id更新实体类接收的数据
|
| | | @Update("UPDATE down_workstation SET width = #{width}, height = #{height}, flow_card_id = #{flowCardId} WHERE workstation_id = #{workstationId}")
|
| | | void updateFlowCardId(DownWorkstation downWorkstation);
|
| | |
|
| | |
|
| | |
|
| | | //满架拉走,清空信息
|
| | | @Update("UPDATE down_workstation SET width = null, height = null, flow_card_id = null WHERE workstation_id = #{workstationId}")
|
| | | void clearFlowCardId(DownWorkstation downWorkstation);
|
| | |
|
| | |
|
| | |
|
| | | @Update("UPDATE down_workstation_task SET state = 0 WHERE flow_card_id = #{flowCardId}")
|
| | | void update_task_state_to_zero(@Param("flowCardId") String flowCardId);
|
| | |
|
| | |
|
| | | @Select(" SELECT * FROM down_workstation WHERE workstation_id >= 1 AND workstation_id <= 5")
|
| | | List<DownWorkstation> getoneDownWorkstations();
|
| | |
|
| | |
|
| | | @Select(" SELECT * FROM down_workstation WHERE workstation_id >= 6 AND workstation_id <= 10")
|
| | | List<DownWorkstation> gettwoDownWorkstations();
|
| | |
|
| | |
|
| | |
|
| | | @Select("SELECT DISTINCT flowcard_id from glass_info")
|
| | | @ResultType(Map.class)
|
| | | List<Map<String, Object>> getflowCardId();
|
| | |
|
| | | @Update("UPDATE down_workstation SET flow_card_id = NULL, total_quantity = NULL, racks_number = NULL WHERE workstation_id = #{workstationId}")
|
| | | void clearFlowCardInfoByWorkstationId(@Param("workstationId") int workstationId);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.mes.mapper;
|
| | |
|
| | | import org.apache.ibatis.annotations.Mapper;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import org.apache.ibatis.annotations.Select;
|
| | | import org.apache.ibatis.annotations.Update;
|
| | |
|
| | | @Mapper
|
| | | public interface GlassInfoMapper {
|
| | |
|
| | | @Select("SELECT COUNT(*) FROM glass_info WHERE flow_card_id = #{flowCardId}")
|
| | | int getGlassInfoCountByFlowCardId(@Param("flowCardId") String flowCardId);
|
| | |
|
| | | @Update("UPDATE down_workstation SET total_quantity = #{glassInfoCount} WHERE flow_card_id = #{flowCardId}")
|
| | | int updateFlowCardIdAndCount(@Param("flowCardId") String flowCardId, @Param("glassInfoCount") int glassInfoCount);
|
| | |
|
| | | // 这里可以添加其他 SQL 语句
|
| | | } |
New file |
| | |
| | | package com.mes.mapper; |
| | | |
| | | import com.mes.entity.DownStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.TaskCache; |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface SelectInfo { |
| | | // 玻璃信息 按ID查询 |
| | | @Select("select * from `glass_info` where id=#{id}") |
| | | GlassInfo SelectGlassId(String id); |
| | | |
| | | // 钢化按工程查询 |
| | | // @Select("select * from `v_optimize_heat_layout` where project_no=#{projeceid} ") |
| | | // List<Tempered> SelectTemperedTerritory(String projeceid); |
| | | // |
| | | // 切割版图按工程查询 |
| | | @Select("select * from optimize_detail where project_no=#{projeceid} ") |
| | | List<Map> SelectCutTerritory(String projeceid); |
| | | |
| | | // 查询磨边信息 |
| | | @Select("select * from task_cache where task_type='2' and task_stauts='2' and end_cell=#{EndCell}") |
| | | List<Map> SelectEdgInfo(String EndCell); |
| | | |
| | | // 查询笼子内空闲 |
| | | @Select("select escd.* from down_storage_cage as esc LEFT JOIN down_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is null order by escd.slot") |
| | | List<DownStorageCageDetails> SelectCacheLeisure(); |
| | | |
| | | // 查询笼子内出片任务 |
| | | @Select("select escd.* from down_storage_cage as esc LEFT JOIN down_storage_cage_details as escd on esc.slot=escd.slot WHERE escd.slot IS NOT NULL order by escd.tempering_layout_id,escd.tempering_feed_sequence") |
| | | List<DownStorageCageDetails> SelectCacheOut(); |
| | | |
| | | // 查询笼子内信息 |
| | | @Select("select escd.* from down_storage_cage as esc LEFT JOIN down_storage_cage_details as escd on esc.slot=escd.slot order by esc.slot") |
| | | List<DownStorageCageDetails> SelectCachInfo(); |
| | | |
| | | // 查询可进此片玻璃的栅格号 |
| | | @Select("select escd.* from down_storage_cage as esc LEFT JOIN down_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is not null escd.tempering_layout_id=#{tempering_layout_id} and escd.tempering_feed_sequence<#{tempering_feed_sequence} and esc.remain_width-#{width}>0 order by escd.tempering_feed_sequence") |
| | | List<DownStorageCageDetails> SelectIsExistIntoCache(Integer tempering_layout_id, Integer tempering_feed_sequence, |
| | | double width); |
| | | |
| | | // 查询可进此片玻璃的栅格号 |
| | | @Select("select escd.* from down_storage_cage as esc LEFT JOIN down_storage_cage_details as escd on esc.slot=escd.slot where escd.slot is not null escd.tempering_layout_id<#{tempering_layout_id} and esc.remain_width-#{width}>0 order by escd.tempering_layout_id desc,escd.tempering_feed_sequence") |
| | | List<DownStorageCageDetails> SelectIsExistIntoCache(Integer tempering_layout_id, double width); |
| | | |
| | | // 查询全部任务 |
| | | @Select("select * from down_glass_task") |
| | | List<TaskCache> SelectCacheInfoAll(); |
| | | |
| | | // 查询进片任务 |
| | | @Select("select * from down_glass_task where task_type='1' and task_stauts='0'") |
| | | List<TaskCache> SelectInputCacheInfo(); |
| | | |
| | | // 查询出片任务 |
| | | @Select("select * from down_glass_task where task_type='2' and task_stauts='0'") |
| | | List<TaskCache> SelectOutCacheInfo(); |
| | | |
| | | // 查询 A04 或 A15 最新的一片 出片任务 |
| | | @Select("select * from down_glass_task where task_type='2' and task_stauts='2' and end_cell=#{EndCell} limit 1") |
| | | GlassInfo SelectLastOutCacheInfo(String EndCell); |
| | | |
| | | // 修改笼子内信息 |
| | | @Update("update") |
| | | Integer UpdateCache(@Param("id") Integer id, @Param("order_id") String order_id); |
| | | |
| | | // 添加下片任务 |
| | | @Insert("INSERT into down_glass_task VALUES(#{id},#{start},#{end},#{type},0,)") |
| | | Integer insertCacheTask(String id, String start, String end, String type,double width,double height,Integer filmsId,double thickness,String flowCardId); |
| | | |
| | | // |
| | | // @Insert("INSERT `order`(order_id)VALUES(#{order_id})") |
| | | // Integer insert(Order order); |
| | | // |
| | | // @Delete("delete from `order` where id=#{id}") |
| | | // Integer deleteById(@Param("id") Integer id); |
| | | // |
| | | // @Update("update `order` set order_id=#{order_id} where id=#{id}") |
| | | // Integer update(@Param("id") Integer id,@Param("order_id") String order_id); |
| | | } |
New file |
| | |
| | | package com.mes.service; |
| | | |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.DownStorageCageDetails; |
| | | import com.mes.entity.device.PlcParameterObject; |
| | | import com.mes.mapper.SelectInfo; |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @Service |
| | | public class DownGlassCacheLogic { |
| | | @Autowired |
| | | private SelectInfo selectInfo; |
| | | |
| | | /** |
| | | * @param Number |
| | | * //识别逻辑 不交互 |
| | | */ |
| | | |
| | | public void identify(String Number){ |
| | | //查询任务 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | String s=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; |
| | | boolean isexist=isExist(Number); |
| | | if (isexist) { |
| | | //存在逻辑 1.添加信息 2.回复PLC存在 |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | }else { |
| | | //不存在逻辑 1.回复PLC不存在 |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); |
| | | } |
| | | } |
| | | //下片前理片 |
| | | public static final String RESULT_IN = "1"; |
| | | public static final String RESULT_OUT = "2"; |
| | | public static final String RESULT_IN_OUT = "3"; |
| | | |
| | | public void process() { |
| | | String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + ""; |
| | | String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + ""; |
| | | |
| | | // 进片请求 |
| | | if (RESULT_IN.equals(result)) { |
| | | processInto(number); |
| | | } |
| | | // 出片请求 |
| | | else if (RESULT_OUT.equals(result)) { |
| | | processOut(); |
| | | } |
| | | // 进出片请求 |
| | | else if (RESULT_IN_OUT.equals(result)) { |
| | | // 先出后进 |
| | | if (!processOut()) { |
| | | processInto(number); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * //下片前理片 进 |
| | | */ |
| | | |
| | | public boolean processInto(String Number){ |
| | | //按id查询玻璃信息表里的玻璃 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //存在此玻璃编号 |
| | | if(GlassInfo!=null){ |
| | | //同钢化版图内的栅格号 |
| | | List<DownStorageCageDetails> list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getTemperingfeedsequence(),GlassInfo.getWidth()); |
| | | //空栅格号 |
| | | if (list.size()==0) { |
| | | list=selectInfo.SelectCacheLeisure(); |
| | | } |
| | | //小于此玻璃钢化版图序号的栅格号 |
| | | if(list.size()==0){ |
| | | list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getWidth()); |
| | | } |
| | | if(list.size()>0){ |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | DownStorageCageDetails item=list.get(0); |
| | | selectInfo.insertCacheTask(GlassInfo.getId()+"","0",item.getSlot()+"","1",GlassInfo.getWidth(),GlassInfo.getHeight(),GlassInfo.getFilmsid(),GlassInfo.getThickness(),GlassInfo.getFlowcardid()); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | return true; |
| | | } |
| | | |
| | | }else{ |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | //理片 出 |
| | | public boolean processOut(){ |
| | | //查询任务 |
| | | String G06=S7control.getinstance().ReadWord("DB14.56", 1).get(0)+""; |
| | | String G11=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | String G13=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | List<DownStorageCageDetails> list=selectInfo.SelectCacheOut(); |
| | | //其他情况条件 如:后续设备故障禁止理片出片 等 |
| | | boolean isOut=true; |
| | | if (list.size()>0&&isOut) { |
| | | DownStorageCageDetails item=list.get(0); |
| | | if(G06=="0"&&G11=="1"){ |
| | | //出到 G06 |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0","06","2",item.getWidth(),item.getHeight(),0,item.getThickness(),item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(G06=="1"&&G11=="0"){ |
| | | //出到 G11 |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0","11","2",item.getWidth(),item.getHeight(),0,item.getThickness(),item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(G06=="0"&&G11=="0"){ |
| | | //都允许 G04/G05 上一片是否和此片玻璃尺寸尺寸相同 |
| | | String endcell="06"; |
| | | String SendEndcell="1"; |
| | | boolean If_=false; |
| | | GlassInfo glassInfo04= selectInfo.SelectLastOutCacheInfo("06"); |
| | | GlassInfo glassInfo05= selectInfo.SelectLastOutCacheInfo("11"); |
| | | if(glassInfo05!=null&&glassInfo05.getWidth()==item.getWidth()&&glassInfo05.getHeight()==item.getHeight()){ |
| | | endcell="11"; |
| | | SendEndcell="2"; |
| | | }else if(glassInfo05!=null&&If_){ |
| | | //其他条件 |
| | | } |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0",endcell,"2",item.getWidth(),item.getHeight(),0,item.getThickness(),item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * @param Number |
| | | * //磨边 不交互 理片和磨边机自己交互 |
| | | */ |
| | | |
| | | public void processMb(String Number){ |
| | | //按id查询玻璃信息表里的玻璃 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){ |
| | | //发送任务 ID 长 宽 厚 倒角 工艺功能等 |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | } |
| | | //返回结果 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * 查询消息队列里此玻璃ID的数据 |
| | | */ |
| | | public boolean selectMessageId(String Number){ |
| | | //查询是否存在 |
| | | |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | //返回 不存在 |
| | | return false; |
| | | |
| | | } |
| | | //返回 存在 |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * 删除消息队列里此玻璃ID的数据 |
| | | */ |
| | | |
| | | public boolean deleteMessageId(String Number){ |
| | | //查询是否存在 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | //返回 不存在 |
| | | return false; |
| | | } |
| | | //返回 存在 |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * //是否存在此编号玻璃 |
| | | */ |
| | | public boolean isExist(String Number){ |
| | | //查询是否存在 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | //返回 不存在 |
| | | return false; |
| | | } |
| | | //返回 存在 |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.service;
|
| | |
|
| | | import com.mes.entity.DownGlassInfo;
|
| | | import com.mes.entity.DownStorageCageDetails;
|
| | | import com.mes.entity.DownWorkstation;
|
| | | import com.mes.entity.device.PlcParameterObject;
|
| | | import com.mes.mapper.DownGlassInfoMapper;
|
| | | import com.mes.mapper.DownWorkstationMapper;
|
| | | import com.mes.tools.WebSocketServer;
|
| | | import lombok.Data;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | @Data
|
| | | @Service
|
| | | public class DownGlassLogic {
|
| | |
|
| | | PlcParameterObject plcread = PLCAutoMes.PlcReadObject;
|
| | | /**
|
| | | * // 机械手1PLC请求字
|
| | | */
|
| | | String robot1PLCrequestword = plcread.getPlcParameter("A01Position").getValue();
|
| | | /**
|
| | | * // 机械手2PLC请求字
|
| | | */
|
| | | String robot2PLCrequestword = plcread.getPlcParameter("A01Position").getValue();
|
| | | /**
|
| | | * // 玻璃id
|
| | | */
|
| | | String glassID = plcread.getPlcParameter("A01Position").getValue();
|
| | | String glasswidth = plcread.getPlcParameter("A01Position").getValue();
|
| | | String glassheight = plcread.getPlcParameter("A01Position").getValue();
|
| | | //
|
| | | String glassthickness = plcread.getPlcParameter("A01Position").getValue();
|
| | | String pLcwancheng = plcread.getPlcParameter("A01Position").getValue();
|
| | | @Autowired
|
| | | private DownWorkstationMapper downWorkstationMapper;
|
| | | private DownGlassInfo downGlassInfo;
|
| | | private DownWorkstation downWorkstation;
|
| | | private DownGlassInfoMapper downGlassInfoMapper;
|
| | | private DownGlassInfoService downGlassInfoService;
|
| | | /**
|
| | | * // 存放待处理的玻璃信息
|
| | | */
|
| | | private List<DownGlassInfo> glassList;
|
| | | /**
|
| | | * 存放玻璃放置在缓存笼中的详细信息
|
| | | */
|
| | | private List<DownStorageCageDetails> cageDetailsList;
|
| | |
|
| | | /**
|
| | | * //当下片任务表状态为1时候将数据插入到下片玻璃信息表
|
| | | */
|
| | |
|
| | | public void insertdownglassinfo() {
|
| | |
|
| | |
|
| | | downWorkstationMapper = WebSocketServer.applicationContext.getBean(DownWorkstationMapper.class);
|
| | | downGlassInfoService = WebSocketServer.applicationContext.getBean(DownGlassInfoService.class);
|
| | | downGlassInfoMapper = WebSocketServer.applicationContext.getBean(DownGlassInfoMapper.class);
|
| | | List<DownGlassInfo> taskdownGlassInf = downGlassInfoMapper.selectunloadingtaskstate();
|
| | | //
|
| | | if (taskdownGlassInf != null && !taskdownGlassInf.isEmpty()) {
|
| | |
|
| | | //
|
| | |
|
| | |
|
| | | for (DownGlassInfo downGlassInfo : taskdownGlassInf) {
|
| | | // 创建新的 DownGlassInfo 对象并设置相关属性
|
| | | DownGlassInfo newdownGlassInfo = new DownGlassInfo();
|
| | |
|
| | | newdownGlassInfo.setFlowCardId(downGlassInfo.getFlowCardId());
|
| | | Integer maxSequence = downGlassInfoMapper.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId());
|
| | | // 初始化顺序字段值
|
| | | int sequence = maxSequence != null ? maxSequence + 1 : 1;
|
| | |
|
| | | newdownGlassInfo.setWidth(downGlassInfo.getWidth());
|
| | | newdownGlassInfo.setHeight(downGlassInfo.getHeight());
|
| | | newdownGlassInfo.setThickness(downGlassInfo.getThickness());
|
| | | newdownGlassInfo.setFilmsid(downGlassInfo.getFilmsid());
|
| | | // 设置顺序字段值
|
| | | newdownGlassInfo.setSequence(sequence);
|
| | |
|
| | | // 插入数据到下片玻璃信息表
|
| | | downGlassInfoMapper.insert(newdownGlassInfo);
|
| | | //插入数据到机械手任务表
|
| | | downWorkstationMapper.insertdownWorkstationtask(newdownGlassInfo);
|
| | | //更新下片任务表状态为0
|
| | | downGlassInfoMapper.updateTaskStateToZero(downGlassInfo.getFlowCardId());
|
| | |
|
| | | sequence++; // 递增顺序字段值
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * //当机械手任务表中状态为1,工位表流程卡绑定了架子 更新已经落架数量,并且把下片任务表的对应记录删掉
|
| | | */
|
| | |
|
| | | public void downWorkstation() {
|
| | |
|
| | |
|
| | | try {
|
| | | //查询下片工位表中架子是否绑定了流程卡号 工位表和任务表中状态为1的流程卡号和已落架数量
|
| | | List<DownWorkstation> taskdownWorkstation = downWorkstationMapper.selectdownWorkstationstate();
|
| | | if (taskdownWorkstation != null && !taskdownWorkstation.isEmpty()) {
|
| | | //,如果已经绑定则更新已落架数量,并且删除下片任务表中的记录
|
| | | for (DownWorkstation downWorkstation : taskdownWorkstation) {
|
| | |
|
| | | //更新下片工位表中已落架数量
|
| | | downWorkstationMapper.update_racks_number(downWorkstation.getFlowCardId(), downWorkstation.getRacksnumber() + 1);
|
| | |
|
| | | //更新机械任务表中状态为0
|
| | | downWorkstationMapper.update_task_state_to_zero(downWorkstation.getFlowCardId());
|
| | | //删除下片任务表中的记录
|
| | | downGlassInfoMapper.deletetask(downWorkstation.getFlowCardId());
|
| | |
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | // 打印异常信息
|
| | | e.printStackTrace();
|
| | | // 或者可以进行其他异常处理,比如记录日志或者返回特定的错误信息
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * @param downWorkstation // 绑定流程卡号架子
|
| | | */
|
| | |
|
| | | public void bindingshelf(DownWorkstation downWorkstation) {
|
| | | downWorkstationMapper.updateFlowCardId(downWorkstation);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * @param downWorkstation // 满架拉走 清除流程卡信息
|
| | | */
|
| | |
|
| | | public void clearFlowCardId(DownWorkstation downWorkstation) {
|
| | |
|
| | | downWorkstationMapper.clearFlowCardId(downWorkstation);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.mes.service;
|
| | |
|
| | | import com.baomidou.dynamic.datasource.annotation.DS;
|
| | | import com.mes.entity.DownWorkstation;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @Service
|
| | | @DS("hangzhoumes")
|
| | | public class DownWorkstationService {
|
| | | @Autowired
|
| | | private com.mes.mapper.DownWorkstationMapper DownWorkstationMapper;
|
| | |
|
| | |
|
| | | public List<DownWorkstation> getoneDownWorkstations() {
|
| | |
|
| | | return DownWorkstationMapper.getoneDownWorkstations();
|
| | | }
|
| | |
|
| | | public List<DownWorkstation> gettwoDownWorkstations() {
|
| | |
|
| | | return DownWorkstationMapper.gettwoDownWorkstations();
|
| | | }
|
| | | public List<Map<String, Object>> getflowCardId() {
|
| | |
|
| | | return DownWorkstationMapper.getflowCardId();
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void clearFlowCardId(int workstationId) {
|
| | | // 执行清除指定工位ID的流程卡信息的逻辑,可以是数据库操作或其他业务逻辑
|
| | | // 例如:
|
| | | DownWorkstationMapper.clearFlowCardInfoByWorkstationId(workstationId);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.mes.service;
|
| | |
|
| | | import com.mes.mapper.GlassInfoMapper;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | @Service
|
| | | public class GlassInfoService {
|
| | |
|
| | | @Autowired
|
| | | private GlassInfoMapper glassInfoMapper;
|
| | |
|
| | | public int getGlassInfoCountByFlowCardId(String flowCardId) {
|
| | | return glassInfoMapper.getGlassInfoCountByFlowCardId(flowCardId);
|
| | | }
|
| | |
|
| | | public void updateFlowCardIdAndCount(String flowCardId, int glassInfoCount) {
|
| | | // 调用 GlassInfoMapper 的 updateFlowCardIdAndCount 方法
|
| | | int rowsAffected = glassInfoMapper.updateFlowCardIdAndCount(flowCardId, glassInfoCount);
|
| | | if (rowsAffected > 0) {
|
| | | System.out.println("更新流程卡 ID 和数量成功");
|
| | | } else {
|
| | | System.out.println("更新流程卡 ID 和数量失败");
|
| | | }
|
| | | }
|
| | |
|
| | | // 这里可以添加其他业务逻辑方法
|
| | | }
|
| | |
| | |
|
| | | public ModuleA(String QUEUENAME) {
|
| | | QUEUE_NAME = QUEUENAME;
|
| | | receiver = new RabbitMQUtils(); // 实例化 RabbitMQUtils 对象
|
| | | // 实例化 RabbitMQUtils 对象
|
| | | receiver = new RabbitMQUtils();
|
| | | }
|
| | |
|
| | | public static void main(String[] argv) throws Exception {
|
| | |
| | | // String message = "Your message to send666";
|
| | | // String messageId = "5"; // 消息ID
|
| | | // receiver.sendMessageWithId(QUEUE_NAME, message, messageId); // 调用 sendMessageWithId 方法发送消息
|
| | | receiver.sendMessageWithId("hangzhou2", "Hello RabbitMQ!", "1");
|
| | | receiver.sendMessageWithId("hangzhou2", "Another message", "2");
|
| | | receiver.sendMessageWithId("hangzhou2", "Another message", "3");
|
| | | receiver.sendMessageWithId("hangzhou2", "Another message", "4");
|
| | | receiver.sendMessageWithId("hangzhou2", "Another message", "5");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Hello RabbitMQ!", "1");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "2");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "3");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "4");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "5");
|
| | | // receiver.sendMessageWithId("hangzhou2", "Yet another message", "1"); // 这条消息会打印重复消息的错误信息
|
| | |
|
| | | }
|
| | |
| | | //receiver.consumeMessageById("5",QUEUE_NAME);
|
| | |
|
| | | // String receivedMessage = receiver.consumeSelectedMessage(1,QUEUE_NAME);
|
| | | List<String> receivedMessage = receiver.browseMessages(QUEUE_NAME);
|
| | | List<String> receivedMessage = RabbitMQUtils.browseMessages(QUEUE_NAME);
|
| | | System.out.println("Received message: " + receivedMessage);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | | @Component
|
| | | public class Plchome extends Thread {
|
| | | private int i = 1;
|
| | | private final Supplier<PlcService> plcServiceSupplier;
|
| | | private final Supplier<DownGlassLogic> plcServiceSupplier;
|
| | |
|
| | | public Plchome() {
|
| | | this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(PlcService.class);
|
| | | this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(DownGlassLogic.class);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | try {
|
| | | i++;
|
| | | Thread.sleep(100);
|
| | | PlcService plcService = plcServiceSupplier.get();
|
| | | DownGlassLogic plcService = plcServiceSupplier.get();
|
| | | // plcService.performPlcActions();
|
| | | //plcService.unloadpush();
|
| | |
|
| | |
| | |
|
| | |
|
| | | //当机械手任务表中状态为1 更新已经落架数量,并且把下片任务表的那条记录删掉 工位表流程卡绑定了架子
|
| | | plcService.down_workstation();
|
| | | plcService.downWorkstation();
|
| | |
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | |
| | | import java.io.InputStream;
|
| | | import java.util.Properties;
|
| | |
|
| | | // Configuration 类用于加载配置文件并提供访问配置项的方法。
|
| | | /**
|
| | | * @author SNG-012
|
| | | *
|
| | | * Configuration 类用于加载配置文件并提供访问配置项的方法。
|
| | | */
|
| | | public class Configuration {
|
| | | private Properties properties; // Properties 对象,用于存储配置文件中的键值对。
|
| | |
|
| | | // 构造函数,根据传入的文件名加载配置文件。
|
| | | /**
|
| | | * // Properties 对象,用于存储配置文件中的键值对。
|
| | | */
|
| | | private Properties properties;
|
| | |
|
| | | /**
|
| | | * @param fileName
|
| | | * @throws IOException
|
| | | * // 构造函数,根据传入的文件名加载配置文件。
|
| | | */
|
| | |
|
| | | public Configuration(String fileName) throws IOException {
|
| | | // 使用类加载器获取资源文件的输入流。
|
| | | InputStream inputStream = getClass().getClassLoader().getResourceAsStream(fileName);
|
| | |
| | | if (inputStream == null) {
|
| | | throw new FileNotFoundException("Property file '" + fileName + "' not found in the classpath");
|
| | | }
|
| | | properties = new Properties(); // 实例化Properties对象。
|
| | | properties.load(inputStream); // 从输入流加载配置项。
|
| | | // 实例化Properties对象。
|
| | | properties = new Properties();
|
| | | // 从输入流加载配置项。
|
| | | properties.load(inputStream);
|
| | | }
|
| | |
|
| | | // 根据配置项的键获取其对应的值。
|
| | | /**
|
| | | * @param key
|
| | | * @return
|
| | | * // 根据配置项的键获取其对应的值。
|
| | | */
|
| | |
|
| | | public String getProperty(String key) {
|
| | | return properties.getProperty(key);
|
| | | }
|