医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
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
package cn.besteam.modules.medical.service.impl;
 
import cn.besteam.modules.medical.dto.ServicePeriodLogDTO;
import cn.besteam.modules.medical.dto.ServicePeriodLogListDTO;
import cn.besteam.modules.medical.entity.MwServicePeriodLog;
import cn.besteam.modules.medical.mapper.MwServicePeriodLogMapper;
import cn.besteam.modules.medical.service.IMwServicePeriodLogService;
import cn.besteam.modules.system.vo.CollectAppletAuthorizationListVO;
import cn.besteam.modules.system.vo.MonthlySmsAuthorizationListVO;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.stereotype.Service;
 
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
 
@Service
public class MwServicePeriodLogServiceImpl extends ServiceImpl<MwServicePeriodLogMapper, MwServicePeriodLog> implements IMwServicePeriodLogService {
 
    @Override
    public IPage<ServicePeriodLogListDTO> getServicePeriodLog(ServicePeriodLogDTO dto, Integer pageNo, Integer pageSize) {
        pageNo = dto.getPageNo();
        pageSize = dto.getPageSize();
        Page<ServicePeriodLogListDTO> pageParam = new Page<>(pageNo, pageSize);
        if(dto.getServiceType() != null && dto.getServiceType()==0){
            dto.setServiceType(null);
        }
        if(dto.getDepartmentId()!=-1) {
            IPage<ServicePeriodLogListDTO> servicePeriodLog = this.baseMapper.getServicePeriodLog(pageParam, dto);
            return servicePeriodLog;
        }else {
            IPage<ServicePeriodLogListDTO> servicePeriodLog = this.baseMapper.getServicePeriodLog1(pageParam, dto);
            return servicePeriodLog;
        }
 
    }
 
    @Override
    public void exportServicePeriodLog(ServicePeriodLogDTO dto, HttpServletResponse response) throws Exception{
        ExcelWriter excelWriter = new ExcelWriter(exportServicePeriodLog(dto, "服务期操作记录"), "服务期操作记录");
        if (excelWriter != null) {
            response.setContentType("application/octet-stream;charset=utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("服务期操作记录", "UTF-8") + ".xlsx");
            excelWriter.flush(response.getOutputStream(), true);
            excelWriter.close();
        }
    }
 
    @Override
    public void saveLog(Integer valueOf, Double serviceCharge, Date expireDate, Integer reminderDays, Integer serviceUnit, String note, Integer userId,Integer i) {
        this.baseMapper.saveLog(valueOf,serviceCharge,expireDate,reminderDays,serviceUnit,note,userId,i);
    }
 
 
    private XSSFWorkbook exportServicePeriodLog(ServicePeriodLogDTO dto, String fileName){
        IPage<ServicePeriodLogListDTO> servicePeriodLog = getServicePeriodLog(dto, 1, 100000);
        List<ServicePeriodLogListDTO> records = servicePeriodLog.getRecords();
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.createSheet(fileName);
        XSSFCellStyle cellStyle = createDefaultCellStyle(workbook);
 
        XSSFRow row = sheet.createRow(0);//表头
        XSSFCell cell = row.createCell(0);
        cell.setCellStyle(cellStyle);
        cell.setCellValue("服务期操作记录");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 7));
 
        XSSFRow row2 = sheet.createRow(0);//表头
 
        XSSFCell cel20 = row2.createCell(0);
        cel20.setCellValue("操作时间");
        cel20.setCellStyle(cellStyle);
 
        XSSFCell cel21 = row2.createCell(1);
        cel21.setCellValue("区域");
        cel21.setCellStyle(cellStyle);
 
        XSSFCell cel22 = row2.createCell(2);
        cel22.setCellValue("医院名称");
        cel22.setCellStyle(cellStyle);
 
        XSSFCell cel23 = row2.createCell(3);
        cel23.setCellValue("操作内容");
        cel23.setCellStyle(cellStyle);
 
        XSSFCell cel24 = row2.createCell(4);
        cel24.setCellValue("操作前");
        cel24.setCellStyle(cellStyle);
 
        XSSFCell cel25 = row2.createCell(5);
        cel25.setCellValue("操作后");
        cel25.setCellStyle(cellStyle);
 
        XSSFCell cel26 = row2.createCell(6);
        cel26.setCellValue("备注");
        cel26.setCellStyle(cellStyle);
 
        XSSFCell cel27 = row2.createCell(7);
        cel27.setCellValue("操作人");
        cel27.setCellStyle(cellStyle);
 
        for (int i = 1; i < records.size(); i++) {
            XSSFRow row1 = sheet.createRow(i);//表头
            XSSFCell cel2 = row1.createCell(0);
            cel2.setCellStyle(cellStyle);
            cel2.setCellValue(records.get(i).getOperationTime());
            cel2.setCellStyle(cellStyle);
 
            XSSFCell cel3 = row1.createCell(1);
            cel3.setCellValue(records.get(i).getDepartmentName());
            cel3.setCellStyle(cellStyle);
 
            XSSFCell cel4 = row1.createCell(2);
            cel4.setCellValue(records.get(i).getHospital());
            cel4.setCellStyle(cellStyle);
 
            XSSFCell cel5 = row1.createCell(3);
            cel5.setCellValue(records.get(i).getServiceType() == 1 ? "修改到期时间" : "修改服务费");
            cel5.setCellStyle(cellStyle);
 
            XSSFCell cel6 = row1.createCell(4);
            cel6.setCellValue(records.get(i).getHistoricalData());
            cel6.setCellStyle(cellStyle);
 
            XSSFCell cel7 = row1.createCell(5);
            cel7.setCellValue(records.get(i).getCurrentData());
            cel7.setCellStyle(cellStyle);
 
            XSSFCell cel8 = row1.createCell(6);
            cel8.setCellValue(records.get(i).getNote());
            cel8.setCellStyle(cellStyle);
 
            XSSFCell cel9 = row1.createCell(7);
            cel9.setCellValue(records.get(i).getOperator());
            cel9.setCellStyle(cellStyle);
        }
        return workbook;
    }
 
 
    private XSSFCellStyle createDefaultCellStyle(XSSFWorkbook workbook) {
 
        XSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
        XSSFFont font = workbook.createFont();
        font.setFontName("宋体");
        font.setFontHeightInPoints((short) 12);
        cellStyle.setFont(font);
        return cellStyle;
    }
 
    private XSSFCellStyle createDefaultLeftCellStyle(XSSFWorkbook workbook) {
 
        XSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        cellStyle.setAlignment(HorizontalAlignment.LEFT);
        XSSFFont font = workbook.createFont();
        font.setFontName("宋体");
        font.setFontHeightInPoints((short) 12);
        cellStyle.setFont(font);
        return cellStyle;
    }
 
    private XSSFCellStyle createDefaultRightCellStyle(XSSFWorkbook workbook) {
 
        XSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        cellStyle.setAlignment(HorizontalAlignment.RIGHT);
        XSSFFont font = workbook.createFont();
        font.setFontName("宋体");
        font.setFontHeightInPoints((short) 12);
        cellStyle.setFont(font);
        return cellStyle;
    }
}