// 根据id查询项目实体对象 ProjectEntity p = projectEntityMapper.selectProjectEntityById(id);

// 创建SimpleDateFormat对象,用于格式化日期 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

// 创建ProjectItems对象 ProjectItems it = new ProjectItems();

// 设置项目id it.setId(p.getId());

// 设置项目开始时间,如果开始时间不为空,则格式化日期,否则设置为空字符串 it.setBeginTime(p.getBegineat != null ? format.format(p.getBegineat) : "");

// 设置项目结束时间,如果结束时间不为空,则格式化日期,否则设置为空字符串 it.setEndTime(p.getEndat != null ? format.format(p.getEndat) : "");

// 设置项目名称 it.setProjectName(p.getProjectname());

// 设置项目内容 it.setProjectContent(p.getProjectcontent());

// 设置村庄名称 it.setVilName(p.getVilname());

// 根据自然村id查询自然村对象 TNatural tNatural = naturalMapper.selectTNaturalById(p.getNatId());

// 设置自然村名称 it.setNatName(tNatural.getName());

// 设置自然村id it.setNatid(tNatural.getId());

// 设置项目类型,将int类型转换为字符串 it.setProjectType(p.getProjectype + "");

// 设置项目部门,将int类型转换为字符串 it.setDept(p.getProjectdep + "");

// 设置类型备注 it.setTypeRemark(p.getTyperemark());

// 设置计划时间,如果计划时间不为空,则格式化日期,否则设置为空字符串 it.setPlanTime(p.getPlanat != null ? format.format(p.getPlanat) : "");

// 设置项目负责人 it.setProjectPerson(p.getProjectperson());

// 设置项目状态 it.setStatus(p.getStatus());

// 设置项目总概算 ProjectMoneyAttribute projectMoneyAttribute = new ProjectMoneyAttribute(); BeanUtils.copyProperties(p, projectMoneyAttribute); it.setAttr(projectMoneyAttribute);

// 设置项目保护情况,将int类型转换为字符串 it.setProtect(p.getProtect + "");

// 返回ProjectItems对象 return it;

Java 项目实体对象转换为 ProjectItems 对象

原文地址: https://www.cveoy.top/t/topic/p2qY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录