管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-02-29 671a88e789a4cd62851bbdc06bbd13b82b535246
src/main/java/com/lf/server/service/sys/ReportService.java
@@ -1,9 +1,8 @@
package com.lf.server.service.sys;
import com.lf.server.entity.all.RedisCacheKey;
import com.lf.server.entity.all.ResAuthEntity;
import com.lf.server.entity.all.SettingData;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.CoordinateEntity;
import com.lf.server.entity.ctrl.CountEntity;
import com.lf.server.entity.data.DownloadEntity;
import com.lf.server.entity.sys.AttachEntity;
@@ -13,7 +12,9 @@
import com.lf.server.mapper.sys.ReportMapper;
import com.lf.server.service.all.RedisService;
import com.lf.server.service.data.DownloadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -28,6 +29,9 @@
 */
@Service
public class ReportService implements ReportMapper {
    @Value("${sys.turfServer}")
    private String turfServer;
    @Resource
    ReportMapper reportMapper;
@@ -42,6 +46,8 @@
    @Resource
    RedisService redisService;
    private final static Log log = LogFactory.getLog(ReportService.class);
    @Override
    public Integer selectCount(String name, String code) {
@@ -133,18 +139,60 @@
        List<CountEntity> list = reportMapper.countExplorationPoints();
        if (null != list && list.size() > 0) {
            countExplorationArea(list);
            redisService.put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES);
            redisService.put(key, list, StaticData.I2, TimeUnit.MINUTES);
        }
        return list;
    }
    @Override
    public List<CoordinateEntity> selectExplorationPoints(String code) {
        return reportMapper.selectExplorationPoints(StringHelper.getRightLike(code));
    }
    /**
     * 统计钻孔点面积
     */
    private void countExplorationArea(List<CountEntity> list) {
        for (CountEntity ce : list) {
            if (0 == ce.getCount()) {
                continue;
            }
            double area = calcPolygonArea(ce.getM3());
            ce.setArea(area);
        }
    }
    /**
     * 计算多边形面积
     */
    private double calcPolygonArea(String code) {
        try {
            String url = turfServer + "/Call/CalcArea?code=" + code;
            String str = RestHelper.get(url);
            if (StringHelper.isEmpty(str)) {
                return 0d;
            }
            return Double.parseDouble(str);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return 0d;
        }
    }
    /**
     * 调用JS方法 *
     */
    private double callJsFn(String str) {
        String staticPath = PathHelper.getStaticPath();
        Object obj = JsHelper.callJsFn(staticPath + "js/turf.min.6.5.js", "pointsToPolygon", str);
        if (null == obj) {
            return 0d;
        }
        return (double) obj;
    }
    /**