mitao
2025-04-14 0852acae13603be95eaaa0b501f3441508ff3fe5
medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java
@@ -12,6 +12,7 @@
import com.sinata.common.utils.DateUtils;
import com.sinata.common.utils.SecurityUtils;
import com.sinata.common.utils.StringUtils;
import com.sinata.system.config.AutoColumnWidthEntityStrategy;
import com.sinata.system.config.AutoColumnWidthStrategy;
import com.sinata.system.domain.MwCollectRecord;
import com.sinata.system.domain.MwMicroEquipment;
@@ -23,7 +24,6 @@
import com.sinata.system.domain.query.MwMicroEquipmentStaticsQuery;
import com.sinata.system.domain.vo.DepartmentReportItemVO;
import com.sinata.system.domain.vo.DepartmentReportVO;
import com.sinata.system.domain.vo.MwCollectRecordVO;
import com.sinata.system.domain.vo.MwMicroEquipmentRecordVO;
import com.sinata.system.domain.vo.MwMicroEquipmentStaticsTitleVO;
import com.sinata.system.domain.vo.MwMicroEquipmentStaticsVO;
@@ -117,11 +117,11 @@
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
        String fileName = URLEncoder.encode("微波设备使用记录", "UTF-8").replaceAll("\\+", "%20");
        String fileName = URLEncoder.encode("小型微波设备使用记录", "UTF-8").replaceAll("\\+", "%20");
        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
        FastExcel.write(response.getOutputStream(), MwCollectRecordVO.class)
                .registerWriteHandler(new AutoColumnWidthStrategy())
                .sheet("微波设备使用记录").doWrite(list);
        FastExcel.write(response.getOutputStream(), MwMicroEquipmentRecordVO.class)
                .registerWriteHandler(new AutoColumnWidthEntityStrategy())
                .sheet("小型微波设备使用记录").doWrite(list);
    }
    /**
@@ -245,13 +245,13 @@
                ).map(MwMicroEquipmentStaticsVO::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
                long count = staticsData.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode())
                        && finalSdf.format(e.getUseTime()).equals(date)).count();
                departmentReportItemVO.getData().add(weight);
                departmentReportItemVO.getData().add(BigDecimal.valueOf(count));
                totalWeight = totalWeight.add(weight);
                departmentReportItemVO.getData().add(weight);
                totalCount = totalCount.add(BigDecimal.valueOf(count));
                totalWeight = totalWeight.add(weight);
            }
            departmentReportItemVO.getData().add(totalWeight);
            departmentReportItemVO.getData().add(totalCount);
            departmentReportItemVO.getData().add(totalWeight);
            result.add(departmentReportItemVO);
        }
@@ -312,7 +312,7 @@
    @Override
    public void staticsExport(MwMicroEquipmentStaticsQuery query, HttpServletResponse response) throws IOException {
        List<List<String>> head = head();
        List<List<String>> head = head(query);
        System.out.println(JSONObject.toJSONString(head));
        // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
@@ -355,16 +355,26 @@
     *
     * @return
     */
    private List<List<String>> head() {
    private List<List<String>> head(MwMicroEquipmentStaticsQuery query) {
        List<SysDictData> medicalWasteTypeList = sysDictDataService.lambdaQuery().eq(SysDictData::getDictType, "medical_waste_type").list();
        List<List<String>> headTitles = Lists.newArrayList();
        headTitles.add(Lists.newArrayList("日期"));
        SysDepartment department = sysDepartmentService.getById(query.getDepartmentId());
        MwMicroEquipment microEquipment = mwMicroEquipmentService.getById(query.getEquipmentId());
        //修改代码判断department不为空才拼接
        String title = "";
        if (Objects.nonNull(department) && Objects.nonNull(microEquipment)) {
            title = department.getDepartmentName() + microEquipment.getEquipmentName() + "处置报表";
        } else {
            title = "处置报表";
        }
        headTitles.add(Lists.newArrayList(title, "日期", "日期"));
        String finalTitle = title;
        medicalWasteTypeList.forEach(item -> {
            headTitles.add(Lists.newArrayList(item.getDictLabel(), "总重量(KG)"));
            headTitles.add(Lists.newArrayList(item.getDictLabel(), "总数量"));
            headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "数量"));
            headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "总重量(kg)"));
        });
        headTitles.add(Lists.newArrayList("小计", "总重量(KG)"));
        headTitles.add(Lists.newArrayList("小计", "总数量"));
        headTitles.add(Lists.newArrayList(title, "小计", "数量"));
        headTitles.add(Lists.newArrayList(title, "小计", "总重量(kg)"));
        return headTitles;
    }