动火作业设置作业位置坐标

pull/4/head
fangjiakai 2024-01-31 10:22:34 +08:00
parent e7e3ed29e9
commit 1f8a3f7f6f
4 changed files with 81 additions and 13 deletions

View File

@ -11,12 +11,21 @@ import java.util.List;
*/ */
public interface HotworkMapper { public interface HotworkMapper {
PageData getCode(PageData pd); PageData getCode(PageData pd);
PageData findById(PageData pd); PageData findById(PageData pd);
void save(PageData pd); void save(PageData pd);
void delete(PageData pd); void delete(PageData pd);
void edit(PageData pd); void edit(PageData pd);
void editGasTime(PageData pd); void editGasTime(PageData pd);
void editStep(PageData pd); void editStep(PageData pd);
void setPosition(PageData pd);
List<PageData> datalistPage(Page page); List<PageData> datalistPage(Page page);
List<PageData> namelist(PageData pd); List<PageData> namelist(PageData pd);
@ -26,4 +35,5 @@ public interface HotworkMapper {
List<PageData> checkWorkCount(PageData pd); List<PageData> checkWorkCount(PageData pd);
List<PageData> getFlowList(PageData pd); List<PageData> getFlowList(PageData pd);
} }

View File

@ -9,10 +9,7 @@ import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.eightwork.*; import com.zcloud.mapper.datasource.eightwork.*;
import com.zcloud.service.eightwork.HotworkService; import com.zcloud.service.eightwork.HotworkService;
import com.zcloud.service.mq.SendMessageService; import com.zcloud.service.mq.SendMessageService;
import com.zcloud.util.Const; import com.zcloud.util.*;
import com.zcloud.util.DateUtil;
import com.zcloud.util.Smb;
import com.zcloud.util.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -71,6 +68,7 @@ public class HotworkServiceImpl implements HotworkService {
PageData flow = getStep(pd.get("TASK_ID"),"1"); PageData flow = getStep(pd.get("TASK_ID"),"1");
saveLog(pd,pd.getString("CREATOR"),"1"); saveLog(pd,pd.getString("CREATOR"),"1");
saveNextSigner(pd,flow); saveNextSigner(pd,flow);
setPosition(pd);
} }
} }
@ -86,6 +84,7 @@ public class HotworkServiceImpl implements HotworkService {
PageData flow = getStep(pd.get("TASK_ID"),"1"); PageData flow = getStep(pd.get("TASK_ID"),"1");
saveLog(pd,pd.getString("CREATOR"),"1"); saveLog(pd,pd.getString("CREATOR"),"1");
saveNextSigner(pd,flow); saveNextSigner(pd,flow);
setPosition(pd);
} }
} }
@ -388,14 +387,12 @@ public class HotworkServiceImpl implements HotworkService {
eightWorkFlowLogMapper.save(log); eightWorkFlowLogMapper.save(log);
} }
// private void saveNext(PageData pd,PageData flow) throws Exception { private void setPosition(PageData pd) throws Exception {
// PageData log = new PageData(); JSONObject body = PLSUtil.getRyRegionInfo(Jurisdiction.getCORPINFO_ID(),Integer.parseInt(pd.getString("PLS_ID")));
// log.put("LOG_ID", UuidUtil.get32UUID()); List pointList = (List)((Map) body.get("data")).get("list");
// log.put("WORK_ID", pd.get(primary_key)); List<String> positions = PLSUtil.getRandomPointInPolygon(pointList);
// log.put("TASK_ID", pd.get("TASK_ID")); pd.put("WORK_POSITION", String.join(",",positions));
// log.put("STEP_ID", flow.get("NEXT_STEP_ID")); hotworkMapper.setPosition(pd);
// log.put("STATUS", "0"); }
// eightWorkFlowLogMapper.save(log);
// }
} }

View File

@ -515,4 +515,55 @@ public class PLSUtil {
} }
return pageData; return pageData;
} }
/**
*
*
* @param polygon [[lng,lat,alt],[lng,lat,alt],[lng,lat,alt],...]
* @return [lng,lat,alt]
* @throws IOException
*/
public static List<String> getRandomPointInPolygon(List<List<Double>> polygon) {
double minX = Double.POSITIVE_INFINITY;
double minY = Double.POSITIVE_INFINITY;
double maxX = Double.NEGATIVE_INFINITY;
double maxY = Double.NEGATIVE_INFINITY;
for (List<Double> 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<String> 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<List<Double>> 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;
}
} }

View File

@ -393,6 +393,16 @@
HOTWORK_ID = #{HOTWORK_ID} HOTWORK_ID = #{HOTWORK_ID}
</update> </update>
<!-- 修改位置 -->
<update id="setPosition" parameterType="pd">
update
<include refid="tableName"></include>
set
WORK_POSITION = #{WORK_POSITION}
where
HOTWORK_ID = #{HOTWORK_ID}
</update>
<!-- 列表 --> <!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd"> <select id="datalistPage" parameterType="page" resultType="pd">
select select