|  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<XhProductModel> getAllTree(Boolean showXdy, Integer ztShow, Long productId) { | 
 |  |  |         List<XhProductModel> productList = null; | 
 |  |  |         List<XhProductModel> productList = new ArrayList<>(); | 
 |  |  |         if (showXdy) { | 
 |  |  |             if (productId != null) { | 
 |  |  |                 productList = baseDao.selectList(new QueryWrapper<XhProductModel>().eq(Constant.TableColumn.IS_DELETE, | 
 |  |  | 
 |  |  |                     productList = baseDao.selectList(new QueryWrapper<XhProductModel>().eq(Constant.TableColumn.IS_DELETE, | 
 |  |  |                             Constant.Bool.NO).lt("product_type", 5).ne("product_type", 1).and(wrapper -> wrapper.eq("ship_id", productId).or().eq("id", productId)).orderByAsc(Constant.TableColumn.SORT)); | 
 |  |  |                 } else if (ztShow == 5) { | 
 |  |  |                     productList = baseDao.selectList(new QueryWrapper<XhProductModel>().eq(Constant.TableColumn.IS_DELETE, | 
 |  |  |                             Constant.Bool.NO).gt("product_type", 1).and(wrapper -> wrapper.eq("ship_id", productId).or().eq("id", productId)).orderByAsc(Constant.TableColumn.SORT)); | 
 |  |  |                     List<XhProductModel> dbList = baseDao.getProductListByShip(productId,2,5); | 
 |  |  |                     for (XhProductModel row : dbList) { | 
 |  |  |                         if (row.getSameSbNum()!=null && row.getSameSbNum() > 1) { | 
 |  |  |                             for (int i = 1; i <= row.getSameSbNum(); i++) { | 
 |  |  |                                 try { | 
 |  |  |                                     XhProductModel newRow = row.clone(); | 
 |  |  |                                     newRow.setDeviceNo(i); | 
 |  |  |                                     newRow.setName(row.getName() + "-" + i); | 
 |  |  |                                     newRow.setDataId(row.getId().toString() + "-" + i); | 
 |  |  |                                     productList.add(newRow); | 
 |  |  |                                 } catch (CloneNotSupportedException e) { | 
 |  |  |                                     e.printStackTrace(); | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } else { | 
 |  |  |                             row.setDeviceNo(0); | 
 |  |  |                             row.setDataId(row.getId().toString()); | 
 |  |  |                             productList.add(row); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     productList.sort(Comparator.comparing(XhProductModel::getSort, Comparator.naturalOrder()) | 
 |  |  |                             .thenComparing(XhProductModel::getDeviceNo, Comparator.naturalOrder())); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |         return baseDao.getNo(pid, productType); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<XhProductModel> getProductList() { | 
 |  |  |         List<XhProductModel> ProductList = baseDao.getProductList(); | 
 |  |  |     public List<XhProductModel> getProductList(Long shipId, Integer type) { | 
 |  |  |         List<XhProductModel> ProductList = baseDao.getProductList(shipId,type); | 
 |  |  |         return TreeUtils.build(ProductList); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         ParamData itemEntity = new ParamData(); | 
 |  |  |                         itemEntity.setShipId(shipId); | 
 |  |  |                         itemEntity.setProductId(curXtId); | 
 |  |  |                         itemEntity.setBasicUnitNum(1); | 
 |  |  |                         paramDataService.insert(itemEntity); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         ParamData itemEntity = new ParamData(); | 
 |  |  |                         itemEntity.setShipId(shipId); | 
 |  |  |                         itemEntity.setProductId(curFxtId); | 
 |  |  |                         itemEntity.setBasicUnitNum(1); | 
 |  |  |                         paramDataService.insert(itemEntity); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     xhProductModel.setPid(curFxtId == null ? curXtId : curFxtId); | 
 |  |  |                     xhProductModel.setId(curSbId); | 
 |  |  |                     xhProductModel.setName(sb); | 
 |  |  |                     //xhProductModel.setSameSbName(sameSbName); | 
 |  |  |                     xhProductModel.setSameSbNum(sameSbNum); | 
 |  |  |                     xhProductModel.setEquipType(equipType); | 
 |  |  |                     xhProductModel.setProductType("5"); | 
 |  |  |                     xhProductModel.setSort(Integer.valueOf(sort)); | 
 |  |  | 
 |  |  |                     //绑定设备ID | 
 |  |  |                     itemEntity.setShipId(shipId); | 
 |  |  |                     itemEntity.setProductId(curSbId); | 
 |  |  |                     itemEntity.setBasicUnitNum(sameSbNum); | 
 |  |  |                     itemEntity.setReliabDistribType(reliabType.get(reliabDistribType)); | 
 |  |  |                     itemEntity.setBasicJoinCompute(isOrNot.get(basicJoinCompute)); | 
 |  |  |                     itemEntity.setBasicUnitNum(sameSbNum); | 
 |  |  |                     itemEntity.setBasicMtbfRegulate(basicMtbfRegulate); | 
 |  |  |                     itemEntity.setBasicMtbfRegulSuccRate(basicMtbfRegulSuccRate); | 
 |  |  |                     itemEntity.setBasicMtbfOperatingRatio(basicMtbfOperatingRatio); | 
 |  |  | 
 |  |  |         List<ProductDto> data = baseDao.getProductByShip(shipId); | 
 |  |  |         data = TreeUtils.build(data); | 
 |  |  |         List<ProductDto> List = new ArrayList<>(); | 
 |  |  |         this.writeExcel(data, List); | 
 |  |  |         this.writeList(data, List); | 
 |  |  |         // 读取模板文件 | 
 |  |  |         try (InputStream inputStream = getClass().getResourceAsStream("/产品结构树导出模板.xlsx")) { | 
 |  |  |             Workbook workbook = new XSSFWorkbook(inputStream); | 
 |  |  | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     cell = row.createCell(4); | 
 |  |  |                     if (StringUtils.isNotBlank(List.get(i).getSameSbName())) { | 
 |  |  |                         cell.setCellValue(List.get(i).getSameSbName()); | 
 |  |  |                     } | 
 |  |  |                     cell.setCellValue(List.get(i).getSameSbNum()); | 
 |  |  |  | 
 |  |  |                     cell = row.createCell(5); | 
 |  |  |                     if (StringUtils.isNotBlank(List.get(i).getEquipType())) { | 
 |  |  |                         cell.setCellValue(List.get(i).getEquipType()); | 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void writeExcel(List<ProductDto> data, List<ProductDto> List) { | 
 |  |  |     private void writeList(List<ProductDto> data, List<ProductDto> List) { | 
 |  |  |         for (ProductDto dto : data) { | 
 |  |  |             List.add(dto); | 
 |  |  |             writeExcel(dto.getChildren(), List); | 
 |  |  |             writeList(dto.getChildren(), List); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     public void refreshCache() { | 
 |  |  |         List<XhProductModel> productList = baseDao.getProductListAll(); | 
 |  |  |         Map<Long, XhProductModel> imgMap = new HashMap<>(); | 
 |  |  |         for (XhProductModel product : productList) { | 
 |  |  |             imgMap.put(product.getId(), product); | 
 |  |  |         } | 
 |  |  |         CacheUtils.put("sysImgCache", "sysImgCache", imgMap); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void getImg(HttpServletResponse response, Long id) { | 
 |  |  |         Map<Long, XhProductModel> imgMap = new HashMap<>(); | 
 |  |  |         imgMap = (Map<Long, XhProductModel>) CacheUtils.get("sysImgCache","sysImgCache"); | 
 |  |  |         XhProductModel product = imgMap.get(id); | 
 |  |  |         sysPictureBaseService.getSvgImage(response,product.getOperatImg()); | 
 |  |  |     } | 
 |  |  | } |