自定义报表代码提交
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package com.njcn.common.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/10/21 9:32【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public class NjcnBeanUtil {
|
||||
|
||||
|
||||
/**
|
||||
* beancopy
|
||||
* 大小写可以忽略
|
||||
* 下划线 _ 被忽略
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T copyPropertiesIgnoreCase(Object source, Object target) {
|
||||
Map<String, Field> sourceMap = CacheFieldMap.getFieldMap (source.getClass ( ));
|
||||
CacheFieldMap.getFieldMap (target.getClass ( )).values ( ).forEach ((it) -> {
|
||||
Field field = sourceMap.get (it.getName ( ).toLowerCase ( ).replace ("_", ""));
|
||||
if (field != null) {
|
||||
it.setAccessible (true);
|
||||
field.setAccessible (true);
|
||||
try {
|
||||
//忽略null和空字符串
|
||||
// if(field.get(source)!=null&& StringUtils.isBlank(field.get(source).toString()))
|
||||
it.set (target, field.get (source));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace ( );
|
||||
}
|
||||
}
|
||||
});
|
||||
System.out.println (target.toString ( ));
|
||||
return (T) target;
|
||||
}
|
||||
|
||||
private static class CacheFieldMap {
|
||||
private static Map<String, Map<String, Field>> cacheMap = new HashMap<> ( );
|
||||
|
||||
private static Map<String, Field> getFieldMap(Class clazz) {
|
||||
Map<String, Field> result = cacheMap.get (clazz.getName ( ));
|
||||
if (result == null) {
|
||||
synchronized (CacheFieldMap.class) {
|
||||
if (result == null) {
|
||||
Map<String, Field> fieldMap = new HashMap<> ( );
|
||||
for (Field field : getAllFields (clazz)) {
|
||||
fieldMap.put (field.getName ( ).toLowerCase ( ).replace ("_", ""), field);
|
||||
}
|
||||
cacheMap.put (clazz.getName ( ), fieldMap);
|
||||
result = cacheMap.get (clazz.getName ( ));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本类及其父类的字段属性
|
||||
*
|
||||
* @param clazz 当前类对象
|
||||
* @return 字段数组
|
||||
*/
|
||||
public static Field[] getAllFields(Class<?> clazz) {
|
||||
List<Field> fieldList = new ArrayList<> ( );
|
||||
while (clazz != null) {
|
||||
fieldList.addAll (new ArrayList<> (Arrays.asList (clazz.getDeclaredFields ( ))));
|
||||
clazz = clazz.getSuperclass ( );
|
||||
}
|
||||
Field[] fields = new Field[fieldList.size ( )];
|
||||
return fieldList.toArray (fields);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.harmonic.pojo.vo.ReportTemplateVO;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -22,5 +23,5 @@ public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
|
||||
|
||||
List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
|
||||
|
||||
List<ReportTemplateVO> getReportTemplateByDept(@Param("deptId")String deptId);
|
||||
List<ReportTemplateVO> getReportTemplateByDept(@Param("list") List<DeptDTO> list);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
|
||||
WHERE
|
||||
a.state = 1
|
||||
and b.dept_id = #{deptId}
|
||||
and b.dept_id in
|
||||
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -31,6 +31,8 @@ import com.njcn.influxdb.param.InfluxDBTableConstant;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -150,7 +152,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
@Override
|
||||
public List<ReportTemplateVO> getTemplateByDept(String id) {
|
||||
return excelRptTempMapper.getReportTemplateByDept(id);
|
||||
//获取子孙部门,去重
|
||||
List<DeptDTO> depts = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData().stream().distinct().collect(Collectors.toList());
|
||||
return excelRptTempMapper.getReportTemplateByDept(depts);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user