生成职业代码工具类

这是一个使用Java编写的工具类OccupationUtil,可以根据aloc.xls文件生成多级联动的数据结构,适用于mui框架。数据结构包括各种职业分类,如内勤、外勤、企事业单位负责人等,并提供了详细的层级和代码。
摘要由CSDN通过智能技术生成

生成职业代码工具类,可以参考当前文件目录下的aloc.xls文件,生成这样的数据结构微链可以使用mui框架的多级联动

工具类OccupationUtil.java

 
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import com.alibaba.fastjson.JSON;
public class OccupationUtil {
   public static void main(String[] args) throws IOException, Exception {
      //alOc();
      alOc2();
   }
   public static void alOc() throws Exception, IOException{
      List<Element> rootElement=new ArrayList<Element>();
      Set<String> rootSet=new LinkedHashSet<String>();
      int start=1;
      POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D:/aloc.xls"));
      HSSFWorkbook wb = new HSSFWorkbook(fs);
      HSSFSheet sheet=wb.getSheetAt(0);
      for(int i=1;i<741;i++){
         HSSFRow hSSFRow=sheet.getRow(i);
         HSSFCell cell=hSSFRow.getCell(0);
         rootSet.add(cell.getStringCellValue());
      }
      for(String str:rootSet){
         Element element=new Element();
         element.setValue((start++)+"");
         element.setText(str);
         List<Element> secondElement=new ArrayList<Element>();
         element.setChildren(secondElement);
         Set<String> secondSet=new LinkedHashSet<String>();
         for(int i=1;i<741;i++){
            HSSFRow hSSFRow=sheet.getRow(i);
            HSSFCell cell0=hSSFRow.getCell(0);
            HSSFCell cell1=hSSFRow.getCell(1);
            if(str.equals(cell0.getStringCellValue())){
               secondSet.add(cell1.getStringCellValue());
            }
         }
         for(String str2:secondSet){
            Element element2=new Element();
            element2.setValue((start++)+"");
            element2.setText(str2);
            List<Element> thridElement=new ArrayList<Element>();
            element2.setChildren(thridElement);
            Set<String> thridSet=new LinkedHashSet<String>();
            for(int i=1;i<741;i++){
               HSSFRow hSSFRow=sheet.getRow(i);
               HSSFCell cell0=hSSFRow.getCell(0);
               HSSFCell cell1=hSSFRow.getCell(1);
               HSSFCell cell2=hSSFRow.getCell(2);
               HSSFCell cell3=hSSFRow.getCell(3);
               if(str.equals(cell0.getStringCellValue())&&str2.equals(cell1.getStringCellValue())){
                  thridSet.add(cell1.getStringCellValue());
                  Element element3=new Element();
                  element3.setText(cell3.getStringCellValue());
                  element3.setValue(cell2.getStringCellValue());
                  thridElement.add(element3)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值