diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java index 19d85ad..f79e150 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java @@ -31,5 +31,17 @@ public interface CommonConst { String ARCHIVED = "归档"; + String FILE_NAME = "name"; + + String NULL = "null"; + + String TITLE = "title"; + + String FILE_NAME_STR = "fileName"; + String FILE_LIST = "fileList"; + String ITEM_BASED = "依据项:"; + String ITEM_BASED_FILE_NAME = "依据文件名:"; + String APPENDIX = "文件:"; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java index 1eb9f3d..d2d2d9c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java @@ -4,18 +4,23 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.*; import java.util.function.BiConsumer; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; +import cn.hutool.json.JSONUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSONObject; import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.pmapi.common.constant.CommonConst; import com.ningdatech.pmapi.common.enumeration.ExportOptionEnum; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.scheduler.contants.TaskContant; import com.wflow.workflow.bean.vo.ProcessInstanceVo; import com.wflow.workflow.bean.vo.ProcessTaskVo; import org.apache.commons.collections4.CollectionUtils; @@ -204,7 +209,19 @@ public class ExcelDownUtil { projects.forEach(project -> { String s = JSON.toJSONString(project); JSONObject jsonObject = JSON.parseObject(s); - String columnValue = String.valueOf(jsonObject.get(column.toString())); + String columnValue; + if (ExportOptionEnum.preliminaryPlanFile.equals(column) + || ExportOptionEnum.supportingMaterialsFile.equals(column)){ + String fileStr = String.valueOf(jsonObject.get(column.toString())); + if (Objects.isNull(fileStr) || CommonConst.NULL.equals(fileStr)){ + return; + } + List fileArray = JSON.parseArray(fileStr, JSONObject.class); + List nameList = CollUtils.fieldList(fileArray, w -> w.getString(CommonConst.FILE_NAME)); + columnValue = nameList.stream().collect(Collectors.joining(StrPool.COMMA)); + }else { + columnValue = String.valueOf(jsonObject.get(column.toString())); + } columnValues.add(columnValue); }); rowList.add(columnValues); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 456cdd0..c986008 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -6,13 +6,16 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.StopWatch; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Sets; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.basic.util.StrPool; import com.ningdatech.file.entity.File; import com.ningdatech.file.entity.vo.result.FileResultVO; import com.ningdatech.file.service.FileService; @@ -21,6 +24,7 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; +import com.ningdatech.pmapi.common.util.StrUtils; import com.ningdatech.pmapi.irs.sign.IRSAPIRequest; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; @@ -1191,6 +1195,7 @@ public class TodoCenterManage { // 获取表单数据 PdfGenerateDTO pdfGenerateDTO = new PdfGenerateDTO(); BeanUtils.copyProperties(project, pdfGenerateDTO); + JSONObject paramsMap = JSONObject.parseObject(JSONObject.toJSONString(pdfGenerateDTO)); // 设置title String title = "【" + project.getProjectName() + "】" + fileName; @@ -1241,6 +1246,31 @@ public class TodoCenterManage { paramsMap.put("yearPlanInvest",yearPlanInvest); // TODO 根据地区编码获取当地大数据局(中心)的名称 paramsMap.put("bigDataBureauName",null); + + // 获取立项依据 + String buildBasis = project.getBuildBasis(); + StringBuilder builder = new StringBuilder(); + List fileArray = JSON.parseArray(buildBasis, JSONObject.class); + for (JSONObject jsonObject : fileArray) { + String titleStr = jsonObject.getString(CommonConst.TITLE); + builder.append(CommonConst.ITEM_BASED); + builder.append(titleStr); + builder.append(StrPool.SPACE); + String fileNameStr = jsonObject.getString(CommonConst.FILE_NAME_STR); + builder.append(CommonConst.ITEM_BASED_FILE_NAME); + builder.append(fileNameStr); + builder.append(StrPool.SPACE); + String fileInfo = jsonObject.getString(CommonConst.FILE_LIST); + List fileInfoArray = JSON.parseArray(fileInfo, JSONObject.class); + List nameList = CollUtils.fieldList(fileInfoArray, w -> w.getString(CommonConst.FILE_NAME)); + String appendixStr = nameList.stream().collect(Collectors.joining(StrPool.COMMA)); + builder.append(CommonConst.APPENDIX); + builder.append(appendixStr); + builder.append(StrPool.SEMICOLON); + builder.append(StrPool.NEWLINE); + } + String buildBasisList = builder.toString(); + paramsMap.put("buildBasisList",buildBasisList); return paramsMap; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/PdfGenerateDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/PdfGenerateDTO.java index 499d195..adc7f7c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/PdfGenerateDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/PdfGenerateDTO.java @@ -61,7 +61,7 @@ public class PdfGenerateDTO { private String bizDomain; @ApiModelProperty("立项依据") - private String buildBasis; + private String buildBasisList; @ApiModelProperty("是否上云 0:否 1:是") diff --git a/pmapi/src/main/resources/template/预审申请单.html b/pmapi/src/main/resources/template/预审申请单.html index 5c25ab8..2641489 100644 --- a/pmapi/src/main/resources/template/预审申请单.html +++ b/pmapi/src/main/resources/template/预审申请单.html @@ -151,7 +151,7 @@ 立项依据 - #buildBasis# + #buildBasisList# 是否上云