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} + +