医院废弃物信息化管理平台
“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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
package cn.besteam.modules.medical.controller;
 
import java.io.IOException;
import java.math.RoundingMode;
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.constant.CommonConstant;
import cn.besteam.common.constant.MedicalWasteEnum;
import cn.besteam.common.util.DateUtil;
import cn.besteam.modules.medical.dto.MwCollectRecordOpsDTO;
import cn.besteam.modules.medical.vo.MwCollectRecordVO;
import cn.besteam.modules.medical.vo.MwCollectionAmendantRecordVO;
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.common.util.oConvertUtils;
import cn.besteam.modules.medical.entity.MwCollectionAmendantRecord;
import cn.besteam.modules.medical.service.IMwCollectionAmendantRecordService;
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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
 
 /**
 * @Title: Controller
 * @Description: 医废修改记录
 * @author: besteam
 * @date:   2022-02-14
 * @version: V1.0
 */
@RestController
@RequestMapping("/medical/mwCollectionAmendantRecord")
@Slf4j
@Api(description = "医废修改记录")
public class MwCollectionAmendantRecordController {
 
    @Autowired
    private IMwCollectionAmendantRecordService mwCollectionAmendantRecordService;
    
    /**
      * 分页列表查询
     * @param mwCollectionAmendantRecord
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @GetMapping(value = "/list")
    @ApiOperation(value = "获取医废修改记录数据列表", notes = "获取所有医废修改记录数据列表", produces = "application/json")
    public Result<IPage<MwCollectionAmendantRecord>> queryPageList(MwCollectionAmendantRecord mwCollectionAmendantRecord, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
 
        Result<IPage<MwCollectionAmendantRecord>> result = new Result<IPage<MwCollectionAmendantRecord>>();
        QueryWrapper<MwCollectionAmendantRecord> queryWrapper = new QueryWrapper<MwCollectionAmendantRecord>(mwCollectionAmendantRecord);
        Page<MwCollectionAmendantRecord> page = new Page<MwCollectionAmendantRecord>(pageNo, pageSize);
        //排序逻辑 处理
        String column = req.getParameter("column");
        String order = req.getParameter("order");
        if(oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
            if("asc".equals(order)) {
                queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
            }else {
                queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column));
            }
        }else{
            queryWrapper.orderByAsc("create_time");
        }
        IPage<MwCollectionAmendantRecord> pageList = mwCollectionAmendantRecordService.page(page, queryWrapper);
        //log.debug("查询当前页:"+pageList.getCurrent());
        //log.debug("查询当前页数量:"+pageList.getSize());
        //log.debug("查询结果数量:"+pageList.getRecords().size());
        //log.debug("数据总数:"+pageList.getTotal());
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
    
    /**
      *   添加
     * @param mwCollectionAmendantRecord
     * @return
     */
    @PostMapping(value = "/add")
    @AutoLog(value = "添加医废修改记录")
    @ApiOperation(value = "添加医废修改记录", notes = "添加医废修改记录", produces = "application/json")
    public Result<MwCollectionAmendantRecord> add(@RequestBody MwCollectionAmendantRecord mwCollectionAmendantRecord) {
 
        Result<MwCollectionAmendantRecord> result = new Result<MwCollectionAmendantRecord>();
        try {
            mwCollectionAmendantRecordService.save(mwCollectionAmendantRecord);
            result.success("添加成功!");
        } catch (Exception e) {
            log.error("", e);
            result.error500("操作失败");
        }
        return result;
    }
    
    /**
      *  编辑
     * @param mwCollectionAmendantRecord
     * @return
     */
    @PostMapping(value = "/edit")
    @AutoLog(value = "编辑医废修改记录")
    @ApiOperation(value = "编辑医废修改记录", notes = "编辑医废修改记录", produces = "application/json")
    public Result<MwCollectionAmendantRecord> edit(@RequestBody MwCollectionAmendantRecord mwCollectionAmendantRecord) {
 
        Result<MwCollectionAmendantRecord> result = new Result<MwCollectionAmendantRecord>();
        MwCollectionAmendantRecord mwCollectionAmendantRecordEntity = mwCollectionAmendantRecordService.getById(mwCollectionAmendantRecord.getId());
        if(mwCollectionAmendantRecordEntity==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = mwCollectionAmendantRecordService.updateById(mwCollectionAmendantRecord);
            //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<MwCollectionAmendantRecord> delete(@RequestParam(name="id",required=true) String id) {
 
        Result<MwCollectionAmendantRecord> result = new Result<MwCollectionAmendantRecord>();
        MwCollectionAmendantRecord mwCollectionAmendantRecord = mwCollectionAmendantRecordService.getById(id);
        if(mwCollectionAmendantRecord==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = mwCollectionAmendantRecordService.removeById(id);
            if(ok) {
                result.success("删除成功!");
            }
        }
        
        return result;
    }
    
    /**
      *  批量删除
     * @param ids
     * @return
     */
    @PostMapping(value = "/deleteBatch")
    @AutoLog(value = "批量删除医废修改记录")
    @ApiOperation(value = "批量删除医废修改记录", notes = "批量删除医废修改记录", produces = "application/json")
    public Result<MwCollectionAmendantRecord> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
 
        Result<MwCollectionAmendantRecord> result = new Result<MwCollectionAmendantRecord>();
        if(ids==null || "".equals(ids.trim())) {
            result.error500("参数不识别!");
        }else {
            this.mwCollectionAmendantRecordService.removeByIds(Arrays.asList(ids.split(",")));
            result.success("删除成功!");
        }
        return result;
    }
    
    /**
      * 通过id查询
     * @param id
     * @return
     */
    @GetMapping(value = "/queryById")
    @ApiOperation(value = "通过id查询医废修改记录", notes = "通过id查询医废修改记录", produces = "application/json")
    public Result<MwCollectionAmendantRecord> queryById(@RequestParam(name="id",required=true) String id) {
 
        Result<MwCollectionAmendantRecord> result = new Result<MwCollectionAmendantRecord>();
        MwCollectionAmendantRecord mwCollectionAmendantRecord = mwCollectionAmendantRecordService.getById(id);
        if(mwCollectionAmendantRecord==null) {
            result.error500("未找到对应实体");
        }else {
            result.setResult(mwCollectionAmendantRecord);
            result.setSuccess(true);
        }
        return result;
    }
 
 
     @GetMapping(value = "/listHistory")
     @ApiOperation(value = "医废修改记录列表", notes = "医废修改记录列表", produces = "application/json")
     public Result<IPage<MwCollectionAmendantRecordVO>> listHistory(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
 
         dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus());
         dto.setDelFlag(CommonConstant.DEL_FLAG_0);
         //
         IPage<MwCollectionAmendantRecordVO> pageList = mwCollectionAmendantRecordService.queryPageCollectList(pageNo, pageSize, dto);
         return Result.ok(pageList);
     }
 
     /*=====医废追溯导出--开始=======*/
     private static Map<String, String> headerMapListHistory = new LinkedHashMap<>();
 
     static {
         headerMapListHistory.put("createTime", "收集时间");
         headerMapListHistory.put("code", "废物编号");
         headerMapListHistory.put("hospitalName", "医院名称");
         headerMapListHistory.put("departmentName", "科室名称");
         /*headerMapListHistory.put("wasteTypeStr", "废物类型");
         headerMapListHistory.put("weight", "重量(kg)");*/
         headerMapListHistory.put("departmentUserName", "科室人员");
         headerMapListHistory.put("creator", "收集人员");
         headerMapListHistory.put("statusName", "状态");
         headerMapListHistory.put("typeName", "修改内容");
         headerMapListHistory.put("contentBefore", "修改前");
         headerMapListHistory.put("contentAfter", "修改后");
     }
 
     @Data
     private static class MwCollectRecordExportListHistoryVO {
 
         private String createTime="";
 
         private String code="";
 
         private String hospitalName="";
 
         private String departmentName="";
 
         /*private String wasteTypeStr="";
 
         private String weight="";*/
 
         private String departmentUserName="";
 
         private String creator="";
 
         private String statusName="";
         private String typeName="";
         private String contentBefore="";
         private String contentAfter="";
 
     }
 
     @GetMapping("/listHistoryExport")
     @OpenApi
     @ApiOperation(value = "医废修改导出", notes = "医废修改导出", produces = "application/json")
     public void listHistoryExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException {
         dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus());
         dto.setDelFlag(CommonConstant.DEL_FLAG_0);
         List<MwCollectionAmendantRecordVO> list=mwCollectionAmendantRecordService.queryPageCollectList( dto);
         List<MwCollectionAmendantRecordController.MwCollectRecordExportListHistoryVO> voList = new ArrayList<>();
         for (MwCollectionAmendantRecordVO collectRecordVO : list) {
             MwCollectionAmendantRecordController.MwCollectRecordExportListHistoryVO vo=new MwCollectionAmendantRecordController.MwCollectRecordExportListHistoryVO();
             BeanUtils.copyProperties(collectRecordVO, vo);
             vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
             //状态1新增 2已入库 3已出库
             if (collectRecordVO.getStatus().equals(1)) {
                 vo.setStatusName("未入库");
             } else if (collectRecordVO.getStatus().equals(2)) {
                 vo.setStatusName("已入库");
             } else if (collectRecordVO.getStatus().equals(3)) {
                 vo.setStatusName("已出库");
             }
             if(collectRecordVO.getType().equals(1)){
                 vo.setTypeName("修改废物类型");
             } else if (collectRecordVO.getType().equals(2)) {
                 vo.setTypeName("修改重量");
             } else if (collectRecordVO.getType().equals(3)) {
                 vo.setTypeName("删除数据");
             }
             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.setColumnWidth(7, 30);
         writer.setColumnWidth(8, 30);
         writer.setColumnWidth(9, 30);
         writer.setHeaderAlias(headerMapListHistory);
         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();
 
     }
 
}