| | |
| | | import com.mes.common.S7control; |
| | | import com.mes.device.PlcParameterObject; |
| | | |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; |
| | | import com.mes.downworkstation.mapper.DownWorkstationMapper; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.uppattenusage.entity.GlassInfo; |
| | | import com.mes.uppattenusage.service.GlassInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; |
| | | |
| | | @Data |
| | | @Service |
| | | public class DownGlassCacheLogic { |
| | | @Autowired |
| | | private DownStorageCageDetailsMapper selectInfo; |
| | | private GlassInfoService GlassInfoService; |
| | | private DownStorageCageDetailsService downStorageCageDetailsService; |
| | | |
| | | /** |
| | | * @param Number |
| | | * //识别逻辑 不交互 |
| | | */ |
| | | |
| | | public void identify(String Number){ |
| | | //查询任务 |
| | | PlcParameterObject plcmes= PLCAutoMes.PlcMesObject; |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | String s=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; |
| | | boolean isexist=isExist(Number); |
| | | if (isexist) { |
| | | //存在逻辑 1.添加信息 2.回复PLC存在 |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | }else { |
| | | //不存在逻辑 1.回复PLC不存在 |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); |
| | | } |
| | | } |
| | | //下片前理片 |
| | | public static final String RESULT_IN = "1"; |
| | | public static final String RESULT_OUT = "2"; |
| | | public static final String RESULT_IN_OUT = "3"; |
| | | @Autowired |
| | | private DownStorageCageDetailsMapper selectInfo; |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | @Autowired |
| | | private DownStorageCageService downStorageCageService; |
| | | @Autowired |
| | | private DownGlassTaskService downGlassTaskService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public void process() { |
| | | String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + ""; |
| | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * //下片前理片 进 |
| | | * @return //下片前理片 进 |
| | | */ |
| | | |
| | | public boolean processInto(String Number){ |
| | | GlassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class); |
| | | public boolean processInto(String Number) { |
| | | glassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class); |
| | | downStorageCageService = WebSocketServer.applicationContext.getBean(DownStorageCageService.class); |
| | | |
| | | //按id查询玻璃信息表里的玻璃 |
| | | GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | //存在此玻璃编号 |
| | | if(GlassInfo!=null){ |
| | | //同钢化版图内的栅格号 |
| | | List<DownStorageCageDetails> list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getTemperingFeedSequence(),GlassInfo.getWidth()); |
| | | if (GlassInfo != null) { |
| | | //同钢化版图内的栅格号 找到相同版图id并且大于前面的顺序的空格 |
| | | List<DownStorageCageDetails> list = downStorageCageService.getIsExistIntoCacheByLayoutAndSequence(GlassInfo.getTemperingLayoutId(), GlassInfo.getTemperingFeedSequence(), GlassInfo.getWidth()); |
| | | //空栅格号 |
| | | if (list.size()==0) { |
| | | list=selectInfo.SelectCacheLeisure(); |
| | | if (list.size() == 0) { |
| | | //查询笼子内空闲 |
| | | list = downStorageCageService.getCacheLeisure(); |
| | | } |
| | | //小于此玻璃钢化版图序号的栅格号 |
| | | if(list.size()==0){ |
| | | list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getWidth()); |
| | | if (list.size() == 0) { |
| | | list = downStorageCageService.getIsExistIntoCacheByLayout(GlassInfo.getTemperingLayoutId(), GlassInfo.getWidth()); |
| | | } |
| | | if(list.size()>0){ |
| | | if (list.size() > 0) { |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | DownStorageCageDetails item=list.get(0); |
| | | selectInfo.insertCacheTask(GlassInfo.getId()+"","0",item.getSlot()+"","1",GlassInfo.getWidth(),GlassInfo.getHeight(),GlassInfo.getFilmsid(),GlassInfo.getThickness(),GlassInfo.getFlowcardId()); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | DownStorageCageDetails item = list.get(0); |
| | | selectInfo.insertCacheTask(GlassInfo.getId() + "", "0", item.getSlot() + "", "1", GlassInfo.getWidth(), GlassInfo.getHeight(), GlassInfo.getFilmsid(), GlassInfo.getThickness(), GlassInfo.getFlowcardId()); |
| | | |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1); |
| | | |
| | | //完成后插入小片数据到缓存表 |
| | | return true; |
| | | } |
| | | |
| | | }else{ |
| | | |
| | | } else { |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | |
| | | //理片 出 |
| | | public boolean processOut(){ |
| | | //查询任务 |
| | | String G06=S7control.getinstance().ReadWord("DB14.56", 1).get(0)+""; |
| | | String G11=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | String G13=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | List<DownStorageCageDetails> list=selectInfo.SelectCacheOut(); |
| | | //其他情况条件 如:后续设备故障禁止理片出片 等 |
| | | boolean isOut=true; |
| | | if (list.size()>0&&isOut) { |
| | | DownStorageCageDetails item=list.get(0); |
| | | // |
| | | if(G06=="0"&&G11=="1"){ |
| | | //出到 G06 |
| | | public boolean processOut() { |
| | | // 查询任务 |
| | | String G06 = S7control.getinstance().ReadWord("DB14.56", 1).get(0) + ""; |
| | | String G11 = S7control.getinstance().ReadWord("DB14.58", 1).get(0) + ""; |
| | | String G13 = S7control.getinstance().ReadWord("DB14.58", 1).get(0) + ""; |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0","06","2",item.getWidth(),item.getHeight(),item.getFilmsid(),item.getThickness(),item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(G06=="1"&&G11=="0"){ |
| | | //出到 G11 |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0","11","2",item.getWidth(),item.getHeight(),item.getFilmsid(),item.getThickness(),item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(G06=="0"&&G11=="0"){ |
| | | //都允许 G04/G05 上一片是否和此片玻璃尺寸尺寸相同 |
| | | String endcell="06"; |
| | | String SendEndcell="1"; |
| | | boolean If_=false; |
| | | GlassInfo glassInfo06= selectInfo.SelectLastOutCacheInfo("06"); |
| | | GlassInfo glassInfo11= selectInfo.SelectLastOutCacheInfo("11"); |
| | | GlassInfo glassInfo13= selectInfo.SelectLastOutCacheInfo("13"); |
| | | if(glassInfo06!=null&& glassInfo11.getWidth().equals(item.getWidth()) && glassInfo06.getHeight().equals(item.getHeight())){ |
| | | endcell="11"; |
| | | SendEndcell="2"; |
| | | }else if(item.getHeight()>=3440&&item.getWidth()>=1440){ |
| | | //其他条件人工处理 |
| | | List<DownStorageCageDetails> list = downStorageCageService.getCacheOut(1, 5); |
| | | List<DownStorageCageDetails> list2 = downStorageCageService.getCacheOut(6, 10); |
| | | List<DownStorageCageDetails> list3 = downStorageCageService.getCacheOut(1, 10); |
| | | GlassInfo Maxglass=glassInfoService.selectGlassId("2");; |
| | | |
| | | } |
| | | // 优先 超出尺寸优先人工出片 人工处理 |
| | | if (!list3.isEmpty()) { |
| | | DownStorageCageDetails item3 = list3.get(0); |
| | | if (item3.getHeight() >= 1 && item3.getWidth() >= 1) { |
| | | |
| | | selectInfo.insertCacheTask(item.getGlassId()+"","0",endcell,"2",item.getWidth(),item.getHeight(),item.getFilmsid(),item.getThickness(),item.getFlowCardId()); |
| | | String endcell = "13"; |
| | | String SendEndcell = "1"; |
| | | |
| | | selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | //返回结果 |
| | | |
| | | //同时请求 优先后端出片 |
| | | else if (!list3.isEmpty()&&Maxglass.equals(list3.get(0))) { |
| | | DownStorageCageDetails item3 = list3.get(0); |
| | | if (G06.equals("0") && G11.equals("0")) { |
| | | String endcell = "11"; |
| | | String SendEndcell = "1"; |
| | | selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | // 按照大小符合前端出片 |
| | | else if (!list.isEmpty()) { |
| | | DownStorageCageDetails item = list.get(0); |
| | | if (G06.equals("0") && G11.equals("1")) { |
| | | // 出到 G06 |
| | | selectInfo.insertCacheTask(item.getGlassId() + "", "0", "06", "2", item.getWidth(), item.getHeight(), item.getFilmsid(), item.getThickness(), item.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | // 按照顺序符合后端出片 |
| | | } else if (!list2.isEmpty()) { |
| | | DownStorageCageDetails item2 = list2.get(0); |
| | | if (G06.equals("1") && G11.equals("0")) { |
| | | // 出到 G11 |
| | | selectInfo.insertCacheTask(item2.getGlassId() + "", "0", "11", "2", item2.getWidth(), item2.getHeight(), item2.getFilmsid(), item2.getThickness(), item2.getFlowCardId()); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // 返回结果 |
| | | return false; |
| | | } |
| | | //查询是否绑定架子 |
| | | // public boolean selectFlowCardId(String FlowCardId){ |
| | | // |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * //磨边 不交互 理片和磨边机自己交互 |
| | | */ |
| | | |
| | | public void processMb(String Number){ |
| | | //按id查询玻璃信息表里的玻璃 |
| | | GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){ |
| | | //发送任务 ID 长 宽 厚 倒角 工艺功能等 |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | } |
| | | //返回结果 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * 查询消息队列里此玻璃ID的数据 |
| | | * @return 查询消息队列里此玻璃ID的数据 |
| | | */ |
| | | public boolean selectMessageId(String Number){ |
| | | public boolean selectMessageId(String Number) { |
| | | //查询是否存在 |
| | | |
| | | GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); |
| | | if (GlassInfo == null) { |
| | | //返回 不存在 |
| | | return false; |
| | | |
| | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * 删除消息队列里此玻璃ID的数据 |
| | | * @return 删除消息队列里此玻璃ID的数据 |
| | | */ |
| | | |
| | | public boolean deleteMessageId(String Number){ |
| | | public boolean deleteMessageId(String Number) { |
| | | //查询是否存在 |
| | | GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); |
| | | if (GlassInfo == null) { |
| | | //返回 不存在 |
| | | return false; |
| | | } |
| | | //返回 存在 |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @param Number |
| | | * @return |
| | | * //是否存在此编号玻璃 |
| | | * @return //是否存在此编号玻璃 |
| | | */ |
| | | public boolean isExist(String Number){ |
| | | public boolean isExist(String Number) { |
| | | //查询是否存在 |
| | | GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); |
| | | if(GlassInfo==null){ |
| | | GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); |
| | | if (GlassInfo == null) { |
| | | //返回 不存在 |
| | | return false; |
| | | } |
| | | //返回 存在 |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
| | | |