| | |
| | | import com.terra.coal.entity.Coal54Entity; |
| | | import com.terra.coal.entity.StaticData; |
| | | import com.terra.coal.helper.StringHelper; |
| | | import com.terra.coal.mapper.Coal54Mapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | */ |
| | | @Service |
| | | public class MainService { |
| | | @Autowired |
| | | Coal54Mapper coal54Mapper; |
| | | |
| | | /** |
| | | * 加载54数据(入库) |
| | | */ |
| | |
| | | FileReader fr = new FileReader(f); |
| | | BufferedReader reader = new BufferedReader(fr); |
| | | |
| | | int rows = 0; |
| | | int rows = 0, cc = 0; |
| | | String line = reader.readLine(); |
| | | List<Coal54Entity> list = new ArrayList<>(); |
| | | while (null != line) { |
| | | rows++; |
| | | if (rows > 2) { |
| | | cc++; |
| | | if (cc > 2) { |
| | | Coal54Entity entity = getCoal54(line); |
| | | if (null != entity) { |
| | | list.add(entity); |
| | | } |
| | | } |
| | | if (list.size() > 99) { |
| | | rows += coal54Mapper.insertBatch(list); |
| | | list.clear(); |
| | | } |
| | | |
| | | line = reader.readLine(); |
| | | } |
| | | reader.close(); |
| | | |
| | | return 0; |
| | | if (list.size() > 0) { |
| | | rows += coal54Mapper.insertBatch(list); |
| | | list.clear(); |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | | private Coal54Entity getCoal54(String str) { |