Merge branch 'master' of http://10.153.19.25:10101/r/Albania_Mes
# Conflicts:
# springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
# springboot-vue3/src/main/java/com/example/springboot/entity/FlowCard.java
# springboot-vue3/src/main/java/com/example/springboot/entity/StorageCage.java
# springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java
# springboot-vue3/src/main/java/com/example/springboot/entity/flowcard.java
| | |
| | | |
| | | // 单例实例 |
| | | private static PLCAutoMes instance; |
| | | private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.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(); |
| | | // 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(PlcMes); |
| | | public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead); |
| | | public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe); |
| | | |
| | | // 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"); |
| | |
| | | |
| | | // System.out.println(jsonFilePath); |
| | | |
| | | readAndUpdateWordValues(PlcReadObject); |
| | | //readAndUpdateWordValues(PlcReadObject); |
| | | readAndUpdateWordValues(PlcMesObject); |
| | | readAndUpdateWordValues(PlcframeObject); |
| | | //readAndUpdateWordValues(PlcframeObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | |
| | | addresses2.add("FeedID"); |
| | | addresses2.add("FeedCarStatus"); |
| | | |
| | | System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | //System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.SpianService; |
| | | import com.example.springboot.service.SpianServiceNew; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | import com.example.springboot.mapper.AlbaniaMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | | public class PlcHoldNew extends Thread { |
| | |
| | | |
| | | @Autowired |
| | | private JdbcConnections jdbcConnections; |
| | | private SpianMapper spianMapper; |
| | | private SpianService spianService; |
| | | private AlbaniaMapper albaniaMapper; |
| | | private SpianServiceNew spianService; |
| | | int aaa; |
| | | |
| | | @Override |
| | |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | // if (S7control.getinstance().CheckConnected() == false) { |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | |
| | | //读取DB105区文件 |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class); |
| | | albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class); |
| | | spianService.selectAll(albaniaMapper.SelectGlass()); |
| | | //读取DB14区文件 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //读106 |
| | | PlcParameterObject plcread=PLCAutoMes.PlcReadObject; |
| | | //读103 |
| | | PlcParameterObject plcstate=PLCAutoMes.plcStateObject; |
| | | String OutRequest=plcread.getPlcParameter("OutRequest").getValue();//出片请求 |
| | | String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();//出片启动 |
| | | |
| | | |
| | | |
| | | //S7control.getinstance().WriteWord( plcmes.getPlcParameter("1231").getAddress(plcmes.getPlcParameter("1231").getAddressIndex()), (short) 0); |
| | | // 出片任务 |
| | | |
| | | if (OutActivate.equals("1") == false&&OutRequest.equals("1")==true) { |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 0);// 出片任务启动改为0 |
| | | String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//出片请求一线 |
| | | String ExportToMES2=plcmes.getPlcParameter("ExportToMES2").getValue();//出片请求二线 |
| | | String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//进片请求 |
| | | String B01State=plcmes.getPlcParameter("B01State").getValue();//运送车请求 |
| | | String TastState=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//任务完成 |
| | | |
| | | |
| | | //一号线请求 |
| | | if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | spianService.selectout(1); |
| | | } |
| | | String FeedRequest=plcread.getPlcParameter("FeedRequest").getValue();// 进片请求字 |
| | | String AddActivate=plcmes.getPlcParameter("AddActivate").getValue();// 进片启动 |
| | | if (FeedRequest.equals("1") == false&&AddActivate.equals("1")==true) { |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);//进片任务启动改为0 |
| | | } |
| | | |
| | | if (OutActivate.equals("1") == true) { |
| | | // 判断当前是否有未执行的任务 |
| | | int outnum = spianMapper.SelectOutSliceshu();//是否有正在出片的任务 |
| | | int cageoutsum = spianMapper.Selectcageout(3);//笼子内是否还有在出片的玻璃 |
| | | // 当没有任务执行并且出片车空闲时 |
| | | if (outnum == 0 && Plchome.isAllowQueue == true && cageoutsum == 0) { |
| | | // 判断铝框出片队列表是否有待出片的玻璃 |
| | | String outglassid = spianMapper.SelectOutSlice(); |
| | | // 当有待出片的玻璃时 |
| | | if (outglassid != null) { |
| | | // 获取该玻璃是否被禁用 |
| | | int glassdisabled = spianMapper.SelectCageGlassState(outglassid); |
| | | // 未禁用下发任务 |
| | | if (glassdisabled == 0) { |
| | | spianService.selectout2(outglassid); |
| | | Plchome.isQueueWarning = false; |
| | | } else { // 禁用更改状态弹出提示 |
| | | Plchome.isQueueWarning = true; |
| | | } |
| | | //二线号请求时 |
| | | if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | spianService.selectout(2); |
| | | } |
| | | //进片请求时 |
| | | if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){ |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | |
| | | spianService.selectAll(albaniaMapper.SelectGlass()); |
| | | } |
| | | |
| | | |
| | | //任务完成时 |
| | | if(TastState.equals("1")==true){ |
| | | |
| | | //完成确认字 |
| | | for(int i=1;i<7;i++){ |
| | | String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//依次获取任务类型 |
| | | String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//依次获取任务类型 |
| | | if(Tastover.equals("1")){ |
| | | |
| | | //调用完成任务 Glassid |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//完成确认字 |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | ///////////// 进片任务 |
| | | |
| | | String B01backs = plcread.getPlcParameter("B01CompleteTheReport").getValue();// b01汇报 |
| | | String B02backs = plcread.getPlcParameter("B02CompleteTheReport").getValue();// b02汇报 |
| | | |
| | | String B01glassid = plcstate.getPlcParameter("B01ID1").getValue();// BO1的玻璃id |
| | | String B02glassid = plcstate.getPlcParameter("B02ID1").getValue();// B02的玻璃id |
| | | |
| | | // 当进片小车完成任务时 |
| | | if (B01backs.equals("1") == true) { |
| | | // 判断是否汇报正确的id |
| | | int HB = spianMapper.SelectHB(B01glassid.toString()); |
| | | if (HB > 0) { |
| | | // 恢复B01小车应答改为1 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1); |
| | | String yingda =plcmes.getPlcParameter("B01report").getValue();// b01汇报 |
| | | if (yingda.equals("1")) { |
| | | spianService.overtask(B01glassid.toString());// 完成任务 |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | // 恢复B01小车应答改为0 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 0); |
| | | } |
| | | |
| | | // 当出片小车完成任务时 |
| | | if (B02backs.equals("1") == true) { |
| | | // 判断是否汇报正确的id |
| | | int HB = spianMapper.SelectHB(B02glassid); |
| | | if (HB > 0) { |
| | | // 恢复B02小车应答改为1 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 1); |
| | | String yingda =plcmes.getPlcParameter("B01report").getValue();// b02应答 |
| | | if (yingda.equals("1") == true) { |
| | | spianService.overtask(B02glassid);// 完成任务 |
| | | } |
| | | } |
| | | }else{ |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 0); |
| | | } |
| | | |
| | | |
| | | // 获取DO1数据 |
| | | String Do1ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清 |
| | | // 获取DO2数据 |
| | | String Do2ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清 |
| | | |
| | | |
| | | int questate = spianMapper.Selectquecount(Do1ID.toString());// 判断扫码位是否有玻璃已确认 |
| | | // queueid1.toString().isEmpty() |
| | | north_glass_buffer1 glass1 = spianMapper.selectGlass(Do1ID);// D01的玻璃信息 |
| | | north_glass_buffer1 glass2 = spianMapper.selectGlass(Do2ID);// D02玻璃信息 |
| | | // 当扫码位玻璃id为空时 宽度为0 |
| | | if (Do1ID != null && questate == 0) { |
| | | // 写入D01的数据到上片队列表 |
| | | if (glass1 == null) { // 当没有值时传空 |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1); |
| | | } else { |
| | | spianMapper.Updatequeue(Do1ID.toString(), glass1.getordernumber(), glass1.getlistnumber(), |
| | | glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(), |
| | | glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (Do2ID != null) { |
| | | // 写入D02的数据到上片队列表 |
| | | if (glass2 == null) { |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2); |
| | | } else { |
| | | spianMapper.Updatequeue(Do2ID.toString(), glass2.getordernumber(), glass2.getlistnumber(), |
| | | glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(), |
| | | glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2); |
| | | spianMapper.overqueue2(Do2ID.toString(), 0, 1);// 更改扫码位任务表的状态为0 |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);// 关闭任务启动 |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | | |
| | |
| | | import java.util.List; |
| | | import com.example.springboot.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import com.example.springboot.entity.Flowcard; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.MeasureSetting; |
| | | import com.example.springboot.entity.Out_slice; |
| | | import com.example.springboot.entity.Queue; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.StorageTask; |
| | | import com.example.springboot.entity.alarmmg; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.HomeMapper; |
| | | import com.example.springboot.mapper.GlassInfoMapper; |
| | | import com.example.springboot.mapper.MeasureSettingMapper; |
| | | import com.example.springboot.mapper.QueueMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | | public class Plchome extends Thread { |
| | | |
| | | @Autowired |
| | | private HomeMapper homeMapper; |
| | | @Autowired |
| | | private HomeService HomeService; |
| | | private QueueMapper QueueMapper; |
| | | private GlassInfoMapper GlassInfoMapper; |
| | | private MeasureSettingMapper MeasureSettingMapper; |
| | | private OutSliceServive outSliceServive; |
| | | private SpianMapper spianMapper; |
| | | private SpianService spianService; |
| | | |
| | | // 出片队列是否允许出片 |
| | | public static Boolean isAllowQueue = true; |
| | | public static Boolean isAllowReordering = true; |
| | |
| | | try { |
| | | Thread.sleep(1000); |
| | | // 注入mapper |
| | | HomeService = WebSocketServer.applicationContext.getBean(HomeService.class); |
| | | QueueMapper = WebSocketServer.applicationContext.getBean(QueueMapper.class); |
| | | homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | |
| | | jsonObject.append("alarmmg", alarmmg); |
| | | |
| | | |
| | | |
| | | // 获取出片队列信息 |
| | | List<Out_slice> listoutslice = outSliceServive.SelectProductionqueue(); |
| | | jsonObject.append("listoutslice", listoutslice); |
| | |
| | | // 查询当前铝框信息 |
| | | Out_slice CurrentFrame = outSliceServive.SelectCurrentFrame(); |
| | | jsonObject.append("CurrentFrame", CurrentFrame); |
| | | |
| | | |
| | | //读取DB105区文件 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | |
| | | //String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//出片请求一线 |
| | | //double width=plcmes.getPlcParameter("Height").getValue();//出片请求一线 |
| | | //double height=plcmes.getPlcParameter("width").getValue();//出片请求一线 |
| | | // 获取测量的长,宽 |
| | | String PlcRequest = "1"; |
| | | double width = 402; |
| | | double height = 402; |
| | | |
| | | //获取匹配设置 |
| | | if ("1".equals(PlcRequest)) { |
| | | List<GlassInfo> Result=HomeService.NormalGlassInfo(width, height, "1"); |
| | | if(Result.size()==1){ |
| | | //匹配成功 就一种类型 添加数据 |
| | | GlassInfo GlassInfo=Result.get(0); |
| | | QueueMapper.insert(GlassInfo.getGlassid(),width,height,1); |
| | | System.out.println("匹配成功"); |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("GaToMES").getAddress(), (short) 1); |
| | | System.out.println(GlassInfo.getGlassid()); |
| | | }else if(Result.size()>1){ |
| | | //匹配失败 匹配到多条符合的数据 添加数据 |
| | | QueueMapper.insert(null,width,height,2); |
| | | System.out.println("匹配失败"); |
| | | } |
| | | else{ |
| | | //匹配失败 未找到符合的数据 添加数据 |
| | | QueueMapper.insert(null,width,height,3); |
| | | System.out.println("未找到符合的数据"); |
| | | } |
| | | |
| | | } |
| | | // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16)); |
| | | // String J01id = new String( S7controlLK.getinstance().ReadByte("DB17.22",14)); |
| | | |
| | | |
| | | //查询理片笼信息 |
| | | List<StorageCage> StorageCageInfo = storageCageService.SelectStorageCageInfo(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private int getIndexFromAddress(String address) { |
| | |
| | | System.out.println("启动完成"); |
| | | |
| | | // new PlcHold().start(); |
| | | new PlcHoldNew().start(); |
| | | // new PLCAutoMes().start(); |
| | | |
| | | new Plchome().start(); |
| | | //new Plchome().start(); |
| | | // new PlcLayout().start(); |
| | | // new Plcalarm().start(); |
| | | |
| | |
| | | * 线路 |
| | | */ |
| | | private Integer line; |
| | | |
| | | |
| | | } |
| | |
| | | package com.example.springboot.entity; |
| | | |
| | | |
| | | //出片任务表 |
| | | |
| | | public class StorageTask{ |
| | | private Integer id;//自序 |
| | | private String taskType;//类型 |
| | |
| | | private String shelfRack;//起始位 |
| | | private String loadrack;//目标位 |
| | | private Integer count;//玻璃数量 |
| | | private Integer glasstype;//玻璃类型 |
| | | private Integer flowcard;//流程卡 |
| | | private Integer mateid;//配片id |
| | | private Integer tier;//片序 |
| | | |
| | | private StorageCage storageCage; |
| | | |
| | | private StorageCage storageCage; |
| | | public void setstorageCage(StorageCage storageCage) { |
| | | this.storageCage = storageCage; |
| | | } |
| | |
| | | this.loadrack = loadrack; |
| | | } |
| | | |
| | | |
| | | public Integer getGlasstype() { |
| | | return glasstype; |
| | | } |
| | | |
| | | public void setGlasstype(Integer glasstype) { |
| | | this.glasstype = glasstype; |
| | | } |
| | | public Integer getFlowcard() { |
| | | return flowcard; |
| | | } |
| | | |
| | | public void setFlowcard(Integer flowcard) { |
| | | this.flowcard = flowcard; |
| | | } public Integer getMateid() { |
| | | return mateid; |
| | | } |
| | | |
| | | public void setMateid(Integer mateid) { |
| | | this.mateid = mateid; |
| | | } |
| | | public Integer geTier() { |
| | | return tier; |
| | | } |
| | | |
| | | public void setTier(Integer tier) { |
| | | this.tier = tier; |
| | | } |
| | | |
| | | } |
| | |
| | | public void setRatio(int ratio) { |
| | | this.ratio = ratio; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取地址 |
| | |
| | | |
| | | return addressIndex; |
| | | } |
| | | public String getAddress() { |
| | | return getAddress(this.addressIndex); |
| | | } |
| | | } |
| | |
| | | package com.example.springboot.mapper; |
| | | import org.apache.ibatis.annotations.Insert; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface AlbaniaMapper { |
| | | // 获取判断该格子是否需要把外片推入内片位置 |
| | | @Select("select state from storage_cage where cage=#{cage} and cell=#{cell} and tier=1;") |
| | | int selectcell(int cage, int cell); |
| | | // 判断该笼子是否有合适宽度空格 |
| | | @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and disabled=0 and width>=#{width} ORDER BY cell asc,tier asc LIMIT 1") |
| | | StorageCage selectCage1(int cage1, int cell, double width); |
| | | |
| | | // 判断笼子内玻璃数 |
| | | @Select("select COUNT(tier)as tier from storage_cage where cage=#{cage} and cell=#{cell} and state!=0 and state!=3;") |
| | | int selectsum(int cage, int cell); |
| | | |
| | | // 完成出片中的玻璃状态 |
| | | @Update("update storage_cage set state=#{state} where glass_id=#{glassid} and state=3;") |
| | | void UpdateCageOver(String glassid, int state); |
| | | // 完成进片中的玻璃状态 |
| | | @Update("update storage_cage set state=#{state} where glass_id=#{glassid} and state=2;") |
| | | void UpdateCageadd(String glassid, int state); |
| | | //查询是否有该类型的任务还未完成 |
| | | // 判断出片为1时,是否可直接出片 |
| | | @Select("select COUNT(state) from storage_cage where state=#{state}") |
| | | int SelectCageState(int state); |
| | | // 获取玻璃信息 |
| | | @Select("select *,ordernumber ,glasslength_mm as glasslengthmm,glassheight_mm as glassheightmm,barcode,listnumber,boxnumber,glasslength,glassheight,FrameBarcode from north_glass_buffer1 where barcode=#{glassid}") |
| | | north_glass_buffer1 selectGlass(String glassid); |
| | | //判断笼内是否有合适的类型空格 |
| | | @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths} and state=0 order by id limit 1") |
| | | int SelectCage(int glasstype,int width,int widths); |
| | | @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths} and state=0 order by id limit 1") |
| | | int SelectCage(int glasstype,Double width,int widths); |
| | | //判断笼内没有玻璃的空格 |
| | | @Select("select id from storage_cage where state=0 and number=0 order by id limit 1") |
| | | int SelectNewCell(); |
| | | @Select("select id from storage_cage where number=0 and cage>#{cage} and cage<#{cage2} order by id limit 1") |
| | | int SelectNewCell(int cage,int cage2); |
| | | //增加玻璃数 |
| | | @Update("update storage_cage set number=number+1,width=width-glasswidth where id=#{id}") |
| | | void UpdateCageNumberAdd(int id); |
| | | //减少玻璃数 |
| | | @Update("update storage_cage set number=number-1,width=width+glasswidth where id=#{id}") |
| | | void UpdateCageNumberOut(int id); |
| | | //增加任务记录 |
| | | @Insert("INSERT INTO `albania`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time,glass_id,glasstype,flowcard,mateid,tier) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now(),#{glassid},#{glasstype},#{flowcard},#{mateid},#{tier});") |
| | | void Inserttask(int tasktype, int taskstate, int shelfrack, int loadrack, String glassid, int glasstype,String flowcard,int mateid,int tier); |
| | | //新增一条笼子数据 |
| | | @Update("UPDATE `albania`.`storage_cage` SET `glass_id` =#{glassid}, `width` =width-#{glasswidth}, `glasswidth` =#{glasswidth}, `glassheight` =#{glassheight}, `glasswidthmm` =#{glasswidthmm}, `glassheightmm` = #{glassheightmm}, `state` = #{state}, `glasstype` = #{glasstype}, `number` = #{number} WHERE `id` =#{id};") |
| | | void AddCage(int id,String glassid,Double glasswidth,Double glassheight,Double glasswidthmm,Double glassheightmm,int state,int glasstype,int number); |
| | | //获取进片数据 |
| | | @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=0 limit 1") |
| | | GlassInfo SelectGlass(); |
| | | //一号线查询任务 |
| | | @Select("select * from v_cagerelease1 where mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid);") |
| | | GlassInfo SelectOutGlass1(); |
| | | //二号线查询任务 |
| | | @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 from (select Gfd.flowcard,Ggf.glasstype,Ggf.number,Ggf.mateid,Ggf.tier,Ggf.finishnumber,Gfd.starttime,Gfd.totaltier 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") |
| | | StorageCage SelectCageGlass(int glasstype); |
| | | //发送出片后增加已发数量 |
| | | @Update("update glassinfo set finishnumber=finishnumber+1 where flowcard=#{flowcard} and mateid=#{mateid} and tier=#{tier};") |
| | | void AddFinishNumber(String flowcard,int mateid,int tier); |
| | | |
| | | |
| | | } |
| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.MeasureSetting; |
| | | // import com.example.springboot.mapper.GlassInfoMapper; |
| | | // import com.example.springboot.mapper.MeasureSettingMapper; |
| | | // import com.example.springboot.mapper.QueueMapper; |
| | | |
| | | @Service |
| | | public class HomeService { |
| | | |
| | | |
| | | // @Autowired |
| | | // MeasureSettingMapper MeasureSettingMapper; |
| | | // @Autowired |
| | | // GlassInfoMapper GlassInfoMapper; |
| | | // @Autowired |
| | | // QueueMapper QueueMapper; |
| | | |
| | | // // 匹配玻璃 宽,高,线路 |
| | | // public List<GlassInfo> NormalGlassInfo(double width, double height, String line) { |
| | | // // |
| | | // List<GlassInfo> Results=new ArrayList<GlassInfo>(); |
| | | // // 获取匹配设置 |
| | | // MeasureSetting MeasureSetting = MeasureSettingMapper.SelectMeasureSetting(line); |
| | | // if (height > 0 && width > 0 && MeasureSetting != null) { |
| | | // // 有效参数 请求=1 长/宽>0 |
| | | // double maxheight = height + MeasureSetting.getErrorHeight(); |
| | | // double minheight = height - MeasureSetting.getErrorHeight(); |
| | | // double maxwidth = width + MeasureSetting.getErrorWidth(); |
| | | // double minwidth = width - MeasureSetting.getErrorWidth(); |
| | | // // 查询当前测量数据 |
| | | // List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight); |
| | | // List types = new ArrayList<>(); |
| | | // for (int i = 0; i < GlassInfos.size(); i++) { |
| | | // Integer glasstype = GlassInfos.get(i).getGlasstype(); |
| | | // if (!types.contains(glasstype)) { |
| | | // types.add(glasstype); |
| | | // Results.add(GlassInfos.get(i)); |
| | | // } |
| | | // } |
| | | // } |
| | | // return Results; |
| | | // } |
| | | } |
| | |
| | | ids = cages1.getId();// 数据库ID |
| | | tiers = cages1.getTier();// 内外片 |
| | | cells = cages1.getCell();// 格子号 |
| | | prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | //prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | width = cages1.getWidth();// 格子剩余宽度 |
| | | widths = glasslist.getglasslengthmm(); |
| | | |
| | | // 执行进片 |
| | | datas.add((short) 1000);// 起始位置 |
| | | datas.add((short) prcid);// 目标位置 |
| | | datas.add((short) 1);// 目标位置 |
| | | datas.add((short) widths);// 进片玻璃宽 |
| | | datas.add((short) prctier); // 玻璃数 |
| | | datas.add((short) 1);// 任务启动 |
| | |
| | | int cage = cageout.getCage(); // 储存出片位置,笼子格子几号玻璃 |
| | | int cell = cageout.getCell();// 出片格号 |
| | | int tier = cageout.getTier();// 出片内外片 |
| | | int prcid = cageout.getPrcId();// prcid |
| | | //int prcid = cageout.getPrcId();// prcid |
| | | int prcid2; |
| | | int ids; |
| | | int cages; |
| | |
| | | int state = spianMapper.selectGlassState(cage, cell);// 获取格子数量 |
| | | // 判断玻璃可直接出片时 |
| | | // 修改数据库笼子表(出片) |
| | | datas.add((short) prcid); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1000); |
| | | datas.add((short) state); |
| | | datas.add((short) 1); |
| | |
| | | // 判断内片是否需要调拨 |
| | | if (state == 1) { |
| | | // spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3); |
| | | datas.add((short) prcid); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1000); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | |
| | | return (300); |
| | | } |
| | | // 获取调拨位置进行调拨 |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位PRCID |
| | | //prcid2 = cagecell.getPrcId();// 调拨目标位PRCID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages = cagecell.getCage();// 调拨目标位笼子 |
| | | cells = cagecell.getCell();// 调拨目标位格子 |
| | | |
| | | // 填入调拨数据 |
| | | datas.add((short) prcid);// 调拨外片起始位置 |
| | | datas.add((short) prcid2); |
| | | datas.add((short) 1);// 调拨外片起始位置 |
| | | datas.add((short) 1); |
| | | datas.add((short) 2); |
| | | datas.add((short) 1); |
| | | // 更换玻璃的笼子 |
| | |
| | | return (300); |
| | | } |
| | | // 获取调拨位置进行调拨 |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位prcID |
| | | //prcid2 = cagecell.getPrcId();// 调拨目标位prcID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages = cagecell.getCage();// 调拨目标位笼子 |
| | | cells = cagecell.getCell();// 调拨目标位格子 |
| | | // 填入调拨数据 |
| | | datas.add((short) prcid); |
| | | datas.add((short) prcid2); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | | datas.add((short) 2); |
| | | datas.add((short) 1); |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | |
| | | package com.example.springboot.service; |
| | | |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.example.springboot.component.PLCAutoMes; |
| | | import com.example.springboot.component.S7control; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | import com.example.springboot.mapper.AlbaniaMapper; |
| | | import com.google.common.primitives.Bytes; |
| | | |
| | | |
| | | @Service |
| | | public class SpianServiceNew { |
| | | @Autowired |
| | | private SpianMapper spianMapper; |
| | | |
| | | // @GetMapping("/all") |
| | | public Short selectAll(String glassid) { |
| | | //读取DB105区文件 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //读106 |
| | | PlcParameterObject plcread=PLCAutoMes.PlcReadObject; |
| | | int cage1 = 0; |
| | | int cells; |
| | | int ids; |
| | | int prcid; |
| | | int tiers; |
| | | int prctier; |
| | | double width; |
| | | double minwidth = 0; |
| | | private AlbaniaMapper albaniaMapper; |
| | | //读取DB105区文件 |
| | | private PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | public Short selectAll(GlassInfo glassInfo) { |
| | | //定义初始字段 |
| | | int cageid; |
| | | String glassid=glassInfo.getGlassid(); |
| | | Double width=glassInfo.getWidth(); |
| | | //int mateid=glassInfo.getMateid(); |
| | | String flowcard=glassInfo.getFlowcard(); |
| | | int glasstype=glassInfo.getGlasstype(); |
| | | |
| | | |
| | | |
| | | north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数 |
| | | // 如果没有此id时 |
| | | if (glasslist == null) { |
| | | return (300); |
| | | //判断是否有同类型的 |
| | | cageid=albaniaMapper.SelectCage(glasstype,width, 50); |
| | | //如果有同类型时直接增加 |
| | | if(cageid!=Integer.MIN_VALUE){ |
| | | //发送plc任务 |
| | | //Mestast(glassid,1001,cageid,1); |
| | | |
| | | }else{ |
| | | //判断玻璃是否进入大片笼 |
| | | if(glassInfo.getThickness()>=15){ |
| | | cageid=albaniaMapper.SelectNewCell(3,5); |
| | | }else{ |
| | | cageid=albaniaMapper.SelectNewCell(3,5); |
| | | //发送plc任务 |
| | | } |
| | | |
| | | double widths = glasslist.getglasslengthmm(); |
| | | String orderids = glasslist.getordernumber(); |
| | | String FrameBarcode = glasslist.getFrameBarcode(); |
| | | // 获取铝框相关度最高的笼子排序 |
| | | List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode, widths, 400); |
| | | // 判断铝框指定空格是否需要间隔空间 |
| | | if (storageCage.size() == 0) { |
| | | storageCage = spianMapper.selectAll(orderids, FrameBarcode); |
| | | } |
| | | if (storageCage == null) { |
| | | return (400); |
| | | } |
| | | for (StorageCage storageCage2 : storageCage) { |
| | | // 保存订单优先顺序笼子号 |
| | | cage1 = storageCage2.getCage(); |
| | | // 判断该笼子号相邻最大的空格数 |
| | | int cages = spianMapper.selectCage(cage1); |
| | | |
| | | // 如果相邻笼子没有空格,或者有正在执行的出片任务时返回400 |
| | | if (cages == 0) { |
| | | return (400); |
| | | } |
| | | StorageCage cages1; |
| | | // 判断是否是第二片需要加间隔物 |
| | | prctier = spianMapper.selectsum(cage1, storageCage2.getCell());// 传给prc的格子内玻璃数 |
| | | if (prctier > 0) { |
| | | cages1 = spianMapper.selectCage1(cage1, storageCage2.getCell(), widths + 400); |
| | | } else { |
| | | cages1 = spianMapper.selectCage1(cage1, storageCage2.getCell(), widths); |
| | | } |
| | | // 判断选中笼子是否有合适宽度空格 |
| | | // 有合适空格时进片 |
| | | if (cages1 != null && cages >= 1 && storageCage2.getDisabled() == 0) { |
| | | ids = cages1.getId();// 数据库ID |
| | | tiers = cages1.getTier();// 内外片 |
| | | cells = cages1.getCell();// 格子号 |
| | | prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | width = cages1.getWidth();// 格子剩余宽度 |
| | | widths = glasslist.getglasslengthmm(); |
| | | |
| | | // 执行进片 |
| | | |
| | | // 获取该格子内是否有玻璃 |
| | | int cellint = spianMapper.selectcell(cage1, cells); |
| | | if (cellint == 1) { |
| | | // 将外片玻璃的数据更新到内片 |
| | | spianMapper.UpdateDBCage(ids, cage1, cells, 1); |
| | | // 将新入的玻璃存入外片 |
| | | spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids - 1, 2); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度 |
| | | } else { |
| | | // 数据库修改笼子表新增一条玻璃 |
| | | spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids, 2); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度 |
| | | } |
| | | // 进片车起始位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("AddStart").getAddressIndex()), (short) 1000); |
| | | // 进片车目标位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Addgoal").getAddressIndex()), (short) prcid); |
| | | // 进片玻璃宽 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddLength").getAddress(plcmes.getPlcParameter("AddLength").getAddressIndex()), (short) widths); |
| | | // 进片笼内已有玻璃数 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("AddCount").getAddressIndex()), (short) prctier); |
| | | // 进片车启动 1为启动 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1); |
| | | String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | int activate2 = 0; |
| | | if (activate.equals("1")) { |
| | | activate2 = 1; |
| | | }else{ |
| | | while (activate.equals("1")) { |
| | | // 出片任务发送字改为1 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1); |
| | | activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | } |
| | | } |
| | | outmesid(glassid, "FeedID");//派发id |
| | | spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier,activate2);// 新增任务 |
| | | return (200); |
| | | |
| | | } |
| | | |
| | | } |
| | | return (400); |
| | | |
| | | } |
| | | |
| | | public Short selectout2(String glassid) { |
| | | //读取DB105区文件 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | //读106 |
| | | PlcParameterObject plcread=PLCAutoMes.PlcReadObject; |
| | | |
| | | char[] a = glassid.toCharArray(); |
| | | List<Short> datas = new ArrayList<>(); |
| | | // 获取优先出片的位置 |
| | | StorageCage cageout = spianMapper.selectOut2(glassid); |
| | | if (cageout == null) { |
| | | return (300); |
| | | } |
| | | |
| | | int cage = cageout.getCage(); // 储存出片位置,笼子格子几号玻璃 |
| | | int cell = cageout.getCell();// 出片格号 |
| | | int tier = cageout.getTier();// 出片内外片 |
| | | int prcid = cageout.getPrcId();// prcid |
| | | int prcid2; |
| | | int ids; |
| | | int cages; |
| | | int cells; |
| | | double glasswidth = cageout.getGlassWidth(); |
| | | int state = spianMapper.selectGlassState(cage, cell);// 获取格子数量 |
| | | // 判断玻璃内外片 |
| | | if (tier == 2) { |
| | | //当返回的格子号为空时,返回400笼子已满 |
| | | if(cageid!=Integer.MIN_VALUE){ |
| | | Mestast(glassid,1001,cageid,1); |
| | | //发送plc任务 |
| | | |
| | | // 判断玻璃可直接出片时 |
| | | spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCageState(glassid.toString(), 3);// 更改笼子表的玻璃状态 |
| | | spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state, 3);// 新增任务 |
| | | |
| | | } else { |
| | | // 获取格子的玻璃数量 |
| | | |
| | | // 判断内片是否需要调拨 |
| | | if (state == 1) { |
| | | spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态 |
| | | spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1,3);// 新增任务 |
| | | |
| | | |
| | | } else { |
| | | // 玻璃需要调拨时,判断属于哪个半区的笼子 |
| | | if (cage < 6) { |
| | | StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6, cell); |
| | | if (cagecell == null) { |
| | | return (300); |
| | | } |
| | | // 获取调拨位置进行调拨 |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位PRCID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages = cagecell.getCage();// 调拨目标位笼子 |
| | | cells = cagecell.getCell();// 调拨目标位格子 |
| | | // 更换玻璃的笼子 |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态 |
| | | spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2, 3);// 新增调度任务 |
| | | |
| | | } else {// 笼子号大于5时 |
| | | StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11, cell); |
| | | if (cagecell == null) { |
| | | return (300); |
| | | } |
| | | // 获取调拨位置进行调拨 |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位prcID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages = cagecell.getCage();// 调拨目标位笼子 |
| | | cells = cagecell.getCell();// 调拨目标位格子 |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态 |
| | | spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2, 3);// 新增调度任务 |
| | | spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | |
| | | |
| | | } |
| | | //发送plc任务 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("AddStart").getAddressIndex()), (short) prcid); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Addgoal").getAddressIndex()), (short) prcid2); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("AddCount").getAddressIndex()), (short) state); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1); |
| | | String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | int activate2 = 0; |
| | | if (activate.equals("1")) { |
| | | activate2 = 1; |
| | | }else{ |
| | | while (activate.equals("1")) { |
| | | // 出片任务发送字改为1 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1); |
| | | activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | } |
| | | } |
| | | outmesid(glassid, "ReleaseID");//派发id |
| | | //发送完倒片结束 |
| | | return (200); // 结束 |
| | | } |
| | | }else{ |
| | | return(400); |
| | | } |
| | | // 出片车起始位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("OutStart").getAddressIndex()), (short) prcid); |
| | | // 出片车目标位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Outgoal").getAddressIndex()), (short) 1000); |
| | | // 出片笼内已有玻璃数 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("OutCount").getAddressIndex()), (short) state); |
| | | // 出片车启动 1为启动 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("OutActivate").getAddressIndex()), (short) 1); |
| | | String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | int activate2 = 0; |
| | | if (activate.equals("1")) { |
| | | activate2 = 1; |
| | | }else{ |
| | | while (activate.equals("1")) { |
| | | // 出片任务发送字改为1 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1); |
| | | |
| | | activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入 |
| | | } |
| | | } |
| | | outmesid(glassid, "ReleaseID");//派发id |
| | | //直接出片结束 |
| | | } |
| | | //增加任务记录 |
| | | albaniaMapper.Inserttask(0, 0, 1001, cageid, glassid,glasstype, flowcard,0,0); |
| | | return(200); |
| | | |
| | | } |
| | | |
| | | //出片 |
| | | public Short selectout(int line) { |
| | | int mateid; |
| | | int glasstype; |
| | | int tier; |
| | | int sumid; |
| | | String flowcard; |
| | | GlassInfo glassmate=new GlassInfo(); |
| | | |
| | | for(int i=1;i<=7;i++){ |
| | | glassmate= albaniaMapper.SelectOutGlass(line); |
| | | mateid=glassmate.getMateid(); |
| | | glasstype=glassmate.getGlasstype(); |
| | | tier=glassmate.getTier(); |
| | | sumid=glassmate.getId(); |
| | | flowcard=glassmate.getFlowcard(); |
| | | |
| | | StorageCage glass= albaniaMapper.SelectCageGlass(glasstype); |
| | | //发送配片数据 |
| | | Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0); |
| | | albaniaMapper.AddFinishNumber(flowcard, mateid, tier); |
| | | albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid()+i, glasstype,glass.getFlowcard(),mateid,tier); |
| | | if(tier==sumid){ |
| | | //本次配片完成发送启动命令 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//出片任务启动 |
| | | return (200);//结束 |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | return(200);// 结束 |
| | | } |
| | | |
| | |
| | | } |
| | | byte[] bytes = Bytes.toArray(glassidlist); |
| | | System.out.println("outmesidbytes:" + bytes.length); |
| | | S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(plcmes.getPlcParameter(address).getAddressIndex()),bytes); |
| | | S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes); |
| | | //S7control.getinstance().WriteByte(address, bytes);// 派发出片id |
| | | |
| | | } |
| | |
| | | writedstrIdOut.append((char) iditem); |
| | | } |
| | | } |
| | | return writedstrIdOut; |
| | | return writedstrIdOut; |
| | | } |
| | | |
| | | // char数组转化成bit数组 |
| | |
| | | return listbool; |
| | | } |
| | | |
| | | // 根据玻璃id完成在进行中的任务 |
| | | public void overtask(String glassid) { |
| | | |
| | | spianMapper.UpdatetaskOut(glassid.toString());// 完成上一次 出片或者进片任务 |
| | | spianMapper.OverOutSlice(glassid.toString(), 2, 1);// 完成出片队列任务 |
| | | spianMapper.UpdataGlassCage(glassid.toString(), 0);// 清除出片格子玻璃信息 |
| | | spianMapper.UpdateCageOver(glassid.toString(), 0);// 更改笼子表出片状态 |
| | | spianMapper.UpdateCageadd(glassid.toString(), 1);// 更改笼子表进片状态 |
| | | spianMapper.UpdateAddQueue(glassid.toString());// 把进片的玻璃更新到出片队列中 |
| | | //下发理片任务 |
| | | public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC) { |
| | | outmesid(glassid, "MESID1");//下发玻璃id |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart1").getAddress(), (short) MESToPLCStart1);//起始位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget1").getAddress(), (short) MESToPLCTarget1);//目标位置 |
| | | if(MESToPLC!=0){ |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes理片任务类型 |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | { |
| | | "plcAddressBegin":"DB14.0", |
| | | "plcAddressLenght":"210", |
| | | "dataType":"word", |
| | | "parameteInfor":[ |
| | | { |
| | | "codeId": "PLCToMES", |
| | | "addressIndex":"0", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus1", |
| | | "addressIndex":"2", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus2", |
| | | "addressIndex":"4", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"m/min" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus3", |
| | | "addressIndex":"6", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus4", |
| | | "addressIndex":"8", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "IDStatus5", |
| | | "addressIndex":"10", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "IDStatus6", |
| | | "addressIndex":"12", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID1", |
| | | "addressIndex":"14", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID2", |
| | | "addressIndex":"16", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID3", |
| | | "addressIndex":"18", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID4", |
| | | "addressIndex":"20", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "StautsID5", |
| | | "addressIndex":"22", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "StautsID6", |
| | | "addressIndex":"24", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "GaToMES", |
| | | "addressIndex":"26", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "Height", |
| | | "addressIndex":"28", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "width", |
| | | "addressIndex":"30", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "ExportTOMES1", |
| | | "addressIndex":"32", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | , |
| | | { |
| | | "codeId": "ExportToMES2", |
| | | "addressIndex":"34", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESToPLC", |
| | | "addressIndex":"36", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID1", |
| | | "addressIndex":"38", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } , |
| | | { |
| | | "codeId": "MESID2", |
| | | "addressIndex":"54", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID3", |
| | | "addressIndex":"70", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID4", |
| | | "addressIndex":"86", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID5", |
| | | "addressIndex":"102", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESID6", |
| | | "addressIndex":"118", |
| | | "addressLenght":"14", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | }, |
| | | { |
| | | "codeId": "MESToPLCStart1", |
| | | "addressIndex":"134", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart2", |
| | | "addressIndex":"136", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStart3", |
| | | "addressIndex":"138", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart4", |
| | | "addressIndex":"140", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart5", |
| | | "addressIndex":"142", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | ,{ |
| | | "codeId": "MESToPLCStart6", |
| | | "addressIndex":"144", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget1", |
| | | "addressIndex":"146", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget2", |
| | | "addressIndex":"148", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget3", |
| | | "addressIndex":"150", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget4", |
| | | "addressIndex":"152", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget5", |
| | | "addressIndex":"154", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCTarget6", |
| | | "addressIndex":"156", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus1", |
| | | "addressIndex":"158", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus2", |
| | | "addressIndex":"160", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus3", |
| | | "addressIndex":"162", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus4", |
| | | "addressIndex":"164", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus5", |
| | | "addressIndex":"166", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToPLCStatus6", |
| | | "addressIndex":"168", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MESToGaStatus", |
| | | "addressIndex":"170", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01Err", |
| | | "addressIndex":"172", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02Err", |
| | | "addressIndex":"174", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Err", |
| | | "addressIndex":"176", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Err", |
| | | "addressIndex":"178", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Err", |
| | | "addressIndex":"180", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace1", |
| | | "addressIndex":"182", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace2", |
| | | "addressIndex":"184", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "ErrSpace3", |
| | | "addressIndex":"186", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01Position", |
| | | "addressIndex":"188", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01Position", |
| | | "addressIndex":"190", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02Position", |
| | | "addressIndex":"192", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "DeviceState", |
| | | "addressIndex":"194", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "AllFVRun", |
| | | "addressIndex":"196", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A01State", |
| | | "addressIndex":"198", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "A02State", |
| | | "addressIndex":"200", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "B01State", |
| | | "addressIndex":"202", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C01State", |
| | | "addressIndex":"204", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "C02State", |
| | | "addressIndex":"206", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MainControl", |
| | | "addressIndex":"208", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | ] |
| | | } |