From 8c5c5ce2938bd4f88f12722abe740570d9ed165e Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期五, 13 十二月 2024 18:03:19 +0800 Subject: [PATCH] 暂存间管理接口 --- medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 1 deletions(-) diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java index 7d4614e..fd187a1 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java @@ -1,10 +1,26 @@ package com.sinata.system.service.impl; +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sinata.common.entity.PageDTO; import com.sinata.system.domain.MwCollectRecord; +import com.sinata.system.domain.SysDepartment; +import com.sinata.system.domain.dto.MwCollectRecordDTO; +import com.sinata.system.domain.query.MwCollectRecordQuery; +import com.sinata.system.domain.vo.MedicalWasteProcessVO; +import com.sinata.system.domain.vo.MwCollectRecordVO; import com.sinata.system.mapper.MwCollectRecordMapper; import com.sinata.system.service.MwCollectRecordService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sinata.system.service.SysDepartmentService; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.List; +import java.util.Objects; /** * <p> @@ -15,6 +31,87 @@ * @since 2024-12-02 */ @Service +@RequiredArgsConstructor public class MwCollectRecordServiceImpl extends ServiceImpl<MwCollectRecordMapper, MwCollectRecord> implements MwCollectRecordService { + private final SysDepartmentService sysDepartmentService; + /** + * 医废追溯分页列表 + * + * @param query + * @return + */ + @Override + public PageDTO<MwCollectRecordVO> pageList(MwCollectRecordQuery query) { + String treeCode = ""; + if (Objects.isNull(query.getDepartmentId())) { + SysDepartment myDepartment = sysDepartmentService.getMyDepartment(); + if (Objects.isNull(myDepartment)) { + return PageDTO.empty(0L, 0L); + } + treeCode = myDepartment.getTreeCode(); + } else { + treeCode = sysDepartmentService.getById(query.getDepartmentId()).getTreeCode(); + } + Page<MwCollectRecordVO> page = baseMapper.pageList(new Page<>(query.getPageCurr(), query.getPageSize()), query, treeCode); + return PageDTO.of(page); + } + + /** + * 医废追溯详情 + * + * @param id + * @return + */ + @Override + public MwCollectRecordVO detail(Long id) { + return baseMapper.detail(id); + } + + /** + * 编辑 + * + * @param dto + */ + @Override + public void edit(MwCollectRecordDTO dto) { + MwCollectRecord collectRecord = getById(dto.getId()); + if (Objects.nonNull(collectRecord)) { + collectRecord.setWeight(dto.getWeight()); + updateById(collectRecord); + } + } + + /** + * 流转过程 + * + * @param id + * @return + */ + @Override + public MedicalWasteProcessVO getProcess(Long id) { + return baseMapper.getProcess(id); + } + + @Override + public void export(MwCollectRecordQuery query, HttpServletResponse response) throws IOException { + String treeCode = ""; + if (Objects.isNull(query.getDepartmentId())) { + SysDepartment myDepartment = sysDepartmentService.getMyDepartment(); + if (Objects.isNull(myDepartment)) { + return; + } + treeCode = myDepartment.getTreeCode(); + } else { + treeCode = sysDepartmentService.getById(query.getDepartmentId()).getTreeCode(); + } + List<MwCollectRecordVO> vo = baseMapper.getExportList(query, treeCode); + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("医废收集记录", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), MwCollectRecordVO.class).sheet("医废收集记录").doWrite(vo); + } } -- Gitblit v1.7.1