Browse Source

fix: 修复演练、培训模块导出和分页功能问题

zhongwei
liwen 11 months ago
parent
commit
6b7680b62f
  1. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml
  2. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java
  3. 14
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

10
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml

@ -68,16 +68,16 @@
t2.people_num, t2.actual_start_time, t2.actual_end_time, t1.rehearsal_status t2.people_num, t2.actual_start_time, t2.actual_end_time, t1.rehearsal_status
FROM FROM
hzims_rehearsal_plan t1 hzims_rehearsal_plan t1
LEFT JOIN hzims_rehearsal_record t2 ON t1.id = t2.rehearsal_record_id LEFT JOIN hzims_rehearsal_record t2 ON t1.id = t2.rehearsal_plan_id
WHERE WHERE
t1.is_deleted = 0 t1.is_deleted = 0
<if test="unit != null and unit != ''"> <if test="unit != 'null' and unit != ''">
AND t1.unit = #{unit} AND t1.unit like #{unit}
</if> </if>
<if test="startTime != null and startTime != ''"> <if test="startTime != 'null' and startTime != ''">
AND t1.scheduled_start_time >= #{startTime} AND t1.scheduled_start_time >= #{startTime}
</if> </if>
<if test="endTime != null and endTime != ''"> <if test="endTime != 'null' and endTime != ''">
AND t1.scheduled_end_time &lt; #{endTime} AND t1.scheduled_end_time &lt; #{endTime}
</if> </if>
</select> </select>

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java

@ -181,7 +181,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
}); });
// 设置响应头 // 设置响应头
// URLEncoder.encode防止中文乱码 // URLEncoder.encode防止中文乱码
String fileName = URLEncoder.encode("演练记录表", "UTF-8"); String fileName = URLEncoder.encode("演练数据表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -192,7 +192,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
.registerConverter(new LongStringConverter()) .registerConverter(new LongStringConverter())
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
.build(); .build();
WriteSheet writeSheet = EasyExcel.writerSheet(1, "演练记录表").head(RehearsalExportDTO.class) WriteSheet writeSheet = EasyExcel.writerSheet(1, "演练数据表").head(RehearsalExportDTO.class)
.build(); .build();
excelWriter.write(rehearsalList, writeSheet); excelWriter.write(rehearsalList, writeSheet);
excelWriter.finish(); excelWriter.finish();
@ -243,15 +243,15 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
public IPage<RehearsalPlanEntity> rehearsalPlanPage(Map<String, Object> param, Query query) { public IPage<RehearsalPlanEntity> rehearsalPlanPage(Map<String, Object> param, Query query) {
QueryWrapper<RehearsalPlanEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<RehearsalPlanEntity> queryWrapper = new QueryWrapper<>();
String unit = String.valueOf(param.get("unit")); String unit = String.valueOf(param.get("unit"));
String startTime = String.valueOf(param.get("startTime")); String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf((param.get("endTime"))); String endTime = String.valueOf((param.get("scheduledEndTime")));
if (unit.equals("null") || unit.equals("")) { if (!unit.equals("null") && !unit.equals("")) {
queryWrapper.lambda().eq(RehearsalPlanEntity::getUnit, unit); queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit);
} }
if (startTime.equals("null") || startTime.equals("")) { if (!startTime.equals("null") && !startTime.equals("")) {
queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledStartTime, startTime); queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledStartTime, startTime);
} }
if (endTime.equals("null") || endTime.equals("")) { if (!endTime.equals("null") && !endTime.equals("")) {
queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime); queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime);
} }
return this.page(Condition.getPage(query), queryWrapper); return this.page(Condition.getPage(query), queryWrapper);

14
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

@ -13,9 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO; import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO;
import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity;
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum;
import com.hnac.hzims.safeproduct.enums.TrainStatusEnum; import com.hnac.hzims.safeproduct.enums.TrainStatusEnum;
import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITestService;
@ -243,15 +241,15 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
public IPage<TrainPlanEntity> trainPlanPage(Map<String, Object> param, Query query) { public IPage<TrainPlanEntity> trainPlanPage(Map<String, Object> param, Query query) {
QueryWrapper<TrainPlanEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<TrainPlanEntity> queryWrapper = new QueryWrapper<>();
String unit = String.valueOf(param.get("unit")); String unit = String.valueOf(param.get("unit"));
String startTime = String.valueOf(param.get("startTime")); String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf((param.get("endTime"))); String endTime = String.valueOf((param.get("scheduledEndTime")));
if (unit.equals("null") || unit.equals("")) { if (!unit.equals("null") && !unit.equals("")) {
queryWrapper.lambda().eq(TrainPlanEntity::getUnit, unit); queryWrapper.lambda().like(TrainPlanEntity::getUnit, unit);
} }
if (startTime.equals("null") || startTime.equals("")) { if (!startTime.equals("null") && !startTime.equals("")) {
queryWrapper.lambda().ge(TrainPlanEntity::getScheduledStartTime, startTime); queryWrapper.lambda().ge(TrainPlanEntity::getScheduledStartTime, startTime);
} }
if (endTime.equals("null") || endTime.equals("")) { if (!endTime.equals("null") && !endTime.equals("")) {
queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime); queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime);
} }
return this.page(Condition.getPage(query), queryWrapper); return this.page(Condition.getPage(query), queryWrapper);

Loading…
Cancel
Save