|
|
@@ -15,7 +15,11 @@ import java.util.Map;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.components.poi.excel.entity.enmus.ExcelType;
|
|
|
+import com.lc.ibps.components.poi.excel.export.styler.ExcelExportStylerColorImpl;
|
|
|
+import com.lc.ibps.components.poi.excel.export.styler.ExcelExportStylerDefaultImpl;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
@@ -1290,7 +1294,7 @@ public class DataTemplateProvider extends GenericProvider implements IDataTempla
|
|
|
* @param exportColumns
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<ExcelExportEntity> getEntityList(String exportColumns) {
|
|
|
+ private List<ExcelExportEntity> getEntityList(String exportColumns,double width,boolean isWrap) {
|
|
|
List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
|
|
|
if (JsonUtil.isEmpty(exportColumns)) {
|
|
|
return entityList;
|
|
|
@@ -1301,7 +1305,21 @@ public class DataTemplateProvider extends GenericProvider implements IDataTempla
|
|
|
JSONObject jsonObject = (JSONObject) obj;
|
|
|
String name = JsonUtil.getString(jsonObject, "name");
|
|
|
if (StringUtil.isNotEmpty(name)) {
|
|
|
- entityList.add(new ExcelExportEntity(JsonUtil.getString(jsonObject, "label"), name));
|
|
|
+ ExcelExportEntity entity = new ExcelExportEntity(JsonUtil.getString(jsonObject, "label"), name);
|
|
|
+ String labelDesc = JsonUtil.getString(jsonObject, "labelDesc");
|
|
|
+ if (StringUtil.isNotEmpty(labelDesc)) {
|
|
|
+ entity.setComment(labelDesc);
|
|
|
+ }
|
|
|
+ double labelWidth = JsonUtil.getDouble(jsonObject, "labelWidth");
|
|
|
+ entity.setWidth(labelWidth == 0 ? width : labelWidth);
|
|
|
+ String lineWrap = JsonUtil.getString(jsonObject, "lineWrap");
|
|
|
+ if(StringUtil.isNotEmpty(lineWrap)){
|
|
|
+ entity.setWrap(BooleanUtils.toBoolean(lineWrap));
|
|
|
+ }else{
|
|
|
+ entity.setWrap(isWrap);
|
|
|
+ }
|
|
|
+
|
|
|
+ entityList.add(entity);
|
|
|
}
|
|
|
|
|
|
// 收集字段权限信息
|
|
|
@@ -1607,12 +1625,15 @@ public class DataTemplateProvider extends GenericProvider implements IDataTempla
|
|
|
|
|
|
String pk = JsonUtil.getString(responseData, "unique", "ID_");
|
|
|
|
|
|
+ double width = JsonUtil.getDouble(responseData, "labelWidth", 10);
|
|
|
+ boolean isWrap = JsonUtil.getBoolean(responseData, "lineWrap", false);
|
|
|
+
|
|
|
String datasetKey = JsonUtil.getString(responseData, "datasetKey");
|
|
|
DatasetPo datasetPo = datasetRepository.getDatasetByKey(datasetKey);
|
|
|
|
|
|
responseData.element("isExport", true);
|
|
|
List<?> list;
|
|
|
- if ("exportMuBan".equals(action)){
|
|
|
+ if ("exportTemplate".equals(action)){
|
|
|
list = new ArrayList<>();
|
|
|
}else {
|
|
|
list = dataTemplateRepository.queryForList(new ResponseDataTemplateVo(responseData, queryFilter));
|
|
|
@@ -1621,7 +1642,7 @@ public class DataTemplateProvider extends GenericProvider implements IDataTempla
|
|
|
throw new RuntimeException(I18nUtil.getMessage("com.lc.ibps.form.provider.DataTemplateProvider.exportDataMap.error.exportColumns"));
|
|
|
}
|
|
|
// 导出字段对象的实体
|
|
|
- List<ExcelExportEntity> entityList = getEntityList(JsonUtil.getString(exportColumns, "fields"));
|
|
|
+ List<ExcelExportEntity> entityList = getEntityList(JsonUtil.getString(exportColumns, "fields"),width,isWrap);
|
|
|
if(BeanUtils.isEmpty(entityList)){
|
|
|
throw new RuntimeException(I18nUtil.getMessage("com.lc.ibps.form.provider.DataTemplateProvider.exportDataMap.error.entityList"));
|
|
|
}
|
|
|
@@ -1636,46 +1657,12 @@ public class DataTemplateProvider extends GenericProvider implements IDataTempla
|
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
resultMap.put(PoiViewConstants.FILE_NAME, label + "_" + DateUtil.getCurrentTime("yyyyMMddHHmmss"));
|
|
|
- resultMap.put(PoiViewConstants.PARAMS, new ExportParams(label));
|
|
|
+ ExportParams exportParams = new ExportParams(label);
|
|
|
+ exportParams.setType(ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelExportStylerColorImpl.class);
|
|
|
+ resultMap.put(PoiViewConstants.PARAMS, exportParams);
|
|
|
resultMap.put(PoiViewConstants.ENTITY_LIST, entityList);
|
|
|
|
|
|
- // 物料基本信息 和 物料库存信息 导出 excel 供应商字段值id --> name 查询修改
|
|
|
- String menu = (String) responseData.get("key");
|
|
|
- // 罗湖 wljbxx wlkcxx
|
|
|
- // 明鉴 mjwljbxx
|
|
|
- if (menu.equals("wljbxx") || menu.equals("mjwljbxx") || menu.equals("wlkcxx") || menu.equals("wljbxx1") || menu.equals("bzwzgltz") || menu.equals("llckwlxx")) {
|
|
|
- String sql = " SELECT id_,gong_ying_shang_m FROM t_gysml ";
|
|
|
- List<Map<String, Object>> gysList = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
- for (Map<String, Object> objectMap : listMap) {
|
|
|
- String gysName = "";
|
|
|
- String gysIds = "";
|
|
|
- if (objectMap.get("gong_ying_shang_") != null){
|
|
|
- gysIds = objectMap.get("gong_ying_shang_").toString();
|
|
|
- }
|
|
|
- String[] providers = {};
|
|
|
- if (gysIds != null && !gysIds.equals("")) {
|
|
|
- providers = gysIds.split(",");
|
|
|
- }
|
|
|
- if (providers.length==1) {
|
|
|
- for (Map<String, Object> objMap : gysList) {
|
|
|
- if (objMap.get("id_").equals(gysIds)) {
|
|
|
- gysName = objMap.get("gong_ying_shang_m").toString();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (providers.length > 1) {
|
|
|
- for (String str : providers) {
|
|
|
- for (Map<String, Object> objMap : gysList) {
|
|
|
- if (objMap.get("id_").equals(str)) {
|
|
|
- gysName = gysName + "/" + objMap.get("gong_ying_shang_m");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- gysName = gysName.substring(1);
|
|
|
- }
|
|
|
- objectMap.put("gong_ying_shang_", gysName==null?"": gysName);
|
|
|
- }
|
|
|
- }
|
|
|
resultMap.put(PoiViewConstants.MAP_LIST, listMap);
|
|
|
return resultMap;
|
|
|
}
|