You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hostar/src/com/engine/hostar/util/HostarUtil.java

92 lines
2.7 KiB
Java

package com.engine.hostar.util;
1 year ago
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;
1 year ago
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 12
*/
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;
}
1 year ago
/**
*
* @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);
}
}