音视频文本配置列表界面选中配置,增加编译配置id
导出excel增加性质、分类、标签属性值获取
This commit is contained in:
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.derby.tools.sysinfo;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Comment;
|
||||
@@ -39,10 +40,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.Encodes;
|
||||
import com.nis.util.Reflections;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.fieldtype.RoleListType;
|
||||
|
||||
/**
|
||||
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion)
|
||||
@@ -493,7 +496,7 @@ public class ExportExcel {
|
||||
* 添加数据(通过annotation.ExportField添加数据)
|
||||
* @return list 数据列表
|
||||
*/
|
||||
public <E> ExportExcel setDataList(Properties msgProp,List<E> list){
|
||||
public <E> ExportExcel setDataList(Properties msgProp,List<E> list,Map map){
|
||||
for (E e : list){
|
||||
int colunm = 0;
|
||||
Row row = this.addRow();
|
||||
@@ -512,13 +515,22 @@ public class ExportExcel {
|
||||
val = Reflections.invokeMethod(e, ((Method)os[1]).getName(), new Class[] {}, new Object[] {});
|
||||
}
|
||||
}
|
||||
// If is dict, get dict label
|
||||
// If is dict, get dict label
|
||||
if (StringUtils.isNotBlank(ef.dictType())){
|
||||
val = DictUtils.getDictLabel(ef.dictType(),val==null?"":val.toString() , "");
|
||||
String valStr=val==null?"":val.toString();
|
||||
if("type".equals(ef.dictType()) || "attribute".equals(ef.dictType())
|
||||
|| "label".equals(ef.dictType())){
|
||||
// Get basic info
|
||||
val = getBasicInfo(ef.dictType(),map,valStr);
|
||||
}else{
|
||||
//字典数据已做国际化处理
|
||||
val = msgProp.get(DictUtils.getDictLabel(ef.dictType(), valStr, ""));
|
||||
}
|
||||
|
||||
}
|
||||
}catch(Exception ex) {
|
||||
// Failure to ignore
|
||||
log.info(ex.toString());
|
||||
log.error("Get entity value failed",ex);
|
||||
val = "";
|
||||
}
|
||||
this.addCell(row, colunm++, val, ef.align(), ef.fieldType());
|
||||
@@ -528,7 +540,52 @@ public class ExportExcel {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置性质、分类、标签等信息
|
||||
* @param dictType
|
||||
* @param map
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
public String getBasicInfo(String dictType,Map map,String val) {
|
||||
String basicInfo="";
|
||||
List<ServiceDictInfo> list=new ArrayList<ServiceDictInfo>();
|
||||
if("type".equals(dictType)){
|
||||
list=(List<ServiceDictInfo>) map.get("fls");
|
||||
for (String info : val.split(",")) {
|
||||
for (ServiceDictInfo dictInfo : list) {
|
||||
if(info.equals(dictInfo.getServiceDictId().toString())){
|
||||
basicInfo+=","+dictInfo.getItemValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if("attribute".equals(dictType)){
|
||||
list=(List<ServiceDictInfo>) map.get("xzs");
|
||||
for (String info : val.split(",")) {
|
||||
for (ServiceDictInfo dictInfo : list) {
|
||||
if(info.equals(dictInfo.getServiceDictId().toString())){
|
||||
basicInfo+=","+dictInfo.getItemValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if("label".equals(dictType)){
|
||||
list=(List<ServiceDictInfo>) map.get("labels");
|
||||
for (String info : val.split(",")) {
|
||||
for (ServiceDictInfo dictInfo : list) {
|
||||
if(info.equals(dictInfo.getServiceDictId().toString())){
|
||||
basicInfo+=","+dictInfo.getItemValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(basicInfo)){
|
||||
basicInfo=basicInfo.substring(1);
|
||||
}
|
||||
return basicInfo;
|
||||
}
|
||||
/**
|
||||
* 输出数据流
|
||||
* @param os 输出数据流
|
||||
@@ -594,7 +651,7 @@ public class ExportExcel {
|
||||
*/
|
||||
public static void main(String[] args) throws Throwable {
|
||||
|
||||
List<String> headerList = Lists.newArrayList();
|
||||
/*List<String> headerList = Lists.newArrayList();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
headerList.add("表头"+i);
|
||||
}
|
||||
@@ -623,7 +680,7 @@ public class ExportExcel {
|
||||
ee.dispose();
|
||||
|
||||
log.debug("Export success.");
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user