管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-03-13 faf2f21a483e5b90bb15457f4edb37e37705aaee
src/main/java/com/lf/server/service/show/OneMapService.java
@@ -3,10 +3,17 @@
import com.lf.server.entity.bs.MpipelineEntity;
import com.lf.server.entity.ctrl.CountEntity;
import com.lf.server.entity.show.OneMapEntity;
import com.lf.server.helper.PathHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.show.OneMapMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.lf.server.service.data.FmeService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -18,25 +25,36 @@
 */
@Service
public class OneMapService implements OneMapMapper {
    @Autowired
    @Resource
    OneMapMapper oneMapMapper;
    @Resource
    FmeService fmeService;
    @Resource
    PathHelper pathHelper;
    /**
     * 测绘
     */
    private static final String MEASUREMENT = "测绘(ESV)";
    /**
     * 调查
     */
    private static final String TOINVESTIGATE = "勘察(EGE)";
    /**
     * 地灾
     */
    private static final String DISASTER = "地灾(EGD)";
    /**
     * 地下结构洞库
     */
    private static final String UNDERGROUNDSTRUCTURE = "洞库(EGD)";
    private final static Log log = LogFactory.getLog(OneMapService.class);
    /**
     * 项目类别conut
@@ -255,7 +273,6 @@
        return null;
    }
    /**
     * 查询表信息
     *
@@ -375,4 +392,60 @@
    public List<CountEntity> countByMajor() {
        return oneMapMapper.countByMajor();
    }
    @Override
    public Integer selectLineBuffer() {
        try {
            return oneMapMapper.selectLineBuffer();
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return 0;
        }
    }
    @Override
    public List<Map<String, Object>> selectMetaByType() {
        try {
            return oneMapMapper.selectMetaByType();
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
        }
    }
    /**
     * 计算数据
     */
    public String calcData() {
        Integer rows = selectLineBuffer();
        List<String> ids = new ArrayList<>();
        List<Map<String, Object>> list = selectMetaByType();
        if (null != list && list.size() > 0) {
            String rootPath = pathHelper.getConfig().getUploadPath();
            for (Map<String, Object> map : list) {
                try {
                    String sjfl = map.get("type").toString();
                    String id = map.get("id").toString();
                    String wjlj = rootPath + File.separator + map.get("path").toString();
                    File file = new File(wjlj);
                    if (!file.exists()) {
                        continue;
                    }
                    String guid = fmeService.calcArea(sjfl, id, wjlj);
                    if (StringUtils.isEmpty(guid)) {
                        ids.add(guid);
                        rows++;
                    }
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
            }
            System.out.println(StringHelper.join(ids, ","));
        }
        return String.format("共处理了 %d 条记录", rows);
    }
}