diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/departext/dto/DepartExtDto.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/departext/dto/DepartExtDto.java new file mode 100644 index 0000000..19abaf0 --- /dev/null +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/departext/dto/DepartExtDto.java @@ -0,0 +1,138 @@ +package org.jeecg.modules.demo.departext.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Description: 部门扩展表 + * @Author: jeecg-boot + * @Date: 2024-10-18 + * @Version: V1.0 + */ +@Data +@ApiModel(value = "depart_ext对象", description = "部门扩展表") +public class DepartExtDto implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private String id; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String createBy; + /** + * 创建日期 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private Date createTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String updateBy; + /** + * 更新日期 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private Date updateTime; + /** + * 部门表id + */ + @Excel(name = "部门表id", width = 15) + @ApiModelProperty(value = "部门表id") + private String departId; + + @ApiModelProperty(value = "项目id") + private String projectId; + + /** + * 单位性质 + */ + @Excel(name = "单位性质", width = 15, dicCode = "depart_category") + @Dict(dicCode = "depart_category") + @ApiModelProperty(value = "单位性质") + private String category; + /** + * 企业登记注册类型 + */ + @Excel(name = "企业登记注册类型", width = 15) + @ApiModelProperty(value = "企业登记注册类型") + private String type; + /** + * 开户银行 + */ + @Excel(name = "开户银行", width = 15) + @ApiModelProperty(value = "开户银行") + private String bankName; + /** + * 账号 + */ + @Excel(name = "账号", width = 15) + @ApiModelProperty(value = "账号") + private String bankNo; + /** + * 职工总数 + */ + @Excel(name = "职工总数", width = 15) + @ApiModelProperty(value = "职工总数") + private String employeeNum; + /** + * 上年度研发经费 + */ + @Excel(name = "上年度研发经费", width = 15) + @ApiModelProperty(value = "上年度研发经费") + private BigDecimal lastYearFee; + /** + * 注册时间 + */ + @Excel(name = "注册时间", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "注册时间") + private Date registerDate; + + private String regDate; + /** + * 联系人 + */ + @Excel(name = "联系人", width = 15) + @ApiModelProperty(value = "联系人") + private String linkmanName; + /** + * 手机 + */ + @Excel(name = "手机", width = 15) + @ApiModelProperty(value = "手机") + private String linkmanPhone; + /** + * 电子邮箱 + */ + @Excel(name = "电子邮箱", width = 15) + @ApiModelProperty(value = "电子邮箱") + private String linkmanEmail; + + private String departNameAbbr; +} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/dto/ProjectDto.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/dto/ProjectDto.java new file mode 100644 index 0000000..d438b01 --- /dev/null +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/dto/ProjectDto.java @@ -0,0 +1,286 @@ +package org.jeecg.modules.demo.project.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecg.common.aspect.annotation.Dict; +import org.jeecg.modules.demo.projectMember.entity.ProjectMember; +import org.jeecg.modules.demo.userext.entity.UserExt; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecg.modules.demo.departext.dto.DepartExtDto; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @Description: 项目表 + * @Author: jeecg-boot + * @Date: 2024-10-17 + * @Version: V1.0 + */ +@Data +public class ProjectDto implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private String id; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String createBy; + /** + * 创建日期 + */ +// @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") +// @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "创建日期") + private String createTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String updateBy; + /** + * 更新日期 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private Date updateTime; + /** + * 所属部门 + */ + @Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "org_code") + @ApiModelProperty(value = "所属部门") + private String sysOrgCode; + /** + * 项目名称 + */ + @Excel(name = "项目名称", width = 15) + @ApiModelProperty(value = "项目名称") + private String projectName; + /** + * 项目领域 + */ + @Excel(name = "项目领域", width = 15, dicCode = "project_domain") + @Dict(dicCode = "project_domain") + @ApiModelProperty(value = "项目领域") + private String projectDomain; + /** + * 新兴产业 + */ + @Excel(name = "新兴产业", width = 15, dicCode = "emerging_industry") + @Dict(dicCode = "emerging_industry") + @ApiModelProperty(value = "新兴产业") + private String emergingIndustry; + /** + * 传统产业 + */ + @Excel(name = "传统产业", width = 15, dicCode = "traditional_industry") + @Dict(dicCode = "traditional_industry") + @ApiModelProperty(value = "传统产业") + private String traditionalIndustry; + /** + * 技术来源 + */ + @Excel(name = "技术来源", width = 15, dicCode = "technical_source") + @Dict(dicCode = "technical_source") + @ApiModelProperty(value = "技术来源") + private String technicalSource; + /** + * 技术水平 + */ + @Excel(name = "技术水平", width = 15, dicCode = "technical_level") + @Dict(dicCode = "technical_level") + @ApiModelProperty(value = "技术水平") + private String technicalLevel; + /** + * 预期主要成果形式 + */ + @Excel(name = "预期主要成果形式", width = 15, dicCode = "result_form") + @Dict(dicCode = "result_form") + @ApiModelProperty(value = "预期主要成果形式") + private String resultForm; + /** + * 经费投入(万元) + */ + @Excel(name = "经费投入(万元)", width = 15) + @ApiModelProperty(value = "经费投入(万元)") + private BigDecimal fundInput; + /** + * 申请省财政拨款(万元) + */ + @Excel(name = "申请省财政拨款(万元)", width = 15) + @ApiModelProperty(value = "申请省财政拨款(万元)") + private BigDecimal applyFund; + /** + * 如无经费支持是否接受指导项目立项 + */ + @Excel(name = "如无经费支持是否接受指导项目立项", width = 15, replace = {"是_Y", "否_N"}) + @ApiModelProperty(value = "如无经费支持是否接受指导项目立项") + private String isAcceptInitProject; + /** + * 所属实验室、研究中心 + */ + @Excel(name = "所属实验室、研究中心", width = 15) + @ApiModelProperty(value = "所属实验室、研究中心") + private String laboratory; + /** + * 地方投入 + */ + @Excel(name = "地方投入", width = 15) + @ApiModelProperty(value = "地方投入") + private BigDecimal localInput; + /** + * 银行贷款 + */ + @Excel(name = "银行贷款", width = 15) + @ApiModelProperty(value = "银行贷款") + private BigDecimal bankLoan; + /** + * 自筹 + */ + @Excel(name = "自筹", width = 15) + @ApiModelProperty(value = "自筹") + private BigDecimal selfRaise; + /** + * 项目开始时间 + */ +// @Excel(name = "项目开始时间", width = 15, format = "yyyy-MM-dd") +// @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") +// @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "项目开始时间") + private String startTime; + /** + * 项目结束时间 + */ +// @Excel(name = "项目结束时间", width = 15, format = "yyyy-MM-dd") +// @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") +// @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "项目结束时间") + private String endTime; + /** + * 年生产能力 + */ + @Excel(name = "年生产能力", width = 15) + @ApiModelProperty(value = "年生产能力") + private BigDecimal yearlyCapacity; + /** + * 就业人数 + */ + @Excel(name = "就业人数", width = 15) + @ApiModelProperty(value = "就业人数") + private String employmentFigure; + /** + * 年销售收入 + */ + @Excel(name = "年销售收入", width = 15) + @ApiModelProperty(value = "年销售收入") + private BigDecimal annualSalesRevenue; + /** + * 年出口创汇 + */ + @Excel(name = "年出口创汇", width = 15) + @ApiModelProperty(value = "年出口创汇") + private BigDecimal annualExportEarnings; + /** + * 年纳税总额 + */ + @Excel(name = "年纳税总额", width = 15) + @ApiModelProperty(value = "年纳税总额") + private BigDecimal totalAnnualTaxPayment; + /** + * 年净利润 + */ + @Excel(name = "年净利润", width = 15) + @ApiModelProperty(value = "年净利润") + private BigDecimal annualProfit; + /** + * 申请专利数 + */ + @Excel(name = "申请专利数", width = 15) + @ApiModelProperty(value = "申请专利数") + private String applyPatentNumber; + /** + * 发明专利数 + */ + @Excel(name = "发明专利数", width = 15) + @ApiModelProperty(value = "发明专利数") + private String invevtionPatentNumber; + /** + * 授权专利数 + */ + @Excel(name = "授权专利数", width = 15) + @ApiModelProperty(value = "授权专利数") + private String creditPatentNumber; + /** + * 项目类别表id + */ + @Excel(name = "项目类别表id", width = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id") + @ApiModelProperty(value = "项目类别表id") + @Dict(dictTable = "project_type", dicCode = "id", dicText = "type_name") + private String projectTypeid; + + @TableField(exist = false) + private String projectTypeName; + + @TableField(exist = false) + private String annualName; + + @TableField(exist = false) + private String departName; + + + /** + * 批次 + */ + @Excel(name = "批次", width = 15) + @ApiModelProperty(value = "批次") + private String batchNo; + /** + * 项目书状态 + */ + @Excel(name = "项目书状态", width = 15, dicCode = "project_status") + @Dict(dicCode = "project_status") + @ApiModelProperty(value = "项目书状态") + private String projectStatus; + /** + * 预算书状态 + */ + @Excel(name = "预算书状态", width = 15, dicCode = "budget_status") + @Dict(dicCode = "budget_status") + @ApiModelProperty(value = "预算书状态") + private String budgetStatus; + /** + * 负责人 + */ + @Excel(name = "负责人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "id") + @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id") + @ApiModelProperty(value = "负责人") + private String projectCharger; + @ApiModelProperty(value = "负责人手机") + private String fzrPhone; + @ApiModelProperty(value = "负责人邮箱") + private String fzrEmail; + private String fzrIdNo; + + + @ApiModelProperty(value = "项目主要内容") + private String projectContent; + + private UserExt fzr; + + private DepartExtDto sqdw; + + private List pms; +} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/IProject4WordService.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/IProject4WordService.java new file mode 100644 index 0000000..b97de63 --- /dev/null +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/IProject4WordService.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.demo.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.demo.project.dto.ProjectShenBaoDto; +import org.jeecg.modules.demo.project.entity.Project; +import org.jeecg.modules.demo.project.service.impl.Project4WordServiceImpl; + +/** + * @Description: 项目表 + * @Author: jeecg-boot + * @Date: 2024-10-17 + * @Version: V1.0 + */ +public interface IProject4WordService extends IService { + + Object getInfo4Word(Project project); +} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java new file mode 100644 index 0000000..dfbab65 --- /dev/null +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java @@ -0,0 +1,236 @@ +package org.jeecg.modules.demo.project.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; +import org.jeecg.common.system.vo.DictModel; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.demo.departext.dto.DepartExtDto; +import org.jeecg.modules.demo.departext.entity.DepartExt; +import org.jeecg.modules.demo.departext.service.IDepartExtService; +import org.jeecg.modules.demo.project.dto.ProjectDto; +import org.jeecg.modules.demo.project.entity.Project; +import org.jeecg.modules.demo.project.mapper.ProjectMapper; +import org.jeecg.modules.demo.project.service.IProject4WordService; +import org.jeecg.modules.demo.projectMember.entity.ProjectMember; +import org.jeecg.modules.demo.projectMember.service.IProjectMemberService; +import org.jeecg.modules.demo.projectType.entity.ProjectType; +import org.jeecg.modules.demo.projectType.service.IProjectTypeService; +import org.jeecg.modules.demo.userext.entity.UserExt; +import org.jeecg.modules.demo.userext.service.IUserExtService; +import org.jeecg.modules.system.entity.SysDepart; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysDepartService; +import org.jeecg.modules.system.service.ISysUserService; +import org.jeecg.modules.system.service.impl.SysBaseApiImpl; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.entity.TemplateExportParams; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @Description: 项目表 + * @Author: jeecg-boot + * @Date: 2024-10-17 + * @Version: V1.0 + */ +@Service +@Slf4j +public class Project4WordServiceImpl extends ServiceImpl implements IProject4WordService { + + @Autowired + private IDepartExtService iDepartExtService; + + @Autowired + private ISysDepartService iSysDepartService; + + @Autowired + private ISysUserService iSysUserService; + + @Autowired + private IUserExtService iUserExtService; + + @Autowired + private SysBaseApiImpl sysBaseApi; + + @Autowired + private IProjectTypeService iProjectTypeService; + @Autowired + private IProjectMemberService iProjectMemberService; + + @Override + public Object getInfo4Word(Project obj) { + Project project = this.getById("1849284130146025473"); + if (ObjectUtils.isEmpty(project)) return null; + + ProjectDto dto = new ProjectDto(); + BeanUtils.copyProperties(project, dto); + + if (!ObjectUtils.isEmpty(project.getProjectTypeid())) { + ProjectType projectType = iProjectTypeService.getById(project.getProjectTypeid()); + dto.setProjectTypeName(projectType.getTypeName()); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日"); + dto.setCreateTime(DateUtils.date2Str(project.getCreateTime(), format)); + dto.setStartTime(DateUtils.date2Str(project.getStartTime(), format)); + dto.setEndTime(DateUtils.date2Str(project.getEndTime(), format)); + + if (!ObjectUtils.isEmpty(project.getProjectTypeid())) { + ProjectType projectType = iProjectTypeService.getById(project.getProjectTypeid()); + dto.setProjectTypeName(projectType.getTypeName()); + } + SysDepart sysDepart = iSysDepartService.getOne(new LambdaQueryWrapper().eq(SysDepart::getOrgCode, project.getSysOrgCode())); + if (ObjectUtil.isNotEmpty(sysDepart)) { + dto.setSysOrgCode(sysDepart.getDepartName()); + } + if (!ObjectUtils.isEmpty(project.getProjectDomain())) { + List dictModels = sysBaseApi.queryDictItemsByCode("project_domain"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(project.getProjectDomain())) { + dto.setProjectDomain(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(project.getEmergingIndustry())) { + List dictModels = sysBaseApi.queryDictItemsByCode("emerging_industry"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(project.getEmergingIndustry())) { + dto.setEmergingIndustry(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(project.getTraditionalIndustry())) { + List dictModels = sysBaseApi.queryDictItemsByCode("traditional_industry"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(project.getTraditionalIndustry())) { + dto.setTraditionalIndustry(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(project.getTechnicalSource())) { + List dictModels = sysBaseApi.queryDictItemsByCode("technical_source"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(project.getTechnicalSource())) { + dto.setTechnicalSource(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(project.getTechnicalLevel())) { + List dictModels = sysBaseApi.queryDictItemsByCode("technical_level"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(project.getTechnicalLevel())) { + dto.setTechnicalLevel(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(project.getResultForm())) { + List dictModels = sysBaseApi.queryDictItemsByCode("result_form"); + if (ObjectUtil.isNotEmpty(dictModels)) { + String[] split = project.getResultForm().split(","); + if (!ObjectUtils.isEmpty(split)) { + dictModels.forEach(e -> { + if (e.getValue().equals(split[0])) { + dto.setResultForm(e.getText()); + } + }); + } + } + } + SysUser sysUser = iSysUserService.getById(project.getProjectCharger()); + UserExt userExt = iUserExtService.getOne(new LambdaQueryWrapper().eq(UserExt::getUserId, project.getProjectCharger()).eq(UserExt::getProjectId, project.getId())); + if (ObjectUtil.isNotEmpty(userExt)) { + if (!ObjectUtils.isEmpty(userExt.getNation())) { + List dictModels = sysBaseApi.queryDictItemsByCode("nation"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(userExt.getNation())) { + userExt.setNation(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(userExt.getPolitical())) { + List dictModels = sysBaseApi.queryDictItemsByCode("political"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(userExt.getPolitical())) { + userExt.setPolitical(e.getText()); + } + }); + } + } + } + dto.setProjectCharger(sysUser.getRealname()); + dto.setFzrEmail(sysUser.getEmail()); + dto.setFzrPhone(sysUser.getPhone()); + dto.setFzrIdNo(sysUser.getIdNo()); + dto.setFzr(userExt); + + DepartExt departExt = iDepartExtService.getOne(new LambdaQueryWrapper() + .eq(DepartExt::getDepartId, sysDepart.getId()) + .eq(DepartExt::getProjectId, project.getId())); + DepartExtDto departExtDto = new DepartExtDto(); + BeanUtils.copyProperties(departExt, departExtDto); + departExtDto.setDepartNameAbbr(sysDepart.getDepartNameAbbr()); + departExtDto.setRegDate(DateUtils.date2Str(departExtDto.getRegisterDate(), format)); + if (!ObjectUtils.isEmpty(departExtDto.getCategory())) { + List dictModels = sysBaseApi.queryDictItemsByCode("depart_category"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(departExtDto.getCategory())) { + departExtDto.setCategory(e.getText()); + } + }); + } + } + dto.setSqdw(departExtDto); + List projectMemberList = iProjectMemberService.list(new LambdaQueryWrapper().eq(ProjectMember::getProjectId, project.getId())); + if(ObjectUtil.isNotEmpty(projectMemberList)){ + projectMemberList.stream().forEach(pm -> { + pm.setZy(pm.getCurrentPerfession()); + if (!ObjectUtils.isEmpty(pm.getPolitical())) { + List dictModels = sysBaseApi.queryDictItemsByCode("political"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(pm.getPolitical())) { + pm.setPolitical(e.getText()); + } + }); + } + } + if (!ObjectUtils.isEmpty(pm.getNation())) { + List dictModels = sysBaseApi.queryDictItemsByCode("nation"); + if (ObjectUtil.isNotEmpty(dictModels)) { + dictModels.forEach(e -> { + if (e.getValue().equals(pm.getNation())) { + pm.setNation(e.getText()); + } + }); + } + } + }); + } + dto.setPms(projectMemberList); + return dto; + } +} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectMember/entity/ProjectMember.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectMember/entity/ProjectMember.java index 6f38ca3..f9c3c72 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectMember/entity/ProjectMember.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/projectMember/entity/ProjectMember.java @@ -1,6 +1,7 @@ package org.jeecg.modules.demo.projectMember.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -122,6 +123,9 @@ public class ProjectMember implements Serializable { @Excel(name = "现从事专业", width = 15) @ApiModelProperty(value = "现从事专业") private java.lang.String currentPerfession; + + @TableField(exist = false) + private java.lang.String zy; /** * 身份证 */ diff --git a/jeecg-boot/jeecg-module-demo/src/main/test/java/org/jeecg/test/word/WordExportUtil_test.java b/jeecg-boot/jeecg-module-demo/src/main/test/java/org/jeecg/test/word/WordExportUtil_test.java index a4c58db..97ce19d 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/test/java/org/jeecg/test/word/WordExportUtil_test.java +++ b/jeecg-boot/jeecg-module-demo/src/main/test/java/org/jeecg/test/word/WordExportUtil_test.java @@ -1,14 +1,21 @@ package org.jeecg.test.word; +import cn.hutool.core.bean.BeanUtil; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.xwpf.usermodel.BreakType; import org.apache.poi.xwpf.usermodel.Document; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFPictureData; import org.apache.xmlbeans.XmlOptions; +import org.jeecg.modules.demo.project.entity.Project; +import org.jeecg.modules.demo.project.service.IProjectService; import org.jeecgframework.poi.word.WordExportUtil; import org.junit.Test; +import org.junit.runner.RunWith; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; import java.io.File; import java.io.FileInputStream; @@ -22,19 +29,27 @@ import java.util.*; * @CreateTime: 2024-11-18 15:33 * @Version: 1.0 */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class WordExportUtil_test { + @Autowired + private IProjectService iProjectService; + /** * 简单导出没有图片和Excel */ @Test public void SimpleWordExport() { - Map map = new HashMap(); + Project project = iProjectService.getById("1857246264504631297"); + Map map = BeanUtil.beanToMap(project); +// Map map = new HashMap(); map.put("department", "Easypoi"); map.put("person", "JueYue"); map.put("time", new Date()); map.put("me", "JueYue"); map.put("date", "2015-01-03"); + System.out.println("map = " + map.values()); try { //jeecg-boot/jeecg-boot-base-core/src/main/resources/templates/email/work/test1118.docx XWPFDocument doc = WordExportUtil.exportWord07("src/main/resources/templates/email/work/test1118.docx", map); diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/pom.xml b/jeecg-boot/jeecg-module-system/jeecg-system-start/pom.xml index e5d099b..9ec4f87 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-start/pom.xml +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/pom.xml @@ -10,7 +10,7 @@ 4.0.0 jeecg-system-start - + @@ -24,7 +24,24 @@ jeecg-module-demo ${jeecgboot.version} - + + + + cn.afterturn + easypoi-base + 4.3.0 + + + cn.afterturn + easypoi-web + 4.3.0 + + + cn.afterturn + easypoi-annotation + 4.3.0 + + org.flywaydb @@ -41,4 +58,4 @@ - \ No newline at end of file + diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index e55f534..c987698 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -190,7 +190,7 @@ mybatis-plus: table-underline: true configuration: # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 - #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 返回类型为Map,显示null对应的字段 call-setters-on-nulls: true #jeecg专用配置 diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/word/WordExportUtil_test.java b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/word/WordExportUtil_test.java new file mode 100644 index 0000000..968fbc0 --- /dev/null +++ b/jeecg-boot/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/word/WordExportUtil_test.java @@ -0,0 +1,145 @@ +package org.jeecg.modules.word; + +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSON; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.xwpf.usermodel.BreakType; +import org.apache.poi.xwpf.usermodel.Document; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFPictureData; +import org.apache.xmlbeans.XmlOptions; +import org.jeecg.JeecgSystemApplication; +import org.jeecg.modules.demo.project.service.IProject4WordService; +import org.jeecg.modules.demo.project.service.IProjectService; +//import org.jeecgframework.poi.word.WordExportUtil; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import cn.afterturn.easypoi.word.WordExportUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.*; + +/** + * @Description: TODO + * @Author: Z.H.C + * @CreateTime: 2024-11-18 15:33 + * @Version: 1.0 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = JeecgSystemApplication.class) +public class WordExportUtil_test { + + @Autowired + private IProjectService iProjectService; + @Autowired + private IProject4WordService iProject4WordService; + + /** + * 简单导出没有图片和Excel + */ + @Test + public void SimpleWordExport() { + Object info4Word = iProject4WordService.getInfo4Word(null); + Map map = BeanUtil.beanToMap(info4Word); +// List> listMap = new ArrayList>(); + System.out.println("map = " + JSON.toJSONString(map)); + List> edu = new ArrayList<>(); + + try { + XWPFDocument doc = WordExportUtil.exportWord07("C:\\Users\\YX\\Desktop\\testword\\model.docx", map); + FileOutputStream fos = new FileOutputStream("C:\\Users\\YX\\Desktop\\testword\\test1120.docx"); + doc.write(fos); + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void test2() { + File newFile = new File("C:\\Users\\YX\\Desktop\\testword\\合并2.docx"); + List srcfile = new ArrayList<>(); + + File file1 = new File("C:\\Users\\YX\\Desktop\\testword\\1.docx"); + File file2 = new File("C:\\Users\\YX\\Desktop\\testword\\2.docx"); + File file3 = new File("C:\\Users\\YX\\Desktop\\testword\\3.docx"); + srcfile.add(file1); + srcfile.add(file2); + srcfile.add(file3); + try { + OutputStream dest = new FileOutputStream(newFile); + ArrayList documentList = new ArrayList<>(); + XWPFDocument doc = null; + for (int i = 0; i < srcfile.size(); i++) { + FileInputStream in = new FileInputStream(srcfile.get(i).getPath()); + OPCPackage open = OPCPackage.open(in); + XWPFDocument document = new XWPFDocument(open); + documentList.add(document); + } + for (int i = 0; i < documentList.size(); i++) { + doc = documentList.get(0); + if (i == 0) {//首页直接分页,不再插入首页文档内容 + documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE); +// appendBody(doc,documentList.get(i)); + } else if (i == documentList.size() - 1) {//尾页不再分页,直接插入最后文档内容 + appendBody(doc, documentList.get(i)); + } else { + documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE); + appendBody(doc, documentList.get(i)); + } + } + doc.write(dest); + dest.close(); + + System.out.println("*****合成成功********"); + + // Runtime.getRuntime().exec("cmd /c start winword C:/Users/gouwe/合并.docx");//直接调用cmd打开合成文档 + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void appendBody(XWPFDocument src, XWPFDocument append) throws Exception { + CTBody src1Body = src.getDocument().getBody(); + CTBody src2Body = append.getDocument().getBody(); + + List allPictures = append.getAllPictures(); + // 记录图片合并前及合并后的ID + Map map = new HashMap(); + for (XWPFPictureData picture : allPictures) { + String before = append.getRelationId(picture); + //将原文档中的图片加入到目标文档中 + String after = src.addPictureData(picture.getData(), Document.PICTURE_TYPE_PNG); + map.put(before, after); + } + appendBody(src1Body, src2Body, map); + } + + private static void appendBody(CTBody src, CTBody append, Map map) throws Exception { + XmlOptions optionsOuter = new XmlOptions(); + optionsOuter.setSaveOuter(); + String appendString = append.xmlText(optionsOuter); + + String srcString = src.xmlText(); + String prefix = srcString.substring(0, srcString.indexOf(">") + 1); + String mainPart = srcString.substring(srcString.indexOf(">") + 1, srcString.lastIndexOf("<")); + String sufix = srcString.substring(srcString.lastIndexOf("<")); + String addPart = appendString.substring(appendString.indexOf(">") + 1, appendString.lastIndexOf("<")); + if (map != null && !map.isEmpty()) { + //对xml字符串中图片ID进行替换 + for (Map.Entry set : map.entrySet()) { + addPart = addPart.replace(set.getKey(), set.getValue()); + } + } + //将两个文档的xml内容进行拼接 + CTBody makeBody = CTBody.Factory.parse(prefix + mainPart + addPart + sufix); + src.set(makeBody); + } +}