业务需求:
步骤一:添加查询语句:```Ora20796StudentMapper.xml```
![13265172-af86d7d819cca0c3.png](https://i-blog.csdnimg.cn/blog_migrate/da540184fc855a97fbeebfc129734db8.webp?x-image-process=image/format,png)
image.png
![13265172-bf7140a27e21425d.png](https://i-blog.csdnimg.cn/blog_migrate/3204754a6660bf35a871a23d34bc5e5d.webp?x-image-process=image/format,png)
image.png
<!--科目-->
<result column="COURSE" property="course" jdbcType="VARCHAR" />
<!--分数-->
<result column="SCORE" property="score" jdbcType="DECIMAL" />
<!---报表管理自定义-->
<select id="selectStudentReport"
resultMap="BaseResultMap"
parameterType="wht.ora20796.dto.Ora20796Student">
SELECT
stu.STUDENT_NAME,
stu.AGE,
stu.EMAIL,
stu.GRADE,
stus.COURSE as COURSE,
stus.SCORE as SCORE
FROM wht_ora_20796_student stu,wht_ora_20796_student_score stus
<where>
stu.student_id=stus.student_id
<if test="studentName!= null">
and stu.STUDENT_NAME LIKE concat( concat("%",#{studentName,jdbcType=VARCHAR}),"%")
</if>
</where>
</select>
去到学生的dto,添加年级和成绩两个字段:Ora20796Student.java
/*****/
private String course;//年级
private Long score; //分数
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
public Long getScore() {
return score;
}
public void setScore(Long score) {
this.score = score;
}
步骤2:修改Ora20796StudentMapper.java
![13265172-2fa2b087fa0fb76f.png](https://i-blog.csdnimg.cn/blog_migrate/23bf00a3e5bb82c770b6648eb3d51b20.webp?x-image-process=image/format,png)
image.png
public interface Ora20796StudentMapper extends Mapper<Ora20796Student>{
List<Ora20796Student> selectStudentInfo(Ora20796Student dto);
//学生成绩报表
List<Ora20796Student> selectStudentReport(Ora20796Student dto);
}
步骤3:接口类 IOra20796StudentService.java
![13265172-85d4751e88f7d846.png](https://i-blog.csdnimg.cn/blog_migrate/26ff790d2aa3c6eebdef3d992d0f15d8.webp?x-image-process=image/format,png)
image.png
package wht.ora20796.service;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hap.system.service.IBaseService;
import wht.ora20796.dto.Ora20796Student;
import java.io.InputStream;
import java.util.List;
public interface IOra20796StudentService extends IBaseService<Ora20796Student>, ProxySelf<IOra20796StudentService>{
/**
* 邮箱发送
*/
ResponseData sendEmail(IRequest iRequest, List<Ora20796Student> dto)throws Exception;
ResponseData importExcel(InputStream is, String fileName) throws Exception;
//学生成绩报表
List<Ora20796Student> selectStudentReport(IRequest iRequest, Ora20796Student dto, int page, int pageSize);
}
步骤4 实现类:Ora20796StudentServiceImpl.java
![13265172-4de3c83ed0b919cd.png](https://i-blog.csdnimg.cn/blog_migrate/d17b21137fa8f4bd516a60180fd769dd.webp?x-image-process=image/format,png)
image.png
![13265172-344e9691d1a4846d.png](https://i-blog.csdnimg.cn/blog_migrate/6f7ce9b856e04337b6f0ea0c46b89c63.webp?x-image-process=image/format,png)
image.png
@Autowired
private IMessageService messageService;
/**
* 学生成绩报表
* @param iRequest
* @param dto
* @param page
* @param pageSize
* @return
*/
@Override
public List<Ora20796Student> selectStudentReport(IRequest iRequest, Ora20796Student dto, int page, int pageSize) {
PageHelper.startPage(page, pageSize);
return ora20796StudentMapper.selectStudentReport(dto);
}
步骤5:在components包下新建:Ora20796StudentScoreBean.java
![13265172-f594de1d055ac6e0.png](https://i-blog.csdnimg.cn/blog_migrate/43ac2f595ecb745638e57114e5310ed6.webp?x-image-process=image/format,png)
image.png
package wht.ora20796.components;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.impl.RequestHelper;
import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wht.ora20796.dto.Ora20796Student;
import wht.ora20796.dto.Ora20796StudentScore;
import wht.ora20796.mapper.Ora20796StudentMapper;
import wht.ora20796.service.IOra20796StudentService;
import java.util.List;
import java.util.Map;
@Component
public class Ora20796StudentScoreBean {
@Autowired
IOra20796StudentService ora20796StudentService;
@Autowired
Ora20796StudentMapper ora20796StudentMapper;
public List<Ora20796Student> loadStudentData(String dsName, String datasetName, Map<String, Object> parameters) {
IRequest iRequest = RequestHelper.newEmptyRequest();//创建一个空的request
//新建一个dto作为一个查询条件
Ora20796Student criteria = new Ora20796Student();
String studentName = String.valueOf(parameters.get("studentName"));
if (StringUtils.isNotBlank(studentName)) {
criteria.setStudentName(String.valueOf(parameters.get("studentName")));
}
return ora20796StudentService.selectStudentReport(iRequest, criteria, 1, 10000);
}
}
ok,到这里代码修改就结束了,重新部署一下
下面去点前端操作:
![13265172-18e3d09810ee8f93.png](https://i-blog.csdnimg.cn/blog_migrate/05c799565141987a15e6737da6f7ebc1.webp?x-image-process=image/format,png)
image.png
![13265172-6c2f72634f340d1f.png](https://i-blog.csdnimg.cn/blog_migrate/62128d8dec6c22318cdc104ba16d5196.webp?x-image-process=image/format,png)
image.png
步骤7:表单设计:
大概样式:
![13265172-94675c967b6e531e.png](https://i-blog.csdnimg.cn/blog_migrate/84e485b51b64592e896e27695677d6b7.webp?x-image-process=image/format,png)
image.png
![13265172-d2714c88ca2e927a.png](https://i-blog.csdnimg.cn/blog_migrate/c20ec041474bdd65350598013afd95c4.webp?x-image-process=image/format,png)
image.png
![13265172-54192be5b5d4e2bf.png](https://i-blog.csdnimg.cn/blog_migrate/de1dbdb396e2073018dccb9192908317.webp?x-image-process=image/format,png)
image.png
![13265172-8999186531cf3f09.png](https://i-blog.csdnimg.cn/blog_migrate/f0f3331ff8086b95212016c6b90f2d34.webp?x-image-process=image/format,png)
image.png
![13265172-d9598fa21d6df08b.png](https://i-blog.csdnimg.cn/blog_migrate/c8fc0163c7bd24c3fe9f6a4b6d641a41.webp?x-image-process=image/format,png)
image.png
![13265172-1d20b1e948171213.png](https://i-blog.csdnimg.cn/blog_migrate/0180cbd6aece74c5637fb4c312637581.webp?x-image-process=image/format,png)
image.png
ok,保存,去新建一个表单s
![13265172-45b495fb85f66cad.png](https://i-blog.csdnimg.cn/blog_migrate/bd6f8e3bf6b2f543536b5160d76be700.webp?x-image-process=image/format,png)
image.png
添加参数:
![13265172-ba7f057f998afb94.png](https://i-blog.csdnimg.cn/blog_migrate/2f002a7344b29889847f865b67566abc.webp?x-image-process=image/format,png)
image.png
![13265172-ea89629db281518e.png](https://i-blog.csdnimg.cn/blog_migrate/2a7164af37d0fdf7a9ae1b2cad55e3b6.webp?x-image-process=image/format,png)
image.png
预览:
![13265172-88869e75f5255d83.png](https://i-blog.csdnimg.cn/blog_migrate/f7322e0b87853a67e0e2d485c7fbc43f.webp?x-image-process=image/format,png)
image.png