Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
22个文件已修改
5 文件已重命名
19个文件已添加
5个文件已删除
| | |
| | | |
| | | import com.mes.entity.userInfo.SysMenuItem; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface SysMenuItemMapper { |
| | | |
| | | @Select("select * from `sys_menu_item` as a where a.state=1 order by a.menuId,a.listSort;") |
| | | |
| | | |
| | | List<SysMenuItem> findAll() ; |
| | | } |
| | |
| | | |
| | | User findOne(Integer id); |
| | | |
| | | @Select("select user_name FROM `user` where login_name=#{LoginName} ") |
| | | User findOneLoginName(String LoginName); |
| | | |
| | | @Select("select count(id) FROM `user` where login_name=#{userName} and password=#{password} ") |
| | | int checkUser(@Param("userName") String userName,@Param("password") String password); |
| | | |
| | |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 192.168.6.128:8848 |
| | | server-addr: 10.153.19.150:8848 |
| | | gateway: |
| | | discovery: |
| | | locator: |
New file |
| | |
| | | package com.mes.common; |
| | | 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; |
| | | |
| | | 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 = S7object.getinstance().plccontrol.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 = S7object.getinstance().plccontrol.ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength()); |
| | | plcParameterObject.setPlcParameterList(getplcvlues); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.common; |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static com.mes.common.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.common; |
| | | |
| | | |
| | | |
| | | 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.common; |
| | | |
| | | 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.common; |
| | | 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.common; |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/temperingglass/controller/GlassInfoController.java |
| | |
| | | package com.mes.temperingglass.controller; |
| | | package com.mes.glassinfo.controller; |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/temperingglass/entity/GlassInfo.java |
| | |
| | | package com.mes.temperingglass.entity; |
| | | package com.mes.glassinfo.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/temperingglass/mapper/GlassInfoMapper.java |
| | |
| | | package com.mes.temperingglass.mapper; |
| | | package com.mes.glassinfo.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | |
| | | /** |
| | | * <p> |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/temperingglass/service/GlassInfoService.java |
| | |
| | | package com.mes.temperingglass.service; |
| | | package com.mes.glassinfo.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | |
| | | /** |
| | | * <p> |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/temperingglass/service/impl/GlassInfoServiceImpl.java |
| | |
| | | package com.mes.temperingglass.service.impl; |
| | | package com.mes.glassinfo.service.impl; |
| | | |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.temperingglass.mapper.GlassInfoMapper; |
| | | import com.mes.temperingglass.service.GlassInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.mapper.GlassInfoMapper; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | package com.mes.taskcache.controller; |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.mes.taskcache.service.HangzhoumesService; |
| | | import com.mes.taskcache.service.PpService; |
| | | import com.mes.utils.Result; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/taskCache") |
| | | public class TaskCacheController { |
| | | |
| | | @Autowired |
| | | private PpService ppService; |
| | | |
| | | @Autowired |
| | | private HangzhoumesService hangzhoumesService; |
| | | |
| | | // @GetMapping("/SelectTerritoryInfo") // 查询钢化版图信息-根据 工程号 |
| | | // @ResponseBody |
| | | // public Result SelectTerritoryInfo(@RequestParam(name = "ProcessId", required = false) String ProcessId) { |
| | | // List<Tempered> h = ppService.selectTemperedTerritory(ProcessId); |
| | | // return Result.seccess(h); |
| | | // } |
| | | |
| | | @GetMapping("/CutTerritory") // 查询切割版图信息-根据 工程号 |
| | | @ResponseBody |
| | | public Result CutTerritory(String ProcessId) { |
| | | List<Map> h = ppService.selectCutTerritory(ProcessId); |
| | | return Result.build(200,"成功",h); |
| | | } |
| | | |
| | | @GetMapping("/CurrentCutTerritory") // 识别显示 当前版图 |
| | | @ResponseBody |
| | | public Result CurrentCutTerritory() { |
| | | List<Map> h = ppService.selectCutTerritory(); |
| | | System.out.println(h); |
| | | return Result.build(200,"成功",h); |
| | | } |
| | | |
| | | @GetMapping("/SelectCutTerritory") // 识别显示 特定版图 |
| | | @ResponseBody |
| | | public Result SelectCutTerritory(String TerritoryId) { |
| | | List<Map> h = ppService.selectCutTerritory(TerritoryId); |
| | | return Result.build(200,"成功",h); |
| | | } |
| | | |
| | | @GetMapping("/IdentControls") // 识别操作: 破损/拿走 参数(ID,功能[0:破损,1:拿走]) |
| | | @ResponseBody |
| | | public Result Ident(@RequestParam(name = "IdentId", required = false) String ProcessId,@RequestParam(name = "ControlsId", required = false) String ControlsId) { |
| | | List<Map> h = ppService.selectCutTerritory("P24032508"); |
| | | return Result.build(200,"成功",h); |
| | | } |
| | | |
| | | @GetMapping("/SelectCageInfo") // 查询笼内信息 |
| | | @ResponseBody |
| | | public Result SelectCageInfo(String ProcessId) { |
| | | List<Map> h = hangzhoumesService.SelectCageInfo(); |
| | | return Result.build(200,"成功",h); |
| | | } |
| | | |
| | | @GetMapping("/SelectEdgTask") //磨边任务 |
| | | @ResponseBody |
| | | public Result SelectEdgTask(String ProcessId) { |
| | | List<Map> EdgTasks = hangzhoumesService.SelectEdgInfo("1"); |
| | | return Result.build(200,"成功",EdgTasks); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.mes.taskcache.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class TaskCache implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID编号 |
| | | */ |
| | | @TableId("ID") |
| | | private String id; |
| | | |
| | | /** |
| | | * 起始 |
| | | */ |
| | | private String startCell; |
| | | |
| | | /** |
| | | * 目标 |
| | | */ |
| | | private String endCell; |
| | | |
| | | /** |
| | | * 任务类型 1:进 2:出 |
| | | */ |
| | | private String taskType; |
| | | |
| | | /** |
| | | * 任务状态 0 未开始 1正在进行 2完成 |
| | | */ |
| | | private String taskStauts; |
| | | |
| | | @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.taskcache.mapper; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.taskcache.entity.TaskCache; |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | | public interface HangzhouMesMapper { |
| | | |
| | | // 玻璃信息 按ID查询 |
| | | @Select("select * from `glass_info` where id=#{id}") |
| | | GlassInfo selectGlassId(String id); |
| | | // 查询磨边信息 |
| | | @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 esc.*,escd.id as detailsID,escd.device_id as details_device_id,escd.glass_id,escd.sequence,escd.flow_card_id,escd.glass_type,escd.width,escd.height,escd.thickness,escd.edg_width,escd.edg_height,escd.tempering_layout_id,escd.tempering_feed_sequence,escd.pattern_sequence,escd.state,escd.gap from edg_storage_cage as esc LEFT JOIN edg_storage_cage_details as escd on esc.slot=escd.slot order by esc.slot") |
| | | List<Map> 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); |
| | | } |
New file |
| | |
| | | package com.mes.taskcache.mapper; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | // |
| | | //@DS("pp") |
| | | @Mapper |
| | | public interface PpMapper { |
| | | |
| | | // // 钢化按工程查询 |
| | | // @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} and stock_id=#{TerritoryId}") |
| | | List<Map> selectCutTerritory(String projeceid,String TerritoryId); |
| | | |
| | | // 切割版图 按工程查询 |
| | | @Select("select * from optimize_detail where project_no=#{projeceid} ") |
| | | List<Map> selectCutTerritory(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); |
| | | } |
New file |
| | |
| | | package com.mes.taskcache.service; |
| | | |
| | | |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.taskcache.mapper.HangzhouMesMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class HangzhoumesService { |
| | | |
| | | @Autowired |
| | | private HangzhouMesMapper hangzhouMesMapper; |
| | | //根据编号 查找玻璃小片信息 |
| | | public GlassInfo getUserInfo(String process_id){ |
| | | return hangzhouMesMapper.selectGlassId(process_id); |
| | | } |
| | | |
| | | //理片缓存 笼内信息 |
| | | public List<Map> SelectCageInfo(){ |
| | | return hangzhouMesMapper.selectCachInfo(); |
| | | } |
| | | |
| | | //磨边小片信息 |
| | | public List<Map> SelectEdgInfo(String line){ |
| | | return hangzhouMesMapper.selectEdgInfo(line); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.taskcache.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.mes.common.PLCAutoMes; |
| | | import com.mes.common.PlcParameterObject; |
| | | import com.mes.common.S7object; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.taskcache.mapper.HangzhouMesMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | |
| | | |
| | | |
| | | @Service |
| | | public class LogicService { |
| | | @Autowired |
| | | private HangzhouMesMapper hangzhouMesMapper; |
| | | |
| | | // //理片 |
| | | // public void Process(){ |
| | | // String Result= S7object.getinstance().plccontrol.ReadWord("DB14.0", 1).get(0)+""; |
| | | // String Number=S7object.getinstance().plccontrol.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 boolean processInto(String Number){ |
| | | //查询消息队列里的玻璃 |
| | | GlassInfo GlassInfo=hangzhouMesMapper.selectGlassId(Number); |
| | | PlcParameterObject plcmes= PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){//存在此玻璃编号 |
| | | //同钢化版图内的栅格号 |
| | | List<EdgStorageCageDetails> list=hangzhouMesMapper.selectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getTemperingFeedSequence(),GlassInfo.getWidth()); |
| | | //空栅格号 |
| | | if (list.size()==0) { |
| | | list=hangzhouMesMapper.selectCacheLeisure(); |
| | | } |
| | | //小于此玻璃钢化版图序号的栅格号 |
| | | if(list.size()==0){ |
| | | list=hangzhouMesMapper.selectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getWidth()); |
| | | } |
| | | if(list.size()>0){ |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | EdgStorageCageDetails item=list.get(0); |
| | | hangzhouMesMapper.insertCacheTask(GlassInfo.getId()+"","0",item.getSlot()+"","1"); |
| | | S7object.getinstance().plccontrol.WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | return true; |
| | | } |
| | | |
| | | }else{ |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | // //理片 出 |
| | | // public boolean processOut(){ |
| | | // //查询任务 |
| | | // String A09=S7object.getinstance().plccontrol.ReadWord("DB14.56", 1).get(0)+""; |
| | | // String A10=S7object.getinstance().plccontrol.ReadWord("DB14.58", 1).get(0)+""; |
| | | // PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | // List<EdgStorageCageDetails> list=hangzhouMesMapper.selectCacheOut(); |
| | | // boolean isOut=true;//其他情况条件 如:后续设备故障禁止理片出片 等 |
| | | // if (list.size()>0&&isOut) { |
| | | // EdgStorageCageDetails item=list.get(0); |
| | | // if(A09=="0"&&A10=="1"){ |
| | | // //出到 A09 |
| | | // hangzhouMesMapper.insertCacheTask(item.getGlassid()+"","0","09","2"); |
| | | // S7object.getinstance().plccontrol.writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | // S7object.getinstance().plccontrol.writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | // return true; |
| | | // }else if(A09=="1"&&A10=="0"){ |
| | | // //出到 A10 |
| | | // hangzhouMesMapper.insertCacheTask(item.getGlassid()+"","0","10","2"); |
| | | // S7object.getinstance().plccontrol.writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | // S7object.getinstance().plccontrol.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= hangzhouMesMapper.selectLastOutCacheInfo("09"); |
| | | // GlassInfo glassInfo10= hangzhouMesMapper.selectLastOutCacheInfo("10"); |
| | | // if(glassInfo10!=null&&glassInfo10.getWidth()==item.getWidth()&&glassInfo10.getHeight()==item.getHeight()){ |
| | | // endcell="10"; |
| | | // SendEndcell="2"; |
| | | // }else if(glassInfo10!=null&&If_){ |
| | | // //其他条件 |
| | | // } |
| | | // hangzhouMesMapper.insertCacheTask(item.getGlassid()+"","0",endcell,"2"); |
| | | // S7object.getinstance().plccontrol.writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | // S7object.getinstance().plccontrol.writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | // return true; |
| | | // } |
| | | // } |
| | | // //返回结果 |
| | | // return false; |
| | | // } |
| | | |
| | | // //磨边 不交互 理片和磨边机自己交互 |
| | | // public void processMb(String Number){ |
| | | // //查询任务 |
| | | // GlassInfo GlassInfo=hangzhouMesMapper.selectGlassId(Number); |
| | | // PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | // if(GlassInfo!=null){ |
| | | // //发送任务 ID 长 宽 厚 倒角 工艺功能等 |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); |
| | | // S7object.getinstance().plccontrol.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | // } |
| | | // //返回结果 |
| | | // } |
| | | |
| | | //查询消息队列里此玻璃ID的数据 |
| | | public boolean SelectMessageId(String num){ |
| | | //查询是否存在 |
| | | GlassInfo glassInfo=hangzhouMesMapper.selectGlassId(num); |
| | | if(glassInfo==null){ |
| | | return false;//返回 不存在 |
| | | } |
| | | return true;//返回 存在 |
| | | } |
| | | //删除消息队列里此玻璃ID的数据 |
| | | public boolean DeleteMessageId(String num){ |
| | | //查询是否存在 |
| | | GlassInfo glassInfo=hangzhouMesMapper.selectGlassId(num); |
| | | if(glassInfo==null){ |
| | | return false;//返回 不存在 |
| | | } |
| | | return true;//返回 存在 |
| | | } |
| | | |
| | | //是否存在此编号玻璃 |
| | | public boolean isExist(String num){ |
| | | //查询是否存在 |
| | | GlassInfo glassInfo=hangzhouMesMapper.selectGlassId(num); |
| | | if(glassInfo==null){ |
| | | return false;//返回 不存在 |
| | | } |
| | | return true;//返回 存在 |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.taskcache.service; |
| | | |
| | | |
| | | import com.mes.taskcache.mapper.HangzhouMesMapper; |
| | | import com.mes.taskcache.mapper.PpMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class PpService { |
| | | |
| | | @Autowired |
| | | private PpMapper selectInfoMapper; |
| | | @Autowired |
| | | private HangzhouMesMapper hangzhouMesMapper; |
| | | |
| | | // public GlassInfo getUserInfo(String process_id){ |
| | | // return hangzhouMesMapper.selectGlassId(process_id); |
| | | // } |
| | | |
| | | // public List<Tempered> selectTemperedTerritory(String process_id){ |
| | | // return selectInfoMapper.selectTemperedTerritory(process_id); |
| | | // } |
| | | |
| | | //切割版图 当前识别版图 |
| | | public List<Map> selectCutTerritory(){ |
| | | //得到要显示的 工程ID 以及版图ID |
| | | //1.在Hangzhoumes数据库里 得到目前已经 领取但未完成的 工程ID集合 |
| | | //2.拿工程集合去PP数据库里 得到对应的小片集合 |
| | | //3.拿对应的小片集合 与 缓存任务表进行对比 查找下一版图显示 |
| | | String process_id = "P24032204"; |
| | | String territory_id = "1"; |
| | | return selectInfoMapper.selectCutTerritory(process_id,territory_id); |
| | | } |
| | | //切割版图 根据工程号查询 所有版图小片数据 |
| | | public List<Map> selectCutTerritory(String process_id){ |
| | | return selectInfoMapper.selectCutTerritory(process_id); |
| | | } |
| | | //切割版图 根据工程号,版图编号查询 版图编号里所有小片数据 |
| | | public List<Map> selectCutTerritory(String process_id,String TerritoryId){ |
| | | return selectInfoMapper.selectCutTerritory(process_id,TerritoryId); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: cacheGlass |
| | | # redis: |
| | | # database: 0 |
| | | # host: 192.168.56.10 |
| | | # port: 6379 |
| | | # password: |
| | | redis: |
| | | database: 0 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: 123456 |
| | | session: |
| | | store-type: redis |
| | | mybatis-plus: |
| | |
| | | }catch (Exception e){ |
| | | log.error(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | package com.mes.bigstorage.controller; |
| | | |
| | | |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/bigStorageCage") |
| | | public class BigStorageCageController { |
| | | |
| | | private BigStorageCageService bigStorageCageService; |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | |
| | | //todo: 实例代码 待删除 |
| | | @ApiOperation("测试") |
| | | @GetMapping("/index") |
| | | public String index() { |
| | | return "hello world"; |
| | | } |
| | | |
| | | @ApiOperation("理片笼信息") |
| | | @GetMapping("/BigStorageCage") |
| | | public List<BigStorageCage> BigStorageCage() { |
| | | return bigStorageCageService.list(); |
| | | } |
| | | |
| | | @ApiOperation("理片笼详情") |
| | | @GetMapping("/BigStorageCageDetails") |
| | | public List<BigStorageCageDetails> BigStorageCageDetails() { |
| | | return bigStorageCageDetailsService.list(); |
| | | } |
| | | |
| | | @ApiOperation("小车实时位置") |
| | | @GetMapping("/CarPosition") |
| | | public List<Integer> CarPosition() { |
| | | return bigStorageCageDetailsService.getCarposition(); |
| | | } |
| | | |
| | | @ApiOperation("手动完成任务") |
| | | @GetMapping("/FinishTask") |
| | | public void FinishTask(int type, int id) { |
| | | // bigStorageCageDetailsService.FinishTask(); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import feign.Param; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface BigStorageCageDetailsMapper extends BaseMapper<BigStorageCageDetails> { |
| | | |
| | | BigStorageCageDetails SelectTemperingFeedSlot(@Param("bigStorageCageDetails") BigStorageCageDetails bigStorageCageDetails); |
| | | |
| | | BigStorageCageDetails SelectEmptyFeedSlot(); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface BigStorageCageMapper extends BaseMapper<BigStorageCage> { |
| | | |
| | | |
| | | BigStorageCageDetails SelectEmptyFeedSlot(); |
| | | |
| | | @Update("update big_storage_cage set remain_width = #{width} where slot=#{slot}") |
| | | public void UpdateRemainWidth(int slot,int width); |
| | | |
| | | BigStorageCageDetails SelectTemperingFeedSlot(GlassInfo glassInfo); |
| | | |
| | | BigStorageCageDetails SelectOtherFeedSlot(); |
| | | |
| | | List<String> selectTemperingId(); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface BigStorageCageDetailsService extends IService<BigStorageCageDetails> { |
| | | |
| | | public boolean getTemperingGlass(); |
| | | |
| | | List<Integer> getCarposition(); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2024-03-27 |
| | | */ |
| | | public interface BigStorageCageService extends IService<BigStorageCage> { |
| | | |
| | | public void updateRemainWidth(int Slot); |
| | | public BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class BigStorageCageDetailsServiceImpl extends ServiceImpl<BigStorageCageDetailsMapper, BigStorageCageDetails> implements BigStorageCageDetailsService { |
| | | @Autowired |
| | | private BigStorageCageMapper bigStorageCageMapper; |
| | | @Override |
| | | public boolean getTemperingGlass(){ |
| | | //获取笼子内所有版图号 |
| | | List<String> temperingIdList=bigStorageCageMapper.selectTemperingId(); |
| | | for (String temperingId:temperingIdList |
| | | ) { |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | @Override |
| | | public List<Integer> getCarposition(){ |
| | | return null; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class BigStorageCageServiceImpl extends ServiceImpl<BigStorageCageMapper, BigStorageCage> implements BigStorageCageService { |
| | | @Autowired |
| | | private BigStorageCageMapper bigStorageCageMapper; |
| | | @Autowired |
| | | private BigStorageCageDetailsMapper bigStorageCageDetailsMapper; |
| | | @Override |
| | | public BigStorageCageDetails FeedGlass(GlassInfo glassInfo, BigStorageCageDetails bigStorageCageDetails) { |
| | | |
| | | |
| | | //获取同钢化版图id可进片的格子 |
| | | BigStorageCageDetails layoutSlotInfo =bigStorageCageMapper.SelectTemperingFeedSlot(glassInfo); |
| | | //有符合条件的格子时 |
| | | if (layoutSlotInfo!=null) { |
| | | //将玻璃信息填入理片笼详情表 |
| | | bigStorageCageDetails.setSlot(layoutSlotInfo.getSlot()); |
| | | }else{ |
| | | //获取不到时: |
| | | |
| | | //获取可进片格子信息 |
| | | BigStorageCageDetails EmptySlotInfo=bigStorageCageMapper.SelectEmptyFeedSlot(); |
| | | if (EmptySlotInfo!=null){ |
| | | bigStorageCageDetails.setSlot(EmptySlotInfo.getSlot()); |
| | | }else{ |
| | | //获取其他笼格子- |
| | | BigStorageCageDetails OtherSlotInfo=bigStorageCageMapper.SelectOtherFeedSlot(); |
| | | bigStorageCageDetails.setSlot(OtherSlotInfo.getSlot()); |
| | | } |
| | | //将玻璃信息放入该格子 |
| | | |
| | | } |
| | | |
| | | updateRemainWidth(bigStorageCageDetails.getSlot()); |
| | | return bigStorageCageDetails; |
| | | } |
| | | |
| | | //修改格子剩余宽度 |
| | | @Override |
| | | public void updateRemainWidth(int Slot){ |
| | | //获取该格子内玻璃信息 |
| | | int width=5000; |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList= Collections.singletonList(bigStorageCageDetailsMapper.selectById(Slot)); |
| | | for (BigStorageCageDetails bigStorageCageDetails:bigStorageCageDetailsList |
| | | ) { |
| | | width-=Integer.parseInt(bigStorageCageDetails.getWidth().toString())+bigStorageCageDetails.getGap(); |
| | | } |
| | | //修改格子剩余宽度 |
| | | bigStorageCageMapper.UpdateRemainWidth(Slot,width); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.component; |
| | | |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import com.mes.uppattenusage.service.GlassInfoService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class PlcStorageCage extends Thread { |
| | | |
| | | @Autowired |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Autowired |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Autowired |
| | | private TemperingGlassInfoService temperingGlassInfoService; |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | |
| | | Thread.sleep(500); |
| | | String plcFeedReq ="0"; |
| | | String plcFeedGlassid ="111"; |
| | | //Plc进片请求时 |
| | | if("1".equals(plcFeedReq)){ |
| | | BigStorageCageDetails bigStorageCageDetails=new BigStorageCageDetails(); |
| | | //传入玻璃id |
| | | GlassInfo glassInfo=glassInfoService.getById(plcFeedGlassid); |
| | | |
| | | BigStorageCageDetails SlotInfo=bigStorageCageService.FeedGlass(glassInfo,bigStorageCageDetails); |
| | | if(SlotInfo!=null){ |
| | | //plc任务发送字 |
| | | } |
| | | } |
| | | |
| | | //出片请求 |
| | | String plcOutReq ="0"; |
| | | boolean result=false; |
| | | if("1".equals(plcOutReq)){ |
| | | //获取钢化小片表未出笼信息 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.SelectTemperingGlassInfo(); |
| | | //没有可出的玻璃时 |
| | | if(temperingGlassInfoList!=null){ |
| | | //查询是否有小片全部到齐的钢化版图 |
| | | result = bigStorageCageDetailsService.getTemperingGlass(); |
| | | }else{ |
| | | //继续当前钢化版图的任务 |
| | | |
| | | temperingGlassInfoService.addOutTask(temperingGlassInfoList); |
| | | result=true; |
| | | } |
| | | if(result==true){ |
| | | //plc任务发送字 |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | |
| | | * @since 2024-03-27 |
| | | */ |
| | | public interface TemperingGlassInfoService extends IService<TemperingGlassInfo> { |
| | | |
| | | public void addOutTask(List<TemperingGlassInfo> temperingGlassInfoList); |
| | | public List<TemperingGlassInfo> SelectTemperingGlassInfo(); |
| | | } |
| | |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | |
| | | @Service |
| | | public class TemperingGlassInfoServiceImpl extends ServiceImpl<TemperingGlassInfoMapper, TemperingGlassInfo> implements TemperingGlassInfoService { |
| | | |
| | | @Override |
| | | public void addOutTask(List<TemperingGlassInfo> temperingGlassInfoList) { |
| | | double carwidth=5000; |
| | | double gay=50; |
| | | //写入任务到任务表 |
| | | for (TemperingGlassInfo temperingGlassInfo:temperingGlassInfoList |
| | | ) { |
| | | if((carwidth-gay-temperingGlassInfo.getWidth())>0){ |
| | | //添加任务到任务表 |
| | | }else{ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<TemperingGlassInfo> SelectTemperingGlassInfo() { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 127.0.0.1:8848 |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: cacheVerticalGlass |
| | | redis: |
| | | database: 0 |
| | | host: 192.168.56.10 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: 123456 |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | configuration: |
| | |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>loadGlass</artifactId> |
| | | <artifactId>cacheGlass</artifactId> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | | <artifactId>junit</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.mes</groupId> |
| | | <artifactId>servicebase</artifactId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <properties> |
| | | <maven.compiler.source>8</maven.compiler.source> |
New file |
| | |
| | | package com.mes.upworkstation.controller; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.mes.upworkstation.entity.UpWorkstation; |
| | | import com.mes.upworkstation.service.LoadGlassService; |
| | | import com.mes.utils.Result; |
| | | |
| | | @RestController |
| | | @RequestMapping("/LoadGlass") |
| | | |
| | | // TidyUpGlassModule 钢化模块 |
| | | public class LoadGlassController { |
| | | |
| | | @Autowired |
| | | private LoadGlassService loadGlassService; |
| | | |
| | | @PostMapping("/SelectAll") //查询现在上片机的玻璃信息 |
| | | @ResponseBody |
| | | public Result SelectGlassInfo() { |
| | | List<UpWorkstation> glass = loadGlassService.selectAll(); |
| | | System.out.println(glass); |
| | | return Result.build(200,"", glass); |
| | | } |
| | | |
| | | @PostMapping("/insertGlass") //修改一条工位信息,接收实例类字段为宽高厚膜系数量工位id |
| | | @ResponseBody |
| | | public void insertGlassinfo(@RequestBody UpWorkstation upwork) { |
| | | loadGlassService.insertGlass(upwork); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/deleteGlass") //修改一条工位的玻璃信息,传输工位id将玻璃信息相关字段更改为null |
| | | @ResponseBody |
| | | public void SelectCutTerritory(int upworkid) { |
| | | loadGlassService.deleteGlass(upworkid); |
| | | } |
| | | |
| | | @PostMapping("/selectPriority") //开始上片任务 |
| | | @ResponseBody |
| | | public void selectPriority() { |
| | | boolean result = loadGlassService.isCanLoadGlass(); |
| | | if(result==true){ |
| | | loadGlassService.selectPriority(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.upworkstation.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.*; |
| | | import com.mes.upworkstation.entity.UpWorkstation; |
| | | @Mapper |
| | | public interface LoadGlassMapper extends BaseMapper<UpWorkstation> { |
| | | //显示目前工位玻璃信息 |
| | | @Select("SELECT * FROM up_workstation") |
| | | List<UpWorkstation> selectALL(); |
| | | //删除工位的玻璃信息 |
| | | @Update("UPDATE `hangzhoumes`.`up_workstation` SET `pattern_width` =NULL, `pattern_heigth` = NULL, `pattern_thickness` = NULL, `films_id` = NULL, `number` = NULL WHERE `workstation_id`=#{id}") |
| | | void deleteGlass(int id ); |
| | | //增加上片信息 |
| | | @Update ("UPDATE `hangzhoumes`.`up_workstation` SET `pattern_width` = #{upwork.patternwidth}, `pattern_heigth` = #{upwork.patternheigth}, `pattern_thickness` =#{upwork.patternthickness}, `films_id` =#{upwork.filmsid}, `number` = #{upwork.number} WHERE `id` = #{upwork.workstationid}; ") |
| | | void insertGlass(UpWorkstation upwork); |
| | | //是否发起吸片 |
| | | @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); |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.upworkstation.service; |
| | | import java.util.List; |
| | | import org.springframework.stereotype.Service; |
| | | import com.mes.common.PLCAutoMes; |
| | | import com.mes.common.PlcParameterObject; |
| | | import com.mes.upworkstation.entity.UpWorkstation; |
| | | import com.mes.upworkstation.mapper.LoadGlassMapper; |
| | | |
| | | @Service |
| | | public class LoadGlassService { |
| | | |
| | | |
| | | private LoadGlassMapper LoadGlassMapper; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //显示工位上的玻璃信息 |
| | | public List<UpWorkstation> selectAll() { |
| | | List<UpWorkstation> glassInfo= LoadGlassMapper.selectALL(); |
| | | return glassInfo; |
| | | } |
| | | //增加人工输入的工位玻璃信息 |
| | | public void insertGlass(UpWorkstation upwork) { |
| | | LoadGlassMapper.insertGlass(upwork); |
| | | } |
| | | //删除人工搬走的玻璃信息 |
| | | public void deleteGlass(int id) { |
| | | LoadGlassMapper.deleteGlass(id); |
| | | } |
| | | //判断是否可以吸片进行任务 |
| | | public boolean isCanLoadGlass() { |
| | | String loadstate=plcmes.getPlcParameter("吸片信号").getValue(); |
| | | if(loadstate.equals("1")) { |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | //判断优先吸片位置后发送出片任务 |
| | | public void selectPriority() { |
| | | int loadid1=LoadGlassMapper.selectPriority(1); |
| | | int loadid2=LoadGlassMapper.selectPriority(2); |
| | | //判断一二号工位哪边的顺序更先 |
| | | if(loadid1>loadid2) { |
| | | //s7control.WriteWord("DB100.10", (short)2); |
| | | }else if(loadid1==loadid2){ |
| | | //当两个工位上的玻璃数相同时,判断哪个工位上的玻璃数更少,优先清空一个架子 |
| | | int glassnum1=Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); |
| | | int glassnum2=Integer.parseInt(plcmes.getPlcParameter("玻璃数").getValue()); |
| | | if(glassnum1>glassnum2){ |
| | | // s7control.WriteWord("DB100.10", (short)2); |
| | | }else{ |
| | | //s7control.WriteWord("DB100.10", (short)1); |
| | | } |
| | | }else{ |
| | | //s7control.WriteWord("DB100.10", (short)1); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 127.0.0.1:8848 |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: loadGlass |
| | | redis: |
| | | database: 0 |
| | | host: 192.168.56.10 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: 123456 |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | configuration: |
| | |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>temperingGlass</artifactId> |
| | | <artifactId>cacheGlass</artifactId> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | | <artifactId>junit</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.mes</groupId> |
| | | <artifactId>servicebase</artifactId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <properties> |
| | | <maven.compiler.source>8</maven.compiler.source> |
New file |
| | |
| | | package com.mes.temperingglass.controller; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingOverService; |
| | | import com.mes.temperingglass.service.TemperingService; |
| | | import com.mes.utils.Result; |
| | | |
| | | |
| | | @RestController |
| | | @RequestMapping("/Tempering") |
| | | |
| | | // TidyUpGlassModule 钢化模块 |
| | | public class TemperingController { |
| | | |
| | | @Autowired |
| | | private TemperingService temperingService; |
| | | |
| | | @Autowired |
| | | private TemperingOverService temperingOverService; |
| | | |
| | | @GetMapping("/SelectWaitingGlass") // 查询钢化等片中的版图信息,状态为1的为已到,状态为0的为等待中 |
| | | @ResponseBody |
| | | public Result SelectWaitingGlass(@RequestParam(name = "ProcessId", required = false) String ProcessId) { |
| | | List<TemperingGlassInfo> glass = temperingService.SelectWaitingGlass(); |
| | | System.out.println(glass); |
| | | return Result.build(200,"", glass); |
| | | } |
| | | |
| | | @GetMapping("/SelectIntoGlass") // 查询进炉中的钢化等片中的版图信息,状态全为1的为已到。 |
| | | @ResponseBody |
| | | public Result SelectIntoGlass(String ProcessId) { |
| | | List<TemperingGlassInfo> glass = temperingService.SelectIntoGlass(); |
| | | System.out.println(glass); |
| | | return Result.build(200,"", glass); |
| | | } |
| | | |
| | | @GetMapping("/SelectOutGlass") //钢化后显示出炉的版图信息 |
| | | @ResponseBody |
| | | public Result SelectOutGlass(String ProcessId) { |
| | | List<TemperingGlassInfo> glass = temperingOverService.SelectOutGlass(); |
| | | System.out.println(glass); |
| | | return Result.build(200,"", glass); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.temperingglass.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | | public interface TemperingMapper extends BaseMapper<TemperingGlassInfo> { |
| | | |
| | | |
| | | //查询该玻璃的尺寸和坐标 |
| | | @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<TemperingGlassInfo> 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<TemperingGlassInfo> 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 <TemperingGlassInfo> SelectOutGlass(); |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.temperingglass.service; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.mapper.TemperingMapper; |
| | | import java.util.List; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class TemperingOverService { |
| | | private final TemperingMapper temperingMapper; |
| | | //PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | public TemperingOverService(TemperingMapper temperingMapper) { |
| | | this.temperingMapper = temperingMapper; |
| | | } |
| | | //接收出炉信号和炉号 |
| | | public String SelectOutSignal () { |
| | | |
| | | //S7control.getinstance().WriteWord("出炉信号", (short)1); |
| | | return "GlassInfo"; |
| | | } |
| | | //发送确认收到信号 |
| | | public void OverSignal () { |
| | | //S7control.getinstance().WriteWord("确认字", (short)1); |
| | | } |
| | | //显示钢化出炉后的版图信息 |
| | | public List <TemperingGlassInfo> SelectOutGlass () { |
| | | return temperingMapper.SelectOutGlass(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.temperingglass.service; |
| | | import com.mes.temperingglass.entity.GlassInfo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.tools.S7control; |
| | | import com.mes.temperingglass.mapper.TemperingMapper; |
| | | import java.util.List; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class TemperingService { |
| | | |
| | | private final TemperingMapper temperingMapper; |
| | | private S7control s7control; |
| | | |
| | | public TemperingService(TemperingMapper temperingMapper) { |
| | | this.temperingMapper =temperingMapper; |
| | | } |
| | | //接收id返回坐标和数据 |
| | | public GlassInfo SelectOutGlass (String glassid) { |
| | | GlassInfo GlassInfo = temperingMapper.SelectGlass(glassid); |
| | | return GlassInfo; |
| | | } |
| | | //发送坐标信息 |
| | | public void SendCoordinate (short glassX,short glassY) { |
| | | s7control.WriteWord("DB100.10", glassX); |
| | | s7control.WriteWord("DB100.10", glassY); |
| | | } |
| | | //判断是否可以发送进炉信号 |
| | | public int SelectTempering (String glassid) { |
| | | int tempering = temperingMapper.SelectTempering(glassid); |
| | | if (tempering == 1) { |
| | | return 1; |
| | | } |
| | | else { |
| | | return 0; |
| | | } |
| | | } |
| | | //发送进炉信号 |
| | | public void SendIntoGlass (short start) { |
| | | s7control.WriteWord("DB100.10", start); |
| | | } |
| | | //接受完成字回复确认字 |
| | | public void SendIntoGlass () { |
| | | s7control.WriteWord("DB100.10", (short)1); |
| | | } |
| | | //显示等待中的版图 |
| | | public List <TemperingGlassInfo> SelectWaitingGlass () { |
| | | List<TemperingGlassInfo> WaitingGlass = temperingMapper.SelectWaitingGlass(); |
| | | return WaitingGlass; |
| | | } |
| | | //显示正在进炉的版图 |
| | | public List<TemperingGlassInfo> SelectIntoGlass () { |
| | | List<TemperingGlassInfo> IntoGlass = temperingMapper.SelectInGlass(); |
| | | return IntoGlass; |
| | | } |
| | | } |
| | |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 127.0.0.1:8848 |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: temperingGlass |
| | | redis: |
| | | database: 0 |
| | | host: 192.168.56.10 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: 123456 |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | configuration: |
| | |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | | server-addr: 192.168.6.128:8848 |
| | | server-addr: 10.153.19.150:8848 |
| | | application: |
| | | name: unLoadGlass |
| | | redis: |
| | | database: 0 |
| | | host: 127.0.0.1 |
| | | host: 10.153.19.150 |
| | | port: 6379 |
| | | password: 123456 |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | |