Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
| | |
| | | |
| | | /** |
| | | * 卧式理片笼详情表玻璃状态 |
| | | * 识别后成功状态100 |
| | | * 识别后成功状态0 |
| | | * 识别后成功进笼的状态100 |
| | | * 出片任务101 |
| | | * 人工下片102 |
| | | * 出片中103 |
| | | * 拿走200 |
| | | * 破损201 |
| | | */ |
| | | public static final Integer GLASS_STATE_NEW = 0; |
| | | public static final Integer GLASS_STATE_IN = 100; |
| | | public static final Integer GLASS_STATE_OUT = 101; |
| | | public static final Integer GLASS_STATE_ARTIFICIAL = 102; |
| | | public static final Integer GLASS_STATE_OUT_ING = 103; |
| | | public static final Integer GLASS_STATE_TAKE = 200; |
| | | public static final Integer GLASS_STATE_DAMAGE = 201; |
| | | public static final List<Integer> GLASS_STATE_IN_ALL = Arrays.asList(100, 102, 103); |
| | | |
| | | /** |
| | | * 卧式理片笼详情表玻璃状态 |
| | |
| | | public List<TemperingGlassInfo> selectWaitingGlass() { |
| | | //获取等待进炉中的玻璃信息 |
| | | QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("Top 1 *").eq("state",1); |
| | | wrapper.select("Top 1 *").in("state",1,0); |
| | | TemperingGlassInfo glass=temperingMapper.selectOne(wrapper); |
| | | if(glass!=null) { |
| | | QueryWrapper<TemperingGlassInfo> glassinfo = new QueryWrapper<>(); |
| | |
| | | @PostMapping("/edgStorageCageGlass") |
| | | @ResponseBody |
| | | public Result edgStorageCageGlass(@RequestBody EdgStorageCageDetails edgStorageCageDetails,int edgStorageCageId) { |
| | | |
| | | String isSucess=edgStorageCageService.updateEdgStorageCageDetails(edgStorageCageId,edgStorageCageDetails)?"成功":"失败"; |
| | | return Result.build(200,"【清除/更换/绑定】"+isSucess,1); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("磨边模块汇报玻璃状态 功能:对笼内栅格玻璃进行【破损/拿走】 ") |
| | | @PostMapping("/edgReportStatus") |
| | | @ResponseBody |
| | | public Result edgReportStatus(@RequestBody Map<String, String> arguments) { |
| | | String edgStorageCageDetailsId=arguments.get("glassId"); |
| | | int controlsId=Integer.valueOf(arguments.get("controlsId")); |
| | | String isSucess=edgStorageCageDetailsService.identWorn(edgStorageCageDetailsId,controlsId)?"成功":"失败"; |
| | | /*arguments.put("line","1002"); |
| | | arguments.put("machine","卧式理片");*/ |
| | | String isSucess=edgStorageCageDetailsService.identWorn(arguments)?"成功":"失败"; |
| | | return Result.build(200,"【破损/拿走】"+isSucess,1); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 识别 破损/拿走 |
| | | * @param glassId |
| | | * @param ControlsId |
| | | * @param arguments |
| | | * @return |
| | | */ |
| | | boolean identWorn(String glassId,int ControlsId); |
| | | boolean identWorn(Map<String, String> arguments); |
| | | |
| | | /** |
| | | * 获取 切割当前版图 |
| | |
| | | */ |
| | | EdgStorageCage selectNearestEmpty(int currentSlot, boolean flag); |
| | | |
| | | |
| | | List<EdgStorageCage> selectCacheEmpty(); |
| | | /** |
| | | * 查询笼内出片顺序详情 |
| | | * @return |
| | |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCage; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper; |
| | | import com.mes.edgstoragecage.mapper.EdgStorageCageMapper; |
| | | import com.mes.edgstoragecage.service.EdgStorageCageDetailsService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.mapper.GlassInfoMapper; |
| | | import com.mes.pp.entity.OptimizeDetail; |
| | | import com.mes.pp.entity.OptimizeLayout; |
| | | import com.mes.pp.mapper.OptimizeDetailMapper; |
| | |
| | | |
| | | @Autowired |
| | | EdgStorageCageMapper edgStorageCageMapper; |
| | | @Autowired |
| | | GlassInfoMapper glassInfoMapper; |
| | | |
| | | @Autowired |
| | | TaskCacheService taskCacheService; |
| | | |
| | | @Autowired |
| | | DamageService damageService; |
| | | |
| | | |
| | | /** |
| | | * 识别 拿走:200/破损:201 |
| | | * |
| | | * @param glassId |
| | | * @param ControlsId |
| | | * @param arguments |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean identWorn(String glassId, int ControlsId) { |
| | | List<EdgStorageCageDetails> edgStorageCageDetails = baseMapper.selectList(new MPJLambdaQueryWrapper<EdgStorageCageDetails>().selectAll(EdgStorageCageDetails.class).eq(EdgStorageCageDetails::getGlassId, glassId)); |
| | | public boolean identWorn(Map<String, String> arguments) { |
| | | String glassId=arguments.get("glassId"); |
| | | int controlsId=arguments.get("controlsId").isEmpty()?0:Integer.parseInt(arguments.get("controlsId")); |
| | | int line=arguments.get("line").isEmpty()?0:Integer.parseInt(arguments.get("line")); |
| | | String machine=arguments.get("machine"); |
| | | if(controlsId==0||line==0||machine==null||glassId==null||glassId.isEmpty()){ |
| | | log.info("前端传递数据不全:{}",arguments); |
| | | return false; |
| | | } |
| | | int state; |
| | | if(controlsId==200||controlsId==201){ |
| | | state=controlsId==200?3:2; |
| | | }else if (controlsId==300||controlsId==301){ |
| | | state=controlsId==300?3:2; |
| | | }else{ |
| | | log.info("前端传递状态不合法:{}",arguments); |
| | | return false; |
| | | } |
| | | |
| | | List<GlassInfo> GlassInfos = glassInfoMapper.selectList(new MPJLambdaQueryWrapper<GlassInfo>() |
| | | .selectAll(GlassInfo.class) |
| | | .eq(GlassInfo::getGlassId, glassId)); |
| | | if (GlassInfos.size() == 1) { |
| | | Damage damage =new Damage(); |
| | | damage.setGlassId(glassId); |
| | | damage.setLine(line); |
| | | damage.setWorkingProcedure(machine); |
| | | damage.setRemark(""); |
| | | damage.setStatus(state);//201破损,200拿走 =》破损表 2破损 3 拿走 |
| | | damageService.insertDamage(damage); |
| | | }else{ |
| | | return false; |
| | | } |
| | | List<EdgStorageCageDetails> edgStorageCageDetails = baseMapper.selectList(new MPJLambdaQueryWrapper<EdgStorageCageDetails>() |
| | | .selectAll(EdgStorageCageDetails.class) |
| | | .eq(EdgStorageCageDetails::getGlassId, glassId)); |
| | | if (edgStorageCageDetails.size() == 1) { |
| | | EdgStorageCageDetails item = edgStorageCageDetails.get(0); |
| | | item.setState(ControlsId); |
| | | item.setState(controlsId); |
| | | baseMapper.update(item, new MPJLambdaWrapper<EdgStorageCageDetails>().selectAll(EdgStorageCageDetails.class).eq(EdgStorageCageDetails::getGlassId, glassId)); |
| | | return true; |
| | | } |
| | | |
| | | // Sql版本 |
| | | // List<EdgStorageCageDetails> edgStorageCageDetails = baseMapper.selectList(new QueryWrapper<EdgStorageCageDetails>().eq("glass_id", glassId)); |
| | | // if (edgStorageCageDetails.size() == 1) { |
| | |
| | | // baseMapper.update(edgStorageCageDetails.get(0), new QueryWrapper<EdgStorageCageDetails>().eq("glass_id", glassId)); |
| | | // return true; |
| | | // } |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCage; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper; |
| | | import com.mes.edgstoragecage.mapper.EdgStorageCageMapper; |
| | | import com.mes.edgstoragecage.service.EdgStorageCageDetailsService; |
| | | import com.mes.edgstoragecage.service.EdgStorageCageService; |
| | | import com.mes.uppattenusage.entity.UpPattenUsage; |
| | | import com.mes.uppattenusage.mapper.UpPattenUsageMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Service |
| | | public class EdgStorageCageServiceImpl extends MPJBaseServiceImpl<EdgStorageCageMapper, EdgStorageCage> implements EdgStorageCageService { |
| | | |
| | | @Resource |
| | | @Autowired |
| | | EdgStorageCageDetailsMapper edgStorageCageDetailsMapper; |
| | | @Resource |
| | | @Autowired |
| | | UpPattenUsageMapper upPattenUsageMapper; |
| | | |
| | | @Autowired |
| | | DamageService damageService; |
| | | |
| | | @Override |
| | | public EdgStorageCage selectNearestEmpty(int currentSlot, boolean flag) { |
| | |
| | | .eq(EdgStorageCageDetails::getSlot, EdgStorageCage::getSlot) |
| | | .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN)) |
| | | .isNull(EdgStorageCageDetails::getSlot) |
| | | .eq(EdgStorageCage::getEnableState, Const.SLOT_ON) |
| | | .last("order by abs(t.slot - " + currentSlot + ") asc limit 2") |
| | | ); |
| | | if (flag && CollectionUtil.isNotEmpty(emptyList)) { |
| | |
| | | return null; |
| | | } |
| | | return emptyList.get(0); |
| | | } |
| | | |
| | | /** |
| | | * 查询笼内空格 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EdgStorageCage> selectCacheEmpty() { |
| | | return baseMapper.selectJoinList(EdgStorageCage.class, new MPJLambdaWrapper<EdgStorageCage>() |
| | | .selectAll(EdgStorageCage.class) |
| | | .leftJoin(EdgStorageCageDetails.class, on -> on |
| | | .eq(EdgStorageCageDetails::getSlot, EdgStorageCage::getSlot) |
| | | .eq(EdgStorageCageDetails::getState, "100")) |
| | | .isNull(EdgStorageCageDetails::getSlot) |
| | | .last("order by abs(t.slot - 4) asc") |
| | | ); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (result != null) { |
| | | result.setSlot(0); |
| | | result.setState(201); |
| | | Damage damage =new Damage(); |
| | | damage.setGlassId(edgStorageCageDetails.getGlassId()); |
| | | damage.setLine(1002); |
| | | damage.setWorkingProcedure("卧式理片"); |
| | | damage.setStatus(2); |
| | | damageService.insertDamage(damage); |
| | | edgStorageCageDetailsMapper.updateById(result); |
| | | } |
| | | //添加 |
| | |
| | | @ApiOperation("识别操作: 破损/拿走 参数(ID,功能[200:拿走,201:破损])") |
| | | @PostMapping("/identControls") |
| | | @ResponseBody |
| | | public Result identControls(@RequestParam(name = "identId", required = false) String identId,@RequestParam(name = "controlsId", required = false) int controlsId) { |
| | | boolean issucess = edgStorageCageDetailsService.identWorn(identId,controlsId); |
| | | public Result identControls(@RequestBody Map<String, String> arguments) { |
| | | /* arguments.put("glassId","玻璃ID"); |
| | | arguments.put("controlsId","功能号[200拿走/201破损]");*/ |
| | | /*arguments.put("line","1001"); |
| | | arguments.put("machine","识别");*/ |
| | | boolean issucess = edgStorageCageDetailsService.identWorn(arguments); |
| | | return Result.build(200,"成功",issucess); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCage; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | |
| | | import com.mes.taskcache.entity.TaskCache; |
| | | import com.mes.taskcache.mapper.TaskCacheMapper; |
| | | import com.mes.taskcache.service.TaskCacheService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class TaskCacheServiceImpl extends ServiceImpl<TaskCacheMapper, TaskCache> implements TaskCacheService { |
| | | |
| | |
| | | |
| | | @Autowired |
| | | GlassInfoMapper glassInfoMapper; |
| | | |
| | | |
| | | /** |
| | | * 添加理片笼任务 |
| | | * @param taskCache |
| | |
| | | int serialNumber=1; |
| | | for(TaskCache taskCache1:taskCache){ |
| | | Map<String,Object> map=new HashMap<>(); |
| | | GlassInfo glassInfo=glassInfoMapper.selectOne(new MPJLambdaWrapper<GlassInfo>() |
| | | // GlassInfo glassInfo=glassInfoMapper.selectOne(new MPJLambdaWrapper<GlassInfo>() |
| | | // .selectAll(GlassInfo.class) |
| | | // .eq(GlassInfo::getGlassId,taskCache1.getGlassId())); |
| | | List<GlassInfo> glassInfos=glassInfoMapper.selectJoinList(GlassInfo.class, new MPJLambdaWrapper<GlassInfo>() |
| | | .selectAll(GlassInfo.class) |
| | | .eq(GlassInfo::getGlassId,taskCache1.getGlassId())); |
| | | if(glassInfo!=null){ |
| | | .innerJoin(EdgStorageCageDetails.class, on -> on |
| | | .eq(EdgStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(EdgStorageCageDetails::getEngineerId, GlassInfo::getEngineerId)) |
| | | .eq(GlassInfo::getGlassId,taskCache1.getGlassId()) |
| | | .eq(EdgStorageCageDetails::getState,Const.GLASS_STATE_IN) |
| | | ); |
| | | if(glassInfos.size()==1){ |
| | | GlassInfo glassInfo=glassInfos.get(0); |
| | | map.put("Line",line);//线路 2001 1线, 2002 2线 |
| | | map.put("Width",glassInfo.getWidth());//宽 |
| | | map.put("Height",glassInfo.getHeight());//高 |
| | |
| | | map.put("FilmsId",glassInfo.getFilmsid());//膜系 |
| | | map.put("SerialNumber",serialNumber);//出片顺序 |
| | | result.add(map); |
| | | }else if(glassInfos.size()>1){ |
| | | log.info("数据不符合逻辑--磨边队列glassId重复:",glassInfos); |
| | | return new ArrayList<>(); |
| | | } |
| | | serialNumber++; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.mes.pp.mapper.OptimizeDetailMapper; |
| | | import com.mes.taskcache.entity.TaskCache; |
| | | import com.mes.taskcache.mapper.TaskCacheMapper; |
| | | import com.mes.taskcache.service.TaskCacheService; |
| | | import com.mes.taskcache.service.impl.TaskCacheServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.junit.Test; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | GlassInfoService glassInfoService; |
| | | @Autowired |
| | | CacheGlassTask cacheGlassTask; |
| | | |
| | | @Autowired |
| | | TaskCacheService taskCacheService; |
| | | |
| | | @Test |
| | | public void testFindPath() { |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testidentWorn() { |
| | | Map<String, String> arguments=new HashMap<>(); |
| | | arguments.put("glassId","P24060403|3|6");//玻璃ID |
| | | arguments.put("controlsId","300"); //拿走:200/破损:201 |
| | | arguments.put("line","2001"); //线路: |
| | | arguments.put("machine","冷加工"); //设备名称: |
| | | edgStorageCageDetailsService.identWorn(arguments); |
| | | log.info("识别台【破损/拿走】:{}", 1); |
| | | } |
| | | |
| | | @Test |
| | | public void testPpOptimizeDetail() { |
| | | List<OptimizeDetail> optimizeDetail = optimizeDetailMapper.selectList(new QueryWrapper<OptimizeDetail>() |
| | | .eq("project_no", "P24032204") |
| | |
| | | log.info("出片任务:{}", Arrays.asList(edgStorageCageDetails)); |
| | | } |
| | | |
| | | @Test |
| | | public void testedgTask() { |
| | | List<Map<String,Object>> EdgTasks = taskCacheService.selectEdgInfo("2001"); |
| | | |
| | | log.info("磨边任务:{}", Arrays.asList(EdgTasks)); |
| | | } |
| | | |
| | | } |
| | |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId()) |
| | | .eq(GlassInfo::getEngineerId, item.getEngineerId())); |
| | | .eq(GlassInfo::getEngineerId, item.getEngineerId()) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence)); |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | | computeOutGlassInfo(temperingGlassInfoList, Boolean.TRUE, mesToPLCAddress); |
| | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | public void updateInGlassStateTask() { |
| | | Date startDate = new Date(); |
| | | log.info("1、大理片笼进片完成后更新大理片笼数据任务开始执行时间:{}", startDate); |
| | | //因为大理片笼和出片任务是两个库的数据,所以要分开查找 |
| | | List<Object> list = bigStorageCageDetailsService.listObjs(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .select(BigStorageCageDetails::getGlassId).eq(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW)); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | log.info("2、获取所有正在进片的玻璃信息id:{}", list); |
| | | List<String> glassIds = list.stream().map(String::valueOf).collect(Collectors.toList()); |
| | | List<Object> inSuccessGlassIdsObj = bigStorageCageFeedTaskService.listObjs(new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | | .select(BigStorageCageFeedTask::getGlassId).in(BigStorageCageFeedTask::getGlassId, glassIds) |
| | | .in(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_SLOT)); |
| | | List<String> inSuccessGlassIds = inSuccessGlassIdsObj.stream().map(String::valueOf).collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(inSuccessGlassIds)) { |
| | | log.info("3、获取进片已完成的玻璃信息id:{}", inSuccessGlassIds); |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getState, Const.GLASS_STATE_IN).in(BigStorageCageDetails::getGlassId, inSuccessGlassIds)); |
| | | log.info("4、大理片笼进片状态已完成已完成的玻璃信息id:{}", inSuccessGlassIds); |
| | | //更新理片笼玻璃尺寸 |
| | | updateSlotRemain(inSuccessGlassIds, Boolean.TRUE); |
| | | log.info("5、大理片笼进片目标格子尺寸更新完成"); |
| | | } |
| | | |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("end:大理片笼进片完成后更新大理片笼数据任务结束时间:{},共耗时:{}ms,结束任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | public void updateOutGlassStateTask() { |
| | | Date startDate = new Date(); |
| | | log.info("1、大理片笼出片完成后更新大理片笼数据任务开始执行时间:{}", startDate); |
| | |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getState, Const.GLASS_STATE_OUT).in(BigStorageCageDetails::getGlassId, outSuccessGlassIds)); |
| | | log.info("4、大理片笼出片状态已完成已完成的玻璃信息id:{}", outSuccessGlassIdsObj); |
| | | //更新理片笼玻璃尺寸 |
| | | updateSlotRemain(outSuccessGlassIds, Boolean.FALSE); |
| | | log.info("5、大理片笼进片目标格子尺寸更新完成"); |
| | | } |
| | | } |
| | | Date endDate = new Date(); |
| | |
| | | BeanUtils.copyProperties(info, cageDetails); |
| | | //2、获取目标格子信息 |
| | | BigStorageDTO bigStorageDTO = bigStorageCageDetailsService.queryTargetSlotByTempering(info); |
| | | //3、更新大理片笼表剩余宽度 |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, bigStorageDTO.getWidth() - info.getWidth() - glassGap) |
| | | .eq(BigStorageCage::getSlot, bigStorageDTO.getSlot())); |
| | | //3、更新大理片笼表剩余宽度(更新大理片笼剩余尺寸移到进笼完成后执行) |
| | | // bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, bigStorageDTO.getWidth() - info.getWidth() - glassGap) |
| | | // .eq(BigStorageCage::getSlot, bigStorageDTO.getSlot())); |
| | | //4、更新进片任务表,目标格子及状态(状态改为2 电气扫到自行处理) 遇到问题:无法批量更新,批量更新无法走指定从库 |
| | | e.setTargetSlot(bigStorageDTO.getSlot()); |
| | | // e.setTaskType(Const.BIG_STORAGE_IN_RUN); |
| | | bigStorageCageFeedTaskService.updateById(e); |
| | | |
| | | //5、将进片信息存入大理片笼详情表 |
| | | cageDetails.setSlot(bigStorageDTO.getSlot()); |
| | | cageDetails.setState(Const.GLASS_STATE_IN); |
| | | cageDetails.setState(Const.GLASS_STATE_NEW); |
| | | cageDetails.setDeviceId(bigStorageDTO.getDeviceId()); |
| | | cageDetails.setGap(glassGap); |
| | | bigStorageCageDetailsService.save(cageDetails); |
| | |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getState, Const.GLASS_STATE_OUT_ING) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | //更新笼子内格子的剩余尺寸 |
| | | updateSlotRemain(list, glassIds); |
| | | //更新笼子内格子的剩余尺寸(移至出片任务完成后) |
| | | // updateSlotRemain(list, glassIds); |
| | | |
| | | int returnData = 0; |
| | | int count = 1; |
| | |
| | | /** |
| | | * 更新笼子内格子的剩余尺寸 |
| | | * |
| | | * @param list 笼内可以出笼的玻璃信息 |
| | | * @param taskGlassIds 本次任务出去的玻璃ids |
| | | * @param <T> |
| | | * @param flag 是否进出片 true 进片 false 出片 |
| | | */ |
| | | public <T extends BigStorageCageBaseInfo> void updateSlotRemain(List<T> list, List<String> taskGlassIds) { |
| | | //获取需要出去(包括待出去的)的所有玻璃格子号 |
| | | List<Integer> slotList = list.stream().map(T::getSlot).distinct().collect(Collectors.toList()); |
| | | //获取待出去的玻璃信息(等待本次任务结束后下车出去的玻璃) |
| | | Map<Integer, Double> slotRemainMap = list.stream().filter(e -> !taskGlassIds.contains(e.getGlassId())) |
| | | .collect(Collectors.groupingBy(T::getSlot, Collectors.summingDouble(item -> item.getWidth() + glassGap))); |
| | | public void updateSlotRemain(List<String> taskGlassIds, Boolean flag) { |
| | | //按照玻璃id获取玻璃信息及玻璃的格子号 |
| | | List<BigStorageCageDetails> glassList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getGlassId, taskGlassIds)); |
| | | //获取需要出去/进笼(包括待出去的)的所有玻璃格子号 |
| | | List<Integer> slotList = glassList.stream().map(BigStorageCageDetails::getSlot).distinct().collect(Collectors.toList()); |
| | | //获取格子内所有的玻璃信息 |
| | | List<BigStorageCageDetails> inSlotGlassList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getSlot, slotList).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | //获取待进片/出去的玻璃信息 |
| | | Map<Integer, Double> slotRemainMap = null; |
| | | if (flag) { |
| | | slotRemainMap = inSlotGlassList.stream().filter(e -> taskGlassIds.contains(e.getGlassId())) |
| | | .collect(Collectors.groupingBy(BigStorageCageDetails::getSlot, Collectors.summingDouble(item -> item.getWidth() + glassGap))); |
| | | } else { |
| | | slotRemainMap = inSlotGlassList.stream().filter(e -> !taskGlassIds.contains(e.getGlassId())) |
| | | .collect(Collectors.groupingBy(BigStorageCageDetails::getSlot, Collectors.summingDouble(item -> item.getWidth() + glassGap))); |
| | | } |
| | | //格子内有玻璃的,计算为: 格子的宽度 - (给子内玻璃的尺寸+间距) |
| | | if (CollectionUtils.isNotEmpty(slotRemainMap)) { |
| | | //按照格子号更新剩余尺寸 |
| | | slotRemainMap.forEach((e, v) -> { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth - v) |
| | | .eq(BigStorageCage::getSlot, e)); |
| | | }); |
| | | } |
| | | Set<Integer> remainSlotList = slotRemainMap.keySet(); |
| | | slotList.removeAll(remainSlotList); |
| | | if (CollectionUtils.isNotEmpty(slotList)) { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth) |
| | | .in(BigStorageCage::getSlot, slotList)); |
| | | //只更新进笼完成的状态,如果进笼完成,格子内必定有玻璃,不存在出片后格子内没有玻璃的情况,所有格子尺寸重置,只能存在于出片任务 |
| | | if (!flag) { |
| | | Set<Integer> remainSlotList = slotRemainMap.keySet(); |
| | | slotList.removeAll(remainSlotList); |
| | | if (CollectionUtils.isNotEmpty(slotList)) { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth) |
| | | .in(BigStorageCage::getSlot, slotList)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public Boolean computeIsRun(int line, String glassId) { |
| | |
| | | public void plcLoadGlassTask() throws InterruptedException { |
| | | try { |
| | | //获取联机状态 |
| | | String inkageStatus =plcParameterObject.getPlcParameter("MesToPlc").getValue(); |
| | | String inkageStatus = plcParameterObject.getPlcParameter("InkageStatus").getValue(); |
| | | //获取是否有上片请求 |
| | | String loadRequest = plcParameterObject.getPlcParameter("loadRequest").getValue(); |
| | | //mes状态 |
| | | String mesToPlc = plcParameterObject.getPlcParameter("MesToPlc").getValue(); |
| | | if("1".equals(inkageStatus)&&"1".equals(loadRequest)) { |
| | | if ("1".equals(inkageStatus) && "1".equals(loadRequest)) { |
| | | //判断开始上片的工程号 |
| | | Engineering engineering = engineeringService.selectInitiate(1); |
| | | if (engineering != null) { |
| | |
| | | int workId = upwork.getWorkstationId();//工位id |
| | | double width = upwork.getPatternWidth();//宽度 |
| | | double height = upwork.getPatternHeight();//高度 |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("WorkId").getAddress(), workId); |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (long) width); |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (long) height); |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 1); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("WorkId").getAddress(), workId); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (int) width); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (int) height); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 1); |
| | | //更改上片表状态 |
| | | upPattenUsageService.updateUpPattenUsageState(upPattenUsage, workId); |
| | | |
| | |
| | | } |
| | | if ("1".equals(mesToPlc) && "0".equals(loadRequest)) { |
| | | //请求字为零时,任务字清零 |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 0); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 0); |
| | | } |
| | | //执行后休眠300毫秒 |
| | | //Thread.sleep(300); |
| | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | public void plcLoadGlassReport(){ |
| | | public void plcLoadGlassReport() { |
| | | //获取是否有汇报 |
| | | String loadStatus = plcParameterObject.getPlcParameter("PlcStatus").getValue(); |
| | | if (loadStatus != null) { |
| | |
| | | overTask(loadStatus, 0); |
| | | break; |
| | | case "0": |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 0); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 0); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadGlassHome(){ |
| | | public void loadGlassHome() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | List<UpPattenUsage> upPattenUsages = upPattenUsageService.prioritylist(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void loadGlassStatus(){ |
| | | public void loadGlassStatus() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | String inkageStatus =plcParameterObject.getPlcParameter("MesToPlc").getValue(); |
| | | String inkageStatus =plcParameterObject.getPlcParameter("InkageStatus").getValue(); |
| | | // String inkageStatus ="1"; |
| | | jsonObject.append("InkageStatus", inkageStatus); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlass"); |
| | |
| | | } |
| | | } |
| | | |
| | | public void overTask(String loadStatus, int state) { |
| | | public void overTask(String loadStatus, int state) { |
| | | |
| | | UpPattenUsage upPattenUsage = upPattenUsageService.selectOverTask(); |
| | | if (upPattenUsage != null) { |
| | |
| | | //完成上片表状态 |
| | | upPattenUsageService.updateUpPattenUsageState(upPattenUsage, state); |
| | | //判断是否是最后一块玻璃 |
| | | UpPattenUsage sequence=upPattenUsageService.selectSequence(upPattenUsage); |
| | | UpPattenUsage sequence = upPattenUsageService.selectSequence(upPattenUsage); |
| | | //如果是最后一块时完成工程任务 |
| | | optimizeProjectService.overTask(sequence,300); |
| | | optimizeProjectService.overTask(sequence, 300); |
| | | } |
| | | S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1); |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | public interface DownStorageCageDetailsMapper extends MPJBaseMapper<DownStorageCageDetails> { |
| | | |
| | | DownStorageCageDetails getGlassInfoMaxCount(); |
| | | DownStorageCageDetails getGlassInfoMaxCount(@Param(value = "workList") List<Integer> workList); |
| | | } |
| | |
| | | */ |
| | | boolean DirectConnection(GlassInfo glassInfo); |
| | | |
| | | String getGlassInfoMaxCount(String glassId); |
| | | String getGlassInfoMaxCount(String glassId, List<Integer> workList); |
| | | |
| | | /** |
| | | * @param glassId |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getGlassInfoMaxCount(String glassId) { |
| | | DownStorageCageDetails glassInfoMaxCount = baseMapper.getGlassInfoMaxCount(); |
| | | public String getGlassInfoMaxCount(String glassId, List<Integer> workList) { |
| | | DownStorageCageDetails glassInfoMaxCount = baseMapper.getGlassInfoMaxCount(workList); |
| | | return null == glassInfoMaxCount ? glassId : glassInfoMaxCount.getGlassId(); |
| | | } |
| | | |
| | |
| | | workList.addAll(Const.G06_WORK_STATION); |
| | | } |
| | | } |
| | | List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6); |
| | | List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList()); |
| | | List<DownStorageCageDetails> list = new ArrayList(); |
| | | Boolean isEmptyShelf = Boolean.FALSE; |
| | | //对笼内玻璃进行过滤,仅出符合逻辑的玻璃 |
| | |
| | | } else { |
| | | log.info("存在未绑定流程卡架子,直接获取笼内所有玻璃,且未绑定架子的玻璃信息"); |
| | | //获取禁用架子的流程号,将笼内绑定架子且架子被禁用的流程卡信息 |
| | | List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6); |
| | | List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList()); |
| | | |
| | | List<DownWorkstation> downWorkstationOffList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .and(i -> i.in(DownWorkstation::getWorkstationId, offWorkStationList).or().eq(DownWorkstation::getEnableState, Const.SLOT_OFF))); |
| | | //获取被禁用的流程卡信息 |
| | |
| | | } |
| | | } |
| | | loop: |
| | | if (tempGlassId == null) { |
| | | if (StringUtils.isBlank(tempGlassId)) { |
| | | //获取正在落架的绑定流程卡的信息(流程卡、层数、落架数量) |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE); |
| | | List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(downGlassFlowList)) { |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId); |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList); |
| | | |
| | | isBind = Boolean.TRUE; |
| | | break loop; |
| | | } |
| | |
| | | // .isNull(DownWorkstation::getFlowCardId)); |
| | | if (isEmptyShelf) { |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId); |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList); |
| | | isBind = Boolean.TRUE; |
| | | break loop; |
| | | } |
| | |
| | | |
| | | Map<String, List<DownStorageCageDetails>> singleLayerMap = list.stream().filter(item -> item.getTotalLayer() == 1) |
| | | .collect(Collectors.groupingBy(item -> item.getFlowCardId() + item.getLayer(), Collectors.toList())); |
| | | if (tempGlassId == null) { |
| | | if (StringUtils.isBlank(tempGlassId)) { |
| | | if (CollectionUtils.isNotEmpty(singleLayerMap)) { |
| | | //获取已落架流程卡信息,按落架数量排序 |
| | | for (DownGlassInfoDTO e : downGlassInfoDTOList) { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (tempGlassId == null) { |
| | | if (StringUtils.isBlank(tempGlassId)) { |
| | | log.info("没有找到可以下片的的玻璃,结束任务"); |
| | | return Boolean.FALSE; |
| | | } else { |
| | | //按照出片的玻璃id更新笼内的玻璃状态为已出片 |
| | | return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isBind, cageDetails); |
| | | return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isBind, cageDetails, workList); |
| | | } |
| | | } |
| | | |
| | | public Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean |
| | | isBind, DownStorageCageDetails cageDetails) { |
| | | isBind, DownStorageCageDetails cageDetails, List<Integer> workList) { |
| | | //按玻璃id获取玻璃信息 |
| | | DownStorageCageDetails downStorageCageDetails = null; |
| | | if (glassId.equals(cageDetails.getGlassId())) { |
| | | downStorageCageDetails = cageDetails; |
| | | taskType = 3; |
| | | //将下片玻璃存入笼子详情信息表中 |
| | | //将任务插入理片笼详情表 |
| | | downStorageCageDetails.setState(Const.GLASS_STATE_OUT); |
| | | downStorageCageDetailsService.save(downStorageCageDetails); |
| | | } else { |
| | | downStorageCageDetails = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>() |
| | | .eq(DownStorageCageDetails::getGlassId, glassId).eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)); |
| | | } |
| | | |
| | | Integer endCell = null; |
| | | if (isBind) { |
| | | //获取空架子信息,将空架子信息绑定流程卡 |
| | | DownWorkstation emptyDownWorkstation = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>() |
| | | .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1")); |
| | | if (null != emptyDownWorkstation) { |
| | | log.info("获取到空架子信息,绑定流程卡"); |
| | | downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getWorkstationId(), downStorageCageDetails.getLayer()); |
| | | endCell = emptyDownWorkstation.getWorkstationId(); |
| | | //将下片玻璃存入笼子详情信息表中 |
| | | //将任务插入理片笼详情表 |
| | | downStorageCageDetails.setState(Const.GLASS_STATE_OUT); |
| | | downStorageCageDetailsService.save(downStorageCageDetails); |
| | | } else { |
| | | log.info("没有空架子信息,无法绑定流程卡"); |
| | | return Boolean.FALSE; |
| | | } |
| | | } else { |
| | | DownWorkstation workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>() |
| | | .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer())); |
| | | endCell = workstation.getWorkstationId(); |
| | | |
| | | if (downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>() |
| | | .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId))) { |
| | | log.info("更新详情表内的状态成功"); |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | } |
| | | |
| | | Integer endCell = null; |
| | | if (isBind) { |
| | | //获取空架子信息,将空架子信息绑定流程卡 |
| | | DownWorkstation emptyDownWorkstation = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>() |
| | | .isNull(DownWorkstation::getFlowCardId).in(DownWorkstation::getWorkstationId, workList).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1")); |
| | | if (null != emptyDownWorkstation) { |
| | | log.info("获取到空架子信息,绑定流程卡"); |
| | | downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getWorkstationId(), downStorageCageDetails.getLayer()); |
| | | endCell = emptyDownWorkstation.getWorkstationId(); |
| | | } else { |
| | | log.info("没有空架子信息,无法绑定流程卡"); |
| | | return Boolean.FALSE; |
| | | } |
| | | } else { |
| | | DownWorkstation workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>() |
| | | .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer())); |
| | | endCell = workstation.getWorkstationId(); |
| | | } |
| | | //更新落架玻璃数量 |
| | | if (endCell == 7) { |
| | | downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId()) |
| | |
| | | SELECT * |
| | | FROM DOWN_STORAGE_CAGE_DETAILS |
| | | WHERE (FLOW_CARD_ID, LAYER) = (SELECT FLOW_CARD_ID, LAYER |
| | | FROM DOWN_STORAGE_CAGE_DETAILS |
| | | WHERE STATE = 100 |
| | | GROUP BY FLOW_CARD_ID, LAYER |
| | | ORDER BY COUNT(FLOW_CARD_ID) DESC |
| | | LIMIT 1 ) |
| | | AND STATE = 100 |
| | | FROM DOWN_STORAGE_CAGE_DETAILS |
| | | WHERE STATE = 100 |
| | | and (FLOW_CARD_ID, LAYER) not in ( |
| | | select FLOW_CARD_ID, LAYER from down_workstation where flow_card_id is not null and workstation_id not in |
| | | <foreach collection="workList" item="item" open='(' close=')' separator=','> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | |
| | | GROUP BY FLOW_CARD_ID, LAYER |
| | | ORDER BY COUNT(FLOW_CARD_ID) DESC |
| | | LIMIT 1 ) |
| | | AND STATE = 100 |
| | | ORDER BY |
| | | WIDTH DESC, |
| | | HEIGHT DESC |
| | | LIMIT 1 |
| | | WIDTH DESC, |
| | | HEIGHT DESC |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | |