Commit 8973c55d71c3578dd605f0052e81770c0fed115b

Authored by 陈威
1 parent d03f6e3d
Exists in dev

累加户数项目公司-报表

zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/controller/McBasicCmtyController.java
... ... @@ -224,4 +224,42 @@ public class McBasicCmtyController extends BaseController {
224 224 response.getWriter().println(JSON.toJSONString(map));
225 225 }
226 226 }
  227 +
  228 +
  229 +
  230 + @GetMapping("/summaryList")
  231 + public TableDataInfo summaryList(McBasicCmtyVo mcBasicCmtyVo) {
  232 + startPage();
  233 + mcBasicCmtyVo.setDefFlag("0");
  234 + List<McBasicCmty> list = mcBasicCmtyService.selectMcBasicCmtySummaryList(mcBasicCmtyVo);
  235 + return getDataTable(list);
  236 + }
  237 +
  238 +
  239 + @PostMapping("/summaryExport")
  240 + public void summaryExport(McBasicCmtyVo mcBasicCmtyVo,HttpServletResponse response) throws IOException {
  241 + List<McBasicCmty> list = mcBasicCmtyService.selectMcBasicCmtySummaryList(mcBasicCmtyVo);
  242 + try {
  243 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
  244 + response.setCharacterEncoding("utf-8");
  245 + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
  246 + String fileName = URLEncoder.encode("累加户数项目公司", "UTF-8").replaceAll("\\+", "%20");
  247 + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
  248 + // 这里需要设置不关闭流
  249 + EasyExcel.write(response.getOutputStream(), McBasicCmty.class).autoCloseStream(Boolean.FALSE).sheet("累加户数项目公司").doWrite(list);
  250 + } catch (Exception e) {
  251 + // 重置response
  252 + e.printStackTrace();
  253 + response.reset();
  254 + response.setContentType("application/json");
  255 + response.setCharacterEncoding("utf-8");
  256 + Map<String, String> map = MapUtils.newHashMap();
  257 + map.put("status", "failure");
  258 + map.put("message", "下载文件失败" + e.getMessage());
  259 + response.getWriter().println(JSON.toJSONString(map));
  260 + }
  261 + }
  262 +
  263 +
  264 +
227 265 }
... ...
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/mapper/McBasicCmtyMapper.java
... ... @@ -80,4 +80,11 @@ public interface McBasicCmtyMapper
80 80 List<McBasicCmty> selectVisitDeptList(McBasicCmtyVo mcBasicCmtyVo);
81 81  
82 82  
  83 + /**
  84 + * 汇总报表
  85 + * @param mcBasicCmtyVo
  86 + * @return
  87 + */
  88 + List<McBasicCmty> selectMcBasicCmtySummaryList(McBasicCmtyVo mcBasicCmtyVo);
  89 +
83 90 }
... ...
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/service/IMcBasicCmtyService.java
... ... @@ -82,4 +82,12 @@ public interface IMcBasicCmtyService
82 82  
83 83 List<McBasicCmty> selectVisitDeptList(McVisit mcVisit);
84 84  
  85 + /**
  86 + * 报表汇总
  87 + * @param mcBasicCmtyVo
  88 + * @return
  89 + */
  90 + List<McBasicCmty> selectMcBasicCmtySummaryList(McBasicCmtyVo mcBasicCmtyVo);
  91 +
  92 +
85 93 }
... ...
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/service/impl/McBasicCmtyServiceImpl.java
... ... @@ -169,6 +169,11 @@ public class McBasicCmtyServiceImpl implements IMcBasicCmtyService {
169 169 return mcBasicCmtyMapper.selectVisitDeptList(mcBasicCmtyVo);
170 170 }
171 171  
  172 + @Override
  173 + public List<McBasicCmty> selectMcBasicCmtySummaryList(McBasicCmtyVo mcBasicCmtyVo) {
  174 + return mcBasicCmtyMapper.selectMcBasicCmtySummaryList(mcBasicCmtyVo);
  175 + }
  176 +
172 177 private List<CompanyDto> loadDistinctGroups(McBasicCmtyVo mcBasicCmtyVo, CompanyDto parent) {
173 178 mcBasicCmtyVo.setRegionName(parent.getValue());
174 179 return mcBasicCmtyMapper.getDistinctGroupList(mcBasicCmtyVo);
... ...
zr-cloud/zr-modules/zr-schsf/src/main/resources/mapper/McBasicCmtyMapper.xml
... ... @@ -369,4 +369,142 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
369 369 and m.company_code = #{companyCode}
370 370 and m.vlg_or_cmty = #{vlgOrCmty}
371 371 </select>
  372 +
  373 + <select id="selectMcBasicCmtySummaryList" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
  374 + SELECT d.fiscal_year, d.region_name, d.group_name, d.company_name, d.company_code,
  375 + d.province, d.city, d.district, d.street, d.vlg_or_cmty, d.resp_person, d.urb_rur_cls,
  376 + d.project_type_name,
  377 + d.comm_hh,d.acct_fy_start_conf,(d.hh_prev_full+ d.hh_prev_inst_dp) as acct_prev_recov,d.acct_prev_charged,
  378 + (d.hh_new_full + d.hh_new_install) as curr_fy_new_recovered,
  379 + (d.hh_new_full + d.hh_new_install+d.hh_prev_full + d.acct_prev_charged) as total_charged,
  380 + d.qtr_target_company,d.hh_gsg_charged,d.hh_gsg_uncharged,(IFNULL(d.hh_gsg_charged,0)+ IFNULL(d.hh_gsg_uncharged,0)) as hh_gsg_total,
  381 + d.hh_new_full ,d.hh_new_install ,d.hh_prev_full ,d.hh_prev_inst_dp,
  382 + (IFNULL(d.acct_fy_start_conf,0) - d.hh_prev_full - d.hh_prev_inst_dp) as hh_unchg,
  383 + d.hh_unchg_conf,d.hh_unchg_scan,
  384 + (d.hh_new_full + d.hh_new_install+d.hh_prev_full + d.hh_prev_inst_dp) as hh_ev_cum_paid,
  385 + (d.hh_new_install + d.hh_prev_inst_dp) as hh_ev_inst,
  386 + (d.hh_new_full + d.hh_prev_full) as hh_ev_full,
  387 + d.hh_ev_ignite,
  388 + ((d.hh_new_full + d.hh_new_install+d.hh_prev_full + d.acct_prev_charged) / d.comm_hh) as hh_ev_cum_setup,
  389 + ((d.hh_new_full + d.hh_prev_full) / d.comm_hh) as hh_ev_cum_gas
  390 + FROM (
  391 + select m.id,m.update_time,m.fiscal_year, m.region_name, m.group_name, m.company_name, m.company_code,
  392 + m.province, m.city, m.district, m.street, m.vlg_or_cmty, m.resp_person, m.urb_rur_cls,
  393 + m.project_type_name,
  394 + (IFNULL(m.comm_hh,0) + IFNULL(hs.comm_hh,0)) AS comm_hh,
  395 + m.acct_fy_start_conf,
  396 + (IFNULL(m.hh_new_full,0)+ IFNULL(qkhs.hh_new_full,0)) as hh_new_full,
  397 + (IFNULL(m.hh_new_install,0) + IFNULL(fqhs.hh_new_install,0)) as hh_new_install,
  398 + m.hh_prev_full,m.hh_prev_inst_dp,
  399 + (IFNULL(m.hh_ev_ignite,0) + IFNULL(dhhs.hh_ev_ignite,0)) as hh_ev_ignite,
  400 + null as acct_prev_recov,
  401 + m.acct_prev_charged,
  402 + null as curr_fy_new_recovered,
  403 + null as total_charged,
  404 + m.qtr_target_company,
  405 + m.hh_gsg_charged,
  406 + m.hh_gsg_uncharged,
  407 + null as hh_gsg_total,
  408 + null as hh_unchg,
  409 + m.hh_unchg_conf,
  410 + m.hh_unchg_scan,
  411 +
  412 + null as hh_ev_cum_paid,
  413 + null as hh_ev_inst,
  414 + null as hh_ev_full,
  415 + null as hh_ev_cum_setup,
  416 + null as hh_ev_cum_gas
  417 +
  418 + FROM mc_basic_cmty m
  419 + left join sys_user u on u.user_id = m.create_by
  420 + left join sys_dept d on d.dept_id = m.company_code
  421 + left join (
  422 + SELECT fiscal_year, company_code, urb_rur_cls,
  423 + user_province, user_city, user_district, user_street, vlg_or_cmty,
  424 + COUNT(DISTINCT user_name,user_phone) AS comm_hh
  425 + FROM
  426 + mc_visit
  427 + GROUP BY
  428 + fiscal_year, company_code, urb_rur_cls,
  429 + user_province, user_city, user_district, user_street, vlg_or_cmty
  430 + ) hs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
  431 + and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
  432 + left join (
  433 + SELECT fiscal_year, company_code, urb_rur_cls,
  434 + user_province, user_city, user_district, user_street, vlg_or_cmty,
  435 + COUNT(DISTINCT user_name,user_phone) AS hh_new_full
  436 + FROM mc_visit
  437 + WHERE 1=1
  438 + AND charge_type='2'
  439 + AND status_code NOT IN ('CANCEL')
  440 + GROUP BY
  441 + fiscal_year, company_code, urb_rur_cls,
  442 + user_province, user_city, user_district, user_street, vlg_or_cmty
  443 + ) qkhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
  444 + and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
  445 + left join (
  446 + SELECT fiscal_year, company_code, urb_rur_cls,
  447 + user_province, user_city, user_district, user_street, vlg_or_cmty,
  448 + COUNT(DISTINCT user_name,user_phone) AS hh_new_install
  449 + FROM mc_visit
  450 + WHERE 1=1
  451 + AND charge_type in ("1","4")
  452 + AND status_code NOT IN ('CANCEL')
  453 + GROUP BY
  454 + fiscal_year, company_code, urb_rur_cls,
  455 + user_province, user_city, user_district, user_street, vlg_or_cmty
  456 + ) fqhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
  457 + and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
  458 + left join (
  459 + SELECT v.fiscal_year, i.company_code, i.urb_rur_cls,i.user_province, i.user_city, i.user_district, i.user_street, i.vlg_or_cmty,COUNT(DISTINCT i.id) as hh_ev_ignite
  460 + FROM mc_ignition i
  461 + INNER JOIN mc_visit v on i.visit_id= v.id
  462 + WHERE i.status_code in ('MAINTENANCE_YES','MAINTENANCE_NO')
  463 + GROUP BY v.fiscal_year, i.company_code, i.urb_rur_cls,i.user_province, i.user_city, i.user_district, i.user_street, i.vlg_or_cmty
  464 + ) dhhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
  465 + and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
  466 + where 1=1
  467 + <if test="fiscalYear != null "> and m.fiscal_year = #{fiscalYear}</if>
  468 + <if test="regionName != null and regionName != ''"> and m.region_name like concat('%', #{regionName}, '%')</if>
  469 + <if test="groupName != null and groupName != ''"> and m.group_name like concat('%', #{groupName}, '%')</if>
  470 + <if test="companyName != null and companyName != ''"> and m.company_name like concat('%', #{companyName}, '%')</if>
  471 + <if test="companyCode != null and companyCode != ''"> and m.company_code = #{companyCode}</if>
  472 + <if test="province != null and province != ''"> and m.province = #{province}</if>
  473 + <if test="city != null and city != ''"> and m.city = #{city}</if>
  474 + <if test="district != null and district != ''"> and m.district = #{district}</if>
  475 + <if test="street != null and street != ''"> and m.street = #{street}</if>
  476 + <if test="vlgOrCmty != null and vlgOrCmty != ''"> and m.vlg_or_cmty = #{vlgOrCmty}</if>
  477 + <if test="respPerson != null and respPerson != ''"> and m.resp_person = #{respPerson}</if>
  478 + <if test="urbRurCls != null and urbRurCls != ''"> and m.urb_rur_cls = #{urbRurCls}</if>
  479 + <if test="projectTypeName != null and projectTypeName != ''"> and m.project_type_name like concat('%', #{projectTypeName}, '%')</if>
  480 + <if test="commHh != null "> and m.comm_hh = #{commHh}</if>
  481 + <if test="acctFyStartConf != null "> and m.acct_fy_start_conf = #{acctFyStartConf}</if>
  482 + <if test="acctPrevRecov != null "> and m.acct_prev_recov = #{acctPrevRecov}</if>
  483 + <if test="acctPrevCharged != null "> and m.acct_prev_charged = #{acctPrevCharged}</if>
  484 + <if test="currFyNewRecovered != null "> and m.curr_fy_new_recovered = #{currFyNewRecovered}</if>
  485 + <if test="totalCharged != null "> and m.total_charged = #{totalCharged}</if>
  486 + <if test="qtrTargetCompany != null "> and m.qtr_target_company = #{qtrTargetCompany}</if>
  487 + <if test="hhGsgCharged != null "> and m.hh_gsg_charged = #{hhGsgCharged}</if>
  488 + <if test="hhGsgUncharged != null "> and m.hh_gsg_uncharged = #{hhGsgUncharged}</if>
  489 + <if test="hhGsgTotal != null "> and m.hh_gsg_total = #{hhGsgTotal}</if>
  490 + <if test="hhNewFull != null "> and m.hh_new_full = #{hhNewFull}</if>
  491 + <if test="hhNewInstall != null "> and m.hh_new_install = #{hhNewInstall}</if>
  492 + <if test="hhPrevFull != null "> and m.hh_prev_full = #{hhPrevFull}</if>
  493 + <if test="hhPrevInstDp != null "> and m.hh_prev_inst_dp = #{hhPrevInstDp}</if>
  494 + <if test="hhUnchg != null "> and m.hh_unchg = #{hhUnchg}</if>
  495 + <if test="hhUnchgConf != null "> and m.hh_unchg_conf = #{hhUnchgConf}</if>
  496 + <if test="hhUnchgScan != null "> and m.hh_unchg_scan = #{hhUnchgScan}</if>
  497 + <if test="hhEvCumPaid != null "> and m.hh_ev_cum_paid = #{hhEvCumPaid}</if>
  498 + <if test="hhEvInst != null "> and m.hh_ev_inst = #{hhEvInst}</if>
  499 + <if test="hhEvFull != null "> and m.hh_ev_full = #{hhEvFull}</if>
  500 + <if test="hhEvIgnite != null "> and m.hh_ev_ignite = #{hhEvIgnite}</if>
  501 + <if test="hhEvCumSetup != null "> and m.hh_ev_cum_setup = #{hhEvCumSetup}</if>
  502 + <if test="hhEvCumGas != null "> and m.hh_ev_cum_gas = #{hhEvCumGas}</if>
  503 + <if test="defFlag != null and defFlag != ''"> and m.def_flag = #{defFlag}</if>
  504 + <if test="startFiscalYear != null and startFiscalYear != ''"> and m.fiscal_year &gt;= #{startFiscalYear}</if>
  505 + <if test="finishFiscalYear != null and finishFiscalYear != ''"> and m.fiscal_year &lt;= #{finishFiscalYear}</if>
  506 + ${params.dataScope}
  507 + ) d
  508 + ORDER BY d.update_time desc
  509 + </select>
372 510 </mapper>
... ...