28个文件已修改
1 文件已重命名
13个文件已添加
38个文件已删除
| | |
| | | |
| | | // 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 |
| | |
| | | package com.mes; |
| | | |
| | | import com.mes.common.PlcTools.S7object; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | private SysMenuService sysMenuService; |
| | | @GetMapping |
| | | public Result getMenu(){ |
| | | //MyChannelHandlerPool myChannelHandlerPool = new MyChannelHandlerPool(); |
| | | //myChannelHandlerPool.sendMsg("123"); |
| | | //MyChannelHandlerPool.channelGroup.writeAndFlush( new TextWebSocketFrame("123123")); |
| | | //获取缓存 |
| | | return Result.seccess(sysMenuService.getMenu()); |
| | | |
| | | } |
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)); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.mes.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.entity.OrderTest; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | import com.mes.entity.UpWorkstation; |
| | | @Mapper |
| | | public interface LoadGlassMapper extends BaseMapper<UpWorkstation> { |
| | | //显示目前工位玻璃信息 |
| | | @Select("SELECT * FROM up_workstation") |
| | | UpWorkstation SelectALL(); |
| | | List<UpWorkstation> SelectALL(); |
| | | //删除工位的玻璃信息 |
| | | @Delete("DELETE FROM up_workstation where workstation_id=#{id}") |
| | | void DeleteALL(int id ); |
| | | void deleteGlass(int id ); |
| | | //增加上片信息 |
| | | @Insert ("INSERT INTO up_workstation (pattern_width,pattern_heigth,pattern_thickness)value(#{patternwidth},#{patternheigth},#{patternthickness}where workstation_id=#{workstationid) ") |
| | | void InsertALL(Double patternwidth,Double patternheigth,Double patternthickness,int workstationid); |
| | | void insertGlass(Double patternwidth,Double patternheigth,Double patternthickness,int workstationid); |
| | | //是否发起吸片 |
| | | @Select("SELECT * FROM up_workstation where workstation_id=#{id}") |
| | | UpWorkstation SelectAdd(int id); |
| | | //判断优先工位吸片 |
| | | @Select("select b.layout_sequence from up_workstation a left join up_patten_usage b on a.pattern_width=b.width and a.pattern_heigth=b.width and a.pattern_thickness=b.thickness where a.workstation_id=#{id}") |
| | | int SelectPriority(int id); |
| | | |
| | | } |
| | |
| | | package com.mes.service; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.example.springboot.component.PLCAutoMes; |
| | | import com.example.springboot.component.S7control; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.mes.entity.device.PLCAutoMes; |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.device.PlcParameterObject; |
| | | import com.google.common.primitives.Bytes; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.UpWorkstation; |
| | | import com.mes.mapper.LoadGlassMapper; |
| | | import com.mes.mapper.TemperingMapper; |
| | | |
| | | @Service |
| | | public class LoadGlassService { |
| | | @Autowired |
| | | private com.mes.common.PlcTools.S7control s7control; |
| | | private LoadGlassMapper LoadGlassMapper; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //显示工位上的玻璃信息 |
| | | public GlassInfo selectAll() { |
| | | GlassInfo glassInfo = LoadGlassMapper.SelectALL(); |
| | | public List<UpWorkstation> selectAll() { |
| | | List<UpWorkstation> glassInfo= LoadGlassMapper.SelectALL(); |
| | | return glassInfo; |
| | | } |
| | | //增加人工输入的工位玻璃信息 |
| | | public void insertGlass(UpWorkstation upwork) { |
| | | LoadGlassMapper.insertGlass(upwork.Getpatternwidth(),upwork.getPatternheigth(),upwork.getPatternthickness(),1); |
| | | LoadGlassMapper.insertGlass(upwork.getPatternwidth(),upwork.getPatternheigth(),upwork.getPatternthickness(),1); |
| | | } |
| | | //删除人工搬走的玻璃信息 |
| | | public void deleteGlass(String id) { |
| | | public void deleteGlass(int id) { |
| | | LoadGlassMapper.deleteGlass(id); |
| | | } |
| | | //判断是否可以吸片进行任务 |
| | | public boolean isCanLoadGlass() { |
| | | boolean result=s7control.WriteWord("100.10", 1); |
| | | return result; |
| | | String loadstate=plcmes.getPlcParameter("吸片信号").getValue(); |
| | | if(loadstate.equals("1")) { |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | //判断优先吸片位置 |
| | | public int selectPriority() { |
| | | int loadid1=LoadGlassMapper.SelectPriority(1); |
| | | int loadid2=LoadGlassMapper.SelectPriority(2); |
| | | if(loadid1>loadid2) { |
| | | return 1; |
| | | }else{ |
| | | return 2; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
New file |
| | |
| | | { |
| | | "plcAddressBegin":"DB14.0", |
| | | "plcAddressLenght":"208", |
| | | "dataType":"word", |
| | | "parameteInfor":[ |
| | | { |
| | | "codeId": "PLCToMES", |
| | | "addressIndex":"0", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus1", |
| | | "addressIndex":"2", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus2", |
| | | "addressIndex":"4", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus3", |
| | | "addressIndex":"6", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus4", |
| | | "addressIndex":"8", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus5", |
| | | "addressIndex":"10", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "IDStatus6", |
| | | "addressIndex":"12", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID1", |
| | | "addressIndex":"14", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID2", |
| | | "addressIndex":"16", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID3", |
| | | "addressIndex":"18", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID4", |
| | | "addressIndex":"20", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID5", |
| | | "addressIndex":"22", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID6", |
| | | "addressIndex":"24", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "GaToMES", |
| | | "addressIndex":"26", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "Height", |
| | | "addressIndex":"28", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "width", |
| | | "addressIndex":"30", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "ExportTOMES1", |
| | | "addressIndex":"32", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "ExportToMES2", |
| | | "addressIndex":"34", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESToPLC", |
| | | "addressIndex":"36", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID1", |
| | | "addressIndex":"38", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID2", |
| | | "addressIndex":"54", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID3", |
| | | "addressIndex":"70", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID4", |
| | | "addressIndex":"86", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID5", |
| | | "addressIndex":"102", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID6", |
| | | "addressIndex":"118", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESToPLCStart1", |
| | | "addressIndex":"134", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart2", |
| | | "addressIndex":"136", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart3", |
| | | "addressIndex":"138", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart4", |
| | | "addressIndex":"140", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart5", |
| | | "addressIndex":"142", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart6", |
| | | "addressIndex":"144", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget1", |
| | | "addressIndex":"146", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget2", |
| | | "addressIndex":"148", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget3", |
| | | "addressIndex":"150", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget4", |
| | | "addressIndex":"152", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget5", |
| | | "addressIndex":"154", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget6", |
| | | "addressIndex":"156", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus1", |
| | | "addressIndex":"158", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus2", |
| | | "addressIndex":"160", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus3", |
| | | "addressIndex":"162", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus4", |
| | | "addressIndex":"164", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus5", |
| | | "addressIndex":"166", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus6", |
| | | "addressIndex":"168", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToGaStatus", |
| | | "addressIndex":"170", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01Err", |
| | | "addressIndex":"172", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02Err", |
| | | "addressIndex":"174", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Err", |
| | | "addressIndex":"176", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Err", |
| | | "addressIndex":"178", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Err", |
| | | "addressIndex":"180", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace1", |
| | | "addressIndex":"182", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace2", |
| | | "addressIndex":"184", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace3", |
| | | "addressIndex":"186", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Position", |
| | | "addressIndex":"188", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Position", |
| | | "addressIndex":"190", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Position", |
| | | "addressIndex":"192", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "DeviceState", |
| | | "addressIndex":"194", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "AllFVRun", |
| | | "addressIndex":"196", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01State", |
| | | "addressIndex":"198", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02State", |
| | | "addressIndex":"200", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01State", |
| | | "addressIndex":"202", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01State", |
| | | "addressIndex":"204", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02State", |
| | | "addressIndex":"206", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ] |
| | | } |
New file |
| | |
| | | { |
| | | "plcAddressBegin":"DB14.0", |
| | | "plcAddressLenght":"208", |
| | | "dataType":"word", |
| | | "parameteInfor":[ |
| | | { |
| | | "codeId": "PLCToMES", |
| | | "addressIndex":"0", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus1", |
| | | "addressIndex":"2", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus2", |
| | | "addressIndex":"4", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus3", |
| | | "addressIndex":"6", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus4", |
| | | "addressIndex":"8", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus5", |
| | | "addressIndex":"10", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "IDStatus6", |
| | | "addressIndex":"12", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID1", |
| | | "addressIndex":"14", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID2", |
| | | "addressIndex":"16", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID3", |
| | | "addressIndex":"18", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID4", |
| | | "addressIndex":"20", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID5", |
| | | "addressIndex":"22", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID6", |
| | | "addressIndex":"24", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "GaToMES", |
| | | "addressIndex":"26", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "Height", |
| | | "addressIndex":"28", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "width", |
| | | "addressIndex":"30", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "ExportTOMES1", |
| | | "addressIndex":"32", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "ExportToMES2", |
| | | "addressIndex":"34", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESToPLC", |
| | | "addressIndex":"36", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID1", |
| | | "addressIndex":"38", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID2", |
| | | "addressIndex":"54", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID3", |
| | | "addressIndex":"70", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID4", |
| | | "addressIndex":"86", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID5", |
| | | "addressIndex":"102", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID6", |
| | | "addressIndex":"118", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESToPLCStart1", |
| | | "addressIndex":"134", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart2", |
| | | "addressIndex":"136", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart3", |
| | | "addressIndex":"138", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart4", |
| | | "addressIndex":"140", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart5", |
| | | "addressIndex":"142", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart6", |
| | | "addressIndex":"144", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget1", |
| | | "addressIndex":"146", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget2", |
| | | "addressIndex":"148", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget3", |
| | | "addressIndex":"150", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget4", |
| | | "addressIndex":"152", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget5", |
| | | "addressIndex":"154", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget6", |
| | | "addressIndex":"156", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus1", |
| | | "addressIndex":"158", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus2", |
| | | "addressIndex":"160", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus3", |
| | | "addressIndex":"162", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus4", |
| | | "addressIndex":"164", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus5", |
| | | "addressIndex":"166", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus6", |
| | | "addressIndex":"168", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToGaStatus", |
| | | "addressIndex":"170", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01Err", |
| | | "addressIndex":"172", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02Err", |
| | | "addressIndex":"174", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Err", |
| | | "addressIndex":"176", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Err", |
| | | "addressIndex":"178", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Err", |
| | | "addressIndex":"180", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace1", |
| | | "addressIndex":"182", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace2", |
| | | "addressIndex":"184", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace3", |
| | | "addressIndex":"186", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Position", |
| | | "addressIndex":"188", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Position", |
| | | "addressIndex":"190", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Position", |
| | | "addressIndex":"192", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "DeviceState", |
| | | "addressIndex":"194", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "AllFVRun", |
| | | "addressIndex":"196", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01State", |
| | | "addressIndex":"198", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02State", |
| | | "addressIndex":"200", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01State", |
| | | "addressIndex":"202", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01State", |
| | | "addressIndex":"204", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02State", |
| | | "addressIndex":"206", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ] |
| | | } |
| | |
| | | package com.mes; |
| | | |
| | | import com.mes.common.PlcTools.S7object; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | //springboot 启动入口 |
| | | @SpringBootApplication |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | // TODO Auto-generated method stub |
| | | // |
| | | System.out.println("启动完成"); |
| | | System.out.println("启动完成Tempering"); |
| | | |
| | | |
| | | } |
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)); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.Tempering; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | |
| | | |
| | | //查询该玻璃的尺寸和坐标 |
| | | @Select("select *from glass_info where id=#{glassid};") |
| | | GlassInfo SelectOutGlass(String glassid); |
| | | |
| | | @Select("select *from glass_info where id=#{glassid};") |
| | | GlassInfo SelectGlass(String glassid); |
| | | //是否可以发送进炉信号 |
| | | @Select("select count(*) from glass_info where id=#{glassid};") |
| | | int SelectTempering(String glassid); |
| | | //查询等待中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,count(state)state from tempering_glass_info GROUP BY flowcard_id,state)b on a.flowcard_id=b.flowcard_id where b.state=2") |
| | | List<Tempering> SelectWaitingGlass(); |
| | | //查询进炉中的钢化版图玻璃信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=1)b on a.flowcard_id=b.flowcard_id where b.state1=1") |
| | | List<Tempering> SelectInGlass(); |
| | | //查询钢化后的钢化版图信息 |
| | | @Select("select*from tempering_glass_info a left join (select flowcard_id,min(state)state1 from tempering_glass_info GROUP BY flowcard_id having state1=2)b on a.flowcard_id=b.flowcard_id where b.state1=2") |
| | | List <Tempering> SelectOutGlass(); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.mes.service; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.userInfo.SysError; |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.Tempering; |
| | | import com.mes.entity.device.PLCAutoMes; |
| | | import com.mes.entity.device.PlcParameterObject; |
| | | import com.mes.mapper.TemperingMapper; |
| | | import com.mes.mapper.userInfo.SysErrorMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import java.util.List; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | @DS("glass_info") |
| | | public class TemperingOverService { |
| | | private final TemperingMapper temperingMapper; |
| | | |
| | | private final TemperingMapper temperingMapper; |
| | | //PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | public TemperingOverService(TemperingMapper temperingMapper) { |
| | | this.temperingMapper = temperingMapper; |
| | | } |
| | | //接收出炉信号和炉号 |
| | | public GlassInfo SelectOutGlass (String glassid) { |
| | | GlassInfo GlassInfo = temperingMapper.SelectOutGlass(glassid); |
| | | return GlassInfo; |
| | | public String SelectOutSignal () { |
| | | |
| | | S7control.getinstance().WriteWord("出炉信号", (short)1); |
| | | return "GlassInfo"; |
| | | } |
| | | //发送确认收到 |
| | | //发送确认收到信号 |
| | | public void OverSignal () { |
| | | S7control.getinstance().WriteWord("确认字", (short)1); |
| | | } |
| | | //显示钢化出炉后的版图信息 |
| | | public List <Tempering> SelectOutGlass () { |
| | | return temperingMapper.SelectOutGlass(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.mes.service; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.userInfo.SysError; |
| | | import com.mes.entity.Tempering; |
| | | import com.mes.mapper.TemperingMapper; |
| | | import com.mes.mapper.userInfo.SysErrorMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import java.util.List; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | |
| | | } |
| | | //接收id返回坐标和数据 |
| | | public GlassInfo SelectOutGlass (String glassid) { |
| | | GlassInfo GlassInfo = temperingMapper.SelectOutGlass(glassid); |
| | | GlassInfo GlassInfo = temperingMapper.SelectGlass(glassid); |
| | | return GlassInfo; |
| | | } |
| | | //发送坐标信息 |
| | |
| | | else { |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | //发送进炉信号 |
| | | public void SendIntoGlass (short start) { |
| | | s7control.WriteWord("DB100.10", start); |
| | | } |
| | | //接受完成字回复确认字 |
| | | |
| | | public void SendIntoGlass () { |
| | | s7control.WriteWord("DB100.10", (short)1); |
| | | } |
| | | //显示等待中的版图 |
| | | public List <Tempering> SelectWaitingGlass () { |
| | | List<Tempering> WaitingGlass = temperingMapper.SelectWaitingGlass(); |
| | | return WaitingGlass; |
| | | } |
| | | //显示正在进炉的版图 |
| | | public List<Tempering> SelectIntoGlass () { |
| | | List<Tempering> IntoGlass = temperingMapper.SelectInGlass(); |
| | | return IntoGlass; |
| | | } |
| | | } |
| | |
| | | server: |
| | | port: 8080 |
| | | servlet: |
| | | context-path: /mesModuleTools |
| | | context-path: /mesModuleTools |
| | | |
| | | spring: |
| | | datasource: |
| | | dynamic: |
| | | primary: user_info #设置默认的数据源或者数据源组,默认值即为master |
| | | primary: hangzhoumes #设置默认的数据源或者数据源组,默认值即为master |
| | | strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候回抛出异常,不启动会使用默认数据源. |
| | | datasource: |
| | | user_info: |
| | | 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 |
| | | |
| | | hangzhoumes: |
| | | 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 |
| | |
| | | children:[ |
| | | |
| | | |
| | | { |
| | | path: 'Temperedlayout', |
| | | name: 'Temperedlayout', |
| | | component: () => import('../views/TL/Temperedlayout/Temperedlayout.vue'), |
| | | children:[ |
| | | { |
| | | path: 'selectLayout', |
| | | name: 'selectLayout', |
| | | component: () => import('../views/TL/Temperedlayout/SelectLayout.vue'), |
| | | } |
| | | ] |
| | | }, |
| | | |
| | | /*----------- 上片机 ----------------*/ |
| | | { |
| | |
| | | } |
| | | ] |
| | | }, |
| | | /*----------- 用户管理 ----------------*/ |
| | | { |
| | | path: 'User', |
| | | name: 'userlist', |
| | | component: () => import('../views/User/userlist.vue'), |
| | | children:[ |
| | | { |
| | | path: '/User/userlist', |
| | | name: 'userlist', |
| | | component: () => import('../views/User/userlist.vue') |
| | | }, |
| | | ] |
| | | }, |
| | | /*----------- 权限管理 ----------------*/ |
| | | { |
| | | path: 'Permissions', |
| | | name: 'permissionslist', |
| | | component: () => import('../views/Permissions/permissionslist.vue'), |
| | | children:[ |
| | | { |
| | | path: '/Permissions/permissionslist', |
| | | name: 'permissionslist', |
| | | component: () => import('../views/Permissions/permissionslist.vue') |
| | | }, |
| | | ] |
| | | }, |
| | | { |
| | | path: '', |
| | | redirect:'/Slicecage/slicecage' |
| | |
| | | <div style="margin-left: 150px;font-size: 20px;">版图编号:1</div> |
| | | </div> |
| | | <div> |
| | | <div id="boxa" style="width: 700px;height: 220px;margin-left: 260px;"> |
| | | <div id="boxa" style="width: 700px;height: 220px;margin-left: 300px;"> |
| | | <div style="margin-top: 85px;"> NG202405060798A01-1</div> |
| | | <div> 500×1500</div> |
| | | </div> |
| | |
| | | </div> |
| | | </el-card> |
| | | <div id="parent"> |
| | | <img src="../../assets/shangpianji .png" alt="" style="max-width: 20%;max-height: 20%;margin-top: 20px;margin-left: 130px;"> |
| | | <img src="../../assets/shangpianji .png" alt="" style="max-width: 20%;max-height: 20%;margin-top: 20px;margin-left: 510px;"> |
| | | <el-button style="margin-top: -830px;margin-left: -40px;" size="mini" id="searchButton" @click="add = true">添加原片</el-button> |
| | | <el-button style="margin-top: -10px;margin-left: -80px;" size="mini" id="searchButton" @click="adda = true">添加原片</el-button> |
| | | <!-- <div id="overlay" v-show="state"></div> --> |
| | |
| | | } |
| | | #parent{ |
| | | position: relative; |
| | | /* margin-left: 250px; */ |
| | | } |
| | | #overlay{ |
| | | position: absolute; |
| | |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | 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;
|
| | |
|
| | | } |
File was renamed from TemperingGlassModule/src/main/java/com/mes/entity/BigStorageCageDetails.java |
| | |
| | | import lombok.Data; |
| | | |
| | | @Data //lombok 简写java代码 实体类的get与set |
| | | @TableName("`big_storage_cage_details`") |
| | | public class BigStorageCageDetails { |
| | | @TableName("`edg_storage_cage_details`") |
| | | public class EdgStorageCageDetails { |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id;//大理片笼详情表id |
| | | private Integer id;//磨边前理片笼详情表id |
| | | private Integer deviceid;//设备id |
| | | private Integer slot;//栅格号 |
| | | private Integer glassid;//玻璃id |
| | |
| | | private Double width;//宽 |
| | | private Double height;//高 |
| | | private Double thickness;//厚度 |
| | | private Double edgwidth;//磨前宽 |
| | | private Double edgheight;//磨前高 |
| | | private Integer temperinglayoutid;//钢化版图id |
| | | private Integer temperingfeedsequence;//钢化版图片序 |
| | | private Integer state;//状态 |
| | | 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);
|
| | | }
|