医院废弃物信息化管理平台
“mitao”
2026-01-14 ce8e86e7045a6eadc2f06d3cd1af90d22b04fdd0
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
package cn.besteam.modules.medical.controller;
 
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import cn.besteam.common.aspect.annotation.OpenApi;
import cn.besteam.common.util.DateUtil;
import cn.besteam.modules.medical.dto.MwBusinessApprovalDTO;
import cn.besteam.modules.medical.dto.MwBusinessApprovalHandleDTO;
import cn.besteam.modules.medical.service.IMwBusinessApprovalHandleService;
import cn.besteam.modules.medical.vo.MwBusinessApprovalHandleVO;
import cn.besteam.modules.medical.vo.MwBusinessApprovalVO;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.AutoLog;
import cn.besteam.modules.medical.entity.MwBusinessApproval;
import cn.besteam.modules.medical.service.IMwBusinessApprovalService;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
 
 /**
 * @Title: Controller
 * @Description: 审批记录
 * @author: besteam
 * @date:   2022-02-09
 * @version: V1.0
 */
@RestController
@RequestMapping("/medical/mwBusinessApproval")
@Slf4j
@Api(description = "审批记录")
public class MwBusinessApprovalController {
 
    @Autowired
    private IMwBusinessApprovalService mwBusinessApprovalService;
 
    @Autowired
    private IMwBusinessApprovalHandleService mwBusinessApprovalHandleService;
    
    /**
      * 分页列表查询
     * @param mwBusinessApprovalDTO
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @GetMapping(value = "/list")
    @ApiOperation(value = "获取审批记录数据列表", notes = "获取所有审批记录数据列表", produces = "application/json")
    public Result<IPage<MwBusinessApprovalVO>> queryPageList(MwBusinessApprovalDTO mwBusinessApprovalDTO, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
 
        IPage<MwBusinessApprovalVO> result=mwBusinessApprovalService.queryPageList(pageNo, pageSize,mwBusinessApprovalDTO);
        return Result.ok(result);
    }
 
     /**
      *  立即审核
      * @param dto
      * @return
      */
     @PostMapping(value = "/audit")
     @AutoLog(value = "审批记录-审核")
     @ApiOperation(value = "审批记录-审核", notes = "审批记录-审核", produces = "application/json")
     public Result<Boolean> audit(@RequestBody MwBusinessApprovalHandleDTO dto) {
         return Result.ok(mwBusinessApprovalHandleService.businessApprovalHandle(dto));
     }
 
     /**
      * 通过id查询审批记处理记录数据
      * @param approvalId
      * @return
      */
     @GetMapping(value = "/queryHandleList")
     @ApiOperation(value = "通过id查询审批记处理记录数据", notes = "通过id查询审批记处理记录数据", produces = "application/json")
     public Result<List<MwBusinessApprovalHandleVO>> queryHandleList(@RequestParam(name="id",required=true) Integer approvalId) {
 
         List<MwBusinessApprovalHandleVO> list = mwBusinessApprovalHandleService.getBusinessApprovalHandleList(approvalId);
         return Result.ok(list);
     }
 
     /*=====医废追溯导出--开始=======*/
     private static Map<String, String> headerMapList = new LinkedHashMap<>();
 
     static {
         //申请机构、申请时间、申请人、联系电话、申请内容、申请说明、审批状态
         headerMapList.put("hospitalName", "申请机构");
         headerMapList.put("createTime", "申请时间");
         headerMapList.put("userName", "申请人");
         headerMapList.put("userPhone", "联系电话");
         headerMapList.put("applyContent", "申请内容");
         headerMapList.put("applyMark", "申请说明");
         headerMapList.put("status", "审批状态");
     }
 
     @Data
     private static class MwCollectionExportListVO {
 
 
         private String hospitalName="";
 
         private String createTime="";
 
         private String userName="";
 
         private String userPhone="";
 
         private String applyContent="";
 
         private String applyMark="";
 
         private String status="";
 
     }
 
     @GetMapping("/listExport")
     @OpenApi
     @ApiOperation(value = "审批数据导出", notes = "审批数据导出", produces = "application/json")
     public void listExport(HttpServletResponse response, MwBusinessApprovalDTO dto) throws IOException {
         List<MwBusinessApprovalVO> list=mwBusinessApprovalService.queryPageList( dto);
         List<MwCollectionExportListVO> voList = new ArrayList<>();
         for (MwBusinessApprovalVO businessApprovalVO : list) {
             MwCollectionExportListVO vo=new MwCollectionExportListVO();
             BeanUtils.copyProperties(businessApprovalVO, vo);
             //性质(1=院内站点,2=院外站点)
             if (businessApprovalVO.getStatus().equals(0)) {
                 vo.setStatus("未审批");
             } else if (businessApprovalVO.getStatus().equals(1)) {
                 vo.setStatus("通过");
             }else if (businessApprovalVO.getStatus().equals(2)) {
                 vo.setStatus("未通过");
             }
             vo.setCreateTime(DateUtil.formatTime(businessApprovalVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
             voList.add(vo);
         }
         ExcelWriter writer = ExcelUtil.getWriter(true);
         writer.renameSheet("审批数据信息");
         writer.setColumnWidth(0, 30);
         writer.setColumnWidth(1, 30);
         writer.setColumnWidth(2, 30);
         writer.setColumnWidth(3, 30);
         writer.setColumnWidth(4, 30);
         writer.setColumnWidth(5, 30);
         writer.setColumnWidth(6, 30);
         writer.setHeaderAlias(headerMapList);
         writer.write(voList);
         //
         String fileName = "审批数据信息";
         response.setContentType("application/octet-stream;charset=utf-8");
         response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
         //response.setContentType("application/octet-stream"); // 响应内容格式
         writer.flush(response.getOutputStream());
         writer.close();
 
     }
 
 
    
    /**
      *   添加
     * @param mwBusinessApproval
     * @return
     */
    @PostMapping(value = "/add")
    @AutoLog(value = "添加审批记录")
    @ApiOperation(value = "添加审批记录", notes = "添加审批记录", produces = "application/json")
    public Result<MwBusinessApproval> add(@RequestBody MwBusinessApproval mwBusinessApproval) {
 
        Result<MwBusinessApproval> result = new Result<MwBusinessApproval>();
        try {
            mwBusinessApprovalService.save(mwBusinessApproval);
            result.success("添加成功!");
        } catch (Exception e) {
            log.error("", e);
            result.error500("操作失败");
        }
        return result;
    }
    
    /**
      *  编辑
     * @param mwBusinessApproval
     * @return
     */
    @PostMapping(value = "/edit")
    @AutoLog(value = "编辑审批记录")
    @ApiOperation(value = "编辑审批记录", notes = "编辑审批记录", produces = "application/json")
    public Result<MwBusinessApproval> edit(@RequestBody MwBusinessApproval mwBusinessApproval) {
 
        Result<MwBusinessApproval> result = new Result<MwBusinessApproval>();
        MwBusinessApproval mwBusinessApprovalEntity = mwBusinessApprovalService.getById(mwBusinessApproval.getId());
        if(mwBusinessApprovalEntity==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = mwBusinessApprovalService.updateById(mwBusinessApproval);
            //TODO 返回false说明什么?
            if(ok) {
                result.success("修改成功!");
            }
        }
        
        return result;
    }
 
 
    
    /**
      *   通过id删除
     * @param id
     * @return
     */
    @PostMapping(value = "/delete")
    @AutoLog(value = "删除审批记录")
    @ApiOperation(value = "删除审批记录", notes = "删除审批记录", produces = "application/json")
    public Result<MwBusinessApproval> delete(@RequestParam(name="id",required=true) String id) {
 
        Result<MwBusinessApproval> result = new Result<MwBusinessApproval>();
        MwBusinessApproval mwBusinessApproval = mwBusinessApprovalService.getById(id);
        if(mwBusinessApproval==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = mwBusinessApprovalService.removeById(id);
            if(ok) {
                result.success("删除成功!");
            }
        }
        
        return result;
    }
    
    /**
      *  批量删除
     * @param ids
     * @return
     */
    @PostMapping(value = "/deleteBatch")
    @AutoLog(value = "批量删除审批记录")
    @ApiOperation(value = "批量删除审批记录", notes = "批量删除审批记录", produces = "application/json")
    public Result<MwBusinessApproval> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
 
        Result<MwBusinessApproval> result = new Result<MwBusinessApproval>();
        if(ids==null || "".equals(ids.trim())) {
            result.error500("参数不识别!");
        }else {
            this.mwBusinessApprovalService.removeByIds(Arrays.asList(ids.split(",")));
            result.success("删除成功!");
        }
        return result;
    }
 
}