|
|
package com.engine.hostar.util;
|
|
|
|
|
|
import weaver.formmode.setup.ModeRightInfo;
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author chenwnj
|
|
|
* @date 2023/12/14
|
|
|
* @description
|
|
|
**/
|
|
|
public class HostarUtil {
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
// 地球半径,单位:米
|
|
|
private static final int EARTH_RADIUS = 6371000;
|
|
|
|
|
|
/**
|
|
|
* 根据开始日期和结束日期,计算出之间的所有日期
|
|
|
* @params startDate 指定日期
|
|
|
* @params endDate 结束日期
|
|
|
*/
|
|
|
public List<String> getAllDates(String startDate, String endDate) {
|
|
|
List<String> result = new ArrayList<>();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
LocalDate start = LocalDate.parse(startDate, formatter);
|
|
|
LocalDate end = LocalDate.parse(endDate, formatter);
|
|
|
|
|
|
while (!start.isAfter(end)) {
|
|
|
result.add(start.format(formatter));
|
|
|
start = start.plusDays(1);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**经度、纬度
|
|
|
* 判断两个经纬度坐标之间的距离
|
|
|
* @params lat1 坐标1的纬度
|
|
|
* @params lon1 坐标1的经度
|
|
|
* @params lat2 坐标2的纬度
|
|
|
* @params lon2 坐标2的经度
|
|
|
* @return 坐标1、2间距离(米)
|
|
|
*/
|
|
|
public Double calculateDistance(Double lat1, Double lon1, Double lat2, Double lon2) {
|
|
|
double dLat = Math.toRadians(lat2 - lat1);
|
|
|
double dLon = Math.toRadians(lon2 - lon1);
|
|
|
|
|
|
lat1 = Math.toRadians(lat1);
|
|
|
lat2 = Math.toRadians(lat2);
|
|
|
|
|
|
double a = Math.pow(Math.sin(dLat / 2), 2) + Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
|
|
|
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
|
|
return EARTH_RADIUS * c;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 建模权限重构
|
|
|
* @param userId
|
|
|
* @param modeId
|
|
|
* @param billid
|
|
|
*/
|
|
|
public void modePerRecon(Integer userId, String modeId, String billid) {
|
|
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
|
|
ModeRightInfo.setNewRight(true);
|
|
|
ModeRightInfo.editModeDataShare( userId, Integer.parseInt(modeId), Integer.parseInt(billid));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 建模权限重构
|
|
|
* @param billid_creator
|
|
|
* @param modeId
|
|
|
* @param billids
|
|
|
*/
|
|
|
public void modePerReconBatch(Map<Integer,Integer> billid_creator, String modeId, List<Integer> billids) {
|
|
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
|
|
ModeRightInfo.setNewRight(true);
|
|
|
ModeRightInfo.editModeDataShare( billid_creator, Integer.parseInt(modeId), billids);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|