| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.downglassinfo.entity.DownGlassInfo; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.mapper.DownGlassInfoMapper; |
| | | import com.mes.downglassinfo.service.DownGlassInfoService; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | |
| | | import com.mes.downworkstation.mapper.DownWorkstationTaskMapper; |
| | | import com.mes.downworkstation.service.DownWorkstationService; |
| | | import com.mes.downworkstation.service.DownWorkstationTaskService; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private DownWorkstationMapper downWorkstationMapper; |
| | | @Autowired |
| | | @Autowired(required = false) |
| | | private DownWorkstationTaskMapper downWorkstationTaskMapper; |
| | | @Autowired |
| | | private DownGlassInfoService downGlassInfoService; |
| | |
| | | private DownGlassInfoMapper downGlassInfoMapper; |
| | | @Autowired |
| | | private DownGlassTaskService downGlassTaskService; |
| | | |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | @Autowired |
| | | private DamageService damageservice; |
| | | |
| | | @Autowired |
| | | private DownWorkstationTaskService downWorkstationTaskService; |
| | |
| | | //获取总数量 |
| | | @Override |
| | | public int getTotalQuantity(int workstationId) { |
| | | QueryWrapper<DownWorkstation> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("total_quantity") |
| | | .eq("workstation_id", workstationId); |
| | | DownWorkstation result = baseMapper.selectOne(new QueryWrapper<DownWorkstation>().lambda() |
| | | .select(DownWorkstation::getTotalQuantity) |
| | | .eq(DownWorkstation::getWorkstationId, workstationId)); |
| | | |
| | | DownWorkstation result = baseMapper.selectOne(queryWrapper); |
| | | return result != null ? result.getTotalquantity() : 0; |
| | | return result != null ? result.getTotalQuantity() : 0; |
| | | } |
| | | |
| | | |
| | | //工位显示 |
| | | @Override |
| | | public List<Map<String, Object>> getTotalGlassDimensionsByWorkstation() { |
| | | MPJQueryWrapper<DownWorkstionAndDownGlassinfo> queryWrapper = new MPJQueryWrapper<>(); |
| | | public List<Map<String, Object>> getTotalGlassDimensionsByWorkstation(int start, int end) { |
| | | MPJQueryWrapper<DownWorkstation> queryWrapper = new MPJQueryWrapper<>(); |
| | | queryWrapper.select("t.workstation_id", "t.flow_card_id", "COALESCE(SUM(b.width), 0) AS totalwidth", "COALESCE(SUM(b.height), 0) AS totalheight") |
| | | .leftJoin("down_glass_info b on t.flow_card_id = b.flow_card_id") |
| | | .groupBy("t.workstation_id", "t.flow_card_id"); |
| | | .groupBy("t.workstation_id", "t.flow_card_id") |
| | | .orderByAsc("t.workstation_id").between("t.workstation_id", start, end) |
| | | |
| | | // List<DownWorkstionAndDownGlassinfo> workstationList = downWorkstationMapper.selectJoinList(DownWorkstionAndDownGlassinfo.class, queryWrapper); |
| | | List<DownWorkstionAndDownGlassinfo> workstationList = null; |
| | | ; |
| | | |
| | | List<DownWorkstionAndDownGlassinfo> workstationList = downWorkstationMapper.selectJoinList(DownWorkstionAndDownGlassinfo.class, queryWrapper); |
| | | // List<DownWorkstionAndDownGlassinfo> workstationList = null; |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (DownWorkstionAndDownGlassinfo downWorkstionAndDownGlassinfo : workstationList) { |
| | | Map<String, Object> rack = new HashMap<>(); |
| | | |
| | | // 创建子项(item)对象 |
| | | Map<String, Object> item = new HashMap<>(); |
| | | item.put("height", downWorkstionAndDownGlassinfo.getTotalheight()); // 设置子项高度,根据实际情况设置 |
| | | item.put("width", downWorkstionAndDownGlassinfo.getTotalwidth()); // 设置子项宽度,根据实际情况设置 |
| | | item.put("fillColor", "yellow"); // 设置子项颜色 |
| | | item.put("content", downWorkstionAndDownGlassinfo.getFlowCardId()); // 使用流程卡号作为子项内容 |
| | | item.put("height", downWorkstionAndDownGlassinfo.getTotalheight()); |
| | | item.put("width", downWorkstionAndDownGlassinfo.getTotalwidth()); |
| | | item.put("fillColor", "yellow"); |
| | | item.put("content", downWorkstionAndDownGlassinfo.getFlowCardId()); |
| | | |
| | | rack.put("item", item); // 将子项对象放入货架对象中 |
| | | // 查询 DownGlassInfo 并添加到 item 中 |
| | | MPJQueryWrapper<DownGlassInfo> glassInfoQueryWrapper = new MPJQueryWrapper<>(); |
| | | glassInfoQueryWrapper.select("*"); // 查询所有列 |
| | | glassInfoQueryWrapper.eq("flow_card_id", downWorkstionAndDownGlassinfo.getFlowCardId()); |
| | | List<DownGlassInfo> downGlassInfoList = downGlassInfoMapper.selectList(glassInfoQueryWrapper); |
| | | |
| | | result.add(rack); // 将货架对象添加到结果列表中 |
| | | //log.info("货架对象: {}", rack); |
| | | |
| | | if (!downGlassInfoList.isEmpty()) { |
| | | |
| | | item.put("downGlassInfoList", downGlassInfoList); |
| | | |
| | | } |
| | | |
| | | rack.put("item", item); |
| | | result.add(rack); |
| | | } |
| | | |
| | | log.info("result" + (result)); |
| | | return result; // 返回最终结果 |
| | | } |
| | | |
| | | |
| | | // @Override |
| | | // public int getTotalQuantity(int workstationId) { |
| | | // Integer totalQuantity = downWorkstationMapper.getTotalQuantity(workstationId); |
| | | // return totalQuantity != null ? totalQuantity : 0; |
| | | // } |
| | | |
| | | // @Override |
| | | // public int getRacksNumber(int workstationId) { |
| | | // Integer racksNumber = downWorkstationMapper.getRacksNumber(workstationId); |
| | | // return racksNumber != null ? racksNumber : 0; |
| | | // } |
| | | //根据条件获取落架数量 |
| | | @Override |
| | | public int getRacksNumber(int workstationId) { |
| | |
| | | .eq("workstation_id", workstationId); |
| | | |
| | | DownWorkstation result = baseMapper.selectOne(queryWrapper); |
| | | return result != null ? result.getRacksnumber() : 0; |
| | | return result != null ? result.getRacksNumber() : 0; |
| | | } |
| | | |
| | | //根据条件获取工位玻璃信息 |
| | |
| | | public void updateracksnumber(String flowCardId, int racksNumber) { |
| | | UpdateWrapper<DownWorkstation> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("racks_number", racksNumber).eq("flow_card_id", flowCardId); |
| | | baseMapper.update(null, updateWrapper); |
| | | baseMapper.update(new DownWorkstation(), updateWrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int updateFlowCardIdAndCount(String flowCardId, int glassInfoCount, int workstationId) { |
| | | public void updateFlowCardIdAndCount(String flowCardId, int workstationId, int layer) { |
| | | int glassInfoCount = glassInfoService.getGlassInfoCountByFlowCardId(flowCardId, layer); |
| | | QueryWrapper<Damage> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("process_id", flowCardId); |
| | | queryWrapper.eq("technology_number", layer); |
| | | |
| | | int otherNumber = damageservice.count(queryWrapper); |
| | | UpdateWrapper<DownWorkstation> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("total_quantity", glassInfoCount) |
| | | .set("flow_card_id", flowCardId) |
| | | .set("layer", layer) |
| | | .set("other_number", otherNumber) |
| | | .eq("workstation_id", workstationId); |
| | | |
| | | return baseMapper.update(null, updateWrapper); |
| | | this.update(updateWrapper); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | .set("racks_number", 0) |
| | | .eq("workstation_id", workstationId); |
| | | |
| | | baseMapper.update(null, updateWrapper); |
| | | baseMapper.update(new DownWorkstation(), updateWrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public DownWorkstation selectByFlowCardId(String flowcardid) { |
| | | QueryWrapper<DownWorkstation> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("flow_card_id", flowcardid); |
| | |
| | | |
| | | |
| | | @Override |
| | | public void insertdownglassinfo() { |
| | | public boolean updateDownWorkstationstate(DownWorkstation downWorkstation) { |
| | | |
| | | DownWorkstation downWork = baseMapper.selectById(downWorkstation.getId()); |
| | | |
| | | List<DownGlassTask> taskdownGlassInf = downGlassTaskService.getUnloadingTaskState(); |
| | | // |
| | | if (downWork != null) { |
| | | |
| | | downWork.setEnableState(downWorkstation.getEnableState()); |
| | | |
| | | if (taskdownGlassInf != null && !taskdownGlassInf.isEmpty()) { |
| | | baseMapper.updateById(downWork); |
| | | |
| | | // |
| | | return true; |
| | | } else { |
| | | |
| | | for (DownGlassTask downGlassInfo : taskdownGlassInf) { |
| | | // 创建新的 DownGlassInfo 对象并设置相关属性 |
| | | DownGlassInfo newdownGlassInfo = new DownGlassInfo(); |
| | | |
| | | newdownGlassInfo.setFlowCardId(downGlassInfo.getFlowCardId()); |
| | | Integer maxSequence = downGlassInfoService.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId()); |
| | | // 初始化顺序字段值 |
| | | int sequence = maxSequence != null ? maxSequence + 1 : 1; |
| | | // newdownGlassInfo.setId(downGlassInfo.getId()); |
| | | newdownGlassInfo.setWidth(downGlassInfo.getWidth()); |
| | | newdownGlassInfo.setHeight(downGlassInfo.getHeight()); |
| | | newdownGlassInfo.setThickness(downGlassInfo.getThickness()); |
| | | newdownGlassInfo.setFilmsid(downGlassInfo.getFilmsid()); |
| | | // 设置顺序字段值 |
| | | newdownGlassInfo.setSequence(sequence); |
| | | |
| | | // 插入数据到下片玻璃信息表 |
| | | downGlassInfoService.insertDownGlassInfo(newdownGlassInfo); |
| | | //插入数据到机械手任务表 |
| | | |
| | | downWorkstationTaskService.insertdownWorkstationtask(newdownGlassInfo); |
| | | //更新下片任务表状态为0 |
| | | downGlassTaskService.updateTaskStateToZero(downGlassInfo.getId()); |
| | | //删除下片任务表中的记录 |
| | | downGlassTaskService.deleteTask(downGlassInfo.getFlowCardId()); |
| | | |
| | | sequence++; // 递增顺序字段值 |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | try { |
| | | //查询下片工位表中架子是否绑定了流程卡号 工位表和任务表中状态为1的流程卡号和已落架数量 |
| | | List<DownWorkstationTask> taskdownWorkstation = downWorkstationTaskService.getTaskState(); |
| | | if (taskdownWorkstation != null && !taskdownWorkstation.isEmpty()) { |
| | | //,如果已经绑定则更新已落架数量,并且删除下片任务表中的记录 |
| | | for (DownWorkstationTask downWorkstation : taskdownWorkstation) { |
| | | //更新下片工位表中已落架数量 |
| | | DownWorkstation downWorkstation1 = selectByFlowCardId(downWorkstation.getFlowCardId()); |
| | | updateracksnumber(downWorkstation.getFlowCardId(), downWorkstation1.getRacksnumber() + 1); |
| | | //更新机械任务表中状态为0 |
| | | downWorkstationTaskService.updateTaskStateToZero(downWorkstation.getId()); |
| | | //删除机械任务表 |
| | | downWorkstationTaskService.removeById(downWorkstation.getId()); |
| | | |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // 打印异常信息 |
| | | e.printStackTrace(); |
| | | // 或者可以进行其他异常处理,比如记录日志或者返回特定的错误信息 |
| | | return false; |
| | | } |
| | | } |
| | | |