缘起

最近一周都在写报表,样式很统一,上面是查询条件,下面是查询结果,页面如下图所示。由于要写很多报表,都是重复的工作,所以部门里的小哥哥在写了一个基于node的小程序,直接配置JSON文件,就可以生成报表模板,感觉很强(后面想学习一下)。

作为一个优秀的CV工程师(复制粘贴),我也没怎么写前端的工作,直接用生成的模板就好了,但是后台的查询我还是稍微走心的。由于JAVA基础不是很好,总结的可能出错,欢迎大家批评指正。

controller、service、serviceImpl、Mapper、Xml等文件的作用

在项目中的使用情况,由于业务逻辑很简单,所以每个文件中的代码行数都很少

  1. controller.java
1
2
3
4
5
6
7
8
9
/**
* 资产rim项目信息报表
*
*/
@RequestMapping(value = "/hls/cus/rpt/rim/project/detail/query")
@ResponseBody
public ResponseData rptRimProjecrDetailQuery(@RequestBody Map map) {
return new ResponseData(hlsCusRptRimProjectDetailService.rptRimProjectDetailQuery(map));
}
  1. service.java
1
2
3
4
5
 
public interface HlsCusRptRimProjectDetailService extends IBaseService<HlsCusRptRimProjectDetail>,ProxySelf<HlsCusRptRimProjectDetailService> {

List<Map> rptRimProjectDetailQuery(Map map);
}
  1. serviceImpl.java
1
2
3
4
5
6
7
@Override
public List<Map> rptRimProjectDetailQuery(Map map) {
int page = Integer.parseInt(String.valueOf(map.get("page")));
int pageSize = Integer.parseInt(String.valueOf(map.get("pageSize")));
PageHelper.startPage(page,pageSize);
return hlsCusRptRimProjectDetailMapper.rptRimProjectDetailQuery(map);
}
  1. mapper.java
1
2
3
4
5
public interface HlsCusRptRimProjectDetailMapper extends Mapper<HlsCusRptRimProjectDetail> {

List<Map> rptRimProjectDetailQuery( Map<String, Object> map);// 资产rim表项目信息报表

}
  1. mapper.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<select id="rptRimProjectDetailQuery" resultMap="BaseResultMap">

SELECT
V.*,
(case when V.REMAIN_PRINCIPAL > 0 then (V.REMAIN_PRINCIPAL - nvl(
(SELECT SUM(CCC.DUE_AMOUNT)
FROM CON_CONTRACT_CASHFLOW CCC
WHERE CCC.CONTRACT_ID = V.CONTRACT_ID
AND CCC.CF_ITEM = 5)
,0)) else 0 end) as PROJECT_EXPOSURE
FROM (SELECT
--项目编号
CC.PROJECT_CONTRACT_NUMBER PROJECT_NUMBER,

-------------------------省略部分代码-------------------------

-- 项目核销申请日期
(SELECT CCT.TERMINATION_DATE
FROM CON_CONTRACT_TERMINATION CCT
WHERE CCT.CONTRACT_ID = CC.CONTRACT_ID) TERMINATION_DATE,
CC.BEFORE_RENT_FLAG
FROM CON_CONTRACT CC
LEFT JOIN PRJ_PROJECT PP
ON CC.PROJECT_ID = PP.PROJECT_ID
WHERE
cc.contract_status IN ('INCEPT', 'TERMINATE', 'ET')
OR (CC.contract_status = 'SIGN' AND cc.before_rent_flag = 'Y')
) V
----------------下面写查询条件----------------------
<where>
<if test="projectNumber !=null and projectNumber !=''">
and v.project_number like concat(concat('%',#{projectNumber}),'%')
</if>
<if test="businessType !=null and businessType.size() !=0">
and v.business_type in
<foreach item="item" index="index" collection="businessType" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>

</select>