ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBannerController.java
@@ -39,7 +39,7 @@ /** * 获取轮播图管理列表 */ @PreAuthorize("@ss.hasPermi('system:banner:list')") @PreAuthorize("@ss.hasPermi('system:banner')") @ApiOperation(value = "获取轮播图分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TBanner>> pageList(@RequestBody TBannerQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCheckAcceptRecordController.java
@@ -58,7 +58,7 @@ /** * 获取验收记录管理列表 */ @PreAuthorize("@ss.hasPermi('houseManage:check:list')") @PreAuthorize("@ss.hasPermi('houseManage:check')") @ApiOperation(value = "获取验收记录分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TCheckAcceptRecordVO>> pageList(@RequestBody TCheckAcceptRecordQuery query) { @@ -113,6 +113,7 @@ tBill.setContractId(dto.getContractId()); tBill.setContractNumber(contract.getContractNumber()); tBill.setPayableFeesMoney(dto.getCheckMoney()); tBill.setOutstandingMoney(dto.getCheckMoney()); tBill.setPayableFeesTime(LocalDate.now()); tBill.setPayFeesStatus("1"); tBill.setBillType("4"); ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDeptController.java
@@ -51,7 +51,7 @@ /** * 获取部门管理管理列表 */ @PreAuthorize("@ss.hasPermi('system:department:list')") @PreAuthorize("@ss.hasPermi('system:department')") @ApiOperation(value = "获取部门管理分页列表") @PostMapping(value = "/pageList") public R<PageInfo<DeptVO>> pageList(@RequestBody TDeptQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultAreaDicController.java
@@ -46,7 +46,7 @@ /** * 获取故障区域管理列表 */ @PreAuthorize("@ss.hasPermi('system:faultArea:list')") @PreAuthorize("@ss.hasPermi('system:faultArea')") @ApiOperation(value = "获取故障区域分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultAreaDic>> pageList(@RequestBody TFaultAreaDicQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultDescribeDicController.java
@@ -42,7 +42,7 @@ /** * 获取故障描述管理列表 */ @PreAuthorize("@ss.hasPermi('system:tag:list')") @PreAuthorize("@ss.hasPermi('system:tag')") @ApiOperation(value = "获取故障描述分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultDescribeDicVO>> pageList(@RequestBody TFaultDescribeDicQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultRepairMessageController.java
@@ -41,7 +41,7 @@ /** * 获取报修管理列表 */ @PreAuthorize("@ss.hasPermi('houseManage:acceptance:list')") @PreAuthorize("@ss.hasPermi('houseManage:acceptance')") @ApiOperation(value = "获取报修分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultRepairMessageVO>> pageList(@RequestBody TFaultRepairMessageQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInvoiceController.java
@@ -12,10 +12,16 @@ import com.ruoyi.system.query.TInvoiceQuery; import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TInvoiceService; import com.ruoyi.web.controller.tool.TencentCosUtil; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; /** @@ -33,6 +39,8 @@ private TInvoiceService invoiceService; @Autowired TBillService tBillService; @Autowired TencentCosUtil tencentCosUtil; @PreAuthorize("@ss.hasPermi('invoice:list')") @ApiOperation(value = "获取开票列表") @PostMapping("/list") @@ -58,7 +66,51 @@ @PostMapping("/uploadVoucher") @PreAuthorize("@ss.hasPermi('invoice:list:payment')") public R<Boolean> uploadVoucher(@RequestBody TInvoiceQuery query) { return R.ok(invoiceService.uploadVoucher(query)); String invoiceVoucher = query.getInvoiceVoucher(); String invoiceVoucherName = query.getInvoiceVoucherName(); if (invoiceVoucher == null || invoiceVoucherName == null) { return R.fail("请上传发票文件"); } String[] voucherUrls = invoiceVoucher.split(","); String[] voucherNames = invoiceVoucherName.split(","); // 确保两个数组长度一致 int length = Math.min(voucherUrls.length, voucherNames.length); if (length == 0) { return R.fail("请上传发票文件"); } // 构建附件列表 List<Map<String, String>> attachments = new ArrayList<>(length); for (int i = 0; i < length; i++) { String voucherUrl = voucherUrls[i]; String fileName = voucherNames[i]; Map<String, String> attachment = new HashMap<>(2); // 初始容量为2,避免扩容 String tempDir = System.getProperty("java.io.tmpdir"); Path filePath = Paths.get(tempDir, fileName); // 保存到临时目录 tencentCosUtil.download(voucherUrl,filePath.toString(),fileName); attachment.put("filePath", filePath.toString()); attachment.put("fileName", fileName); attachments.add(attachment); } return R.ok(invoiceService.uploadVoucher(query,attachments)); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
@@ -62,7 +62,7 @@ @Autowired private ISysMenuService menuService; @PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role')") @ApiOperation(value = "角色列表") @PostMapping("/list") public AjaxResult list(@RequestBody SysRoleQuery query) @@ -71,7 +71,7 @@ return AjaxResult.success(list); } @PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role')") @ApiOperation(value = "角色列表不分页") @PostMapping("/listNotPage") public AjaxResult list() ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -22,6 +22,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -56,6 +57,7 @@ */ @ApiOperation(value = "获取用户列表") @PostMapping("/list") @PreAuthorize("@ss.hasPermi('system:user')") public AjaxResult list(@RequestBody SysUserQuery query) { PageInfo<SysUserVO> list = userService.pageList(query); @@ -64,6 +66,8 @@ @ApiOperation(value = "获取用户列表-不分页") @PostMapping("/listNotPage") @PreAuthorize("@ss.hasPermi('system:user')") public AjaxResult listNotPage() { List<SysUser> list = userService.selectList(); ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TencentCosUtil.java
@@ -27,6 +27,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Base64; import java.util.Date; import java.util.UUID; @@ -256,4 +261,29 @@ } /** * 将文件下载到指定目录 * @param fileUrl * @param saveDir * @param fileName * @throws IOException */ public void download(String fileUrl, String saveDir, String fileName){ fileUrl = fileUrl.replace(cosConfig.getRootSrc(), ""); // 下载文件并获取输入流 COSObject object = cosClient.getObject(cosConfig.getBucketName(),fileUrl); try ( InputStream in = object.getObjectContent(); ){ Path targetPath = Paths.get(saveDir, fileName); // 确保目录存在 Files.createDirectories(targetPath.getParent()); // 将文件保存到目标路径 Files.copy(in, targetPath, StandardCopyOption.REPLACE_EXISTING); }catch (IOException e){ log.error("读取cos图片发生异常", e); } } } ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
@@ -8,16 +8,18 @@ import javax.activation.DataHandler; import javax.activation.FileDataSource; import java.net.URLEncoder; import javax.activation.URLDataSource; import javax.annotation.Resource; import javax.mail.*; import javax.mail.internet.*; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; import java.util.concurrent.CompletableFuture; @@ -132,14 +134,43 @@ // 设置邮件标题 message.setSubject("发票"); // 创建邮件内容 Multipart multipart = createMultipart(list); Multipart multipart = new MimeMultipart(); // 添加文本消息部分 BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setHeader("Content-Type", "text/plain;charset=utf-8"); messageBodyPart.setContent("您在小程序提交的开票申请已开票成功,请查看附件内容","text/html;charset=UTF-8"); multipart.addBodyPart(messageBodyPart); List<Path> tempFilePath = new ArrayList<>(); // 添加附件部分 for (Map<String, String> map : list) { messageBodyPart = new MimeBodyPart(); String filePath = map.get("filePath"); String fileName = map.get("fileName"); tempFilePath.add(Paths.get(filePath)); FileDataSource source = new FileDataSource(filePath); messageBodyPart.setDataHandler(new DataHandler(source)); String filenameEncode = MimeUtility.encodeText(fileName, "UTF-8", "base64"); // String encodedFileName = Base64.getEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8)); // String filenameEncode = MimeUtility.encodeText(encodedFileName); messageBodyPart.setFileName(filenameEncode); messageBodyPart.setHeader("Content-Transfer-Encoding", "base64"); messageBodyPart.setHeader("Content-Disposition", "attachment"); messageBodyPart.setHeader("Content-Type", "application/octet-stream;name=\"" + filenameEncode + "\""); multipart.addBodyPart(messageBodyPart); } // 设置邮件内容 message.setContent(multipart); // 发送邮件 Transport.send(message); // 删除临时目录里面的文件 for (Path path : tempFilePath) { Files.deleteIfExists(path); } } catch (MessagingException | UnsupportedEncodingException | MalformedURLException e) { log.error("发送邮件发生异常", e); throw new ServiceException("发送邮件失败, 请检查"); } catch (IOException e) { throw new RuntimeException("文件下载发生异常"); } } @@ -167,31 +198,6 @@ return new PasswordAuthentication(userName, password); } }; } private Multipart createMultipart(List<Map<String, String>> list) throws MessagingException, UnsupportedEncodingException, MalformedURLException { Multipart multipart = new MimeMultipart(); // 添加文本消息部分 BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setHeader("Content-Type", "text/plain;charset=utf-8"); messageBodyPart.setContent("您在小程序提交的开票申请已开票成功,请查看附件内容","text/html;charset=UTF-8"); multipart.addBodyPart(messageBodyPart); // 添加附件部分 for (Map<String, String> map : list) { messageBodyPart = new MimeBodyPart(); String url = map.get("url"); String fileName = map.get("fileName"); URLDataSource source = new URLDataSource(new URL(url)); messageBodyPart.setDataHandler(new DataHandler(source)); String filenameEncode = MimeUtility.encodeText(fileName, "UTF-8", "base64"); messageBodyPart.setFileName(filenameEncode); messageBodyPart.setHeader("Content-Transfer-Encoding", "base64"); messageBodyPart.setHeader("Content-Disposition", "attachment"); messageBodyPart.setHeader("Content-Type", "application/octet-stream;name=\"" + filenameEncode + "\""); multipart.addBodyPart(messageBodyPart); } return multipart; } // public static void main(String[] args) throws UnsupportedEncodingException { ruoyi-system/src/main/java/com/ruoyi/system/service/TInvoiceService.java
@@ -7,6 +7,7 @@ import com.ruoyi.system.query.TInvoiceQuery; import java.util.List; import java.util.Map; /** * <p> @@ -19,5 +20,5 @@ public interface TInvoiceService extends IService<TInvoice> { PageInfo<TInvoice> pageList(TInvoiceQuery query); List<TInvoice> makeQuery(TInvoiceQuery query); Boolean uploadVoucher(TInvoiceQuery query); Boolean uploadVoucher(TInvoiceQuery query, List<Map<String, String>> map); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
@@ -948,9 +948,9 @@ // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()))); originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth())))+1; }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getEndTime())); originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getEndTime()))+1; } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); @@ -966,8 +966,10 @@ break; } } if (originalTime.isBefore(tBill.getEndTime())){ long tempOriginal = ChronoUnit.DAYS.between(originalTime,tBill.getEndTime()); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); } tBill.setPayableFeesMoney(originalMoney); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TContractServiceImpl.java
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
@@ -18,6 +18,7 @@ import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; /** @@ -37,7 +38,7 @@ PageInfo<THouse> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<THouse> list = this.baseMapper.houseList(query,pageInfo); List<TContract> tContracts = contractMapper.selectList(new LambdaQueryWrapper<TContract>() .eq(TContract::getStatus, 4) .in(TContract::getStatus, Arrays.asList(4,6,7)) .le(TContract::getStartTime, LocalDateTime.now()) .ge(TContract::getEndTime, LocalDateTime.now())); for (THouse tHouse : list) { @@ -46,10 +47,11 @@ if (tContract!=null){ tHouse.setTenantType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE,tContract.getPayType())); // tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,"2")); tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,"2")); }else{ // tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tHouse.getLeaseStatus())); } tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tHouse.getLeaseStatus())); } } pageInfo.setRecords(list); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInvoiceServiceImpl.java
@@ -58,7 +58,7 @@ } @Override public Boolean uploadVoucher(TInvoiceQuery query) { public Boolean uploadVoucher(TInvoiceQuery query, List<Map<String, String>> map) { // 检查是否存在对应的发票记录 TInvoice preexist = getById(query.getId()); if (preexist == null) { @@ -74,17 +74,11 @@ tInvoice.setInvoiceTime(query.getInvoiceTime()); tInvoice.setStatus(2); // 处理附件信息 List<Map<String, String>> attachments = buildAttachments(query.getInvoiceVoucher(), query.getInvoiceVoucherName()); if (attachments.isEmpty()) { log.warn("未找到有效的附件信息"); return updateById(tInvoice); } // 异步发送邮件 CompletableFuture.runAsync(() -> { try { mailUtil.sendInvoice(preexist.getEmail(), attachments); mailUtil.sendInvoice(preexist.getEmail(), map); } catch (ServiceException e) { log.error("邮件发送失败", e); } @@ -93,57 +87,4 @@ // 更新数据库 return updateById(tInvoice); } private List<Map<String, String>> buildAttachments(String invoiceVoucher, String invoiceVoucherName) { if (invoiceVoucher == null || invoiceVoucherName == null) { return Collections.emptyList(); } String[] voucherUrls = invoiceVoucher.split(","); String[] voucherNames = invoiceVoucherName.split(","); // 确保两个数组长度一致 int length = Math.min(voucherUrls.length, voucherNames.length); if (length == 0) { return Collections.emptyList(); } // 构建附件列表 List<Map<String, String>> attachments = new ArrayList<>(length); for (int i = 0; i < length; i++) { Map<String, String> attachment = new HashMap<>(2); // 初始容量为2,避免扩容 attachment.put("url", voucherUrls[i]); attachment.put("fileName", voucherNames[i]); attachments.add(attachment); } return attachments; } // @Override // public Boolean uploadVoucher(TInvoiceQuery query) { // TInvoice preexist = getById(query.getId()); // if (preexist == null){ // return false; // } // TInvoice tInvoice = new TInvoice(); // tInvoice.setId(query.getId()); // tInvoice.setInvoiceVoucher(query.getInvoiceVoucher()); // tInvoice.setInvoiceVoucherName(query.getInvoiceVoucherName()); // tInvoice.setInvoiceTime(query.getInvoiceTime()); // tInvoice.setStatus(2); // List<Map<String, String>> mapArrayList = new ArrayList<>(); // String invoiceVoucher = query.getInvoiceVoucher(); // String invoiceVoucherName = query.getInvoiceVoucherName(); // // List<String> list = Arrays.stream(invoiceVoucher.split(",")).collect(Collectors.toList()); // for (int i = 0; i < list.size()-1; i++) { // Map<String, String> map = new HashMap<>(); // map.put("url", list.get(i)); // map.put("fileName",invoiceVoucherName.split(",")[i]); // mapArrayList.add(map); // } // mailUtil.sendInvoice(preexist.getEmail(),mapArrayList); // return updateById(tInvoice); // } }