Ver Fonte

删除设备时删除其保养标准以及保养任务

há 2 anos atrás
pai
commit
83d100915f

+ 36 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -27,6 +27,9 @@ import com.platform.dao.dto.upms.SysDeptDTO;
 import com.platform.dao.dto.upms.SysUserDeptDTO;
 import com.platform.dao.dto.workplace.WorkplaceBacklogDTO;
 import com.platform.dao.dto.workplace.WorkplaceBacklogUserDTO;
+import com.platform.dao.entity.check.CheckJob;
+import com.platform.dao.entity.check.CheckStandard;
+import com.platform.dao.entity.check.CheckStandardSpare;
 import com.platform.dao.entity.firm.FirmProducer;
 import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.sb.*;
@@ -37,6 +40,9 @@ import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.entity.upms.SysUserDept;
 import com.platform.dao.enums.*;
+import com.platform.dao.mapper.check.CheckJobMapper;
+import com.platform.dao.mapper.check.CheckStandardMapper;
+import com.platform.dao.mapper.check.CheckStandardSpareMapper;
 import com.platform.dao.mapper.firm.FirmProducerMapper;
 import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
 import com.platform.dao.mapper.sb.*;
@@ -132,6 +138,10 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
     private final CheckStandardService checkStandardService;
     private final WorkplaceBacklogUserMapper backlogUserMapper;
     private final ActivitiBusinessService activitiBusinessService;
+    private final CheckStandardMapper checkStandardMapper;
+    private final CheckJobMapper checkJobMapper;
+    private final CheckStandardSpareMapper checkStandardSpareMapper;
+
 
     private final String useArea = "5e64ac691c527828b2114da0";
     private final String useCompany = "6063f905eb190003685af6d4";
@@ -140,10 +150,36 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
     private final String useGroup = "606540c8eb19002808e276d8";
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int batchDelete(List<String> ids) {
         Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
         WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
         weekendCriteria.andIn(SbInfo::getId, ids);
+//        Weekend<CheckStandard> weekend3 = new Weekend<>(CheckStandard.class);
+//        WeekendCriteria<CheckStandard, Object> weekendCriteria3 = weekend3.weekendCriteria();
+//        weekendCriteria3.andIn(CheckStandard::getSbId, ids);.
+        //删除保养标准
+        Weekend<CheckStandard> weekend1 = new Weekend<>(CheckStandard.class);
+        WeekendCriteria<CheckStandard, Object> weekendCriteria1 = weekend1.weekendCriteria();
+        weekendCriteria1.andIn(CheckStandard::getSbId, ids);
+        //删除关联备件
+        List<String> checkIds = new ArrayList<>();
+        List<CheckStandard> checkStandards = checkStandardMapper.selectByExample(weekend1);
+        for (CheckStandard standard:checkStandards){
+            checkIds.add(standard.getId());
+        }
+        Weekend<CheckStandardSpare> weekend3 = new Weekend<>(CheckStandardSpare.class);
+        WeekendCriteria<CheckStandardSpare, Object> weekendCriteria3 = weekend3.weekendCriteria();
+        weekendCriteria3.andIn(CheckStandardSpare::getCheckId, checkIds);
+        checkStandardSpareMapper.deleteByExample(weekend3);
+
+        checkStandardMapper.deleteByExample(weekend1);
+        //删除保养任务
+        Weekend<CheckJob> weekend2 = new Weekend<>(CheckJob.class);
+        WeekendCriteria<CheckJob, Object> weekendCriteria2 = weekend2.weekendCriteria();
+        weekendCriteria2.andIn(CheckJob::getSbId, ids);
+        checkJobMapper.deleteByExample(weekend2);
+        checkStandardMapper.deleteByExample(weekend1);
         mapper.deleteByExample(weekend);
         return 1;
     }