From 2890e7b5f66df21afb0169630b9d0ad311791848 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Wed, 10 Jan 2024 14:37:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XxhbtkxxController.java | 38 ++++++++++++++++++- .../kc/ktgl/mapper/xml/KcKetangbiaoMapper.xml | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/imports/controller/XxhbtkxxController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/imports/controller/XxhbtkxxController.java index 5a4a26ca..ffc5b7bc 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/imports/controller/XxhbtkxxController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/imports/controller/XxhbtkxxController.java @@ -11,8 +11,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.kc.grab.imports.entity.Xxhbtkxx; import org.jeecg.modules.kc.grab.imports.service.IXxhbtkxxService; @@ -29,6 +31,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -52,7 +55,9 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; public class XxhbtkxxController extends JeecgController { @Autowired private IXxhbtkxxService xxhbtkxxService; - + + @Value("${jeecg.path.upload}") + private String upLoadPath; /** * 分页列表查询 * @@ -161,9 +166,38 @@ public class XxhbtkxxController extends JeecgController clazz, String title) { + // Step.1 组装查询条件 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + // 过滤选中数据 + String selections = request.getParameter("selections"); + if (oConvertUtils.isNotEmpty(selections)) { + List selectionList = Arrays.asList(selections.split(",")); + queryWrapper.in("id",selectionList); + } + queryWrapper.eq(StringUtils.isNotBlank(object.getXqxn()),"b.title",object.getXqxn()); + // Step.2 获取导出数据 + List exportList = service.list(queryWrapper); + + // Step.3 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, title); + mv.addObject(NormalExcelConstants.CLASS, clazz); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); + exportParams.setImageBasePath(upLoadPath); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS,exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + return mv; + } + /** * 通过excel导入数据 * diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/ktgl/mapper/xml/KcKetangbiaoMapper.xml b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/ktgl/mapper/xml/KcKetangbiaoMapper.xml index 3062e721..127ad50d 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/ktgl/mapper/xml/KcKetangbiaoMapper.xml +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/ktgl/mapper/xml/KcKetangbiaoMapper.xml @@ -43,7 +43,7 @@ left join xxhbjxljbxx jxljbxx on jsjbxx.jxlh = jxljbxx.jzwh left join kc_jieci jc on ktb.hh = jc.jieci left join kc_kechengbiao kcb on kcb.kcmc = ktb.kcmc and kcb.kcxz = ktb.kcxz and kcb.skjs = ktb.skjs and kcb.skdd=ktb.skdd and kcb.kkdw = ktb.kkdw and kcb.kcbh = ktb.kcbh and kcb.id = ktb.kechengbiaoid - left join (select distinct tkxx.xm,tkxx.kcmc,concat(substring(tkxx.skrq,1,4),'-',substring(tkxx.skrq,5,2),'-',substring(tkxx.skrq,7,2)) as skrq,tkxx.skjs,tkxx.tksy from xxhbtkxx tkxx where tkxx.skrq is not null) tkxx + left join (select distinct tkxx.xm,tkxx.kcmc,concat(substring(tkxx.skrq,1,4),'-',substring(tkxx.skrq,5,2),'-',substring(tkxx.skrq,7,2)) as skrq,tkxx.skjs,tkxx.tksy from xxhbtkxx tkxx where tkxx.tklx != '3' and tkxx.skrq is not null) tkxx on ktb.kcmc =tkxx.kcmc and ktb.skrq = tkxx.skrq and ktb.skdd=tkxx.skjs and ktb.skjs = tkxx.xm left join kc_kkdw kkdw on ktb.kkdw = kkdw.kkdw