From 90e2fa776f8a69055bddd159f9e84e7f70a11c8d Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 02 三月 2026 09:54:39 +0800
Subject: [PATCH] bug处理

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/THelpNeedsController.java |  103 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 92 insertions(+), 11 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/THelpNeedsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/THelpNeedsController.java
index 92aef03..641bc3c 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/THelpNeedsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/THelpNeedsController.java
@@ -1,25 +1,43 @@
 package com.ruoyi.web.controller.api;
 
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.WebUtils;
+import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.dto.HandleAppealServicesDTO;
+import com.ruoyi.system.dto.HandleHelpNeedsDTO;
+import com.ruoyi.system.export.THelpNeedsExport;
+import com.ruoyi.system.export.TMicroWishExport;
 import com.ruoyi.system.model.TAppUser;
+import com.ruoyi.system.model.TAppealServices;
 import com.ruoyi.system.model.THelpNeeds;
 import com.ruoyi.system.model.THelpNeeds;
 import com.ruoyi.system.query.AssistedDiningListQuery;
 import com.ruoyi.system.query.HelpNeedsListQuery;
+import com.ruoyi.system.query.TCourseOrderQuery;
 import com.ruoyi.system.service.THelpNeedsService;
 import com.ruoyi.system.service.THelpNeedsService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -36,6 +54,8 @@
 public class THelpNeedsController {
     @Autowired
     private THelpNeedsService helpNeedsService;
+    @Autowired
+    private TokenService tokenService;
     @ApiOperation(value = "助需管理分页列表")
     @PostMapping(value = "/pageList")
     public R<PageInfo<THelpNeeds>> pageList(@RequestBody HelpNeedsListQuery query) {
@@ -46,30 +66,91 @@
     @Transactional
     @Log(title = "助需管理-添加", businessType = BusinessType.INSERT)
     @PostMapping(value = "/add")
-    public R<Boolean> save(@RequestBody THelpNeeds entity) {
-        helpNeedsService.save(entity);
+    public R<Boolean> save(@RequestBody THelpNeeds dto) {
+        String nickName = tokenService.getLoginUser().getUser().getNickName();
+        dto.setNickName(nickName);
+        helpNeedsService.save(dto);
         return R.ok();
     }
     @ApiOperation(value = "修改")
     @Log(title = "助需管理-修改", businessType = BusinessType.UPDATE)
     @PostMapping(value = "/edit")
-    public R<Boolean> edit(@RequestBody THelpNeeds entity) {
-        helpNeedsService.updateById(entity);
+    public R<Boolean> edit(@RequestBody THelpNeeds dto) {
+        helpNeedsService.updateById(dto);
         return R.ok();
     }
     @Log(title = "助需管理-删除", businessType = BusinessType.DELETE)
     @ApiOperation(value = "助需管理-删除")
-    @DeleteMapping(value = "/delete")
-    public R delete(@RequestParam String ids) {
-        List<Integer> res = Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList());
-        // 转换成Integer
-        helpNeedsService.removeBatchByIds(res);
-        return R.ok();
+    @DeleteMapping(value = "/deleteById")
+    public R<Boolean> deleteById(@RequestParam String id) {
+        return R.ok(helpNeedsService.removeById(id));
+    }
+
+    /**
+     * 批量删除助需管理
+     */
+    @Log(title = "助需管理-批量删除", businessType = BusinessType.DELETE)
+    @ApiOperation(value = "助需管理-批量删除")
+    @DeleteMapping(value = "/deleteByIds")
+    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
+        return R.ok(helpNeedsService.removeByIds(ids));
     }
     @ApiOperation(value = "查看详情")
     @GetMapping(value = "/detail")
-    public R<THelpNeeds> detail(Integer id) {
+    public R<THelpNeeds> detail(String id) {
         return R.ok(helpNeedsService.getById( id));
     }
+
+    /**
+     * 处理助需
+     */
+    @Log(title = "助需管理-处理助需", businessType = BusinessType.UPDATE)
+    @ApiOperation(value = "处理助需")
+    @PostMapping(value = "/handleHelpNeeds")
+    public R<String> handleHelpNeeds(@RequestBody HandleHelpNeedsDTO dto) {
+
+        Long userId = tokenService.getLoginUser().getUserId();
+        String nickName = tokenService.getLoginUser().getUser().getNickName();
+
+        THelpNeeds helpNeeds = helpNeedsService.getById(dto.getId());
+        helpNeeds.setStatus(2);
+        helpNeeds.setUserId(userId);
+        helpNeeds.setProcessPersonName(nickName);
+        helpNeeds.setProcessTime(LocalDateTime.now());
+        helpNeeds.setProcessRemark(dto.getProcessRemark());
+        helpNeeds.setProcessPictures(dto.getProcessPictures());
+        helpNeedsService.updateById(helpNeeds);
+        return R.ok();
+    }
+
+    @Log(title = "助需管理-助需记录导出", businessType = BusinessType.EXPORT)
+    @ApiOperation(value = "助需记录导出")
+    @PostMapping("/exportHelpNeeds")
+    public void exportHelpNeeds(@RequestBody HelpNeedsListQuery query){
+        List<THelpNeedsExport> helpNeedsExports = helpNeedsService.exportHelpNeeds(query);
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), THelpNeedsExport.class, helpNeedsExports);
+        HttpServletResponse response = WebUtils.response();
+        assert response != null;
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        ServletOutputStream outputStream = null;
+        try {
+            String fileName = URLEncoder.encode("助需记录导出.xls", "utf-8");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            response.setHeader("Pragma", "no-cache");
+            response.setHeader("Cache-Control", "no-cache");
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                outputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 }
 

--
Gitblit v1.7.1