| | |
| | | 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.mes.entity.EdgStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | 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 Number){ |
| | | 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 Number){ |
| | | 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 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 |
| | |
| | | <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> |
| | |
| | | import deepClone from "@/utils/deepClone"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { useRouter } from "vue-router"; |
| | | import GlassType from '@/components/basic/product/GlassType.vue' |
| | | |
| | | |
| | | const router = useRouter() |
| | |
| | | export default { |
| | | mounted() { |
| | | //获取数据 |
| | | request.get("/Temper/Tindex").then((res) => { |
| | | var data="ProcessId="+"P24032508"; |
| | | request.get("/TidyUpGlassModule/SelectTerritoryInfo?"+data).then((res) => { |
| | | if (res.code == 200) { |
| | | var StoveCount=0; |
| | | var temperid; |
| | |
| | | |
| | | <template> |
| | | <div ref="content"> |
| | | |
| | | <canvas ref="mycanvas"></canvas> |
| | | </div> |
| | | <canvas ref="mycanvas" > |
| | | |
| | | </canvas> |
| | | </template> |
| | | |
| | | <style scoped> |