| | |
| | | package com.mes.downglassinfo.service.impl; |
| | | |
| | | 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.CollectionUtils; |
| | | 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.glassinfo.entity.GlassInfo; |
| | | import com.mes.job.DownLoadCacheGlassTask; |
| | | import com.mes.pp.service.FlowCardService; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | @Autowired |
| | | FlowCardService flowCardService; |
| | | |
| | | @Resource |
| | | DownGlassTaskService downGlassTaskService; |
| | | |
| | | /** |
| | | * 根据流程卡号查询最大序号 |
| | |
| | | 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)); |
| | | // } |
| | | } |
| | | // 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)); |
| | | //// } |
| | | // } |
| | | List<DownWorkstation> workstationFull = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .eq(DownWorkstation::getEnableState, Const.SLOT_ON) |
| | | .isNotNull(DownWorkstation::getFlowCardId) |
| | | .ne(DownWorkstation::getFlowCardId, "") |
| | | .apply("total_quantity = racks_number + other_number")); |
| | | return workstationFull; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> downGlassLabelPrint(DownGlassInfo downGlassInfo) { |
| | | |
| | | List<Map<String, Object>> resultList = baseMapper.downGlassLabelPrint(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()); |
| | | log.info("MES落架数据:{}", resultList); |
| | | //获取ERP标签所需的信息 |
| | | List<Map<String, Object>> labelInfo; |
| | | if (downGlassInfo.getLayer() != 0) { |
| | | labelInfo = flowCardService.selectLabel(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()); |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | if (downGlassInfo.getFlowCardId() == null) { |
| | | List<DownGlassTask> downGlassTasks = downGlassTaskService.list( |
| | | new LambdaQueryWrapper<DownGlassTask>() |
| | | .eq(DownGlassTask::getEndCell, 7) |
| | | .eq(DownGlassTask::getTaskType, 3) |
| | | .lt(DownGlassTask::getTaskStatus, 3) |
| | | ); |
| | | List<String> glassIds = downGlassTasks.stream().map(DownGlassTask::getGlassId).collect(Collectors.toList()); |
| | | resultList = baseMapper.downGlassLabelPrint(null, null, glassIds); |
| | | } else { |
| | | labelInfo = flowCardService.selectLabel(downGlassInfo.getFlowCardId(), 1); |
| | | if (downGlassInfo.getGlassId() != null) { |
| | | List<String> glassIds = new ArrayList<>(); |
| | | glassIds.add(downGlassInfo.getGlassId()); |
| | | // resultList = baseMapper.downGlassLabelPrint(null, null, glassIds); |
| | | resultList = baseMapper.downGlassLabelPrintScan(null, null, glassIds); |
| | | } else { |
| | | if (downGlassInfo.getLayer() == 0) { |
| | | downGlassInfo.setLayer(null); |
| | | } |
| | | resultList = baseMapper.downGlassLabelPrint(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer(), null); |
| | | } |
| | | } |
| | | log.info("标签数据:{}", labelInfo); |
| | | if (CollectionUtils.isNotEmpty(resultList)) { |
| | | List<String> flowCardIds = resultList.stream() |
| | | .map(map -> (String) map.get("flow_card_id")) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | List<Integer> layers = resultList.stream() |
| | | .map(map -> (Integer) map.get("layer")) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | log.info("MES落架数据:{}", resultList); |
| | | //获取ERP标签所需的信息 |
| | | List<Map<String, Object>> labelInfo; |
| | | if (downGlassInfo.getFlowCardId() != null) { |
| | | flowCardIds.add(downGlassInfo.getFlowCardId()); |
| | | labelInfo = flowCardService.selectLabel(flowCardIds, layers); |
| | | } else { |
| | | labelInfo = flowCardService.selectLabel(flowCardIds, layers); |
| | | } |
| | | log.info("标签数据:{}", labelInfo); |
| | | |
| | | for (Map<String, Object> row : resultList) { |
| | | int glass_type = (int) row.get("glass_type"); |
| | | int layer = (int) row.get("layer"); |
| | | for (Map<String, Object> row1 : labelInfo) { |
| | | int orderNumber = (int) row1.get("orderNumber"); |
| | | int technologyNumber = (int) row1.get("technologyNumber"); |
| | | if (downGlassInfo.getLayer() != 0) { |
| | | if (orderNumber == glass_type && technologyNumber == layer) { |
| | | |
| | | String order_id = (String) row1.get("order_id"); |
| | | String project = (String) row1.get("project"); |
| | | Long customer_id = (Long) row1.get("customer_id"); |
| | | BigDecimal width = (BigDecimal) row1.get("width"); |
| | | BigDecimal height = (BigDecimal) row1.get("height"); |
| | | Long quantity = (Long) row1.get("quantity"); |
| | | String glass_child = (String) row1.get("glass_child"); |
| | | String process = (String) row1.get("process"); |
| | | String customer_name = (String) row1.get("customer_name"); |
| | | String processing_note = (String) row1.get("processing_note"); |
| | | String other_colunmns = (String) row1.get("other_colunmns"); |
| | | String building_number = (String) row1.get("building_number"); |
| | | String bend_radius = (String) row1.get("bend_radius"); |
| | | |
| | | row.put("orderNumber", orderNumber); |
| | | row.put("technology_number", technologyNumber); |
| | | row.put("order_id", order_id); |
| | | row.put("project", project); |
| | | row.put("customer_id", customer_id); |
| | | row.put("width", width); |
| | | row.put("height", height); |
| | | row.put("quantity", quantity); |
| | | row.put("glass_child", glass_child); |
| | | row.put("process", process); |
| | | row.put("customer_name", customer_name); |
| | | row.put("processing_note", processing_note); |
| | | row.put("other_colunmns", other_colunmns); |
| | | row.put("building_number", building_number); |
| | | row.put("bend_radius", bend_radius); |
| | | } |
| | | } else { |
| | | if (orderNumber == glass_type) { |
| | | |
| | | for (Map<String, Object> row : resultList) { |
| | | int glass_type = (int) row.get("glass_type"); |
| | | int layer = (int) row.get("layer"); |
| | | String flowCardId = (String) row.get("flow_card_id"); |
| | | for (Map<String, Object> row1 : labelInfo) { |
| | | int orderNumber = (int) row1.get("orderNumber"); |
| | | int technologyNumber = (int) row1.get("technologyNumber"); |
| | | String processId = (String) row1.get("process_id"); |
| | | if (orderNumber == glass_type && processId.equals(flowCardId) && technologyNumber == layer) { |
| | | String order_id = (String) row1.get("order_id"); |
| | | String project = (String) row1.get("project"); |
| | | Long customer_id = (Long) row1.get("customer_id"); |