| | |
| | | import com.lf.server.mapper.sys.ReportMapper; |
| | | import com.lf.server.service.all.RedisService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.data.PublishService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.locationtech.jts.geom.Coordinate; |
| | | 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) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | List<CoordinateEntity> ces = selectExplorationPoints(ce.getM3()); |
| | | if (null == ces || ces.size() < 3) { |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("["); |
| | | for (CoordinateEntity e : ces) { |
| | | sb.append(e.getX() + "," + e.getY() + ","); |
| | | } |
| | | sb.replace(sb.length() - 1, sb.length(), "]"); |
| | | |
| | | // double area = JtsHelper.calcAreaByPoints(ces) |
| | | double area = callJsFn(sb.toString()); |
| | | double area = calcPolygonArea(ce.getM3()); |
| | | ce.setArea(area); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 调用JS方法 |
| | | * 计算多边形面积 |
| | | */ |
| | | 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(); |