From 23015d814cefc8c56e3cbbc64793503832f18f03 Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Wed, 24 Mar 2021 17:16:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E6=89=93=E5=8D=A1=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/CommonController.java | 11 +- .../impl/SysCustomerHealthyServiceImpl.java | 11 +- .../mapper/custom/SysWxUserInfoMapper.xml | 11 +- .../components/PhysicalSignsDialog/index.vue | 3 +- stdiet-ui/src/utils/ruoyi.js | 4 +- .../src/views/custom/wxUserLog/index.vue | 712 ++++++++++-------- 6 files changed, 444 insertions(+), 308 deletions(-) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/common/CommonController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/common/CommonController.java index 079283e3d..961de15e5 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/common/CommonController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/common/CommonController.java @@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.net.URLDecoder; import java.util.concurrent.TimeUnit; /** @@ -46,12 +47,18 @@ public class CommonController { * @param delete 是否删除 */ @GetMapping("common/download") - public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { + public void fileDownload(String fileName, Boolean delete, String downFileName,HttpServletResponse response, HttpServletRequest request) { try { + if(StringUtils.isEmpty(fileName)){ + return; + } + //解码 + fileName = URLDecoder.decode(fileName, "UTF-8"); + downFileName = StringUtils.isEmpty(downFileName) ? null : URLDecoder.decode(downFileName, "UTF-8"); if (!FileUtils.isValidFilename(fileName)) { throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); } - String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String realFileName = (downFileName != null && downFileName.length() <= 200) ? downFileName : System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); String filePath = RuoYiConfig.getDownloadPath() + fileName; response.setCharacterEncoding("utf-8"); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java index aa6b9ae1d..8170cd5db 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java @@ -38,6 +38,8 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService @Autowired private ISysCustomerService sysCustomerService; + public static final String reportDownFileNameFormat = "%s超重%s斤%s"; + /** * 查询客户健康 * @@ -164,8 +166,10 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService //查询客户健康信息 SysCustomerHealthy sysCustomerHealthy = selectSysCustomerHealthyById(healthyDetailRequest.getId()); if(sysCustomerHealthy != null){ - ajaxResult = PdfUtils.generatePdfFile(templatePath, filePath, getReportData(sysCustomerHealthy, healthyDetailRequest)); + Map reportData = getReportData(sysCustomerHealthy, healthyDetailRequest); + ajaxResult = PdfUtils.generatePdfFile(templatePath, filePath, reportData); ajaxResult.put("path", fileName); + ajaxResult.put("downReportFileName", reportData.get("downReportFileName")+".pdf"); } return ajaxResult; } @@ -235,6 +239,11 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService } data.put("company","深圳胜唐体控有限公司"); data.put("date", DateUtils.getDate()); + + //文件下载时的名称,名字+超重几斤+病史体征 + String sign = StringUtils.isEmpty(healthyDetailRequest.getPhysicalSigns()) ? "" : healthyDetailRequest.getPhysicalSigns().replace(",","").replace(",","").replace("/", ""); + String downReportFileName = String.format(reportDownFileNameFormat, healthyDetailRequest.getName(), nutritionalCalories.getOverWeight() > 0 ? nutritionalCalories.getOverWeight().toString() : "0", sign); + data.put("downReportFileName", downReportFileName); return data; } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml index cb72bfb52..98cae17fc 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml @@ -36,14 +36,13 @@ select distinct wxuser.openid, wxuser.nick_name, wxuser.appid, wxuser.phone, wxuser.avatar_url, wxuser.sex, wxuser.update_time from sys_wx_user_info wxuser where (SELECT COUNT(wxlog.id) FROM sys_wx_user_log wxlog WHERE wxlog.openid = wxuser.openid) > 0 - - and wxuser.appid = #{appid} - and wxuser.openid != #{openid} - + and wxuser.appid = #{appid} + and wxuser.openid ]]> #{openid} order by wxuser.update_time desc diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml index c726b5f43..86a1f4a4d 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserLogMapper.xml @@ -171,7 +171,7 @@ - + + + + \ No newline at end of file