liusheng
2024-04-17 d7bfd8dadd802a55225f9d5ea2ecb92c02b7dcce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package com.ruoyi.web.controller.project;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.annotation.Log;
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.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.DtoConversionUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.domain.*;
import com.ruoyi.project.service.IServiceDonorchargeorganService;
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.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
/**
 * 捐献器官Controller
 *
 * @author ruoyi
 * @date 2023-12-25
 */
@Slf4j
@Api("捐献器官")
@RestController
@RequestMapping("/project/donorchargeorgan")
public class ServiceDonorchargeorganController extends BaseController {
    @Autowired
    private IServiceDonorchargeorganService serviceDonorchargeorganService;
 
    /**
     * 查询捐献器官列表
     */
    @ApiOperation("查询捐献器官列表")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceDonorchargeorgan serviceDonorchargeorgan) {
        log.info("查询捐献器官列表的入参:{}", serviceDonorchargeorgan);
        startPage();
        List<ServiceDonorchargeorgan> list = null;
        if (serviceDonorchargeorgan.getPaymentidIsNotNull()) {
            list = serviceDonorchargeorganService.queryList(serviceDonorchargeorgan);
        } else {
            list = serviceDonorchargeorganService.queryListBypaymentidIsNull(serviceDonorchargeorgan);
        }
        List<ServiceDonorchargeorganVO> serviceDonorchargeorganVOList = DtoConversionUtils.sourceToTarget(list, ServiceDonorchargeorganVO.class);
 
        for (ServiceDonorchargeorganVO serviceDonorchargeorganVO : serviceDonorchargeorganVOList) {
            if (!StringUtils.isEmpty(serviceDonorchargeorganVO.getAnnexFiles())) {
                List<RbDetailFile> rbDetailFiles = JSONArray.parseArray(serviceDonorchargeorganVO.getAnnexFiles(), RbDetailFile.class);
                serviceDonorchargeorganVO.setAnnexFilesList(rbDetailFiles);
            }
        }
        return getDataTable2(serviceDonorchargeorganVOList, list);
    }
 
    /**
     * 导出捐献器官列表
     */
    @ApiOperation("导出捐献器官列表")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:export')")
    @Log(title = "捐献器官", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ServiceDonorchargeorgan serviceDonorchargeorgan) {
        List<ServiceDonorchargeorgan> list = serviceDonorchargeorganService.queryList(serviceDonorchargeorgan);
        ExcelUtil<ServiceDonorchargeorgan> util = new ExcelUtil<ServiceDonorchargeorgan>(ServiceDonorchargeorgan.class);
        return util.exportExcel(list, "捐献器官数据");
    }
 
    /**
     * 获取捐献器官详细信息
     */
    @ApiOperation("获取捐献器官详细信息")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(serviceDonorchargeorganService.getById(id));
    }
 
    /**
     * 新增捐献器官
     */
    @ApiOperation("新增捐献器官")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:add')")
    @Log(title = "捐献器官", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @RepeatSubmit
    public AjaxResult add(@RequestBody ServiceDonorchargeorganVO serviceDonorchargeorganvo) {
        if (!CollectionUtils.isEmpty(serviceDonorchargeorganvo.getAnnexFilesList())) {
            serviceDonorchargeorganvo.setAnnexFiles(JSON.toJSONString(serviceDonorchargeorganvo.getAnnexFilesList()));
        }
        ServiceDonorchargeorgan serviceDonorchargeorgan = DtoConversionUtils.sourceToTarget(serviceDonorchargeorganvo, ServiceDonorchargeorgan.class);
        boolean save = serviceDonorchargeorganService.save(serviceDonorchargeorgan);
        return AjaxResult.success(serviceDonorchargeorgan);
    }
 
    /**
     * 修改捐献器官
     */
    @ApiOperation("修改捐献器官")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:edit')")
    @Log(title = "捐献器官", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @RepeatSubmit
    public AjaxResult edit(@RequestBody ServiceDonorchargeorganVO serviceDonorchargeorganVO) {
        if (!CollectionUtils.isEmpty(serviceDonorchargeorganVO.getAnnexFilesList())) {
            serviceDonorchargeorganVO.setAnnexFiles(JSON.toJSONString(serviceDonorchargeorganVO.getAnnexFilesList()));
        }
        ServiceDonorchargeorgan serviceDonorchargeorgan = DtoConversionUtils.sourceToTarget(serviceDonorchargeorganVO, ServiceDonorchargeorgan.class);
        return toAjax(serviceDonorchargeorganService.updateById(serviceDonorchargeorgan));
    }
 
    /**
     * 删除捐献器官
     */
    @ApiOperation("删除捐献器官")
//    @PreAuthorize("@ss.hasPermi('project:donorchargeorgan:remove')")
    @Log(title = "捐献器官", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(serviceDonorchargeorganService.removeByIds(Arrays.asList(ids)));
    }
 
    @RepeatSubmit
    @ApiOperation("新增或修改捐献器官")
    @Log(title = "捐献器官", businessType = BusinessType.UPDATE)
    @PostMapping("/saveOrUpdateDonorchargeorgan")
    public AjaxResult saveOrUpdateDonorchargeorgan(@RequestBody List<ServiceDonorchargeorganVO> serviceDonorchargeorganList) {
        if (CollectionUtils.isEmpty(serviceDonorchargeorganList)) {
            throw new BaseException("请检查需要新增或修改的捐献器官参数是否完整");
        }
        Boolean i = null;
        for (ServiceDonorchargeorganVO serviceDonorchargeorganVO : serviceDonorchargeorganList) {
            log.info("捐献器官id是否为空 : {},基础表的id为 : {}", serviceDonorchargeorganVO.getId(), serviceDonorchargeorganVO.getInfoid());
            ServiceDonorchargeorgan serviceDonorchargeorgan = DtoConversionUtils.sourceToTarget(serviceDonorchargeorganVO, ServiceDonorchargeorgan.class);
            serviceDonorchargeorgan.setAnnexFiles(JSON.toJSONString(serviceDonorchargeorganVO.getAnnexFilesList()));
            if (serviceDonorchargeorgan.getDel_flag() == null) {
                serviceDonorchargeorgan.setDel_flag(0);
            }
            if (serviceDonorchargeorgan.getId() == null) {
                i = serviceDonorchargeorganService.save(serviceDonorchargeorgan);
            } else {
                i = serviceDonorchargeorganService.updateDonorchargeorgan(serviceDonorchargeorgan);
            }
        }
        return toAjax(i);
    }
 
    @ApiOperation("收费统计")
    @PostMapping("/getListBySpStatChange")
    public TableDataInfo getListBySpStatChange(@RequestBody SpStatChangeReq spStatChangeReq) {
        return getDataTable(serviceDonorchargeorganService.getListBySpStatChange(spStatChangeReq));
    }
}