霍林河露天煤矿生产一体化平台
1
13693261870
2023-04-07 a51147871c8e862d4882f4087171b8d25e743ebd
src/main/java/service/MainService.java
@@ -4,6 +4,8 @@
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;
@@ -20,6 +22,9 @@
 */
@Service
public class MainService {
    @Autowired
    Coal54Mapper coal54Mapper;
    /**
     * 加载54数据(入库)
     */
@@ -27,23 +32,32 @@
        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) {