ty
10 months ago
17 changed files with 309 additions and 32 deletions
@ -0,0 +1,5 @@
|
||||
package com.hnac.hzims.common.support.constants; |
||||
|
||||
public enum Order { |
||||
ASC,DESC; |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.hnac.hzims.common.support.utils; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.google.common.collect.Lists; |
||||
import com.hnac.hzims.common.support.constants.Order; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
|
||||
import java.lang.reflect.Field; |
||||
import java.util.*; |
||||
import java.util.function.Function; |
||||
|
||||
public class Condition extends org.springblade.core.mp.support.Condition { |
||||
|
||||
public static List<Field> getFieldList(Object object) { |
||||
Class<?> clazz = object.getClass(); |
||||
List<Field> fields = Lists.newArrayList(); |
||||
while (null != clazz){ |
||||
fields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
||||
clazz = clazz.getSuperclass(); |
||||
} |
||||
return fields; |
||||
} |
||||
|
||||
public static <T> LambdaQueryWrapper<T> getQueryWrapper(Object query, Class<T> clazz, Map<String,? extends Enum<Order>> orderFields) { |
||||
QueryWrapper<T> queryWrapper = getQueryWrapper(BeanUtil.copy(query,clazz)); |
||||
List<Field> fields = getFieldList(query); |
||||
// 填充排序字段
|
||||
orderFields.forEach((fieldName,order) -> { |
||||
Optional<Field> existField = fields.stream().filter(field -> camel2under(fieldName).equals(camel2under(field.getName()))).findAny(); |
||||
if(existField.isPresent()) { |
||||
if(Order.ASC.equals(order)) { |
||||
queryWrapper.orderByAsc(fieldName); |
||||
} |
||||
else if(Order.DESC.equals(order)) { |
||||
queryWrapper.orderByDesc(fieldName); |
||||
} |
||||
} |
||||
}); |
||||
return queryWrapper.lambda(); |
||||
} |
||||
|
||||
private static String camel2under(String c) { |
||||
String separator = "_"; |
||||
c = c.replaceAll("([a-z])([A-Z])", "$1" + separator + "$2").toUpperCase(); |
||||
return c; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.hnac.hzims.safeproduct.vo; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class DangerSourceExportVO implements Serializable { |
||||
|
||||
@ExcelProperty(value = "所属站点",index = 0) |
||||
@ColumnWidth(value = 25) |
||||
private String refDeptName; |
||||
|
||||
@ExcelProperty(value = "危险源类型",index = 1) |
||||
@ColumnWidth(value = 15) |
||||
private String typeName; |
||||
|
||||
@ExcelProperty(value = "风险等级",index = 2) |
||||
@ColumnWidth(value = 20) |
||||
private String levelName; |
||||
|
||||
@ExcelProperty(value = "设备",index = 3) |
||||
@ColumnWidth(value = 15) |
||||
private String emName; |
||||
|
||||
@ExcelProperty(value = "危险源名称",index = 4) |
||||
@ColumnWidth(value = 30) |
||||
private String name; |
||||
|
||||
@ExcelProperty(value = "危险因素",index = 5) |
||||
@ColumnWidth(value = 30) |
||||
private String dangerEle; |
||||
|
||||
@ExcelProperty(value = "措施",index = 6) |
||||
@ColumnWidth(value = 40) |
||||
private String measures; |
||||
|
||||
} |
Binary file not shown.
Loading…
Reference in new issue