Merge branch 'master' of http://10.153.19.25:10101/r/Albania_Mes
| | |
| | | <!--显示--> |
| | | <div style="width:1000px;height: 720px;border: 2px solid #d1d1d1;float: left;"> |
| | | <!--玻璃图 #81b337--> |
| | | <div :style="'top:10px;bottom: 10px;left: 10px;right: 10px;margin:'+((720-(this.LastQueue.glasswidth / 25 * 7))/2)+'px auto;'+ |
| | | <div :style="'top:10px;bottom: 10px;left: 10px;right: 10px;margin:'+((1000-(this.LastQueue.glasswidth / 25 * 7))/2)+'px auto;'+ |
| | | 'width:'+ (this.LastQueue.glasswidth / 25 * 7) + 'px;'+ |
| | | 'height:'+ (this.LastQueue.glassheight / 25 * 7) + 'px;'+ |
| | | 'line-height: '+ (this.LastQueue.glassheight / 25 * 7) + 'px;'+ |
| | |
| | | import com.example.springboot.service.StorageCageService; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | import com.example.springboot.mapper.AlbaniaMapper; |
| | | |
| | | |
| | | public class PlcHoldNew extends Thread { |
| | | |
| | | private AlarmMapper alarmMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private AlbaniaMapper albaniaMapper; |
| | |
| | | while (this != null) { |
| | | try { |
| | | |
| | | Thread.sleep(100); |
| | | Thread.sleep(500); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(plcmes.getPlcParameter("PLCToMES").getValue()!=null){ |
| | | |
| | | // spianService.Mestast("NG0001-1",0,3,1,"MESID1",1); |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//出片任务启动 |
| | | //spianService.Mestast("NG0001-1",1,4,1,"MESID1",1); |
| | | |
| | | |
| | | |
| | | String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//出片请求一线 |
| | |
| | | String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//运送车请求 |
| | | String IDStatus1=plcmes.getPlcParameter("IDStatus1").getValue();//1号任务完成 |
| | | String MESToPLCStatus1=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//1号确认字 |
| | | String MESToPLC=plcmes.getPlcParameter("MESToPLC").getValue();//发送任务字 |
| | | |
| | | //一号线请求 |
| | | if(ExportTOMES1!=null){ |
| | | if (ExportTOMES1.equals("1") == true&&PLCToMES.equals("1")==true) { |
| | | if(ExportTOMES1!=null&&MESToPLC!=null){ |
| | | if (ExportTOMES1.equals("1") == true&&MESToPLC.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | spianService.selectout(1); |
| | | } |
| | | } |
| | | // //二线号请求时 |
| | | if(ExportToMES2!=null ){ |
| | | if (ExportToMES2.equals("1") == true&&PLCToMES.equals("1")==true) { |
| | | if(ExportToMES2!=null &&MESToPLC!=null){ |
| | | if (ExportToMES2.equals("1") == true&&MESToPLC.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | |
| | | spianService.selectout(2); |
| | | } |
| | | } |
| | | //进片请求时 |
| | | GlassInfo glass=albaniaMapper.SelectGlass(); |
| | | if(PLCToMES!=null && glass!=null){ |
| | | if(PLCToMES.equals("1")==true&&glass!=null){ |
| | | if(PLCToMES!=null && glass!=null&&MESToPLC!=null){ |
| | | if(PLCToMES.equals("1")==true&&MESToPLC.equals("0")==true){ |
| | | spianService.selectAll(glass); |
| | | } |
| | | } |
| | |
| | | |
| | | String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//PLC理片任务状态汇报 |
| | | String Glassid=plcmes.getPlcParameter("MESID"+i).getValueString();//MES玻璃ID |
| | | |
| | | GlassInfo id=albaniaMapper.SelectTaskId(Glassid); |
| | | |
| | | GlassInfo id=albaniaMapper.SelectTaskId(Glassid); |
| | | if(id!=null&&Tastover.equals("1")){ |
| | | //调用完成任务 Glassid |
| | | storageCageService.FinishTask(id.getId()); |
| | | } |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short) 0);//清除任务字 |
| | | } |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//完成确认字 |
| | | |
| | | } |
| | | |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short) 0);//清除任务发送字 |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 匹配 |
| | | // System.err.println(PlcRequest+","+MesSend+","+width+","+height); |
| | | String PlcRequest = plcmes.getPlcParameter("GaToMES").getValue();// 请求 |
| | | String MesSend = plcmes.getPlcParameter("MESToGaStatus").getValue();// 发送 |
| | | double width = Double.valueOf(plcmes.getPlcParameter("width").getValue());// 宽 |
| | | double height = Double.valueOf(plcmes.getPlcParameter("Height").getValue());// 高 |
| | | if ("0".equals(PlcRequest) && istest) { |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 0); |
| | | } |
| | | if ("1".equals(PlcRequest) && "0".equals(MesSend)) { |
| | | boolean is = HomeService.Normal(width, height, "1"); |
| | | if (is && istest) { |
| | | // 测量成功 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | (short) 1); |
| | | // String PlcRequest = plcmes.getPlcParameter("GaToMES").getValue();// 请求 |
| | | // String MesSend = plcmes.getPlcParameter("MESToGaStatus").getValue();// 发送 |
| | | // double width = Double.valueOf(plcmes.getPlcParameter("width").getValue());// 宽 |
| | | // double height = Double.valueOf(plcmes.getPlcParameter("Height").getValue());// 高 |
| | | // if ("0".equals(PlcRequest) && istest) { |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 0); |
| | | // } |
| | | // if ("1".equals(PlcRequest) && "0".equals(MesSend)) { |
| | | // boolean is = HomeService.Normal(width, height, "1"); |
| | | // if (is && istest) { |
| | | // // 测量成功 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | // (short) 1); |
| | | |
| | | } else if (istest) { |
| | | // 重新测量 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | (short) 4); |
| | | } |
| | | // } else if (istest) { |
| | | // // 重新测量 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | // (short) 4); |
| | | // } |
| | | |
| | | } |
| | | // } |
| | | // S7control.getinstance().WriteWord("DB14.170", (short)0); |
| | | Queue LastQueue = QueueMapper.selectLastQueue(); |
| | | if (LastQueue == null) { |
| | |
| | | @Select("select * from v_cagerelease2 where mateid not in(select mateid from v_cagerelease2 where surplus=0 group by mateid)LIMIT 1;") |
| | | GlassInfo SelectOutGlass2(); |
| | | //流程卡任务查询 |
| | | @Select("select G.flowcard,G.glasstype,G.number,G.mateid,G.tier,G.starttime,G.finishnumber,IF((G.number-G.finishnumber-ku.KuCount)<0,G.number,ku.KuCount) as 'surplus',G.totaltier as id,G.width from (select Gfd.flowcard,Ggf.glasstype,Ggf.number,Ggf.mateid,Ggf.tier,Ggf.finishnumber,Gfd.starttime,Gfd.totaltier,Ggf.width from flowcard as Gfd LEFT JOIN glassinfo as Ggf on Gfd.flowcard=Ggf.flowcard where Gfd.state=1 and Gfd.line=#{line}) as G left join (select glasstype,sum(number) AS KuCount from storage_cage where flowcard is not null group by glasstype) as ku on G.glasstype=ku.glasstype where G.mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid)order by `g`.`starttime`,`g`.`mateid`,`g`.`finishnumber`,`g`.`tier`LIMIT 1;") |
| | | @Select("select G.flowcard,G.glasstype,G.number,G.mateid,G.tier,G.starttime,G.finishnumber,IF((G.number-G.finishnumber-ku.KuCount)<0,G.number,ku.KuCount) as 'surplus',G.totaltier as id,G.width,G.glassid from (select Gfd.flowcard,Ggf.glasstype,Ggf.number,Ggf.mateid,Ggf.tier,Ggf.finishnumber,Gfd.starttime,Gfd.totaltier,Ggf.width,Ggf.glassid from flowcard as Gfd LEFT JOIN glassinfo as Ggf on Gfd.flowcard=Ggf.flowcard where Gfd.state=1 and Gfd.line=#{line}) as G left join (select glasstype,sum(number) AS KuCount from storage_cage where flowcard is not null group by glasstype) as ku on G.glasstype=ku.glasstype where G.mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid)order by `g`.`starttime`,`g`.`mateid`,`g`.`finishnumber`,`g`.`tier`LIMIT 1;") |
| | | GlassInfo SelectOutGlass(int line); |
| | | //获取该类型在库存的位置 |
| | | @Select("select * from storage_cage where glasstype=#{glasstype} and number>0 limit 1") |
| | |
| | | @Select("select method from flowcard where state=1 and line=#{line} ORDER BY starttime LIMIT 1;") |
| | | GlassInfo SelectMethod(int line); |
| | | //直出模式任务查询 |
| | | @Select("select b.flowcard,b.glasstype,b.mateid,a.totaltier as id,IFNULL(c.number,0)as number from flowcard a left join glassinfo b on a.flowcard=b.flowcard left join(select sum(number)as number,glasstype from storage_cage GROUP BY glasstype)c on b.glasstype=c.glasstype where a.line=#{line} and c.number>0") |
| | | @Select("select b.flowcard,b.glasstype,b.mateid,a.totaltier as id,IFNULL(c.number,0)as number,b.glassid from flowcard a left join glassinfo b on a.flowcard=b.flowcard left join(select sum(number)as number,glasstype from storage_cage GROUP BY glasstype)c on b.glasstype=c.glasstype where a.line=#{line} and c.number>0") |
| | | GlassInfo SelectOutGlass2(int line); |
| | | @Select("update storage_cage a set a.glasswidth=#{width},a.glassheight=#{height} where id=#{id} ") |
| | | void UpdateStorage(double width,double height,int id); |
| | | |
| | | @Update("update queue set state=2 where glassid=#{glassid};") |
| | | void UpdateQueueState(String glassid); |
| | | |
| | | |
| | | } |
| | |
| | | StorageCage cage; |
| | | String glassid=glassInfo.getGlassid(); |
| | | Double width=glassInfo.getWidth(); |
| | | //int mateid=glassInfo.getMateid(); |
| | | Double height=glassInfo.getHeight(); |
| | | String flowcard=glassInfo.getFlowcard(); |
| | | int glasstype=glassInfo.getGlasstype(); |
| | | //判断是否有同类型的 |
| | |
| | | if(cage!=null){ |
| | | //发送plc任务 |
| | | Mestast(glassid, 1001, cage.getId(), 1,"MESID1",1); |
| | | //任务发送字 |
| | | |
| | | }else{ |
| | | //判断玻璃是否进入大片笼 |
| | |
| | | cage=albaniaMapper.SelectNewCell(3,5); |
| | | }else{ |
| | | cage=albaniaMapper.SelectNewCell(0,5); |
| | | //发送plc任务 |
| | | } |
| | | //当返回的格子号为空时,返回400笼子已满 |
| | | if(cage!=null){ |
| | | albaniaMapper.AddCage(cage.getId(), glassid, cage.getGlassWidth(), cage.getGlassHeight(), cage.getGlassWidthMm(), cage.getGlassHeightMm(), 1, cage.getGlasstype(), 0); |
| | | albaniaMapper.AddCage(cage.getId(), glassid,width, height, cage.getGlassWidthMm(), cage.getGlassHeightMm(), 1, cage.getGlasstype(), 0); |
| | | Mestast(glassid,1001,cage.getId(),1,"MESID1",1); |
| | | albaniaMapper.UpdateStorage(cage.getGlassWidth(),cage.getGlassHeight(),cage.getId()); |
| | | //发送plc任务 |
| | | |
| | | albaniaMapper.UpdateStorage(width,height,cage.getId()); |
| | | albaniaMapper.UpdateQueueState(glassid); |
| | | }else{ |
| | | return(400); |
| | | } |
| | |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//出片任务启动 |
| | | return (200);//结束 |
| | | } |
| | | |
| | | //发送配片数据 |
| | | Mestast(glass.getGlassId(), glass.getId(),line, 0,"MESID"+i,i); |
| | | Mestast(glass.getGlassId(), glass.getId(),40, 0,"MESID"+i,i); |
| | | albaniaMapper.AddFinishNumber(glassmate.getFlowcard(), glassmate.getMateid(), glassmate.getTier()); |
| | | albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid(), glassmate.getGlasstype(),glass.getFlowcard(),glassmate.getMateid(),glassmate.getTier()); |
| | | if(glassmate.getTier()==glassmate.getId()){//当配片数量等于成品小片总片数时 |