forked from integrated_whb/integrated_whb
动火作业设置作业位置坐标
parent
e7e3ed29e9
commit
1f8a3f7f6f
|
@ -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<PageData> datalistPage(Page page);
|
||||
|
||||
List<PageData> namelist(PageData pd);
|
||||
|
@ -26,4 +35,5 @@ public interface HotworkMapper {
|
|||
List<PageData> checkWorkCount(PageData pd);
|
||||
|
||||
List<PageData> getFlowList(PageData pd);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> positions = PLSUtil.getRandomPointInPolygon(pointList);
|
||||
pd.put("WORK_POSITION", String.join(",",positions));
|
||||
hotworkMapper.setPosition(pd);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,6 +393,16 @@
|
|||
HOTWORK_ID = #{HOTWORK_ID}
|
||||
</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
|
||||
|
|
Loading…
Reference in New Issue