| | |
| | | package com.lf.server.service.sys; |
| | | |
| | | import com.lf.server.entity.all.RedisCacheKey; |
| | | 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.mapper.sys.ReportMapper; |
| | | import com.lf.server.service.all.RedisService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | 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; |
| | |
| | | */ |
| | | @Service |
| | | public class ReportService implements ReportMapper { |
| | | @Value("${sys.turfServer}") |
| | | private String turfServer; |
| | | |
| | | @Resource |
| | | ReportMapper reportMapper; |
| | | |
| | |
| | | |
| | | @Resource |
| | | RedisService redisService; |
| | | |
| | | private final static Log log = LogFactory.getLog(ReportService.class); |
| | | |
| | | @Override |
| | | public Integer selectCount(String name, String code) { |
| | |
| | | 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; |
| | |
| | | continue; |
| | | } |
| | | |
| | | List<CoordinateEntity> ces = selectExplorationPoints(ce.getM3()); |
| | | if (null == ces || ces.size() < 3) { |
| | | continue; |
| | | } |
| | | |
| | | double area = JtsHelper.calcAreaByPoints(ces); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 创建报告 |
| | | */ |
| | | public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception { |