| | |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.base.entity.vo.BigStorageVO; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.dto.*; |
| | | import com.mes.bigstorage.entity.vo.BigStorageQueryVO; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageOutTask; |
| | | import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO; |
| | | import com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper; |
| | | import com.mes.bigstoragetask.mapper.BigStorageCageOutTaskMapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.config.ConstSysConfig; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.mapper.GlassInfoMapper; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.job.PlcStorageCageTask; |
| | | import com.mes.pp.entity.OptimizeProject; |
| | | import com.mes.pp.service.OptimizeProjectService; |
| | | import com.mes.sysconfig.entity.SysConfig; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.mapper.TemperingGlassInfoMapper; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Resource |
| | | private GlassInfoMapper glassInfoMapper; |
| | | @Resource |
| | | private OptimizeProjectService optimizeProjectService; |
| | | |
| | | @Resource |
| | | private GlassInfoService glassInfoService; |
| | | |
| | | @Resource |
| | | private TemperingGlassInfoService temperingGlassInfoService; |
| | | |
| | | @Resource |
| | | private PlcStorageCageTask plcStorageCageTask; |
| | | private SysConfigService sysConfigService; |
| | | |
| | | |
| | | @Resource |
| | | private DamageService damageService; |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Value("${mes.minCount}") |
| | | private int minCount; |
| | | |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | |
| | | @Value("${mes.sequence.order}") |
| | | private boolean sequenceOrder; |
| | | @Resource |
| | | BigStorageCageHistoryTaskService bigStorageCageHistoryTaskService; |
| | | // |
| | | // @Value("${mes.minCount}") |
| | | // private int minCount; |
| | | // |
| | | // @Value("${mes.slotWidth}") |
| | | // private Integer slotWidth; |
| | | // |
| | | // @Value("${mes.glassGap}") |
| | | // private Integer glassGap; |
| | | // |
| | | // @Value("${mes.sequence.order}") |
| | | // private boolean sequenceOrder; |
| | | |
| | | |
| | | @Override |
| | |
| | | for (BigStorageCageDetails bigStorageCageDetails : bigStorageCageDetailsList |
| | | ) { |
| | | if (bigStorageCageDetails.getBigStorageCageFeedTask().getTaskState() == 0) { |
| | | carWidth = carWidth - bigStorageCageDetails.getWidth() - glassGap; |
| | | carWidth = carWidth - bigStorageCageDetails.getWidth() - 250; |
| | | } |
| | | } |
| | | return carWidth; |
| | |
| | | if (glassInfo != null) { |
| | | BeanUtils.copyProperties(glassInfo, bigStorageCageDetails); |
| | | bigStorageCageDetails.setState(1); |
| | | bigStorageCageDetails.setGap(glassGap); |
| | | bigStorageCageDetails.setGap(250); |
| | | bigStorageCageDetailsList = new ArrayList<>(); |
| | | bigStorageCageDetailsList.add(bigStorageCageDetails); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BigStorageDTO queryTargetSlot(String EngineerId, String glassId, int thickness) { |
| | | BigStorageDTO bigStorageDTO = null; |
| | | int slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH); |
| | | |
| | | BigStorageCage bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot) |
| | | .inSql(BigStorageCage::getDeviceId, |
| | | "select distinct device_id from big_storage_cage_details where engineer_id = '" + EngineerId + "'") |
| | | .last("limit 1")); |
| | | if (null != bigStorageCage) { |
| | | log.info("根据版图id找到笼子内的目标格子:{},玻璃id:{}", bigStorageCage.getSlot(), glassId); |
| | | bigStorageDTO = new BigStorageDTO(); |
| | | bigStorageDTO.setWidth(bigStorageCage.getRemainWidth()); |
| | | bigStorageDTO.setSlot(bigStorageCage.getSlot()); |
| | | bigStorageDTO.setDeviceId(bigStorageCage.getDeviceId()); |
| | | return bigStorageDTO; |
| | | } |
| | | |
| | | //获取玻璃的厚度:重新选笼子需要按照笼子可放玻璃厚度进行选择 因为子查询排序对主sql无影响,所以先执行子查询获取顺序,然后一次去查询 |
| | | List<Integer> deviceUsedList = bigStorageCageService.queryFreeDeviceByUsed(thickness); |
| | | |
| | | for (Integer item : deviceUsedList) { |
| | | bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot) |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | .eq(BigStorageCage::getDeviceId, item) |
| | | .last("limit 1")); |
| | | if (null != bigStorageCage) { |
| | | log.info("按照存笼玻璃格子数占用最少方式获取信息格子为:{},玻璃id:{}", bigStorageCage.getSlot(), glassId); |
| | | bigStorageDTO = new BigStorageDTO(); |
| | | bigStorageDTO.setWidth(bigStorageCage.getRemainWidth()); |
| | | bigStorageDTO.setSlot(bigStorageCage.getSlot()); |
| | | bigStorageDTO.setDeviceId(bigStorageCage.getDeviceId()); |
| | | return bigStorageDTO; |
| | | } |
| | | } |
| | | Assert.isTrue(null != bigStorageCage, "没有空余的笼子存放玻璃"); |
| | | return bigStorageDTO; |
| | | } |
| | | |
| | | @Override |
| | | public BigStorageDTO queryTargetSlotByTempering(GlassInfo glassInfo) { |
| | | BigStorageDTO bigStorageDTO = null; |
| | | int slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH); |
| | | MPJLambdaWrapper<BigStorageCage> wrapper = new MPJLambdaWrapper<>(BigStorageCage.class) |
| | | .selectAll(BigStorageCage.class) |
| | | .leftJoin(BigStorageCageDetails.class, BigStorageCageDetails::getSlot, BigStorageCage::getSlot) |
| | |
| | | } |
| | | bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot) |
| | | // .notInSql(BigStorageCage::getSlot, "select distinct slot from big_storage_cage_details where state = 0") |
| | | .inSql(BigStorageCage::getDeviceId, |
| | | "select distinct device_id from big_storage_cage_details where engineer_id = '" + glassInfo.getEngineerId() + "' and tempering_layout_id = " + glassInfo.getTemperingLayoutId()) |
| | |
| | | } |
| | | for (Integer item : deviceUsedList) { |
| | | bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot) |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | .eq(BigStorageCage::getDeviceId, item) |
| | | .last("limit 1")); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<TemperingLayoutDTO> temperingIsAllByTemperingLayoutId(String engineerId, Integer temperingLayoutId) { |
| | | return baseMapper.temperingIsAllByTemperingLayoutId(engineerId, temperingLayoutId); |
| | | } |
| | | |
| | | @Override |
| | | public List<TemperingLayoutDTO> temperingIsAll() { |
| | | return baseMapper.temperingIsAll(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<TemperingLayoutDTO> queryTemperingOccupySlot() { |
| | | return baseMapper.queryTemperingOccupySlot(minCount); |
| | | return baseMapper.queryTemperingOccupySlot(10); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public boolean temperingGlass(String temperingLayoutId, String engineerId, String temperingFeedSequence) { |
| | | LambdaQueryWrapper<TemperingGlassInfo> temperingGlassInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | SysConfig sysConfig = sysConfigService.queryConfigById(ConstSysConfig.CACHE_SEQUENCE_ORDER_TRUE); |
| | | boolean sequenceOrder = Boolean.parseBoolean(sysConfig.getConfigValue()); |
| | | temperingGlassInfoLambdaQueryWrapper |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW); |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoMapper.selectList(temperingGlassInfoLambdaQueryWrapper); |
| | | |
| | | int dispatchCount = bigStorageCageHistoryTaskService.count(new LambdaQueryWrapper<BigStorageCageHistoryTask>() |
| | | .eq(BigStorageCageHistoryTask::getTaskState, Const.GLASS_STATE_NEW) |
| | | .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_DISPATCH)); |
| | | |
| | | if (temperingGlassInfoList.size() == 0) { |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | | .select("-1 as state") |
| | | .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot) |
| | | MPJLambdaWrapper<GlassInfo> wrapper = JoinWrappers.lambda(GlassInfo.class) |
| | | .select("-1 as state,t.filmsid as films_id,t.glass_id,t.flow_card_id,t.glass_type,t.width,t.height" + |
| | | ",t.thickness,t.ishorizontal,t.tempering_layout_id,t.tempering_feed_sequence,t.x_coordinate,t.y_coordinate," + |
| | | "t.angle,t1.slot,t.engineer_id") |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(GlassInfo::getTemperingLayoutId, temperingLayoutId) |
| | | .eq(GlassInfo::getEngineerId, engineerId) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence)); |
| | | |
| | | .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence); |
| | | if (dispatchCount > 0) { |
| | | wrapper.in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL); |
| | | } else { |
| | | wrapper.in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN); |
| | | } |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, wrapper); |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | if ("0".equals(temperingFeedSequence)) { |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, ""); |
| | | // plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, ""); |
| | | } |
| | | } else { |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectTemperingGlass() { |
| | | List<Map<String, Object>> temperingGlass = baseMapper.selectTemperingGlassCount(); |
| | | return temperingGlass; |
| | | public List<TemperingGlassCountDTO> selectTemperingGlass(int isTempering) { |
| | | return baseMapper.selectTemperingGlassCount(isTempering); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<GlassInfoLackDTO> queryLackGlassInfo(BigStorageQueryVO bigStorageQueryVO) { |
| | | return baseMapper.queryLackGlassInfo(bigStorageQueryVO); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageCageDetails> queryRealGlassInfo(BigStorageQueryVO bigStorageQueryVO) { |
| | | return this.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getEngineerId, bigStorageQueryVO.getEngineerId()) |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId, bigStorageQueryVO.getTemperingLayoutId()) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).orderByAsc(BigStorageCageDetails::getTemperingFeedSequence)); |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, List<BigStorageVO>> querybigStorageCageDetail() { |
| | | List<BigStorageVO> bigStorageCages = baseMapper.querybigStorageCageDetail(); |
| | | return bigStorageCages.stream().collect(Collectors.groupingBy(item -> item.getDeviceId())); |
| | | } |
| | | |
| | | @Override |
| | | public boolean cancelTemperingTask() { |
| | | redisUtil.deleteObject("temperingEngineerId"); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Override |
| | | public String temperingSwitch(Boolean flag) { |
| | | redisUtil.setCacheObject("temperingSwitch", flag); |
| | | return "success"; |
| | | } |
| | | |
| | | @Override |
| | | public void appointEngineerId(String engineerId) { |
| | | redisUtil.setCacheObject("temperingengineerId", engineerId); |
| | | public boolean appointTemperingEngineerId(String engineerId) { |
| | | String oldEngineerId = redisUtil.getCacheObject("temperingEngineerId"); |
| | | if (StringUtils.isBlank(oldEngineerId)) { |
| | | redisUtil.setCacheObject("temperingEngineerId", engineerId); |
| | | return Boolean.TRUE; |
| | | } else { |
| | | return Boolean.FALSE; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageRelationDTO> queryIsAllNeedDispatchVirtualSlot() { |
| | | return baseMapper.queryIsAllNeedDispatchVirtualSlot(); |
| | | public List<BigStorageRelationDTO> queryIsAllNeedDispatchVirtualSlot(List<Integer> deviceIdList) { |
| | | return baseMapper.queryIsAllNeedDispatchVirtualSlot(deviceIdList); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageSequenceDTO> dispatchBigStorageGlassInfo(BigStorageRelationDTO bigStorageRelationDTO) { |
| | | return baseMapper.queryNeedDispatchSlot(bigStorageRelationDTO); |
| | | } |
| | | |
| | | @Override |
| | | public String bigStorageGlassDamageByGlassId(String glassId) { |
| | | Damage damage = new Damage(); |
| | | damage.setGlassId(glassId); |
| | | damage.setType(Const.GLASS_STATE_DAMAGE); |
| | | damageService.insertDamage(damage); |
| | | return "success"; |
| | | } |
| | | |
| | | @Override |
| | | public void updateDeviceIdBySlot(List<Integer> slotList) { |
| | | baseMapper.updateDeviceIdBySlot(slotList); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageCageDetails> queryEngineer() { |
| | | QueryWrapper<BigStorageCageDetails> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("distinct engineer_id") |
| | | .eq("state", 100); |
| | | return this.list(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<OptimizeProject> queryTemperingOrder() { |
| | | String temperingengineerId = redisUtil.getCacheObject("temperingEngineerId"); |
| | | List<TemperingGlassCountDTO> temperingGlassCountDTOS = baseMapper.queryTemperingGlassCountSummary(1); |
| | | List<OptimizeProject> projectList = optimizeProjectService.engineerScheduling(new OptimizeProject() {{ |
| | | setType(3); |
| | | }}); |
| | | Set<String> projectNoSet = projectList.stream() |
| | | .map(OptimizeProject::getProjectNo) |
| | | .collect(Collectors.toSet()); |
| | | List<OptimizeProject> resultList= new ArrayList<>(); |
| | | for (TemperingGlassCountDTO dto : temperingGlassCountDTOS) { |
| | | if (projectNoSet.contains(dto.getEngineerId())) { |
| | | OptimizeProject project = new OptimizeProject(); |
| | | if (Objects.equals(dto.getEngineerId(), temperingengineerId)) { |
| | | project.setState(1); |
| | | } |
| | | project.setProjectNo(dto.getEngineerId()); |
| | | project.setGlassType(dto.getFilmsId()); |
| | | project.setGlassThickness(dto.getThickness().intValue()); |
| | | project.setGlassTotal(dto.getTotalCount()); |
| | | project.setGlassTotalArea(dto.getRealCount()); |
| | | resultList.add(project); |
| | | } |
| | | } |
| | | return resultList; |
| | | } |
| | | } |