| | |
| | | package com.mes.downglassinfo.service.impl; |
| | | |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.downglassinfo.entity.DownGlassInfo; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.entity.request.DownGlassInfoRequest; |
| | | import com.mes.downglassinfo.mapper.DownGlassInfoMapper; |
| | | import com.mes.downglassinfo.service.DownGlassInfoService; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import com.mes.downstorage.service.DownStorageCageDetailsService; |
| | | import com.mes.downworkstation.entity.DownWorkstation; |
| | | import com.mes.downworkstation.mapper.DownWorkstationMapper; |
| | | import com.mes.downworkstation.entity.dto.DownGlassInfoDTO; |
| | | import com.mes.downworkstation.service.DownWorkstationService; |
| | | import com.mes.downworkstation.service.DownWorkstationTaskService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.job.DownLoadCacheGlassTask; |
| | | import com.mes.pp.service.FlowCardService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.HashMap;import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class DownGlassInfoServiceImpl extends ServiceImpl<DownGlassInfoMapper, DownGlassInfo> implements DownGlassInfoService { |
| | | |
| | | // 根据流程卡号查询最大序号 |
| | | @Autowired |
| | | DownLoadCacheGlassTask downLoadCacheGlassTask; |
| | | |
| | | @Autowired |
| | | DownStorageCageDetailsService downStorageCageDetailsService; |
| | | |
| | | |
| | | @Autowired |
| | | DownWorkstationService downWorkstationService; |
| | | |
| | | @Autowired |
| | | RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | FlowCardService flowCardService; |
| | | |
| | | /** |
| | | * 根据流程卡号查询最大序号 |
| | | */ |
| | | @Override |
| | | public Integer getMaxSequenceByFlowCardId(String flowCardId) { |
| | | public Integer getMaxSequenceByFlowCardId(String flowCardId, int layer) { |
| | | LambdaQueryWrapper<DownGlassInfo> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | lambdaQueryWrapper.eq(DownGlassInfo::getFlowCardId, flowCardId) |
| | | .eq(DownGlassInfo::getLayer, layer) |
| | | .select(DownGlassInfo::getSequence) |
| | | .orderByDesc(DownGlassInfo::getSequence) |
| | | .last("LIMIT 1"); |
| | |
| | | return downGlassInfo != null ? downGlassInfo.getSequence() : 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void insertDownGlassInfo(DownGlassInfo downGlassInfo) { |
| | | |
| | | |
| | | |
| | | baseMapper.insert(downGlassInfo); |
| | | } |
| | | |
| | | @Override |
| | | public DownGlassInfoDTO queryDownGlassMaxLayer(String flowCardId) { |
| | | return baseMapper.queryDownGlassMaxLayer(flowCardId); |
| | | } |
| | | |
| | | @Override |
| | | public Integer queryMaxSequence(String flowCardId, int layer) { |
| | | return baseMapper.queryMaxSequence(flowCardId, layer); |
| | | } |
| | | |
| | | @Override |
| | | public List<DownGlassInfoDTO> queryWorkStationIsIn(List<Integer> workList, Boolean isDownload) { |
| | | //按照要求获取已落架/未落架的玻璃信息 |
| | | return baseMapper.queryWorkStationIsIn(workList, isDownload); |
| | | } |
| | | |
| | | @Override |
| | | public List<DownGlassInfoDTO> queryWorkStationFlowCard(List<Integer> workList) { |
| | | //获取已绑定流程卡的架子未落玻璃的数据信息 |
| | | return baseMapper.queryWorkStationFlowCard(workList); |
| | | } |
| | | |
| | | @Override |
| | | public boolean generateOutGlassTask(String glassId) { |
| | | //更新卧式理片笼内玻璃状态 |
| | | downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>() |
| | | .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | DownStorageCageDetails details = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>() |
| | | .eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | //生成下片信息 |
| | | DownGlassInfo downGlassInfo = new DownGlassInfo(); |
| | | BeanUtils.copyProperties(details, downGlassInfo); |
| | | //获取当前流程卡最大片序 |
| | | downGlassInfo.setSequence(this.getMaxSequenceByFlowCardId(details.getFlowCardId(), details.getLayer()) + 1); |
| | | this.save(downGlassInfo); |
| | | //生成任务信息 并向plc发送出片任务 |
| | | GlassInfo glassInfo = new GlassInfo(); |
| | | BeanUtils.copyProperties(details, glassInfo); |
| | | return downLoadCacheGlassTask.initDownGlassTask(glassInfo, details.getSlot(), Const.G13_WORK_STATION, 2); |
| | | } |
| | | |
| | | @Override |
| | | public String setDownGlassInfoRequest(DownGlassInfoRequest request) { |
| | | if (request == null) { |
| | | redisUtil.deleteObject("downGlassRequest"); |
| | | } else { |
| | | redisUtil.setCacheObject("downGlassRequest", request); |
| | | } |
| | | return "success"; |
| | | } |
| | | @Override |
| | | public List<DownWorkstation> queryWorkStationIsFull() { |
| | | //查询可以落架的玻璃信息且已绑定流程卡的工位信息 |
| | | List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>().eq(DownWorkstation::getEnableState, Const.SLOT_ON) |
| | | .isNotNull(DownWorkstation::getFlowCardId).ne(DownWorkstation::getFlowCardId, "")); |
| | | List<DownWorkstation> workstationFull = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | //都有玻璃的工位信息(包括绑定流程卡) |
| | | List<Integer> workstationList = list.stream().map(DownWorkstation::getWorkstationId).collect(Collectors.toList()); |
| | | //按照符合条件的工位获取未落架的流程卡玻璃,如果返回为空,则表明所有都已落架完成 |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = queryWorkStationIsIn(workstationList, Boolean.FALSE); |
| | | //获取工位上的未满的流程卡及层数 |
| | | List<String> flowCardIdList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList()); |
| | | //可以落架的玻璃信息且已绑定流程卡的所有的工位 - 玻璃未满流程卡及层数的工位 = 已满工位 |
| | | workstationFull = list.stream().filter(item -> !flowCardIdList.contains(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList()); |
| | | //是否需要将已满的工位置为不可落架 |
| | | if (CollectionUtils.isNotEmpty(workstationFull)) { |
| | | List<Integer> workstationIds = workstationFull.stream().map(DownWorkstation::getWorkstationId).collect(Collectors.toList()); |
| | | downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getEnableState, Const.SLOT_OFF) |
| | | .in(DownWorkstation::getWorkstationId, workstationIds)); |
| | | } |
| | | } |
| | | return workstationFull; |
| | | }@Override |
| | | public List<Map<String, List<Map<String, Object>>>> downGlassPrint(DownGlassInfo downGlassInfo){ |
| | | QueryWrapper<DownGlassInfo> queryWrapper = Wrappers.query(); |
| | | queryWrapper.eq("flow_card_id", "NG24080012A001") |
| | | .eq("layer", 1) |
| | | .select("flow_card_id", "layer", "width", "height", "filmsid", "thickness","glass_type","COUNT(*) AS quantity") |
| | | .groupBy("flow_card_id", "layer", "width", "height", "filmsid", "thickness"); |
| | | List<Map<String, Object>> resultList = baseMapper.selectMaps(queryWrapper); |
| | | |
| | | |
| | | List<Map<String, Object>> projectInfo=flowCardService.selectProject(downGlassInfo.getFlowCardId(),downGlassInfo.getLayer()); |
| | | List<Map<String, Object>> flowCardInfo=flowCardService.selectFlowCard(downGlassInfo.getFlowCardId(),downGlassInfo.getLayer()); |
| | | |
| | | for (Map<String, Object> row : flowCardInfo) { |
| | | int order_number = (int) row.get("order_number"); |
| | | int technology_number = (int) row.get("technology_number"); |
| | | |
| | | for (Map<String, Object> row1 : resultList) { |
| | | int glass_type = (int) row1.get("glass_type"); |
| | | int layer = (int) row1.get("layer"); |
| | | Long quantity=(Long) row1.get("quantity"); |
| | | |
| | | if(order_number==glass_type&&technology_number==layer){ |
| | | row.put("quantity1",quantity); |
| | | } |
| | | } |
| | | } |
| | | List<Map<String, List<Map<String, Object>>>> listMap=new ArrayList<>(); |
| | | Map<String, List<Map<String, Object>>> result = new HashMap<>(); |
| | | result.put("detail", projectInfo); |
| | | result.put("detailList", flowCardInfo); |
| | | for (Map<String, Object> row : projectInfo) { |
| | | String order_number = (String) row.get("process"); |
| | | String[] processes=order_number.split("->"); |
| | | List<Map<String, Object>> processList = new ArrayList<>(); |
| | | for (int i = 0; i < processes.length; i++) { |
| | | Map<String, Object> processMap = new JSONObject(); |
| | | processMap.put("process", processes[i]); |
| | | processMap.put("id", i); |
| | | processList.add(processMap); |
| | | } |
| | | result.put("processList", processList); |
| | | } |
| | | listMap.add(result); |
| | | return listMap; |
| | | } |
| | | } |