|
|
@@ -25,6 +25,7 @@ import org.dromara.xg.mapper.XgDormHygieneStudentScoreMapper;
|
|
|
import org.dromara.xg.service.IXgDormHygieneCheckService;
|
|
|
import org.dromara.xg.service.IXgStudentMsgService;
|
|
|
import org.dromara.xg.service.IXgHygieneCheckViolationService;
|
|
|
+import org.dromara.xg.service.IXgDormHygieneStudentScoreService;
|
|
|
import org.dromara.xg.mapper.XgHygieneCheckViolationMapper;
|
|
|
import org.dromara.system.service.ISysDictDataService;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
@@ -57,6 +58,7 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
|
|
private final IXgStudentMsgService xgStudentMsgService;
|
|
|
private final ISysDictDataService sysDictDataService;
|
|
|
private final IXgHygieneCheckViolationService violationService;
|
|
|
+ private final IXgDormHygieneStudentScoreService studentScoreService;
|
|
|
private final XgHygieneCheckViolationMapper violationMapper;
|
|
|
private final ApplicationContext applicationContext;
|
|
|
|
|
|
@@ -170,18 +172,60 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验并批量删除宿舍卫生检查信息
|
|
|
+ * 校验并批量删除宿舍卫生检查信息(级联删除四个表)
|
|
|
*
|
|
|
* @param ids 待删除的主键集合
|
|
|
* @param isValid 是否进行有效性校验
|
|
|
* @return 是否删除成功
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
if (isValid) {
|
|
|
// TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
- return baseMapper.deleteByIds(ids) > 0;
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 逐个处理每个卫生检查记录的级联删除
|
|
|
+ for (Long checkId : ids) {
|
|
|
+ log.info("开始级联删除宿舍卫生检查记录,检查ID: {}", checkId);
|
|
|
+
|
|
|
+ // 1. 查询并删除关联的违纪记录
|
|
|
+ List<XgHygieneCheckViolationVo> violations = violationService.queryByHygieneCheckId(checkId);
|
|
|
+ if (!violations.isEmpty()) {
|
|
|
+ log.info("发现 {} 条违纪关联记录需要删除,检查ID: {}", violations.size(), checkId);
|
|
|
+
|
|
|
+ // 1.1 删除统一违纪记录 (xskh_discipline_record)
|
|
|
+ for (XgHygieneCheckViolationVo violation : violations) {
|
|
|
+ if (violation.getDisciplineRecordId() != null) {
|
|
|
+ deleteDisciplineRecord(violation.getDisciplineRecordId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1.2 删除违纪关联记录 (xg_hygiene_check_violation)
|
|
|
+ violationService.deleteByHygieneCheckId(checkId);
|
|
|
+ log.info("删除违纪关联记录完成,检查ID: {}", checkId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 删除学生评分记录 (xg_dorm_hygiene_student_score)
|
|
|
+ Boolean studentScoreDeleted = studentScoreService.deleteByHygieneCheckId(checkId);
|
|
|
+ if (studentScoreDeleted) {
|
|
|
+ log.info("删除学生评分记录完成,检查ID: {}", checkId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 删除主检查记录 (xg_dorm_hygiene_check)
|
|
|
+ Boolean mainDeleted = baseMapper.deleteByIds(ids) > 0;
|
|
|
+ if (mainDeleted) {
|
|
|
+ log.info("删除宿舍卫生检查主记录完成,删除数量: {}", ids.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ return mainDeleted;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("级联删除宿舍卫生检查记录失败,检查IDs: {}, 错误: {}", ids, e.getMessage(), e);
|
|
|
+ throw new RuntimeException("删除宿舍卫生检查记录失败: " + e.getMessage(), e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|