From 1f8a3f7f6f1c7ac98266e892a089db27e2c7dc8a Mon Sep 17 00:00:00 2001 From: fangjiakai <450850793@qq.com> Date: Wed, 31 Jan 2024 10:22:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E7=81=AB=E4=BD=9C=E4=B8=9A=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BD=9C=E4=B8=9A=E4=BD=8D=E7=BD=AE=E5=9D=90=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/eightwork/HotworkMapper.java | 10 ++++ .../eightwork/impl/HotworkServiceImpl.java | 23 ++++----- src/main/java/com/zcloud/util/PLSUtil.java | 51 +++++++++++++++++++ .../datasource/eightwork/HotWorkMapper.xml | 10 ++++ 4 files changed, 81 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/zcloud/mapper/datasource/eightwork/HotworkMapper.java b/src/main/java/com/zcloud/mapper/datasource/eightwork/HotworkMapper.java index 721cc7c..a318f90 100644 --- a/src/main/java/com/zcloud/mapper/datasource/eightwork/HotworkMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/eightwork/HotworkMapper.java @@ -11,12 +11,21 @@ import java.util.List; */ public interface HotworkMapper { PageData getCode(PageData pd); + PageData findById(PageData pd); + void save(PageData pd); + void delete(PageData pd); + void edit(PageData pd); + void editGasTime(PageData pd); + void editStep(PageData pd); + + void setPosition(PageData pd); + List datalistPage(Page page); List namelist(PageData pd); @@ -26,4 +35,5 @@ public interface HotworkMapper { List checkWorkCount(PageData pd); List getFlowList(PageData pd); + } diff --git a/src/main/java/com/zcloud/service/eightwork/impl/HotworkServiceImpl.java b/src/main/java/com/zcloud/service/eightwork/impl/HotworkServiceImpl.java index 3c70da6..c1c5a26 100644 --- a/src/main/java/com/zcloud/service/eightwork/impl/HotworkServiceImpl.java +++ b/src/main/java/com/zcloud/service/eightwork/impl/HotworkServiceImpl.java @@ -9,10 +9,7 @@ import com.zcloud.entity.PageData; import com.zcloud.mapper.datasource.eightwork.*; import com.zcloud.service.eightwork.HotworkService; import com.zcloud.service.mq.SendMessageService; -import com.zcloud.util.Const; -import com.zcloud.util.DateUtil; -import com.zcloud.util.Smb; -import com.zcloud.util.UuidUtil; +import com.zcloud.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -71,6 +68,7 @@ public class HotworkServiceImpl implements HotworkService { PageData flow = getStep(pd.get("TASK_ID"),"1"); saveLog(pd,pd.getString("CREATOR"),"1"); saveNextSigner(pd,flow); + setPosition(pd); } } @@ -86,6 +84,7 @@ public class HotworkServiceImpl implements HotworkService { PageData flow = getStep(pd.get("TASK_ID"),"1"); saveLog(pd,pd.getString("CREATOR"),"1"); saveNextSigner(pd,flow); + setPosition(pd); } } @@ -388,14 +387,12 @@ public class HotworkServiceImpl implements HotworkService { eightWorkFlowLogMapper.save(log); } -// private void saveNext(PageData pd,PageData flow) throws Exception { -// PageData log = new PageData(); -// log.put("LOG_ID", UuidUtil.get32UUID()); -// log.put("WORK_ID", pd.get(primary_key)); -// log.put("TASK_ID", pd.get("TASK_ID")); -// log.put("STEP_ID", flow.get("NEXT_STEP_ID")); -// log.put("STATUS", "0"); -// eightWorkFlowLogMapper.save(log); -// } + private void setPosition(PageData pd) throws Exception { + JSONObject body = PLSUtil.getRyRegionInfo(Jurisdiction.getCORPINFO_ID(),Integer.parseInt(pd.getString("PLS_ID"))); + List pointList = (List)((Map) body.get("data")).get("list"); + List positions = PLSUtil.getRandomPointInPolygon(pointList); + pd.put("WORK_POSITION", String.join(",",positions)); + hotworkMapper.setPosition(pd); + } } diff --git a/src/main/java/com/zcloud/util/PLSUtil.java b/src/main/java/com/zcloud/util/PLSUtil.java index 2cb6b58..11dce0b 100644 --- a/src/main/java/com/zcloud/util/PLSUtil.java +++ b/src/main/java/com/zcloud/util/PLSUtil.java @@ -515,4 +515,55 @@ public class PLSUtil { } return pageData; } + + /** + * 获取区域内随机坐标点 + * + * @param polygon [[lng,lat,alt],[lng,lat,alt],[lng,lat,alt],...] + * @return [lng,lat,alt] + * @throws IOException + */ + public static List getRandomPointInPolygon(List> polygon) { + double minX = Double.POSITIVE_INFINITY; + double minY = Double.POSITIVE_INFINITY; + double maxX = Double.NEGATIVE_INFINITY; + double maxY = Double.NEGATIVE_INFINITY; + + for (List point : polygon) { + minX = Math.min(minX, point.get(0)); + minY = Math.min(minY, point.get(1)); + maxX = Math.max(maxX, point.get(0)); + maxY = Math.max(maxY, point.get(1)); + } + + Random rand = new Random(); + while (true) { + Double x = minX + rand.nextDouble() * (maxX - minX); + Double y = minY + rand.nextDouble() * (maxY - minY); + + if (pointInPolygon(polygon, x, y)) { + List point = Arrays.asList(x.toString(),y.toString(),polygon.get(0).get(2).toString()); + return point; + } + } + } + + /** + * 判断点是否在多边形内 + * @param polygon + * @param lng + * @param lat + * @return + */ + private static boolean pointInPolygon(List> polygon,double lng, double lat) { + boolean inside = false; + int n = polygon.size(); + for (int i = 0, j = n - 1; i < n; j = i++) { + if (((polygon.get(i).get(1) > lat) != (polygon.get(j).get(1) > lat)) && + (lng < (polygon.get(j).get(0) - polygon.get(i).get(0)) * (lat - polygon.get(i).get(1)) / (polygon.get(j).get(1) - polygon.get(i).get(1)) + polygon.get(i).get(0))) { + inside = !inside; + } + } + return inside; + } } diff --git a/src/main/resources/mybatis/datasource/eightwork/HotWorkMapper.xml b/src/main/resources/mybatis/datasource/eightwork/HotWorkMapper.xml index 83bcfd1..7a7ff5d 100644 --- a/src/main/resources/mybatis/datasource/eightwork/HotWorkMapper.xml +++ b/src/main/resources/mybatis/datasource/eightwork/HotWorkMapper.xml @@ -393,6 +393,16 @@ HOTWORK_ID = #{HOTWORK_ID} + + + update + + set + WORK_POSITION = #{WORK_POSITION} + where + HOTWORK_ID = #{HOTWORK_ID} + +