|
|
@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
+import com.usky.fire.domain.BaseCompany;
|
|
|
import com.usky.fire.domain.MhCompany;
|
|
|
import com.usky.fire.domain.MhFireDuty;
|
|
|
import com.usky.fire.domain.MhFireDutyBusiness;
|
|
|
import com.usky.fire.mapper.MhFireDutyBusinessMapper;
|
|
|
import com.usky.fire.mapper.MhFireDutyMapper;
|
|
|
+import com.usky.fire.service.BaseCompanyService;
|
|
|
import com.usky.fire.service.MhFireDutyBusinessService;
|
|
|
import com.usky.fire.service.MhFireDutyService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
@@ -48,6 +50,8 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
private MhFireDutyBusinessService businessService;
|
|
|
@Autowired
|
|
|
private MhFireDutyBusinessMapper businessMapper;
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyService baseCompanyService;
|
|
|
|
|
|
// private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
@Override
|
|
|
@@ -194,6 +198,18 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
.in(MhFireDutyBusiness::getDutyId, dutyIds);
|
|
|
List<MhFireDutyBusiness> businessList = businessMapper.selectList(businessWrapper);
|
|
|
|
|
|
+ List<String> companyIds = businessList.stream().map(MhFireDutyBusiness::getUnit).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BaseCompany> companyWrapper = new LambdaQueryWrapper<>();
|
|
|
+ companyWrapper.select(BaseCompany::getCompanyName, BaseCompany::getCompanyId)
|
|
|
+ .in(BaseCompany::getCompanyId, companyIds);
|
|
|
+ Map<String, String> companyMap = baseCompanyService.list(companyWrapper).stream()
|
|
|
+ .collect(Collectors.toMap(BaseCompany::getCompanyId, BaseCompany::getCompanyName));
|
|
|
+
|
|
|
+ for(MhFireDutyBusiness dutyBusiness : businessList){
|
|
|
+ dutyBusiness.setUnit(companyMap.get(dutyBusiness.getUnit()));
|
|
|
+ }
|
|
|
+
|
|
|
Map<String, List<MhFireDutyBusiness>> businessMap = businessList.stream()
|
|
|
.collect(Collectors.groupingBy(biz -> biz.getDutyId() + "_" + biz.getBusinessType()));
|
|
|
|
|
|
@@ -231,6 +247,11 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
.orderByDesc(MhFireDuty::getDutyDate);
|
|
|
List<MhFireDuty> dutyList = this.list(queryWrapper);
|
|
|
|
|
|
+ if (dutyList.isEmpty()) {
|
|
|
+ exportEmptyTemplate(response);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
List<Long> dutyIds = dutyList.stream().map(MhFireDuty::getId).collect(Collectors.toList());
|
|
|
List<MhFireDutyBusiness> allBusiness = businessMapper.selectList(
|
|
|
new LambdaQueryWrapper<MhFireDutyBusiness>()
|
|
|
@@ -243,6 +264,18 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
Collectors.groupingBy(MhFireDutyBusiness::getBusinessType)
|
|
|
));
|
|
|
|
|
|
+ List<String> companyIds = allBusiness.stream().map(MhFireDutyBusiness::getUnit).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BaseCompany> companyWrapper = new LambdaQueryWrapper<>();
|
|
|
+ companyWrapper.select(BaseCompany::getCompanyName, BaseCompany::getCompanyId)
|
|
|
+ .in(BaseCompany::getCompanyId, companyIds);
|
|
|
+ Map<String, String> companyMap = baseCompanyService.list(companyWrapper).stream()
|
|
|
+ .collect(Collectors.toMap(BaseCompany::getCompanyId, BaseCompany::getCompanyName));
|
|
|
+
|
|
|
+ for(MhFireDutyBusiness dutyBusiness : allBusiness){
|
|
|
+ dutyBusiness.setUnit(companyMap.get(dutyBusiness.getUnit()));
|
|
|
+ }
|
|
|
+
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
Sheet sheet = workbook.createSheet("批量坐班值守任务表");
|
|
|
|
|
|
@@ -260,7 +293,7 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
new TaskDef(7, "高温气温35℃以上时,每日10:00-16:00期间,调取营区监控等方式,对各训练区域进行动态监测。重点排查是否存在违规训练行为,做好监控画面截图留存,发现问题立即汇报。")
|
|
|
);
|
|
|
|
|
|
- int currentRow = 0; // 当前行指针,逐行填充
|
|
|
+ int currentRow = 0;
|
|
|
for (MhFireDuty duty : dutyList) {
|
|
|
// 获取当前记录的子表分组数据(默认空Map)
|
|
|
Map<Integer, List<MhFireDutyBusiness>> businessMap = dutyBusinessMap.getOrDefault(
|
|
|
@@ -334,6 +367,39 @@ public class MhFireDutyServiceImpl extends AbstractCrudService<MhFireDutyMapper,
|
|
|
workbook.close();
|
|
|
}
|
|
|
|
|
|
+ private void exportEmptyTemplate(HttpServletResponse response) throws IOException {
|
|
|
+ Workbook wb = new XSSFWorkbook();
|
|
|
+ Sheet sh = wb.createSheet("批量坐班值守任务表");
|
|
|
+
|
|
|
+ // 样式与主逻辑保持一致
|
|
|
+ CellStyle titleStyle = createTitleStyle(wb);
|
|
|
+ CellStyle headerStyle = createHeaderStyle(wb);
|
|
|
+
|
|
|
+ /* ---------- 标题行 ---------- */
|
|
|
+ Row titleRow = sh.createRow(0);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ titleCell.setCellValue("坐班值守岗位工作量化任务(防火值班员/行政值班员)");
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ sh.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
|
|
|
+
|
|
|
+ /* ---------- 表头行 ---------- */
|
|
|
+ Row headerRow = sh.createRow(1);
|
|
|
+ String[] headers = {"时间", "值班人员", "工作任务", "完成情况"};
|
|
|
+ for (int i = 0; i < headers.length; i++) {
|
|
|
+ Cell c = headerRow.createCell(i);
|
|
|
+ c.setCellValue(headers[i]);
|
|
|
+ c.setCellStyle(headerStyle);
|
|
|
+ sh.setColumnWidth(i, i == 2 ? 256 * 60 : 256 * 20);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ---------- 输出 ---------- */
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ String fileName = URLEncoder.encode("批量坐班值守任务表.xlsx", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ wb.write(response.getOutputStream());
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取任务完成情况(复用单条导出逻辑)
|
|
|
*/
|