|
@@ -422,17 +422,34 @@ public class CustomFunction {
|
|
|
* @Date 2021.10.27 10:21
|
|
|
**/
|
|
|
public static Object dateAfter(Object date, Object n) {
|
|
|
- if (StringUtils.isNotEmpty(date) && StringUtils.isNumber(n)) {
|
|
|
- if (date instanceof List) {
|
|
|
- date = ((List) date).get(0);
|
|
|
+ if (StringUtils.isNotEmpty(date) && StringUtils.isNotEmpty(n)) {
|
|
|
+ List<String> dateList = ((List<String>)date);
|
|
|
+ LinkedList<Integer> offSet = new LinkedList<>();
|
|
|
+ if (n instanceof List) {
|
|
|
+ offSet.addAll((List<Integer>)n);
|
|
|
+ }else{
|
|
|
+ offSet.add(StringUtils.handObj2Integer(n));
|
|
|
}
|
|
|
- DateTime dt = new DateTime(date.toString());
|
|
|
- dt.offset(DateField.HOUR_OF_DAY, 24 * Integer.parseInt(n.toString()));
|
|
|
- //return dt.toString(DatePattern.UTC_PATTERN);
|
|
|
- return dt.toString(DatePattern.CHINESE_DATE_PATTERN);
|
|
|
+ return dateOffset(dateList,offSet);
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
+ public static Object dateOffset(List<String> dateList,LinkedList<Integer> offSet){
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ if(ListUtils.isNotEmpty(dateList)&&ListUtils.isNotEmpty(offSet)){
|
|
|
+ for(int i=0;i<dateList.size();i++){
|
|
|
+ String d= dateList.get(i);
|
|
|
+ if(StringUtils.isNotEmpty(d)) {
|
|
|
+ Integer n = StringUtils.handObj2Integer(offSet.size() > i ? offSet.get(i) : offSet.getLast());
|
|
|
+ DateTime dt = new DateTime(d);
|
|
|
+ dt.offset(DateField.HOUR_OF_DAY, 24 * n);
|
|
|
+ result.add(dt.toString(DatePattern.CHINESE_DATE_PATTERN));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static Object weather(List<Object> date,Map<String,Object> map){
|
|
|
if(ListUtils.isNotEmpty(date)&&map!=null){
|
|
@@ -1540,7 +1557,7 @@ public class CustomFunction {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return java.util.List<java.lang.Object>
|
|
|
+ * @return java.util.List<java.lang.Object> 不能包含0
|
|
|
* @Description specifiedRangeList
|
|
|
* @Param [hz:频率, design:设计值, dev:偏差范围, xN 偏差范围单位和设计值单位的比值,例如毫米:厘米=0.1, scale:保存小数位, passRate:合格率[0,1]]
|
|
|
* @Author yangyj
|
|
@@ -1570,12 +1587,15 @@ public class CustomFunction {
|
|
|
int hzi = new BigDecimal(hz.toString()).multiply(new BigDecimal(passRate.toString())).setScale(0, ROUND_CEILING).intValue();
|
|
|
for (int i = 0; i < hzi; i++) {
|
|
|
BigDecimal tb = new BigDecimal(rd.nextInt(max - min + 1) + min).divide(BigDecimal.valueOf(Math.pow(10, scaleI)), scaleI, ROUND_HALF_UP);
|
|
|
- if (scaleI > 0) {
|
|
|
- result.add(tb.doubleValue());
|
|
|
- } else {
|
|
|
- result.add(tb.intValue());
|
|
|
+ if(tb.equals(BigDecimal.ZERO)){
|
|
|
+ i--;
|
|
|
+ }else{
|
|
|
+ if (scaleI > 0) {
|
|
|
+ result.add(tb.doubleValue());
|
|
|
+ } else {
|
|
|
+ result.add(tb.intValue());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
int total = StringUtils.handleObj2Integer(hz);
|
|
|
if (total - hzi > 0) {
|
|
@@ -1586,10 +1606,14 @@ public class CustomFunction {
|
|
|
} else {
|
|
|
tb = new BigDecimal(min - 1 - rd.nextInt(((max - min) / 2))).divide(BigDecimal.valueOf(Math.pow(10, scaleI)), scaleI, ROUND_HALF_UP);
|
|
|
}
|
|
|
- if (scaleI > 0) {
|
|
|
- result.add(tb.doubleValue());
|
|
|
- } else {
|
|
|
- result.add(tb.intValue());
|
|
|
+ if(tb.equals(BigDecimal.ZERO)){
|
|
|
+ k--;
|
|
|
+ }else {
|
|
|
+ if (scaleI > 0) {
|
|
|
+ result.add(tb.doubleValue());
|
|
|
+ } else {
|
|
|
+ result.add(tb.intValue());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (ListUtils.isNotEmpty(result)) {
|
|
@@ -1600,6 +1624,9 @@ public class CustomFunction {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+/* public static void main(String[] args) {
|
|
|
+ rangeList(100,0,"-5,5",1,0,1).forEach(System.out::println);
|
|
|
+ }*/
|
|
|
/**
|
|
|
* @return java.util.List<java.lang.Object>
|
|
|
* @Description obj 转List
|
|
@@ -2577,13 +2604,5 @@ public class CustomFunction {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- List<Double> list1 = Arrays.asList(8.2);
|
|
|
- List<Double> list2 = Arrays.asList(7.9);
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("A",list1);
|
|
|
- map.put("B",list2);
|
|
|
- System.out.println(Expression.parse("A-B").calculate(map).toString());
|
|
|
- }
|
|
|
|
|
|
}
|