|
@@ -25,6 +25,7 @@ import org.jsoup.nodes.Element;
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springblade.business.dto.ImportTreeDto;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -136,6 +137,61 @@ public class WbsTreeContractController extends BladeController {
|
|
}
|
|
}
|
|
return R.fail(400, "导入失败");
|
|
return R.fail(400, "导入失败");
|
|
}
|
|
}
|
|
|
|
+ @PostMapping("/importTree")
|
|
|
|
+ @ApiOperationSupport(order = 31)
|
|
|
|
+ @ApiOperation(value = "导入工程划分树", notes = "传入MultipartFile")
|
|
|
|
+ public R importTree(@RequestParam("file") MultipartFile file, @RequestParam Long pkeyId) throws IOException {
|
|
|
|
+ iWbsTreeContractService.importTree(file,pkeyId);
|
|
|
|
+ InputStream inputStream = file.getInputStream();
|
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ List<ImportTreeDto>list=new ArrayList<>();
|
|
|
|
+ for (int i = 2; i <= sheet.getLastRowNum(); i++){
|
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
|
+ if (row == null) continue;
|
|
|
|
+ // 获取每一列的值
|
|
|
|
+ String unitName = getCellValue(row.getCell(0)); // A列:单位工程名称
|
|
|
|
+ String unitCode = getCellValue(row.getCell(1)); // B列:单位工程编号
|
|
|
|
+ String subUnitName = getCellValue(row.getCell(2)); // C列:子单位工程名称
|
|
|
|
+ String subUnitCode = getCellValue(row.getCell(3)); // D列:子单位工程编号
|
|
|
|
+ String divisionName = getCellValue(row.getCell(4)); // E列:分部工程名称
|
|
|
|
+ String divisionCode = getCellValue(row.getCell(5)); // F列:分部工程编号
|
|
|
|
+ String subDivisionName = getCellValue(row.getCell(6)); // G列:子分部工程名称
|
|
|
|
+ String subDivisionCode = getCellValue(row.getCell(7)); // H列:子分部工程编号
|
|
|
|
+ String itemName = getCellValue(row.getCell(8)); // I列:分项工程名称
|
|
|
|
+ String itemCode = getCellValue(row.getCell(9)); // J列:分项工程编号
|
|
|
|
+ String subItemName = getCellValue(row.getCell(10)); // K列:子分项工程名称
|
|
|
|
+ String subItemCode = getCellValue(row.getCell(11));// L列:子分项工程编号
|
|
|
|
+ ImportTreeDto dto=new ImportTreeDto(unitName,unitCode,subUnitName,subUnitCode,divisionName,divisionCode, subDivisionName,subDivisionCode,itemName,itemCode,subItemName,subItemCode);
|
|
|
|
+ list.add(dto);
|
|
|
|
+ }
|
|
|
|
+ String sql="select * from m_wbs_tree_private where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreePrivate wbsTreePrivate = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
|
+
|
|
|
|
+ //先查出这个节点下所有的树
|
|
|
|
+
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取单元格的值
|
|
|
|
+ *
|
|
|
|
+ * @param cell 单元格
|
|
|
|
+ * @return 单元格的值(字符串)
|
|
|
|
+ */
|
|
|
|
+ private static String getCellValue(Cell cell) {
|
|
|
|
+ if (cell == null) {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ switch (cell.getCellType()) {
|
|
|
|
+ case 1:
|
|
|
|
+ return cell.getStringCellValue();
|
|
|
|
+ case 0:
|
|
|
|
+ return String.valueOf((int) cell.getNumericCellValue());
|
|
|
|
+ default:
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
@PostMapping("/import-relation")
|
|
@PostMapping("/import-relation")
|
|
@ApiOperationSupport(order = 4)
|
|
@ApiOperationSupport(order = 4)
|