霍林河露天煤矿生产一体化平台
1
13693261870
2023-04-07 853e68c5d4414acdb2ea98c27572c534184338a3
1
已修改4个文件
78 ■■■■■ 文件已修改
src/main/java/com/terra/coal/controller/MainController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/terra/coal/entity/Coal54Entity.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/terra/coal/entity/StaticData.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/service/MainService.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/terra/coal/controller/MainController.java
@@ -45,7 +45,7 @@
        return mv;
    }
    @ApiOperation(value = "加载54数据入库")
    @ApiOperation(value = "加载54数据(入库)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "txtPath", value = "块体数据文件路径", dataType = "String", paramType = "query", example = "D:\\块体数据.txt")
    })
src/main/java/com/terra/coal/entity/Coal54Entity.java
@@ -47,6 +47,20 @@
    public Coal54Entity() {
    }
    public Coal54Entity(BigDecimal x, BigDecimal y, BigDecimal top, BigDecimal clong, BigDecimal width, BigDecimal height, String ctype, BigDecimal density, BigDecimal gangue) {
        this.top = top;
        this.clong = clong;
        this.width = width;
        this.height = height;
        this.ctype = ctype;
        this.density = density;
        this.gangue = gangue;
        this.bottom = top.add(height);
        this.volume = clong.multiply(width).multiply(height);
        this.geom = String.format("ST_GeomFromText('POINT (%f %f)')", x.doubleValue(), y.doubleValue());
    }
    public Integer getGid() {
        return gid;
    }
src/main/java/com/terra/coal/entity/StaticData.java
@@ -9,6 +9,8 @@
 * @author WWW
 */
public class StaticData {
    public final static Integer NINE = 9;
    public final static List<String> INSERT_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("gid", "objectid", "updateuser", "updatetime", "shape_leng", "shape_area", "serialVersionUID", "createName", "updateName"));
    public final static List<String> UPDATE_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("objectid", "createuser", "createtime", "shape_leng", "shape_area", "serialVersionUID", "createName", "updateName"));
src/main/java/service/MainService.java
@@ -1,8 +1,18 @@
package service;
import com.alibaba.druid.support.spring.stat.annotation.Stat;
import com.terra.coal.entity.Coal54Entity;
import com.terra.coal.entity.StaticData;
import com.terra.coal.helper.StringHelper;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
 * CoalService
@@ -10,9 +20,57 @@
 */
@Service
public class MainService {
    public Integer load54Data(File f){
    /**
     * 加载54数据(入库)
     */
    public Integer load54Data(File f) throws IOException {
        FileReader fr = new FileReader(f);
        BufferedReader reader = new BufferedReader(fr);
        int rows = 0;
        String line = reader.readLine();
        List<Coal54Entity> list = new ArrayList<>();
        while (null != line) {
            rows++;
            if (rows > 2) {
                Coal54Entity entity = getCoal54(line);
                if (null != entity) {
                    list.add(entity);
                }
            }
            line = reader.readLine();
        }
        reader.close();
        return 0;
    }
    private Coal54Entity getCoal54(String str) {
        if (StringHelper.isEmpty(str)) {
            return null;
        }
        String[] strs = str.split(",");
        if (strs.length < StaticData.NINE) {
            return null;
        }
        // 36240.00000,-69460.00000,634.00000,1280.000,1280.000,128.000,岩石,1,1,
        try {
            BigDecimal x = new BigDecimal("4" + strs[1].replace("-", ""));
            BigDecimal y = new BigDecimal("50" + strs[0]);
            BigDecimal top = new BigDecimal(strs[2]);
            BigDecimal clong = new BigDecimal(strs[3]);
            BigDecimal width = new BigDecimal(strs[4]);
            BigDecimal height = new BigDecimal(strs[5]);
            String ctype = strs[6];
            BigDecimal density = new BigDecimal(strs[7]);
            BigDecimal gangue = new BigDecimal(strs[8]);
            return new Coal54Entity(x, y, top, clong, width, height, ctype, density, gangue);
        } catch (Exception ex) {
            return null;
        }
    }
}