liusheng
2024-05-16 2f13f59f023fba63aa993172d48c14bcaaafb233
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceDonateorganController.java
@@ -1,13 +1,16 @@
package com.ruoyi.web.controller.project;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.NotRepeatCommit;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.bean.DtoConversionUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.domain.ServiceDonatecomporgan;
import com.ruoyi.project.domain.ServiceDonateorgan;
import com.ruoyi.project.domain.ServiceDonateorganVO;
import com.ruoyi.project.domain.ServiceOrganallocation;
@@ -17,6 +20,7 @@
import com.ruoyi.project.service.IServiceOrganallocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@@ -30,6 +34,7 @@
 * @author ruoyi
 * @date 2021-11-10
 */
@Slf4j
@Api("捐献器官管理")
@RestController
@RequestMapping("/project/donateorgan")
@@ -45,22 +50,23 @@
     * 查询捐献器官管理列表
     */
    @ApiOperation("捐献器官列表")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:list')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceDonateorgan serviceDonateorgan) {
        startPage();
        List<ServiceDonateorgan> list = serviceDonateorganService.queryList(serviceDonateorgan);
        if (!CollectionUtils.isEmpty(list)) {
            List<ServiceDonateorganVO> serviceDonateorganVOS = DtoConversionUtils.sourceToTarget(list, ServiceDonateorganVO.class);
//            for (ServiceDonateorganVO serviceDonateorganVO : serviceDonateorganVOS) {
//                ServiceOrganallocation serviceOrganallocation = new ServiceOrganallocation();
//                serviceOrganallocation.setOrganid(serviceDonateorganVO.getId());
//                List<ServiceOrganallocation> serviceOrganallocations = serviceOrganallocationService.selectServiceOrganallocationList(serviceOrganallocation);
//                serviceDonateorganVO.setServiceOrganallocations(serviceOrganallocations);
//            }
            return getDataTable(serviceDonateorganVOS);
        }
        return getDataTable(list);
    }
    /**
     * 器官分配累计
     */
    @ApiOperation("器官分配累计")
    @GetMapping("/countList")
    public TableDataInfo countList(ServiceDonateorgan serviceDonateorgan) {
        startPage();
        List<ServiceDonateorgan> list = serviceDonateorganService.countList(serviceDonateorgan);
        return getDataTable(list);
    }
@@ -76,7 +82,7 @@
     * 导出捐献器官管理列表
     */
    @ApiOperation("导出捐献器官列表")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:export')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:export')")
    @Log(title = "捐献器官管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ServiceDonateorgan serviceDonateorgan) {
@@ -89,7 +95,7 @@
     * 获取捐献器官管理详细信息
     */
    @ApiOperation("通过id获得捐献器官信息")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:query')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(serviceDonateorganService.getById(id));
@@ -99,9 +105,9 @@
     * 新增捐献器官管理
     */
    @ApiOperation("新增捐献器官信息")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:add')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:add')")
    @Log(title = "捐献器官管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PostMapping("/add")
    @RepeatSubmit
    public AjaxResult add(@RequestBody ServiceDonateorgan serviceDonateorgan) {
        String organNumber = serviceDonateorgan.getDonorno() + "." + serviceDonateorgan.getOrganno();
@@ -116,7 +122,8 @@
            }
        }
        serviceDonateorgan.setOrgannumber(organNumber);
        return toAjax(serviceDonateorganService.save(serviceDonateorgan));
        boolean save = serviceDonateorganService.save(serviceDonateorgan);
        return AjaxResult.success(serviceDonateorgan);
    }
@@ -124,7 +131,7 @@
     * 新增捐献器官管理
     */
    @ApiOperation("新增捐献器官信息")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:add')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:add')")
    @Log(title = "捐献器官管理", businessType = BusinessType.INSERT)
    @PostMapping("/addData")
    @RepeatSubmit
@@ -138,7 +145,7 @@
     * 修改器官分配
     */
    @ApiOperation("修改器官分配信息")
    //@PreAuthorize("@ss.hasPermi('project:organallocation:edit')")
    //// @PreAuthorize("@ss.hasPermi('project:organallocation:edit')")
    @Log(title = "器官分配", businessType = BusinessType.UPDATE)
    @PostMapping("/editarraydata")
    @RepeatSubmit
@@ -150,7 +157,7 @@
     * 修改捐献器官管理
     */
    @ApiOperation("修改捐献器官信息")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:edit')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:edit')")
    @Log(title = "捐献器官管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @RepeatSubmit
@@ -162,7 +169,7 @@
     * 删除捐献器官管理
     */
    @ApiOperation("删除捐献器官信息")
    //@PreAuthorize("@ss.hasPermi('project:donateorgan:remove')")
    //// @PreAuthorize("@ss.hasPermi('project:donateorgan:remove')")
    @Log(title = "捐献器官管理", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
@@ -279,5 +286,24 @@
        return AjaxResult.success(serviceDonateorganService.getOrganCount(timeVO));
    }
    @RepeatSubmit
    @ApiOperation("新增或修改捐献器官管理")
    @Log(title = "捐献完成", businessType = BusinessType.UPDATE)
    @PostMapping("/saveOrUpdateDonateorgan")
    public AjaxResult saveOrUpdateDonateorgan(@RequestBody List<ServiceDonateorgan> serviceDonateorganList) {
        if (CollectionUtils.isEmpty(serviceDonateorganList)) {
            throw new BaseException("请检查需要新增或修改的捐献器官管理参数是否完整");
        }
        Boolean i = null;
        for (ServiceDonateorgan serviceDonateorgan : serviceDonateorganList) {
            log.info("捐献器官移植id是否为空 : {},基础表的id为 : {}", serviceDonateorgan.getId(), serviceDonateorgan.getInfoid());
            if (serviceDonateorgan.getId() == null) {
                i = serviceDonateorganService.save(serviceDonateorgan);
            } else {
                i = serviceDonateorganService.updateById(serviceDonateorgan);
            }
        }
        return toAjax(i);
    }
}